本文整理汇总了C++中Sentence::is_found_in_sentence方法的典型用法代码示例。如果您正苦于以下问题:C++ Sentence::is_found_in_sentence方法的具体用法?C++ Sentence::is_found_in_sentence怎么用?C++ Sentence::is_found_in_sentence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sentence
的用法示例。
在下文中一共展示了Sentence::is_found_in_sentence方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: is_order_complete
int RestaurantOrder::is_order_complete( Sentence& mSentence )
{
orderFoundComplete = mSentence.are_found_in_sentence( "no more" ) ||
mSentence.are_found_in_sentence( "that's it" ) ||
mSentence.are_found_in_sentence( "that's all" ) ||
mSentence.is_found_in_sentence( "no" );
if (orderFoundComplete)
return 1;
else
return 0;
}
示例3: dow_is_found
// "(yesterday|today|tomorrow)|(\d+ days ago)|(sunday|monday|tuesday|wednesday|thursday|friday|saturday)"
int dow_is_found( Sentence& mSentence )
{
int retval=0;
retval = mSentence.is_found_in_sentence("today");
if (retval) return bd_now.tm_mday;
retval = mSentence.is_found_in_sentence("yesterday");
if (retval) return bd_now.tm_mday-1;
retval = mSentence.is_found_in_sentence("tomorrow");
if (retval) return bd_now.tm_mday+1;
retval = mSentence.regex_find("(\\d+ )days ago");
if (retval) {
string val = mSentence.m_sentence.regex_matches[0];
int d= atoi(val.c_str());
return bd_now.tm_mday-d;
}
for (int d=0; d<7; d++)
if (mSentence.is_found_in_sentence(days_of_week[d].c_str()))
return d;
return retval;
}
示例4: month_is_found
// "((this|last|next) month)|(\d+ months ago)|(\d+ months from now)|(in the last \d+ months)"
int month_is_found( Sentence& mSentence )
{
int retval=0;
retval = mSentence.is_found_in_sentence("this month");
if (retval)
{
retval = bd_now.tm_mon;
return retval;
}
retval = mSentence.is_found_in_sentence("last month");
if (retval)
{ retval = bd_now.tm_mon-1; return retval; }
retval = mSentence.is_found_in_sentence("next month");
if (retval)
{ retval = bd_now.tm_mon+1; return retval; }
retval = mSentence.regex_find("(\\d+) months ago");
if (retval)
{
//mSentence.m_sentence.print_matches();
string val = mSentence.m_sentence.regex_matches[0];
int m = atoi(val.c_str());
retval = bd_now.tm_mon-m;
}
retval = mSentence.regex_find("(\\d+) months from now");
if (retval)
{
//mSentence.m_sentence.print_matches();
string val = mSentence.m_sentence.regex_matches[0];
int m = atoi( val.c_str() );
retval = bd_now.tm_mon+m;
}
for (int m=0; m<12; m++)
if (mSentence.is_found_in_sentence( Months[m].c_str() ))
return m;
return retval;
}
示例5: is_request_order_readback
int RestaurantOrder::is_request_order_readback( Sentence& mSentence, ServerHandler* mh )
{
int proceed = mSentence.is_found_in_sentence( "repeat" ) ||
mSentence.are_found_in_sentence( "say again" ) ||
mSentence.are_found_in_sentence( "say order" ) ||
mSentence.are_found_in_sentence( "so far" ) ||
mSentence.are_found_in_sentence( "tell me" );
if (proceed) {
string str;
read_back_order ( str );
mh->form_response( str.c_str() );
anything_else ( mh );
};
if (proceed)
return 1;
else
return 0;
}
示例6: parse_qualitative_2_time
/* Return : -1 not processed */
int parse_qualitative_2_time( Sentence& mSentence, struct tm& sTime, struct tm& eTime )
{
int retval = -1;
vector<int> answers;
vector<int> remove_wi;
parsed_qualitative_time = false;
parsed_qualitative_duration = false;
time_t start;
time_t now;
time( &now );
int result;
int between = mSentence.is_found_in_sentence( "between" );
// if (result) retval = 1;
result = mSentence.is_found_in_sentence( "today" );
if (result) {
parsed_qualitative_time = true;
parsed_qualitative_duration = true;
eTime = *(localtime( &now ));
sTime = eTime;
sTime.tm_hour = 0;
sTime.tm_min = 0;
sTime.tm_sec = 0;
retval = 1;
}
result = mSentence.is_found_in_sentence( "yesterday" );
if (result) {
parsed_qualitative_time = true;
parsed_qualitative_duration = true;
update_now_time();
eTime = bd_now;
eTime.tm_mday--;
eTime.tm_wday--;
eTime.tm_hour = 23;
eTime.tm_min = 59;
eTime.tm_sec = 59;
sTime = eTime;
sTime.tm_hour = 0;
sTime.tm_min = 0;
sTime.tm_sec = 0;
retval = 1;
}
result = mSentence.are_found_in_sentence( "this week" );
if (result) {
parsed_qualitative_time = true;
parsed_qualitative_duration = true;
eTime = bd_now;
sTime = eTime;
sTime.tm_mday-=sTime.tm_wday;
sTime.tm_wday = 0;
sTime.tm_hour =0; sTime.tm_min=0; sTime.tm_sec=0;
retval = 1;
}
//
result = mSentence.regex_find("(\\d+) days ago");
if (result) {
SuperString val( mSentence.m_reduced_sentence.regex_matches[0] );
string num = "\\d+";
int result2 = val.regex_find(num);
num = val.regex_matches[0];
int d = atoi( num.c_str() );
//printf("days ago: %s result=%d\n\n", num.c_str(), d );
parsed_qualitative_time = true;
parsed_qualitative_duration = true;
eTime = bd_now;
eTime.tm_mday = bd_now.tm_mday-d;
sTime = eTime;
mk_startofday(sTime);
mk_endofday (eTime);
retval = 1;
}
for (int d=0; d<7; d++)
if (mSentence.is_found_in_sentence(days_of_week[d].c_str()))
return d;
int dans = mSentence.are_found_in_sentence( "in the last" );
if (dans)
retval = 1;
string exp = integer_e;
exp += "(day|days|hour|hours|minute|minutes|seconds)";
//parsed_qualitative_duration = mSentence.are_found_in_sentence( "at [specific time ie five thirty]" );
//parsed_qualitative_time = parsed_qualitative_duration;
return retval;
}