本文整理汇总了C++中lem::iridium::Macro_Parser::read_int方法的典型用法代码示例。如果您正苦于以下问题:C++ Macro_Parser::read_int方法的具体用法?C++ Macro_Parser::read_int怎么用?C++ Macro_Parser::read_int使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lem::iridium::Macro_Parser
的用法示例。
在下文中一共展示了Macro_Parser::read_int方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadTxt
void TreeScorerResult::LoadTxt( Dictionary & dict, lem::Iridium::Macro_Parser & txtfile, const TreeScorerMarkers & markers )
{
// ќценка может быть отрицательной.
if( txtfile.probe( B_SUB ) )
{
type=0;
score = -txtfile.read_int();
}
else
{
if( lem::is_int( txtfile.pick().string() ) )
{
type=0;
score = txtfile.read_int();
}
else
{
const lem::Iridium::BethToken & t = txtfile.read();
id_fact = dict.GetLexAuto().GetKnowledgeBase().FindFacts( t.string() );
if( id_fact==UNKNOWN )
{
// todo - тут могут быть другие варианты вызываемых вычислений.
lem::Iridium::Print_Error(t,txtfile);
dict.GetIO().merr().printf( "Unknown scoring expression starts with %us\n", t.string().c_str() );
throw lem::E_BaseException();
}
txtfile.read_it( B_OROUNDPAREN );
while( !txtfile.eof() )
{
if( txtfile.probe( B_CROUNDPAREN ) )
break;
if( !args.empty() )
txtfile.read_it( B_COMMA );
const lem::Iridium::BethToken & var = txtfile.read();
lem::UCString upper_var = lem::to_upper(var.string());
if( !markers.IsAlreadyBound(upper_var) )
{
lem::Iridium::Print_Error(var,txtfile);
dict.GetIO().merr().printf( "variable %us not bound\n", var.string().c_str() );
throw lem::E_BaseException();
}
args.push_back( upper_var );
}
type=1;
}
}
return;
}
示例2: LoadTxt
void ViolationHandler::LoadTxt( lem::Iridium::Macro_Parser & txtfile )
{
if( txtfile.probe( B_OSPAREN ) )
{
txtfile.read_it( B_SUB );
violation_score = -txtfile.read_int();
txtfile.probe( B_CSPAREN );
}
else
{
violation_score=0;
}
return;
}
示例3: LoadTxt
void LEMM_Compiler::LoadTxt( lem::Iridium::Macro_Parser & txtfile, Dictionary & dict )
{
txtfile.read_it( B_OFIGPAREN );
while( !txtfile.eof() )
{
lem::Iridium::BethToken t = txtfile.read();
if( t.eqi( L"suffix" ) )
{
int id = txtfile.read_int();
lem::UCString suffix = txtfile.read();
if( suffix[0]==L'"' && suffix.back()==L'"' )
suffix.strip_quotes();
suffices.push_back( std::make_pair(id,suffix) );
}
else if( t.eqi( L"word" ) )
{
int id = txtfile.read_int();
lem::UCString word = txtfile.read();
if( word[0]==L'"' && word.back()==L'"' )
word.strip_quotes();
words.push_back( std::make_pair(id,word) );
}
else if( t.eqi(L"ngram2") )
{
lem::MCollect<int> terms;
LoadNGram(txtfile,dict,terms,2);
LEMM_Ngram2 n2;
n2.tags.first = terms[0];
n2.tags.second = terms[1];
n2.freq = terms[2];
ngram2.push_back(n2);
}
else if( t.eqi(L"ngram2_1") )
{
lem::MCollect<int> terms;
LoadNGram(txtfile,dict,terms,2);
LEMM_Ngram2 n2;
n2.tags.first = terms[0];
n2.tags.second = terms[1];
n2.freq = terms[2];
ngram2_1.push_back(n2);
}
else if( t.eqi(L"ngram3") )
{
lem::MCollect<int> terms;
LoadNGram(txtfile,dict,terms,3);
LEMM_Ngram3 n3;
n3.tags.first = terms[0];
n3.tags.second = terms[1];
n3.tags.third = terms[2];
n3.freq = terms[3];
ngram3.push_back(n3);
}
else if( t.eqi(L"ngram3_1") )
{
lem::MCollect<int> terms;
LoadNGram(txtfile,dict,terms,3);
LEMM_Ngram3 n3;
n3.tags.first = terms[0];
n3.tags.second = terms[1];
n3.tags.third = terms[2];
n3.freq = terms[3];
ngram3_1.push_back(n3);
}
else if( t.eqi(L"ngram3_2") )
{
lem::MCollect<int> terms;
LoadNGram(txtfile,dict,terms,3);
LEMM_Ngram3 n3;
n3.tags.first = terms[0];
n3.tags.second = terms[1];
n3.tags.third = terms[2];
n3.freq = terms[3];
ngram3_2.push_back(n3);
}
else if( t.eqi(L"ngram4") )
{
lem::MCollect<int> terms;
LoadNGram(txtfile,dict,terms,4);
LEMM_Ngram4 n4;
n4.tags.first = terms[0];
n4.tags.second = terms[1];
n4.tags.third = terms[2];
n4.tags.fourth = terms[3];
n4.freq = terms[4];
ngram4.push_back(n4);
}
else if( t.eqi( L"suffix_len" ) )
{
suffix_len = txtfile.read_int();
}
else if( t.GetToken()==B_CFIGPAREN )
break;
else
{
dict.GetIO().merr().printf( "%vfDInvalid statement [%us]%vn\n", t.string().c_str() );
//.........这里部分代码省略.........
示例4: LoadTxt
void KB_Facts::LoadTxt(Solarix::Dictionary &dict, lem::Iridium::Macro_Parser &txtfile)
{
name = txtfile.read().string();
txtfile.read_it(B_LANGUAGE);
txtfile.read_it(B_EQUAL);
lem::Iridium::BethToken lang = txtfile.read();
id_language = dict.GetSynGram().Find_Language(lang.string());
if (id_language == UNKNOWN)
{
lem::Iridium::Print_Error(lang, txtfile);
dict.GetIO().merr().printf("Unknown language name %us\n", lang.c_str());
throw lem::E_BaseException();
}
txtfile.read_it(B_OFIGPAREN);
n_ret = 0;
while (!txtfile.eof())
{
if (txtfile.probe(B_CFIGPAREN))
break;
lem::Iridium::BethToken t = txtfile.read();
if (t.string().eqi(L"arity"))
{
txtfile.read_it(B_EQUAL);
n_arg = txtfile.read_int();
}
else if (t.string().eqi(L"return"))
{
txtfile.read_it(B_EQUAL);
lem::Iridium::BethToken t_ret = txtfile.read();
if (t_ret.eqi(L"boolean"))
{
n_ret = 1;
ret_type = 0;
}
else if (t_ret.eqi(L"integer"))
{
n_ret = 1;
ret_type = 1;
}
else
{
lem::Iridium::Print_Error(t_ret, txtfile);
dict.GetIO().merr().printf("Unknown return type %us\n", t_ret.c_str());
throw lem::E_BaseException();
}
}
else if (t.string().eqi(L"violation_score"))
{
txtfile.read_it(B_EQUAL);
if (txtfile.probe(B_SUB))
violation_score = -txtfile.read_int();
else
violation_score = txtfile.read_int();
}
else if (t.string().eqi(L"violation_handler"))
{
txtfile.read_it(B_EQUAL);
violation_handler = new PredicateTemplate();
PredicateTemplateParams_KB params(n_arg);
violation_handler->LoadTxt(dict, txtfile, params);
}
else if (t.string().eqi(L"generic"))
{
allow_generic = true;
}
else
{
lem::Iridium::Print_Error(t, txtfile);
dict.GetIO().merr().printf("Unknown property %us\n", t.c_str());
throw lem::E_BaseException();
}
}
return;
}