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 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;
}
Exemple #3
0
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;
}
Exemple #4
0
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 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 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 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;
}