亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? textquery.c

?? C++ Primer(第三版)的隨書源代碼
?? C
字號:
#include "TextQuery.h"

string TextQuery::filt_elems( "\",.;:!?)(\\/" );

void
TextQuery::
// display_solution( ostream &os )
display_solution()
{
	cout << "\n"
	     << "Requested query: "
	     << *query << "\n\n";

	const set<short,less<short>,allocator> *solution = query->solution();
	
	if ( ! solution->size() ) {
	     cout << "\n\t" 
		  << "Sorry, no matching lines were found in text.\n"
		  << endl;
	}

	set<short,less<short>,allocator>::const_iterator 
		it = solution->begin(),
		end_it = solution->end();

	for ( ; it != end_it; ++it ) {
		int line = *it;
		// don't confound user with text lines starting at 0 ...
		cout << "( " << line+1 << " ) "
		     << (*lines_of_text)[line] << '\n';
	}

	cout << endl;
}

void
TextQuery::
retrieve_text()
{
	string file_name;
	
	cout << "please enter file name: ";
	cin  >> file_name;

	ifstream infile( file_name.c_str(), ios::in );
	if ( !infile ) {
		cerr << "oops! unable to open file "
		     << file_name << " -- bailing out!\n";
		exit( -1 );
	}
	else cout << "\n";

	lines_of_text = new vector<string,allocator>;
	string textline;

	while ( getline( infile, textline, '\n' ))
		  lines_of_text->push_back( textline );
}

void
TextQuery::
separate_words()
{
	vector<string,allocator>   *words     = new vector<string,allocator>;
	vector<location,allocator> *locations = new vector<location,allocator>;

        for ( short line_pos = 0; line_pos < lines_of_text->size(); line_pos++ )
        {
		short  word_pos = 0;
                string textline = (*lines_of_text)[ line_pos ];

                string::size_type eol = textline.length();
                string::size_type pos = 0, prev_pos = 0;

                while (( pos = textline.find_first_of( ' ', pos )) 
                            != string::npos )
                {
                        words->push_back( 
                               textline.substr( prev_pos, pos - prev_pos ));
                        locations->push_back( make_pair( line_pos, word_pos ));

                        word_pos++; pos++; prev_pos = pos;
                }

                words->push_back( textline.substr( prev_pos, pos - prev_pos ));
                locations->push_back( make_pair( line_pos, word_pos ));

                // record size of each line
                line_cnt.push_back( word_pos );
        }
	
        text_locations = new text_loc( words, locations );
}

void 
TextQuery::
filter_text()
{
	if ( filt_elems.empty() )
	     return;

	vector<string,allocator> *words = text_locations->first;

	vector<string,allocator>::iterator iter = words->begin();
	vector<string,allocator>::iterator iter_end = words->end();

	while ( iter != iter_end )
	{
                string::size_type pos = 0;
                while (( pos = (*iter).find_first_of( filt_elems, pos )) 
                            != string::npos )
                       (*iter).erase(pos,1);
		iter++;
	}
}

void
TextQuery::
suffix_text()
{
        vector<string,allocator> *words = text_locations->first;

        vector<string,allocator>::iterator iter = words->begin();
        vector<string,allocator>::iterator iter_end = words->end();

        while ( iter != iter_end )
        {
		// if 3 or less characters, let it be
		if ( (*iter).size() <= 3 ) { iter++; continue; }
		if ( (*iter)[ (*iter).size()-1 ] == 's' )
		       suffix_s( *iter );

		// additional suffix handling goes here ...

		iter++;
        }
}

void
TextQuery::
suffix_s( string &word )
{
        string::size_type spos = 0;
        string::size_type pos3 = word.size()-3;

        // "ous", "ss", "is", "ius"
        string suffixes( "oussisius" );

        if ( ! word.compare( pos3, 3, suffixes, spos, 3 ) ||
             ! word.compare( pos3, 3, suffixes, spos+6, 3 ) ||
             ! word.compare( pos3+1, 2, suffixes, spos+2, 2 ) ||
             ! word.compare( pos3+1, 2, suffixes, spos+4, 2 ))
                return;

        string ies( "ies" );
        if ( ! word.compare( pos3, 3, ies ))
        {
             word.replace( pos3, 3, 1, 'y' );
             return;
        }

        string ses( "ses" );
        if ( ! word.compare( pos3, 3, ses ))
        {
             word.erase( pos3+1, 2 );
             return;
        }

        // erase ending 's'
        word.erase( pos3+2 );

        // watch out for "'s"
        if ( word[ pos3+1 ] == '\'' )
             word.erase( pos3+1 );
}

