void ModelTagMatcher::Print( lem::OFormatter & to, Dictionary & dict ) const { if( !lexeme.empty() ) to.printf( "\"%us\" ", lexeme.c_str() ); for( lem::Container::size_type i=0; i<id_lemma.size(); ++i ) { int id_entry = id_lemma[i]; const SG_Entry & e = dict.GetSynGram().GetEntry(id_entry); int id_class = e.GetClass(); const SG_Class & c = dict.GetSynGram().GetClass( id_class ); to.printf( "%us:%us ", c.GetName().c_str(), e.GetName().c_str() ); } for( lem::Container::size_type i=0; i<pos.size(); ++i ) { const SG_Class & c = dict.GetSynGram().GetClass( pos[i] ); lem::mout->printf( "%us ", c.GetName().c_str() ); } for( lem::Container::size_type i=0; i<pairs.size(); ++i ) { const Solarix::GramCoordPair & p = pairs[i]; p.SaveTxt( to, dict.GetSynGram() ); to.printf( " " ); } return; }
void SynPatternResult::PrintExportedNodes(lem::OFormatter &out, SynGram &sg) const { for (lem::Container::size_type i = 0; i < exported_nodes.size(); ++i) { out.printf("%us=", exported_nodes[i].first->c_str()); exported_nodes[i].second->Print(out, &sg, true); out.eol(); } trace.Print(out, sg, true); out.eol(); return; }
void TrFunction::PrintSignature( lem::OFormatter &out ) const { out.printf( "function %vfE%us%vn( ", name.c_str() ); for( lem::Container::size_type i=0; i<arg_name.size(); ++i ) { if( i>0 ) out.printf( ", " ); out.printf( "%us %us", arg_type[i].GetName().c_str(), arg_name[i].c_str() ); } out.printf( ")" ); return; }
void TrContextInvokation::PrintVars( Solarix::Dictionary &dict, lem::OFormatter &out ) const { for( lem::Container::size_type i=0; i<arg_name.size(); ++i ) { if( arg_name[i]==L"((return))" ) continue; out.printf( "%vfF%us%vn %vfA%us%vn=", arg_value[i]->GetType().GetName().c_str(), arg_name[i].c_str() ); arg_value[i]->Print(dict,out); out.eol(); } TrFunContext::PrintVars(dict,out); return; }
void NGramsDBMS::Dump3Grams( const lem::FString &suffix, const lem::FString &sgm, lem::OFormatter &to ) { FString sql = lem::format_str( "SELECT w1.word, w2.word, w3.word, w" " FROM NGRAM3%s%s, NGRAM_WORDS%s%s w1, NGRAM_WORDS%s%s w2, NGRAM_WORDS%s%s w3" " WHERE w1.id=iword1 AND w2.id=iword2 AND w3.id=iword3" , suffix.c_str(), sgm.c_str() , suffix.c_str(), sgm.c_str() , suffix.c_str(), sgm.c_str() , suffix.c_str(), sgm.c_str() ); std::unique_ptr<LS_ResultSet> rs(Select(sql)); while (rs->Fetch()) { UCString s1(rs->GetUCString(0)); UCString s2(rs->GetUCString(1)); UCString s3(rs->GetUCString(2)); const int w = rs->GetInt(3); to.printf("%us %us %us [%d]\n", s1.c_str(), s2.c_str(), s3.c_str(), w); } return; }
void SyllabContext::Print(lem::OFormatter &to) const { for (int k = 0; k < Count(); ++k) { if (k > 0) to.printf(' '); GetPoint(k).Print(to); } return; }
void LEMM_Compiler::PrintModelInfo( lem::OFormatter & out ) const { out.printf( " model: n_suffix=%d n_word=%d ngram2=%d ngram2_1=%d ngram3=%d ngram3_1=%d ngram3_2=%d ngram4=%d", CastSizeToInt(suffices.size()), CastSizeToInt(words.size()), CastSizeToInt(ngram2.size()), CastSizeToInt(ngram2_1.size()), CastSizeToInt(ngram3.size()), CastSizeToInt(ngram3_1.size()), CastSizeToInt(ngram3_2.size()), CastSizeToInt(ngram4.size()) ); return; }
void BackTraceItem::Print( lem::OFormatter &to, SynGram &sg, bool detailed ) const { if( wf!=NULL ) { Solarix::Word_Form dummy( *wf, false ); wf->Print( to, &sg, detailed ); } if( !export_coords.empty() ) { to.printf( " export_coords:=%vf6(%vn" ); for( lem::Container::size_type i=0; i<export_coords.size(); ++i ) { const int id_coord = export_coords[i].GetCoord().GetIndex(); const int id_state = export_coords[i].GetState(); const GramCoord &c = sg.coords()[id_coord]; if( c.IsBistable() ) { if( id_state==1 ) { to.printf( " %us", c.GetName().string().c_str() ); } else { to.printf( " ~%us", c.GetName().string().c_str() ); } } else { to.printf( " %us:%us", c.GetName().string().c_str(), c.GetStateName(id_state).c_str() ); } } to.printf( " %vf6)%vn" ); } if( !export_nodes.empty() ) { to.printf( " export_nodes:=" ); for( lem::Container::size_type i=0; i<export_nodes.size(); ++i ) { to.printf( " %us=", export_nodes[i].first->c_str() ); export_nodes[i].second->Print( to, &sg, true ); } to.eol(); } return; }
void TreeDimension::Print( const Solarix::Dictionary & dict, lem::OFormatter & out, bool detailed ) const { if( !nodes.empty() ) { out.printf( "%vf6<<%vn%vfB%us%vn%vf6>>:%vn", name.c_str() ); if( nodes.size()>1 ) out.printf( "%vf6{%vn" ); for( lem::Container::size_type i=0; i<nodes.size(); ++i ) { out.printf( ' ' ); nodes[i]->Print( out, dict.GetSynGram(), 0, detailed ); } if( nodes.size()>1 ) out.printf( " %vf6}%vn" ); } return; }
void SynPatternResult::PrintLinkageGroups(lem::OFormatter &out, SynGram &sg) const { lem::mout->printf("\nThere are %d groups:\n", CastSizeToInt(linkage_groups.size())); for (lem::Container::size_type k = 0; k < linkage_groups.size(); ++k) { const PatternSynLinkedGroup & g = linkage_groups[k]; Solarix::Word_Form wf0(*g.begin->GetWordform(), false); Solarix::Word_Form wf1(*g.end->GetWordform(), false); Solarix::Word_Form wfr(*g.root_node, false); wf0.Print(out, &sg, true); out.printf(" ... "); wf1.Print(out, &sg, true); out.printf(" ==> "); wfr.Print(out, &sg, true); out.eol(); } return; }
void BackTrace::Print( lem::OFormatter &to, SynGram &sg, bool detailed ) const { if( parent!=NULL ) parent->Print( to, sg, detailed ); for( lem::Container::size_type i=0; i<name.size(); ++i ) { if( seq_number[i]->size()==1 ) to.printf( "%d", seq_number[i]->front() ); else { to.printf( "(" ); for( lem::Container::size_type j=0; j<seq_number[i]->size(); ++j ) to.printf( " %d", seq_number[i]->get(j) ); to.printf( " )" ); } to.printf( ":%us = ", name[i].c_str() ); trace[i]->Print( to, sg, detailed ); to.eol(); } return; }
void SynPatternResult::PrintLinks(lem::OFormatter &out, SynGram &sg) const { lem::mout->printf("\nThere are %d edges:\n", CastSizeToInt(linkage_edges.size())); for (lem::Container::size_type k = 0; k < linkage_edges.size(); ++k) { const PatternLinkEdge & edge = linkage_edges[k]; Solarix::Word_Form wf0(*edge.from, false); Solarix::Word_Form wf1(*edge.to, false); lem::UCString link_name; if (edge.link_type == UNKNOWN) link_name = L"((unknown))"; else link_name = sg.coords()[0].GetStateName(edge.link_type); wf0.Print(out, &sg, true); out.printf(" --(%us)--> ", link_name.c_str()); wf1.Print(out, &sg, true); out.eol(); } return; }
void SynPatternResult::Print(lem::OFormatter &out, SynGram &sg) const { out.printf("Length=%vfE%d%vn Ngrams=%vfE%d%vn Edges=%d Groups=%d\n", res.Length(), res.GetNGramFreq().Composite(), CastSizeToInt(linkage_edges.size()), CastSizeToInt(linkage_groups.size())); out.printf("%vfAMATCHED WORDFORMS%vn:\n"); // Напечатаем список сопоставленных словоформ. lem::MCollect< const Solarix::Word_Form* > wordforms; for (auto it = matched_alts.begin(); it != matched_alts.end(); ++it) { wordforms.push_back(it->first->GetVersion(it->second)); } // Отсортируем в порядке возрастания позиции, чтобы визуально они были в нормальной последовательности. std::sort(wordforms.begin(), wordforms.end(), [](const Word_Form* x, const Word_Form* y) { return x->GetOriginPos() < y->GetOriginPos(); }); for (lem::Container::size_type i = 0; i < wordforms.size(); ++i) { out.printf("[%vfE%d%vn] ", CastSizeToInt(i)); Solarix::Word_Form dummy(*wordforms[i], false); dummy.Print(out, &sg, true); out.eol(); } out.printf("%vfATRACE%vn: "); trace.Print(out, sg, false); out.eol(); /* #if defined SOL_DEBUGGING for( lem::Container::size_type i=0; i<debug_trace.size(); ++i ) { const SynPatternPoint * point = debug_trace[i].point; for( lem::Container::size_type j=0; j<point->GetSources().size(); ++j ) { const int src = point->GetSources()[j]; lem::Path filename; int line=0, column=0; if( sg.GetDict().GetDebugSymbols().GetLocation( src, filename, line, column ) ) { lem::mout->printf( " %vfA%us%vn:%vfE%d%vn", filename.GetFileName().c_str(), line ); } } } #endif */ return; }
void TreeDimension::PrintXML( lem::OFormatter & xml, const Solarix::Dictionary & dict ) const { xml.printf( "<dimension>\n" ); xml.printf( "<name>%us</name>\n", name.c_str() ); xml.printf( "<trees count=\"%d\">\n", CastSizeToInt(nodes.size()) ); for( lem::Container::size_type i=0; i<nodes.size(); ++i ) { xml.printf( "<tree n=\"%d\">\n", CastSizeToInt(i) ); nodes[i]->PrintXML( xml, dict.GetSynGram() ); xml.printf( "</tree>\n" ); } xml.printf( "</trees>\n" ); xml.printf( "</dimension>\n" ); return; }
void NGramsDBMS::Dump2Grams_1( const lem::FString &suffix, const lem::FString &sgm, lem::OFormatter &to ) { FString sql = lem::format_str("SELECT iword1, iword2, w FROM NGRAM2%s%s" , suffix.c_str(), sgm.c_str()); std::unique_ptr<LS_ResultSet> rs(Select(sql)); while (rs->Fetch()) { const int ie1 = rs->GetInt(0); const int ie2 = rs->GetInt(1); const int w = rs->GetInt(2); to.printf("%6d %6d [%d]\n", ie1, ie2, w); } return; }