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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? textquery.c

?? 侯捷翻譯的c++ primer隨書的源代碼,一起學c
?? 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一区二区三区免费野_久草精品视频
国产精品久久久久aaaa| 欧美性色黄大片手机版| 91精品国产色综合久久不卡电影| 亚洲精品成人少妇| 99re热视频精品| 国产精品丝袜久久久久久app| 国产一区二区免费在线| 日韩三级在线观看| 青青草成人在线观看| 在线不卡一区二区| 亚洲二区视频在线| 国产一区在线精品| 国产目拍亚洲精品99久久精品| 国产精品99久久久久| 久久精品在线免费观看| 国产激情视频一区二区三区欧美| 欧美不卡视频一区| 韩国三级电影一区二区| 久久久精品影视| 成人免费视频一区| 亚洲精品中文在线观看| 欧美性三三影院| 日本成人在线看| 2017欧美狠狠色| 国产jizzjizz一区二区| 日本一区二区不卡视频| 91最新地址在线播放| 一区二区三区在线不卡| 4438x成人网最大色成网站| 日韩精品一级中文字幕精品视频免费观看 | 有码一区二区三区| 欧美人与z0zoxxxx视频| 精品一区二区三区影院在线午夜| 久久久久青草大香线综合精品| 国产91清纯白嫩初高中在线观看| 久久综合九色综合97婷婷女人 | 精品国产百合女同互慰| 黄页视频在线91| 国产精品高清亚洲| 欧美久久久久久久久中文字幕| 久久97超碰国产精品超碰| 国产精品久线在线观看| 91丨porny丨首页| 青青草国产成人99久久| 国产精品国产三级国产aⅴ中文| 欧美丝袜丝nylons| 国模一区二区三区白浆| 亚洲欧美日韩在线不卡| 欧美日韩国产精品成人| 国产成人av网站| 亚洲午夜成aⅴ人片| 国产亚洲制服色| 欧美色综合天天久久综合精品| 精彩视频一区二区三区| 亚洲欧美日韩国产另类专区| 日韩欧美激情四射| 日本韩国欧美一区| 久久66热re国产| 一区二区激情视频| 久久久电影一区二区三区| 欧美性videosxxxxx| 粉嫩av一区二区三区粉嫩| 婷婷丁香激情综合| 中文字幕在线不卡一区| 欧美精品一区二区蜜臀亚洲| 欧美性猛片xxxx免费看久爱| 激情国产一区二区| 亚洲电影在线免费观看| 国产精品色哟哟| 久久中文字幕电影| 欧美日韩国产美| bt欧美亚洲午夜电影天堂| 久久99精品久久久久久久久久久久 | 亚洲激情网站免费观看| 国产片一区二区| 日韩精品最新网址| 欧美日本免费一区二区三区| 一本色道久久综合精品竹菊| 国产乱淫av一区二区三区| 美女视频第一区二区三区免费观看网站| 亚洲乱码国产乱码精品精98午夜 | 色欧美片视频在线观看在线视频| 国产精品538一区二区在线| 奇米影视一区二区三区| 有坂深雪av一区二区精品| 国产婷婷一区二区| 久久影院视频免费| 日韩一级精品视频在线观看| 欧美日本视频在线| 91久久久免费一区二区| 97久久精品人人爽人人爽蜜臀 | 欧美精品在线观看一区二区| 91免费版在线| 99久久精品久久久久久清纯| 国产成人av一区二区三区在线 | 亚洲视频 欧洲视频| 国产精品美女www爽爽爽| 国产精品三级av在线播放| 亚洲精品一线二线三线无人区| 日韩欧美一区中文| 日韩三级免费观看| 精品国产3级a| 4438x成人网最大色成网站| 91精品国产一区二区三区香蕉| 欧美熟乱第一页| 7777女厕盗摄久久久| 精品国产乱码久久久久久蜜臀| 国产三级精品视频| ㊣最新国产の精品bt伙计久久| 亚洲男人的天堂在线观看| 亚洲影视在线观看| 裸体一区二区三区| 丁香婷婷深情五月亚洲| 欧美图片一区二区三区| 精品av综合导航| 亚洲欧洲制服丝袜| 欧美日韩久久不卡| 91精品国产品国语在线不卡| 欧美三级三级三级| 欧美不卡视频一区| 亚洲天堂成人网| 奇米在线7777在线精品| 高清在线成人网| 欧美日韩高清一区| 欧美激情自拍偷拍| 视频一区二区中文字幕| 国产精品1区二区.| 91.麻豆视频| 国产精品电影院| 久久国产日韩欧美精品| 成人黄色小视频| 精品美女在线播放| 亚洲高清免费观看| 懂色av一区二区三区免费观看 | 99精品在线免费| 欧美一区日韩一区| 国产精品不卡一区二区三区| 麻豆国产精品777777在线| 色悠悠久久综合| 欧美国产日产图区| 久久99精品视频| 欧美日韩国产区一| 亚洲精品福利视频网站| 国产成人在线视频播放| 日韩一级黄色大片| 亚洲成av人片在www色猫咪| 成人高清在线视频| 2020国产精品自拍| 日本成人在线不卡视频| 日本道免费精品一区二区三区| 国产性做久久久久久| 免费观看30秒视频久久| 欧美日韩另类一区| 亚洲精选视频免费看| 成人av电影在线播放| 久久久久亚洲综合| 久久国产尿小便嘘嘘尿| 欧美一级高清片| 日韩激情中文字幕| 欧美色涩在线第一页| 亚洲精品中文字幕在线观看| 91丨porny丨首页| 亚洲色图.com| 国内精品国产成人| 精品精品欲导航| 久久精品国产第一区二区三区| 欧美一区二区三区四区高清| 五月婷婷综合网| 69堂亚洲精品首页| 日韩激情av在线| 91精品免费在线观看| 秋霞午夜鲁丝一区二区老狼| 91精品蜜臀在线一区尤物| 亚洲成人综合网站| 欧美日韩国产一区| 日本中文字幕一区二区有限公司| 欧美久久久一区| 麻豆高清免费国产一区| 精品国产亚洲在线| 国产福利91精品| 国产精品二区一区二区aⅴ污介绍| 99久久精品99国产精品 | 久久久久久夜精品精品免费| 精品一区二区三区免费| 久久精品视频在线看| 国产a视频精品免费观看| 国产精品欧美久久久久无广告 | 国产在线观看一区二区| 久久综合久久久久88| 成人av网站免费观看| 最新热久久免费视频| 欧洲在线/亚洲| 蜜桃视频一区二区三区| 国产拍揄自揄精品视频麻豆| 91丨九色porny丨蝌蚪| 亚洲国产色一区| 精品日韩一区二区三区免费视频| 国产精品1区2区| 亚洲综合色视频| 精品剧情v国产在线观看在线|