本文整理汇总了C++中CWord类的典型用法代码示例。如果您正苦于以下问题:C++ CWord类的具体用法?C++ CWord怎么用?C++ CWord使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CWord类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LongestPieceFixedStart
CWord::size_type LongestPieceFixedStart(const CWord& w) {
CWord::size_type result = 1;
auto shifted = w;
shifted.CyclicLeftShift();
while (shifted != w) {
result = std::max(result, CommonPrefixLength(w, shifted));
if (result * 6 >= w.size()) {
return result;
}
shifted.CyclicLeftShift();
}
auto inverse = w.Inverse();
if (LeastCyclicShift(inverse) == LeastCyclicShift(w)) {
return result;
}
result = std::max(result, CommonPrefixLength(w, inverse));
inverse.CyclicLeftShift();
while (inverse != w.Inverse()) {
result = std::max(result, CommonPrefixLength(w, inverse));
if (result * 6 >= w.size()) {
return result;
}
inverse.CyclicLeftShift();
}
return result;
}
示例2: GetWordForMultiWord
void CMultiWordCreator::AddQuoteMultiWord(CWordSequence& ws, const TArticleRef& article)
{
SWordHomonymNum wh;
Wtroka str;
CWord* pNewWord = GetWordForMultiWord(ws, str, wh);
if (pNewWord->m_SourceWords.Size() == 1 && pNewWord->HasOnlyUnknownPOS()) {
size_t firstId = pNewWord->IterHomonyms().GetID();
CHomonym& h = pNewWord->GetRusHomonym(firstId);
h.SetSourceWordSequence(&ws);
h.PutArticle(article);
wh.m_HomNum = firstId;
} else {
pNewWord->m_SourceWords.SetPair(ws.FirstWord(), ws.LastWord());
if (str.size() == 0)
str = pNewWord->m_txt;
TMorph::ToLower(str);
CHomonym* pNewHom = new CHomonym(TMorph::GetMainLanguage(), str);
pNewHom->SetSourceWordSequence(&ws);
pNewHom->PutArticle(article);
wh.m_HomNum = pNewWord->AddRusHomonym(pNewHom);
}
if (article.AuxDic().IsValid()) {
const article_t* pArt = GlobalDictsHolder->GetAuxArticle(article.AuxDic());
YASSERT(pArt != NULL);
AddFoundArticle(pArt->get_kw_type(), pArt->get_title(), wh);
} else {
YASSERT(!article.Gzt().Empty());
AddFoundArticle(article.Gzt().GetType(), article.Gzt().GetTitle(), wh);
}
m_wordSequences.push_back(&ws);
}
示例3: SetCurLine
bool CAsmFile::ParseBlockCMT()
{
// 扫描注释.
SetCurLine(0);
CWord* pWord = NULL;
bool bCmt = false;
do
{
// 寻找 / *
while ((pWord = GetAllNextWord()) != NULL)
{
string& str = pWord->GetWord();
if (str == "/*")
{
bCmt = true;
pWord->SetAttrib(EWORD_COMMENT);
break;
}
}
// 标记注释和结束符
while ((pWord = GetAllNextWord()) != NULL)
{
string& str = pWord->GetWord();
pWord->SetAttrib(EWORD_COMMENT);
if (str == "*/")
{
bCmt = false;
break;
}
}
} while (pWord != NULL);
return (bCmt == false);
}
示例4: ExtractText
inline Wtroka ExtractText(const CWord& word, const CWordVector& allWords) {
Wtroka res = word.IsMultiWord() ? allWords.ToString(word) : word.GetText();
if (word.IsFirstInSentence() && !word.HasAtLeastTwoUpper()) {
// Remove title-case for the first word of a sentence (not having other upper-cased letters)
TMorph::ToLower(res);
}
return res;
}
示例5: CommonPrefixLength
CWord::size_type CommonPrefixLength(CWord u, CWord v) {
CWord::size_type result = 0;
while (u.GetFront() == v.GetFront()) {
++result;
u.PopFront();
v.PopFront();
}
return result;
}
示例6: ConjugationInverseNormalForm
CWord ConjugationInverseNormalForm(const CWord& w) {
assert(w.Empty() || w.GetBack().Inverse() != w.GetFront());
auto min_w = LeastCyclicPermutation(w);
auto min_i = LeastCyclicPermutation(w.Inverse());
if (min_w < min_i) {
return min_w;
} else {
return min_i;
}
}
示例7: HasDeclinableSynNounInInstrumentalis
bool CAnalyticFormBuilder::HasDeclinableSynNounInInstrumentalis(const CWord& _W) const
{
for (CWord::SHomIt it = _W.IterHomonyms(); it.Ok(); ++it)
if (IsSynNoun(*it) && it->HasGrammem(gInstrumental) && !it->HasGrammem(gNominative))
return true;
return false;
}
示例8: HasShortParticipleOrAdj
bool CAnalyticFormBuilder::HasShortParticipleOrAdj(const CWord& _W) const
{
for (CWord::SHomIt it = _W.IterHomonyms(); it.Ok(); ++it)
if (it->IsShortAdjectiveOrParticiple())
return true;
return false;
}
示例9: HasCommonHomonyms
bool CWord::HasCommonHomonyms(const CWord& w) const
{
if (!IsDictionary() || !w.IsDictionary()) {
SHomIt it1 = IterHomonyms();
SHomIt it2 = w.IterHomonyms();
if (it1.Ok() && it2.Ok() && TMorph::IdentifSimilar(it1->Lemma, it2->Lemma))
return true;
}
for (SHomIt it1 = IterHomonyms(); it1.Ok(); ++it1)
for (SHomIt it2 = w.IterHomonyms(); it2.Ok(); ++it2)
if (it1->Lemma == it2->Lemma)
return true;
return false;
}
示例10: HasCompar
bool CAnalyticFormBuilder::HasCompar(const CWord& W)
{
for (CWord::SHomIt it = W.IterHomonyms(); it.Ok(); ++it)
if (it->IsFullAdjective() && it->HasGrammem(gComparative))
return true;
return false;
}
示例11: HasInfinitive
bool CAnalyticFormBuilder::HasInfinitive(const CWord& W)
{
for (CWord::SHomIt it = W.IterHomonyms(); it.Ok(); ++it)
if (it->HasGrammem(gInfinitive))
return true;
return false;
}
示例12: ToHTMLColorString
Stroka CSentence::ToHTMLColorString(const yvector<CWordsPair>& wp, const Stroka& sColor, ECharset encoding) const
{
Stroka str;
for (size_t i = 0; i + 1 <= m_words.size(); ++i) {
CWord* pW = m_words[i].Get();
for (size_t j = 0; j < wp.size(); ++j)
if (wp[j].FirstWord() == (int)i)
str += Substitute("<font color=\"$0\">", sColor);
if (i > 0 && (!pW->IsPunct() || pW->IsOpenBracket() || pW->IsCloseBracket()))
str += " ";
str += NStr::Encode(pW->GetOriginalText(), encoding);
for (size_t j = 0; j < wp.size(); ++j)
if (wp[j].LastWord() == (int)i)
str += "</font>";
}
return StripString(str);
}
示例13: HasPredik
bool CAnalyticFormBuilder::HasPredik(const CWord& W)
{
for (CWord::SHomIt it = W.IterHomonyms(); it.Ok(); ++it)
if (!it->Grammems.IsIndeclinable()) // "бух","спасибо" не строятся с анал. формами
if (it->HasGrammem(gPraedic))
return true;
return false;
}
示例14: getPossibleTagsBySuffix
unsigned long long TARGET_LANGUAGE::CTagger::getPossibleTagsForWord( const CWord &word ) {
static unsigned long long possible_tags;
possible_tags = m_TagDict.lookup(word);
if (possible_tags==0) possible_tags = ~0L;
#ifdef _ENGLISH_TAGS_H
possible_tags |= getPossibleTagsBySuffix( word.str() );
possible_tags |= PENN_TAG_MUST_SEE ;
#endif
assert(possible_tags!=0);
return possible_tags;
}
示例15: FindOrMakeMultiwordHomonym
// return found (or newly made) homonym id
static int FindOrMakeMultiwordHomonym(const CWordSequence& ws, CWord& word, TKeyWordType kwtype, THomonymGrammems grammems, THomonymPtr& res) {
// use the content of CWordSequence.m_Lemmas as new homonym lemma
Wtroka str = ws.GetLemma();
if (!str)
str = word.GetLowerText();
TMorph::ToLower(str);
int homId = -1;
// search if we already have a multiword homonym with such text
if (!FindBestHomonym(word, str, kwtype, grammems, homId)) {
// create new homonym, if there is no ready one
res = new CHomonym(TMorph::GetMainLanguage(), str);
if (ws.HasAuxArticle())
res->PutAuxArticle(ws.GetAuxArticleIndex());
else
res->PutGztArticle(ws.GetGztArticle());
homId = word.AddRusHomonym(res);
}
return homId;
}