bool ModelTagMatcher::Match( const Word_Form & wf, Solarix::Dictionary & dict ) const { if( !lexeme.empty() ) { if( !lexeme.eqi( *wf.GetName() ) ) return false; } else if( !id_lemma.empty() ) { bool m=false; for( lem::Container::size_type i=0; i<id_lemma.size(); ++i ) if( id_lemma[i] == wf.GetEntryKey() ) { m=true; break; } if( !m ) return false; } else if( !pos.empty() ) { bool m=false; const int ekey = wf.GetEntryKey(); const SG_Entry & e = dict.GetSynGram().GetEntry(ekey); const int wf_pos = e.GetClass(); for( lem::Container::size_type i=0; i<pos.size(); ++i ) if( pos[i]==wf_pos ) { m=true; break; } if( !m ) return false; } if( !pairs.empty() ) { for( lem::Container::size_type i=0; i<pairs.size(); ++i ) { const GramCoordPair & p = pairs[i]; if( wf.GetPairs().FindOnce(p)!=UNKNOWN ) continue; // для бистабильных координат - состояние 0 равнозначно отсутствию вообще такой пары if( dict.GetSynGram().coords()[ p.GetCoord().GetIndex() ].IsBistable() ) { if( wf.GetPairs().FindOnce( p.GetCoord().GetIndex() ) != UNKNOWN ) return false; } else return false; } } return true; }
int TF_ClassFilter::Score( const Word_Form &wf, const Dictionary &dict ) const { if( allowed_classes.empty() ) return 0; const int ekey = wf.GetEntryKey(); if( lem::is_quantor(ekey) ) return 0; const int iclass = dict.GetSynGram().GetEntry(ekey).GetClass(); return (iclass==UNKNOWN || allowed_classes.find(iclass)!=UNKNOWN) ? 0 : -100; }