void TreeScorerQuantification::LoadTxt(lem::Iridium::Macro_Parser & txtfile)
{
    if (txtfile.probe(B_OSPAREN))
    {
        lem::Iridium::BethToken t1 = txtfile.read();

        int n1 = 0;
        int n2 = MAX_COUNT;

        if (t1.GetToken() == B_NOT)
        {
            // Ветка [not] представляет собой требования отсутствия и хранится через
            // пару -1,-1
            min_count = max_count = -1;
        }
        else
        {
            if (lem::is_int(t1.string()))
            {
                n1 = lem::to_int(t1.string());
            }
            else
            {
                txtfile.seekp(t1); // [,1] эквивалентно [0,1]
            }

            if (txtfile.probe(B_COMMA))
            {
                lem::Iridium::BethToken t2 = txtfile.read();
                if (lem::is_int(t2.string()))
                    n2 = lem::to_int(t2.string());
                else
                    txtfile.seekp(t2);
            }
            else
            {
                n2 = n1; // [1] эквивалентно [1,1]
            }

            min_count = n1;
            max_count = n2;
        }

        txtfile.read_it(B_CSPAREN);
    }

    return;
}
Beispiel #2
0
void LEMM_Compiler::LoadNGram( lem::Iridium::Macro_Parser & txtfile, Dictionary & dict, lem::MCollect<int> & terms, int order ) const
{
 lem::Iridium::BSourceState beg = txtfile.tellp();

 while( !txtfile.eof() )
 {
  lem::Iridium::BethToken t = txtfile.read();
  if( lem::is_int(t.string()) )
   terms.push_back( lem::to_int(t.string()) );
  else
   {
    txtfile.seekp(t);
    break;
   }
 }

 if( terms.size() != order+1 )
  {
   dict.GetIO().merr().printf( "%vfDInvalid ngram%vn\n" );
   lem::Iridium::Print_Error( beg, txtfile );
   throw lem::E_ParserError();
  }

 return;
}
Beispiel #3
0
void TreeScorerResult::LoadTxt(
                               Dictionary & dict,
                               lem::Iridium::Macro_Parser & txtfile,
                               const TreeScorerMarkers & markers
                              )
{
 // ќценка может быть отрицательной.
 if( txtfile.probe( B_SUB ) )
  {
   type=NumberScoreType;
   score = -txtfile.read_int();
  }
 else
  {
   if( lem::is_int( txtfile.pick().string() ) )
    {
     type=NumberScoreType;
     score = txtfile.read_int();
    }
   else
    {
     const lem::Iridium::BethToken & t = txtfile.read();
     id_fact = dict.GetLexAuto().GetKnowledgeBase().FindFacts( t.string() );
     if( id_fact==UNKNOWN )
      {
       type = FuncScoreType;

       Solarix::TrKnownVars vars;

       Solarix::TrTreeType tree_type;
       for( lem::Container::size_type k=0; k<markers.CountMarkers(); ++k )
       {
        vars.RegisterVar( tree_type, markers.GetMarker(k) );
        args.push_back( markers.GetMarker(k) );
       }

       txtfile.seekp(t);
       score_fun = dict.GetLexAuto().GetFunctions().Get().CompileCall( dict.GetLexAuto(), txtfile, vars );
      }
     else
      {
       LoadBoundVars( dict, txtfile, markers );
       type=NGramScoreType;
      }
    }
  }

 return;
}