本文整理汇总了C++中StringTokenizer::val方法的典型用法代码示例。如果您正苦于以下问题:C++ StringTokenizer::val方法的具体用法?C++ StringTokenizer::val怎么用?C++ StringTokenizer::val使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringTokenizer
的用法示例。
在下文中一共展示了StringTokenizer::val方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BuildRusCorpAnnot
string CXmlMorphAnnot::BuildRusCorpAnnot() const
{
StringTokenizer tok (m_GrammemsStr.c_str(), ", ");
set<string> gs;
while ( tok() )
{
string s = tok.val();
EngRusMakeLower(s);
if (IsImportantRusCorpFeature (s))
gs.insert(s);
}
string res;
for (set<string>::const_iterator it = gs.begin(); it != gs.end(); it++)
res += *it + "_";
if (!res.empty())
res.erase(res.length() -1);
return res;
}
示例2: lines
bool CGrammarItem::fromString(string& Result)
{
StringTokenizer lines (Result.c_str(), "\r\n");
int LineNo = 0;
while (lines())
{
LineNo++;
string line = lines.val();
if (LineNo == 1)
continue;
if (LineNo == 2)
{
char buff1[1024];
char buff2[1024];
int iMeta;
int iTokenType;
if (sscanf(line.c_str(), "%i %s %s %i\n", &iMeta, buff1, buff2, &iTokenType) != 4)
return false;
m_bMeta = (bool)iMeta;
m_TokenType = (MainTokenTypeEnum)iTokenType;
m_ItemStrId = buff1;
if (m_ItemStrId.empty()) return false;
m_Token = buff2;
if (m_Token == "null")
m_Token = "";
};
if (LineNo == 3)
{
char buff1[1024];
int Count = sscanf(line.c_str(), "%[^\x1]", buff1);
if (Count != 1) return false;
m_Source = buff1;
};
if (LineNo == 4)
{
if (!m_MorphPattern.FromString(line))
return false;
};
if (LineNo == 5)
{
int i1, i2,i3, i4;
if (sscanf(line.c_str(), "%i %i %i %i", &i1, &i2, &i3, &i4) != 4) return false;
m_bGrammarRoot = i1==1;
m_bSynMain = i2==1;
m_bCanHaveManyHomonyms = i3==1;
m_Register = (RegisterEnum)i4;
};
if (LineNo == 6)
{
m_Attributes.clear();
StringTokenizer pairs(line.c_str(), ";");
while (pairs())
{
char buff1[1024];
char buff2[1024];
string _pair = pairs.val();
sscanf (_pair.c_str(), "%s %s", buff1, buff2);
m_Attributes[buff1] = buff2;
};
};
};
if (LineNo != 7) return false;
return true;
}
示例3: OnToolsSelectByFile
//----------------------------------------------------------------------------
// Ищет слова по заданному в файле перечню.
// В файле на каждой строке сначала стоит часть речи, а потом лемма.
//----------------------------------------------------------------------------
void CMorphwizardView::OnToolsSelectByFile()
{
// TODO: Add your command handler code here
CFileDialog D(TRUE, "slf", "paradigms.txt");
if (D.DoModal() != IDOK) return;
FILE * fp = fopen (D.GetPathName(),"rb");
if (!fp)
{
AfxMessageBox ("Cannot open file");
return;
};
char buf[1000];
std::string strNotFound;
int ParadigmCount = 0;
found_paradigms.clear();
while (fgets(buf, 1000, fp))
{
std::string Line = buf;
Trim(Line);
if (Line.empty()) continue;
StringTokenizer tok (Line.c_str(), ";");
if (!tok())
{
std::string mess = std::string("cannot get lemma from ") + buf + std::string("; The format should be <Lemma>;<TypeGrammems>;<MorphPattern>");
AfxMessageBox (mess.c_str());
break;
};
std::string Lemma = tok.val();
Trim(Lemma);
if (!tok())
{
std::string mess = std::string("cannot get type grammem ") + buf + std::string("; The format should be <Lemma> <PartofSpeech> <Grammems>");
AfxMessageBox (mess.c_str());
break;
};
std::string TypeAncode;
{
std::string grams = tok.val();
Trim(grams);
if (grams != "*")
if (!GetWizard()->slf2ancode(grams, TypeAncode ))
{
std::string mess = std::string("cannot process type grammems ") + grams;
AfxMessageBox (mess.c_str());
break;
};
};
if (!tok())
{
std::string mess = std::string("cannot get morphological pattern ") + buf + std::string("; The format should be <Lemma>;<TypeGrammems>;<MorphPattern>");
AfxMessageBox (mess.c_str());
break;
};
std::string FirstCode;
{
std::string PosStr = tok.val();
Trim(PosStr);
if (!GetWizard()->slf2ancode(PosStr,FirstCode ))
{
std::string mess = std::string("cannot process morph. pattern ") + PosStr;
AfxMessageBox (mess.c_str());
break;
};
};
std::vector<lemma_iterator_t> curr_found_paradigms;
RmlMakeUpper(Lemma, GetWizard()->m_Language);
bool bFound = false;
GetWizard()->find_lemm(Lemma.c_str(), true, curr_found_paradigms);
for(size_t i=0; i<curr_found_paradigms.size(); i++ )
{
std::string str_pos = GetWizard()->m_FlexiaModels[curr_found_paradigms[i]->second.m_FlexiaModelNo].get_first_code();;
if (curr_found_paradigms[i]->second.GetCommonAncodeIfCan() == TypeAncode)
if( FirstCode == str_pos )
if (std::find(found_paradigms.begin(), found_paradigms.end(), curr_found_paradigms[i]) == found_paradigms.end())
{
found_paradigms.push_back(curr_found_paradigms[i]);
bFound = true;
};
}
if (!bFound)
strNotFound += Format("Not found: %s\r\n", Line.c_str());
};
fclose(fp);
FilterFoundParadigms();
ShowFoundParadigms();
if (!strNotFound.empty())
echo(strNotFound.c_str());
//.........这里部分代码省略.........