@@ -41,6 +41,8 @@ Params params;
4141unordered_map<unsigned , vector<float >> pretrained;
4242vector<bool > singletons; // used during training
4343
44+ vector<unsigned > possible_actions;
45+
4446struct ParserBuilder {
4547
4648 LSTMBuilder state_lstm;
@@ -288,8 +290,8 @@ if(params.debug) std::cerr<<"bilstm ok\n";
288290if (params.debug ) cerr<< " action_count " << action_count <<" \n " ;
289291 current_valid_actions.clear ();
290292if (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