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

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

?? textquery.c

?? C++ PRIME書中的原代碼,看本書時可以學習的例子.
?? 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一区二区三区免费野_久草精品视频
精品国产区一区| 国产一区二区在线观看视频| 国产一区二区伦理| 欧美亚洲综合久久| 国产亚洲一区二区三区在线观看 | 久久亚洲精精品中文字幕早川悠里 | 暴力调教一区二区三区| 亚洲天堂2016| 色综合久久综合网97色综合| 国产欧美日本一区视频| 国产一区二区女| 日韩欧美一二三四区| 精品一区二区三区不卡 | 国产免费久久精品| 国产精品亚洲视频| 亚洲一区二区3| 色综合激情久久| 日韩一区二区免费视频| 国产成人亚洲综合a∨猫咪| 日韩精品一区二区三区老鸭窝| 国内成人自拍视频| 中文字幕的久久| 在线观看国产91| 亚洲成人自拍一区| 91精品视频网| 国产在线精品视频| 国产日韩欧美不卡在线| 欧美另类videos死尸| 国产一区欧美一区| 一区二区三区四区五区视频在线观看| 色婷婷综合久色| 成人激情文学综合网| 日韩一区精品视频| 久久久久久日产精品| 丁香婷婷深情五月亚洲| 日韩一区中文字幕| 在线播放一区二区三区| 成人一区在线看| 久久青草国产手机看片福利盒子 | 91婷婷韩国欧美一区二区| 亚洲欧洲日韩一区二区三区| 欧美日韩极品在线观看一区| 久久精品国产99| 亚洲成在人线在线播放| 精品日韩在线一区| 岛国一区二区三区| 亚洲成av人**亚洲成av**| 久久久三级国产网站| 91麻豆蜜桃一区二区三区| 午夜激情久久久| 国产欧美日韩亚州综合 | 日韩手机在线导航| 欧美偷拍一区二区| 欧美性猛交xxxx黑人交| 成人毛片老司机大片| 激情伊人五月天久久综合| 免费观看91视频大全| 亚洲妇熟xx妇色黄| 亚洲一区在线观看视频| 亚洲欧美激情视频在线观看一区二区三区| 久久亚洲一区二区三区明星换脸| 欧美成人国产一区二区| 91精品国产美女浴室洗澡无遮挡| 欧美视频自拍偷拍| 欧美人伦禁忌dvd放荡欲情| 在线观看免费亚洲| 99久久久精品| 99riav久久精品riav| 成人性色生活片| 不卡视频在线看| 欧美日本国产视频| 亚洲精品欧美专区| 国产999精品久久久久久| 91精品国产91热久久久做人人 | 久草中文综合在线| 顶级嫩模精品视频在线看| 欧美精品在线一区二区三区| 日韩一区二区在线免费观看| 亚洲最新视频在线播放| 91同城在线观看| 亚洲欧洲av在线| 国产精品羞羞答答xxdd| 日韩高清在线观看| 欧美aaaaaa午夜精品| 欧美日韩精品电影| 久久伊99综合婷婷久久伊| 一区二区三区影院| 波多野结衣欧美| 欧美视频一区二区在线观看| 日韩欧美亚洲国产精品字幕久久久| 国产欧美日韩精品一区| 天堂成人国产精品一区| 成人精品免费视频| 91麻豆精品国产自产在线 | 亚洲欧美偷拍卡通变态| 激情小说欧美图片| 欧美成人午夜电影| 日韩精品亚洲专区| 欧美日韩精品高清| 性做久久久久久免费观看| av成人免费在线观看| 2023国产精品| 亚洲高清视频的网址| 欧美日韩免费高清一区色橹橹 | 欧美日韩一区二区三区免费看| 国产精品美女久久久久久2018| 日本成人在线不卡视频| 欧美日韩五月天| 午夜精品国产更新| 欧美日韩午夜在线视频| 日韩中文字幕不卡| 在线观看一区二区视频| 性久久久久久久久久久久| 欧美熟乱第一页| 美女尤物国产一区| 久久综合色之久久综合| 国产精品1区2区3区在线观看| 国产午夜亚洲精品午夜鲁丝片| 国产成人av电影在线| 精品国产三级a在线观看| 高清不卡在线观看| 韩国av一区二区| 国产精品午夜春色av| 午夜精品123| 欧美性猛交xxxx黑人交| 欧美日韩第一区日日骚| 激情五月激情综合网| 亚洲第一会所有码转帖| 色狠狠色狠狠综合| 久久精品国产一区二区三| 欧美一级在线免费| 蜜臀91精品一区二区三区| 精品成人一区二区三区| 蜜臀久久99精品久久久画质超高清 | 日韩福利电影在线观看| 精品美女一区二区三区| 不卡视频在线观看| 亚洲成人一区二区在线观看| www亚洲一区| 日韩午夜在线播放| 在线视频国内自拍亚洲视频| 国产成人av电影| 奇米色一区二区| 亚洲免费在线视频一区 二区| 日韩精品一区二区三区老鸭窝| 成人av中文字幕| 国产盗摄女厕一区二区三区| 午夜a成v人精品| 丝袜美腿高跟呻吟高潮一区| 国产精品热久久久久夜色精品三区 | 91麻豆国产在线观看| 久久国产夜色精品鲁鲁99| 日韩国产精品久久久| 美腿丝袜在线亚洲一区| 六月丁香综合在线视频| 国产精品综合一区二区| 成人动漫精品一区二区| 色婷婷综合五月| 6080日韩午夜伦伦午夜伦| 日韩精品一区二| 中文字幕在线播放不卡一区| 亚洲精品免费视频| 蜜桃av一区二区在线观看| 国产东北露脸精品视频| 91视频在线观看免费| 欧美日韩国产另类不卡| 精品国产成人系列| 亚洲色图色小说| 日韩—二三区免费观看av| 豆国产96在线|亚洲| 欧美网站一区二区| 精品久久一区二区| 亚洲婷婷在线视频| 狠狠色狠狠色综合系列| 91女人视频在线观看| 精品免费国产一区二区三区四区| 中文字幕精品一区二区精品绿巨人 | 91国内精品野花午夜精品| 欧美一区中文字幕| 一区二区三区加勒比av| 成人一区二区三区视频在线观看 | 亚洲男女一区二区三区| 国产成人亚洲综合a∨猫咪| 日韩视频一区二区在线观看| 亚洲精品久久7777| 成人性生交大片免费看中文| 这里只有精品电影| 视频一区视频二区中文字幕| 色综合婷婷久久| 国产精品久久久久久久久久久免费看 | 欧美中文字幕一区二区三区| 国产女主播一区| 粗大黑人巨茎大战欧美成人| 久久免费看少妇高潮| 国产一区二区在线看| 欧美电影免费观看完整版| 久久精品国产网站| 精品国精品国产尤物美女| 日韩福利视频网| 26uuu久久综合|