void
TextQuery::
strip_caps()
{
        vector<string,allocator> *words = text_locations->first;

        vector<string,allocator>::iterator iter = words->begin();
        vector<string,allocator>::iterator iter_end = words->end();

        string caps( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" );

        while ( iter != iter_end ) {
                string::size_type pos = 0;
                while (( pos = (*iter).find_first_of( caps, pos )) 
                            != string::npos )
                       (*iter)[ pos ] = tolower( (*iter)[pos] );
                ++iter;
        }
}


void
TextQuery::
build_word_map()
{
     word_map = new map< string, loc*, less<string>, allocator >;

     typedef map<string,loc*,less<string>,allocator>::value_type value_type;
     typedef set<string,less<string>,allocator>::difference_type diff_type;

     set<string,less<string>,allocator> exclusion_set;

     ifstream infile( "exclusion_set" );
     if ( !infile )
     {
          static string default_excluded_words[25] = {
            "the","and","but","that","then","are","been",
            "can","can't","cannot","could","did","for",
            "had","have","him","his","her","its","into",
            "were","which","when","with","would"
          };

          cerr << "warning! unable to open word exclusion file! -- "
               << "using default set\n";

          copy( default_excluded_words, default_excluded_words+25, 
                inserter( exclusion_set, exclusion_set.begin() ));
     }
     else {
          istream_iterator< string, diff_type > input_set( infile ), eos;
          copy( input_set, eos, 
                inserter( exclusion_set, exclusion_set.begin() ));
     }

     // iterate through the the words, entering the key/pair

     vector<string,allocator>   *text_words = text_locations->first;
     vector<location,allocator> *text_locs  = text_locations->second;

     register int elem_cnt = text_words->size();
     for ( int ix = 0; ix < elem_cnt; ++ix )
         {
                string textword = ( *text_words )[ ix ];

                // exclusion strategies
                // less than 3 character or in exclusion set
                if ( textword.size() < 3 ||
                     exclusion_set.count( textword ))
                        continue;

                if ( ! word_map->count((*text_words)[ix] ))
                {  // not present, add it:
                   loc *ploc = new vector<location,allocator>;
                   ploc->push_back( (*text_locs)[ix] );
                   word_map->insert( value_type( (*text_words)[ix], ploc ));
                }
                else (*word_map)[(*text_words)[ix]]->push_back( (*text_locs)[ix] );
         }
}

void 
TextQuery::
query_text() 
{
	string text;
	string caps( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" );

	vector<string, allocator> query_text;

	UserQuery user_query;
 	init_query_statics();
    
	do {
		query_text.clear();

 	cout << "Enter a query -- please separate each item "
			<< "by a space.\n"
		<< "Terminate query (or session) with a dot( . ).\n\n"
			<< "==> ";
	   
	   	while( cin  >> text ) 
   		{ 
		     if ( text == "." )
		          break;

		     // remove all capitalization ...
 		     string::size_type pos = 0;
     while (( pos = text.find_first_of( caps, pos )) 
				     != string::npos )
                          text[pos] = tolower( text[pos] );

		     query_text.push_back( text );
	   	}

	   	if ( ! query_text.empty() ) 
		{
	   		user_query.query( &query_text );
	   		query = user_query.eval();
	   		query->eval();
	   		display_solution();
	    		cout << endl;
		}
        }
	while ( ! query_text.empty() );
        cout << "Ok, bye!\n";
}

void
TextQuery::
display_map_text()
{
        typedef map<string,loc*,less<string>,allocator> map_text;
        map_text::iterator iter = word_map->begin(), iter_end = word_map->end();

        while ( iter != iter_end ) {
                cerr << "word: " << (*iter).first << " (";

                int           loc_cnt = 0;
                loc          *text_locs = (*iter).second;
                loc::iterator liter     = text_locs->begin(),
                              liter_end = text_locs->end();

                while ( liter != liter_end )
                {
                        if ( loc_cnt )
                             cerr << ",";
                        else ++loc_cnt;

                        cerr << "(" << (*liter).first
                             << "," << (*liter).second << ")";

                        ++liter;
                }

                cerr << ")\n";
                ++iter;
        }

        cerr << endl;
}

void
TextQuery::
display_text_locations()
{
        vector<string,allocator>   *text_words     = text_locations->first;
        vector<location,allocator> *text_locs      = text_locations->second;

        register int elem_cnt = text_words->size();

        if ( elem_cnt != text_locs->size() )
        {
             cerr << "oops! internal error: word and position vectors "
                  << "are of unequal size\n"
                  << "words: " << elem_cnt << " "
                  << "locs: "  << text_locs->size()
                  << " -- bailing out!\n";
             exit( -2 );
        }

        for ( int ix = 0; ix < elem_cnt; ix++ )
        {
                cout << "word: " << (*text_words)[ ix ] << "\t"
                     << "location: ("
                     << (*text_locs)[ix].first  << ","
                     << (*text_locs)[ix].second << ")"
                     << "\n";
        }

        cout << endl;
}

/*
sample input text:
------------------

Alice Emma has long flowing red hair. Her Daddy says
when the wind blows through her hair, it looks almost alive,
like a fiery bird in flight. A beautiful fiery bird, he tells her,
magical but untamed. "Daddy, shush, there is no such thing,"
she tells him, at the same time wanting him to tell her more.
Shyly, she asks, "I mean, Daddy, is there?"

---------------------
sample query session:
---------------------

please enter file name: alice_emma

warning! unable to open word exclusion file! -- using default set

enter a word against which to search the text.
to quit, enter a single character ==>  alice

alice occurs 1 time:

        ( line 1 ) Alice Emma has long flowing red hair. Her Daddy says

enter a word against which to search the text.
to quit, enter a single character ==>  daddy

daddy occurs 3 times:

        ( line 1 ) Alice Emma has long flowing red hair. Her Daddy says
        ( line 4 ) magical but untamed. "Daddy, shush, there is no such thing,"
        ( line 6 ) Shyly, she asks, "I mean, Daddy, is there?"

enter a word against which to search the text.
to quit, enter a single character ==>  phoenix

Sorry. There are no entries for phoenix.

enter a word against which to search the text.
to quit, enter a single character ==>  .
Ok, bye!

----------------------------------------------------------
sample text map after: (a) stripping out punctuation,
(b) eliminating semantically neutral words such as `the`,
(c) suffixing, so that fixes and fix become fix, and
(d) removal of capitalization
-----------------------------------------------------------

word: alice ((0,0))
word: alive ((1,10))
word: almost ((1,9))
word: ask ((5,2))
word: beautiful ((2,7))
word: bird ((2,3),(2,9))
word: blow ((1,3))
word: daddy ((0,8),(3,3),(5,5))
word: emma ((0,1))
word: fiery ((2,2),(2,8))
word: flight ((2,5))
word: flowing ((0,4))
word: hair ((0,6),(1,6))
word: has ((0,2))
word: like ((2,0))
word: long ((0,3))
word: look ((1,8))
word: magical ((3,0))
word: mean ((5,4))
word: more ((4,12))
word: red ((0,5))
word: same ((4,5))
word: say ((0,9))
word: she ((4,0),(5,1))
word: shush ((3,4))
word: shyly ((5,0))
word: such ((3,8))
word: tell ((2,11),(4,1),(4,10))
word: there ((3,5),(5,7))
word: thing ((3,9))
word: through ((1,4))
word: time ((4,6))
word: untamed ((3,2))
word: wanting ((4,7))
word: wind ((1,2))

*/

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产美女一区二区三区| 日韩欧美高清一区| 91精品国产综合久久久蜜臀粉嫩 | 久久精品欧美日韩精品| 亚洲在线免费播放| 国产91富婆露脸刺激对白| 欧美酷刑日本凌虐凌虐| 亚洲丝袜美腿综合| 国产美女精品人人做人人爽| 欧美日韩成人一区二区| 亚洲四区在线观看| 国产一区二区三区视频在线播放| 欧美日韩日日摸| 国产精品久久福利| 粗大黑人巨茎大战欧美成人| 精品久久久久久亚洲综合网| 丝袜美腿亚洲色图| 欧美日韩电影在线| 亚洲影院免费观看| 色琪琪一区二区三区亚洲区| 中文字幕在线不卡一区二区三区| 国产一区二区三区在线观看免费视频| 欧美日韩精品三区| 亚洲国产精品一区二区www| 91网站在线播放| 中文字幕日韩精品一区| 成人一道本在线| 国产三级精品在线| 国产成人亚洲精品狼色在线| 2021中文字幕一区亚洲| 狠狠色狠狠色综合系列| 精品欧美一区二区久久| 久久99国产精品久久| 欧美成人欧美edvon| 精品在线免费视频| 国产婷婷色一区二区三区在线| 麻豆91在线播放免费| 日韩精品一区二区三区视频播放| 免费高清在线一区| 久久色在线观看| 成人免费福利片| 亚洲少妇30p| 欧美精品日韩一本| 美腿丝袜亚洲综合| 久久毛片高清国产| aa级大片欧美| 亚洲成人动漫av| 欧美成人综合网站| 国产精品一区二区黑丝| 欧美高清在线一区二区| 91久久精品一区二区二区| 日韩专区一卡二卡| 国产无遮挡一区二区三区毛片日本| 懂色av一区二区三区免费观看| 国产精品国产三级国产有无不卡| 在线国产亚洲欧美| 日韩av午夜在线观看| 久久精品亚洲精品国产欧美| 97精品久久久午夜一区二区三区 | 亚洲视频精选在线| 欧美三级电影在线看| 麻豆精品在线观看| 国产精品午夜在线| 欧美性欧美巨大黑白大战| 蓝色福利精品导航| 亚洲六月丁香色婷婷综合久久| 91精品在线一区二区| 国产成人av电影在线播放| 亚洲在线视频一区| 国产片一区二区三区| 欧美精品一卡两卡| 成人免费av资源| 日本不卡一二三区黄网| 国产精品国模大尺度视频| 欧美一区二区二区| 91网站在线播放| 国产精品一区二区久激情瑜伽 | 欧美亚洲动漫制服丝袜| 激情深爱一区二区| 亚洲国产日韩精品| 日本一区二区电影| 日韩一级片网站| 91视频xxxx| 国产盗摄一区二区| 男人的天堂久久精品| 有坂深雪av一区二区精品| 中文av一区二区| 欧美精品一区二区三区视频| 欧美制服丝袜第一页| 99re6这里只有精品视频在线观看 99re8在线精品视频免费播放 | 午夜不卡av在线| 亚洲欧美欧美一区二区三区| www激情久久| 日韩午夜精品视频| 欧美另类z0zxhd电影| 日本久久一区二区三区| www.色综合.com| 东方欧美亚洲色图在线| 免费观看成人av| 日韩中文字幕不卡| 亚洲一区二区在线观看视频| 亚洲欧洲成人精品av97| 亚洲国产精华液网站w| 国产视频亚洲色图| 久久九九国产精品| 国产亚洲福利社区一区| 久久久久久久久久美女| 久久久精品蜜桃| 久久婷婷综合激情| 欧美激情在线看| 国产日韩欧美激情| 欧美激情一区二区三区蜜桃视频| 久久免费视频色| 国产欧美一区二区三区网站 | 欧美一级久久久| 日韩一区二区视频| 欧美电影免费观看高清完整版在| 91精品国产欧美日韩| 欧美一区二区三区在线视频| 91精选在线观看| 精品国产亚洲在线| 久久久美女毛片| 中文字幕免费观看一区| 亚洲天堂2014| 图片区小说区区亚洲影院| 免费在线观看精品| 国模一区二区三区白浆| 国产成人精品免费看| 96av麻豆蜜桃一区二区| 日本精品免费观看高清观看| 欧美色网一区二区| 日韩一级在线观看| 国产精品家庭影院| 亚洲综合色视频| 青青草成人在线观看| 成人中文字幕在线| 在线亚洲人成电影网站色www| 欧美乱妇20p| 久久精品亚洲乱码伦伦中文| 亚洲人成影院在线观看| 日韩激情一二三区| 粉嫩av一区二区三区| 欧美日韩中文字幕一区二区| 欧美成人性战久久| 亚洲摸摸操操av| 久久精品国产免费看久久精品| 国产成人免费9x9x人网站视频| 91女神在线视频| 精品不卡在线视频| 一区二区三区成人| 国产精品夜夜嗨| 欧美三级视频在线观看| 国产日韩精品一区二区浪潮av| 夜夜精品视频一区二区| 国内久久精品视频| 欧美私模裸体表演在线观看| 久久精品日产第一区二区三区高清版 | 国产精品久久久久影院| 亚洲国产精品人人做人人爽| 久久国产尿小便嘘嘘| 91久久精品午夜一区二区| 337p粉嫩大胆色噜噜噜噜亚洲 | 亚洲欧美激情在线| 精品一区二区三区日韩| 在线观看日韩一区| 国产精品麻豆欧美日韩ww| 另类小说欧美激情| 欧美日韩在线播| 亚洲日本在线视频观看| 国产一区二区精品久久91| 91精品福利在线一区二区三区 | 欧美日韩综合不卡| 国产精品久久久久天堂| 国产综合久久久久久久久久久久| 欧美视频你懂的| 亚洲免费视频成人| 成人性色生活片| 久久尤物电影视频在线观看| 丝瓜av网站精品一区二区| 色综合天天狠狠| 国产精品伦一区二区三级视频| 韩国一区二区在线观看| 日韩欧美国产成人一区二区| 五月婷婷久久丁香| 在线免费观看视频一区| 最近日韩中文字幕| av在线不卡观看免费观看| 中文欧美字幕免费| 成人美女在线视频| 国产区在线观看成人精品| 国产综合色视频| 久久看人人爽人人| 国产乱码精品一区二区三 | 国产麻豆精品视频| 日韩三级中文字幕| 美女视频免费一区| 精品久久久久久久人人人人传媒| 极品少妇xxxx精品少妇偷拍| 日韩你懂的电影在线观看| 久久99日本精品|