Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

bugfix (hierarchical sigtest filter failed for two consecutive nonter…

…minals)
  • Loading branch information...
commit 354946494360b2b8ef1cbaf115b16e792ccd2c7b 1 parent 9a04265
@rsennrich rsennrich authored
Showing with 8 additions and 9 deletions.
  1. +8 −9 contrib/sigtest-filter/filter-pt.cpp
View
17 contrib/sigtest-filter/filter-pt.cpp
@@ -277,17 +277,16 @@ SentIdSet find_occurrences(const std::string& rule, C_SuffixArraySearchApplicati
// if a rule contains multiple sequences of terminals, we intersect their occurrences.
if (hierarchical) {
// std::cerr << "splitting up phrase: " << phrase << "\n";
- size_t pos = 0;
- size_t endPos = 0;
+ int pos = 0;
+ int endPos = 0;
vector<std::string> phrases;
- // NT at start of rule
- if (rule.find("[X][X] ") == 0) {
- pos = 7;
- }
-
- while (rule.find(" [X][X] ", pos) < rule.size()-11) {
- endPos = rule.find(" [X][X] ", pos);
+ while (rule.find("[X][X] ", pos) < rule.size()-10) {
+ endPos = rule.find("[X][X] ",pos) - 1; // -1 to cut space before NT
+ if (endPos < pos) { // no space: NT at start of rule (or two consecutive NTs)
+ pos += 7;
+ continue;
+ }
phrases.push_back(rule.substr(pos,endPos-pos));
pos = endPos + 8;
}
Please sign in to comment.
Something went wrong with that request. Please try again.