当前位置: 首页>>代码示例>>C++>>正文


C++ Sentence::are_found_in_sentence方法代码示例

本文整理汇总了C++中Sentence::are_found_in_sentence方法的典型用法代码示例。如果您正苦于以下问题:C++ Sentence::are_found_in_sentence方法的具体用法?C++ Sentence::are_found_in_sentence怎么用?C++ Sentence::are_found_in_sentence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sentence的用法示例。


在下文中一共展示了Sentence::are_found_in_sentence方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: parse_qualitative_1_time

int parse_qualitative_1_time( Sentence& mSentence, time_t& sTime )
{
	// Parse Qualitative time:
	parsed_qualitative_duration = mSentence.are_found_in_sentence( "in the last %d (day|days|hour|hours|minute|minutes|seconds)" ) || 
								  mSentence.are_found_in_sentence( "between" );	// hour, day, 5 hours, 5 minutes.
	
	parsed_qualitative_duration  = mSentence.are_found_in_sentence( "at [specific time ie five thirty]" );
	parsed_qualitative_time = parsed_qualitative_duration;	
}
开发者ID:stenniswood,项目名称:bk_code,代码行数:9,代码来源:qualitative_time.cpp

示例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;
}
开发者ID:stenniswood,项目名称:bk_code,代码行数:11,代码来源:menus_orders.cpp

示例3: 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;
}
开发者ID:stenniswood,项目名称:bk_code,代码行数:19,代码来源:menus_orders.cpp

示例4: catagory_match

int Menu::catagory_match( Sentence& mSentence, int& match_index )
{
    int match_count = 0;
    match_index =-1;
    
    // Iterate over all menuitems:
    for (int mi=0; mi<m_items.size(); mi++)
    {
        match_count += mSentence.are_found_in_sentence( m_items[mi].catagory );
        if ((match_count) && (match_index==-1))
            match_index = mi;
    }
    return match_count;
}
开发者ID:stenniswood,项目名称:bk_code,代码行数:14,代码来源:menu_items.cpp

示例5: what_kind_of__do_you_have

int Menu::what_kind_of__do_you_have( Sentence& mSentence, ServerHandler* mh )
{
    string str;
    //if (mSentence.regex_found_in_sentence("what (kind|types) of"))
    if (mSentence.are_found_in_sentence("what kind of")||mSentence.are_found_in_sentence("what types of"))
    {
        //int windex  = mSentence.get_word_pointer();
        int index=-1;
        int result = catagory_match( mSentence, index );
        if (result==0)
            mh->form_response( "We do not have any." );
        else {
            //string next_word = mSentence.m_reduced_sentence.m_split_words[0];
            
            // search for a catagory:
            string all_of = list_all_of_catagory(m_items[index].catagory);
            str = "We have ";
            str += all_of.c_str();
            mh->form_response(str.c_str());
            return 1;
        }
    }
    return 0;
}
开发者ID:stenniswood,项目名称:bk_code,代码行数:24,代码来源:menu_items.cpp

示例6: find_matching_required_options

/*  Searches the sentence for any and all matching words
    Works "inplace" ie modifies internal selected_index variable.
 
INPUT:
    mStartingWordIndex  - word index for the menu item.  ie. "baked potatoe soup"  point to 'baked'
RETURN:
    number of distinct required_options that were found and updated.
 */
int MenuItem::find_matching_required_options( Sentence& mSentence, int mStartingWordIndex  )      // match score
{
    int retval = 0;
    
    // Search for any required options present:
    for (int ro=0; ro<m_required_options.size(); ro++ )
    {
        size_t num_words_in_option = m_required_options[ro].name.m_split_words.size();
        size_t prefix_word_index   = mStartingWordIndex - num_words_in_option;
        int result = mSentence.are_found_in_sentence( m_required_options[ro].name.c_str() );
        if (result==prefix_word_index)
        {
            m_required_options[ro].selected_item = ro;
            retval++;
        }
    }
    return retval;
}
开发者ID:stenniswood,项目名称:bk_code,代码行数:26,代码来源:menu_items.cpp

示例7: how_much_is

int Menu::how_much_is( Sentence& mSentence, ServerHandler* mh )
{
    int result =0;
    RestaurantOrder tmpOrder;
    if (mSentence.are_found_in_sentence("how much"))
    {
        result = Parse_Menu( mSentence, mh, tmpOrder);
        if (tmpOrder.m_order.size()==0)
            mh->form_response("I could not find that on the menu.");
        else {
            SuperString tmp = "Okay, ";
            tmpOrder.read_back_items( tmp );
            tmp += " costs $";
            float total = tmpOrder.get_total();
            tmp.append_float ( total );
            mh->form_response( tmp.c_str() );
        }
        return 1;
    }
    return 0;
}
开发者ID:stenniswood,项目名称:bk_code,代码行数:21,代码来源:menu_items.cpp

示例8: 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;
}
开发者ID:stenniswood,项目名称:bk_code,代码行数:91,代码来源:qualitative_time.cpp


注:本文中的Sentence::are_found_in_sentence方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。