本文整理汇总了C++中Sentence::get_word_index方法的典型用法代码示例。如果您正苦于以下问题:C++ Sentence::get_word_index方法的具体用法?C++ Sentence::get_word_index怎么用?C++ Sentence::get_word_index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sentence
的用法示例。
在下文中一共展示了Sentence::get_word_index方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: year_is_found
// "((this|next|last) year)|(\d\d\d\d)"
int year_is_found( Sentence& mSentence, struct tm* mFillin=NULL )
{
int retval=0;
retval = mSentence.is_found_in_sentence("this year");
if (retval)
{
if (mFillin) mFillin->tm_year = retval = bd_now.tm_year;
return retval;
} else if ((retval = mSentence.is_found_in_sentence("next year")))
{
if (mFillin) mFillin->tm_year = retval = bd_now.tm_year+1;
return retval;
} else if ((retval = mSentence.is_found_in_sentence("last year")))
{
if (mFillin) mFillin->tm_year = retval = bd_now.tm_year-1;
return retval;
}
/* Scan numbers 1900 to 2016 */
char year_ascii[4];
for (int year=1900; year<2100; year++) {
sprintf(year_ascii, "%d", year);
if (mSentence.is_found_in_sentence( year_ascii )) {
if (mFillin) mFillin->tm_year = year-1900;
return mSentence.get_word_index(year_ascii);
}
}
return retval;
}