summaryrefslogtreecommitdiff
path: root/extractor/phrase_builder.cc
diff options
context:
space:
mode:
Diffstat (limited to 'extractor/phrase_builder.cc')
-rw-r--r--extractor/phrase_builder.cc5
1 files changed, 2 insertions, 3 deletions
diff --git a/extractor/phrase_builder.cc b/extractor/phrase_builder.cc
index c4e0c2ed..4325390c 100644
--- a/extractor/phrase_builder.cc
+++ b/extractor/phrase_builder.cc
@@ -9,10 +9,9 @@ PhraseBuilder::PhraseBuilder(shared_ptr<Vocabulary> vocabulary) :
Phrase PhraseBuilder::Build(const vector<int>& symbols) {
Phrase phrase;
phrase.symbols = symbols;
- phrase.words.resize(symbols.size());
for (size_t i = 0; i < symbols.size(); ++i) {
if (vocabulary->IsTerminal(symbols[i])) {
- phrase.words[i] = vocabulary->GetTerminalValue(symbols[i]);
+ phrase.words.push_back(vocabulary->GetTerminalValue(symbols[i]));
} else {
phrase.var_pos.push_back(i);
}
@@ -30,7 +29,7 @@ Phrase PhraseBuilder::Extend(const Phrase& phrase, bool start_x, bool end_x) {
}
for (size_t i = start_x; i < symbols.size(); ++i) {
- if (vocabulary->IsTerminal(symbols[i])) {
+ if (!vocabulary->IsTerminal(symbols[i])) {
++num_nonterminals;
symbols[i] = vocabulary->GetNonterminalIndex(num_nonterminals);
}