Skip to content

Commit 8c66f54

Browse files
committed
fix constituent-parser
1 parent cf520dc commit 8c66f54

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

impl/constituent-parser.cc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ Params params;
4141
unordered_map<unsigned, vector<float>> pretrained;
4242
vector<bool> singletons; // used during training
4343

44+
vector<unsigned> possible_actions;
45+
4446
struct ParserBuilder {
4547

4648
LSTMBuilder state_lstm;
@@ -288,8 +290,8 @@ if(params.debug) std::cerr<<"bilstm ok\n";
288290
if(params.debug) cerr<< "action_count " << action_count <<"\n";
289291
current_valid_actions.clear();
290292
if(params.debug) cerr<< "nopen_parens: "<<nopen_parens<<"\n";
291-
for (unsigned a = 0; a < ACTION_SIZE; a++) {
292-
if (IsActionForbidden_Discriminative(adict.convert((int)a), prev_a, bufferi.size(), stacki.size(), nopen_parens))
293+
for (auto a : possible_actions) {
294+
if (IsActionForbidden_Discriminative(adict.convert(a), prev_a, bufferi.size(), stacki.size(), nopen_parens))
293295
continue;
294296
current_valid_actions.push_back(a);
295297
}
@@ -621,10 +623,12 @@ int main(int argc, char** argv) {
621623
action2NTindex[i] = nt;
622624
}
623625

624-
NT_SIZE = ntermdict.size();
625-
POS_SIZE = posdict.size();
626-
VOCAB_SIZE = termdict.size();
627-
ACTION_SIZE = adict.size();
626+
NT_SIZE = ntermdict.size()+10;
627+
POS_SIZE = posdict.size()+10;
628+
VOCAB_SIZE = termdict.size()+10;
629+
ACTION_SIZE = adict.size()+10;
630+
631+
for(unsigned i = 0; i < adict.size(); ++i) possible_actions.push_back(i);
628632

629633
//============================================================================================================
630634

0 commit comments

Comments
 (0)