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

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

?? textquery.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一区二区三区免费野_久草精品视频
欧美成人video| 亚洲成人免费在线| 亚洲va欧美va人人爽午夜| 精品一区二区免费看| 色综合久久久久综合体| 久久久精品tv| 美女久久久精品| 欧美亚洲尤物久久| 国产精品久久一级| 国产麻豆精品在线| 4438成人网| 樱桃国产成人精品视频| 成人看片黄a免费看在线| 日韩欧美在线网站| 日韩专区一卡二卡| 91九色最新地址| 国产精品久99| 国产乱人伦精品一区二区在线观看 | 日韩欧美高清dvd碟片| 玉足女爽爽91| 成人app软件下载大全免费| 久久亚洲一区二区三区明星换脸| 日韩精品五月天| 91成人免费在线| 一区二区三区精品在线观看| 丁香啪啪综合成人亚洲小说| 久久久国产精品麻豆| 国产精品一区二区无线| 久久久久久影视| 国产精品一级在线| 国产午夜精品一区二区三区视频 | 久久老女人爱爱| 国产一区福利在线| 久久夜色精品一区| 东方aⅴ免费观看久久av| 国产欧美一区二区三区在线看蜜臀| 国产一区二区三区免费在线观看| 日韩欧美国产一区二区在线播放| 毛片一区二区三区| 久久久久久久久久久久久女国产乱| 国产精品系列在线观看| 国产精品每日更新| 91在线视频播放地址| 亚洲精品免费电影| 欧美日韩国产在线观看| 免播放器亚洲一区| 国产日产欧美一区| 在线观看免费视频综合| 青草av.久久免费一区| 久久久午夜电影| 99在线视频精品| 视频一区视频二区中文| 久久女同互慰一区二区三区| 成人av免费在线播放| 日韩黄色免费电影| 国产欧美一区在线| 欧美伊人久久久久久久久影院| 日韩电影在线一区| 久久久影院官网| 欧美综合亚洲图片综合区| 黄页视频在线91| 国产精品国产自产拍在线| 欧美另类videos死尸| 国产精品一区二区三区99| 亚洲欧美激情一区二区| 欧美mv日韩mv亚洲| 色婷婷精品久久二区二区蜜臀av| 日韩精品91亚洲二区在线观看| 国产欧美精品在线观看| 欧美视频第二页| 国产91精品一区二区麻豆亚洲| 一区二区三区高清不卡| 久久色在线视频| 色综合中文综合网| 欧美一级黄色大片| 成人激情免费电影网址| 秋霞成人午夜伦在线观看| 国产亚洲精品精华液| 欧美性xxxxxxxx| 岛国av在线一区| 免费看日韩精品| 亚洲一线二线三线久久久| 久久久美女艺术照精彩视频福利播放| 欧洲激情一区二区| 91亚洲永久精品| 国产凹凸在线观看一区二区 | 伊人色综合久久天天人手人婷| 26uuu久久天堂性欧美| 欧美日韩aaa| 日本精品视频一区二区| 大桥未久av一区二区三区中文| 日本不卡123| 五月天激情综合网| 亚洲欧美区自拍先锋| 国产精品青草久久| 久久噜噜亚洲综合| 久久综合999| 日韩亚洲欧美在线| 欧美一区三区四区| 欧美日韩久久久| 91久久精品一区二区三区| eeuss鲁片一区二区三区在线观看 eeuss鲁片一区二区三区在线看 | 777色狠狠一区二区三区| 在线观看一区二区精品视频| 99麻豆久久久国产精品免费 | 日韩一区二区免费在线观看| 色综合av在线| 91影视在线播放| 91浏览器打开| 91毛片在线观看| 91视频.com| 91麻豆产精品久久久久久| 91在线免费看| 在线免费一区三区| 欧美亚洲尤物久久| 4438x成人网最大色成网站| 91麻豆精品国产自产在线| 日韩免费成人网| 久久先锋影音av鲁色资源 | 欧美大黄免费观看| 精品久久国产字幕高潮| 久久麻豆一区二区| 中文字幕一区在线| 亚洲免费在线视频一区 二区| 一区二区不卡在线视频 午夜欧美不卡在 | 国产精品美女久久久久高潮| 国产女人18毛片水真多成人如厕 | 欧美三级视频在线| 欧美伦理影视网| 精品国产欧美一区二区| 久久久无码精品亚洲日韩按摩| 国产精品国产三级国产a| 亚洲宅男天堂在线观看无病毒| 天天亚洲美女在线视频| 国产麻豆精品在线观看| 99久久国产综合精品女不卡| 欧美日韩在线三级| 26uuu成人网一区二区三区| 国产喷白浆一区二区三区| 一区二区三区在线看| 日韩中文欧美在线| 盗摄精品av一区二区三区| 日本精品视频一区二区三区| 日韩午夜在线观看| 国产网红主播福利一区二区| 亚洲美女电影在线| 久久精品国产第一区二区三区| 成人禁用看黄a在线| 欧美日韩一区二区三区四区| 精品久久久三级丝袜| 亚洲男人的天堂av| 老色鬼精品视频在线观看播放| 成人av在线看| 日韩欧美www| 一区二区三区日韩欧美精品| 精品在线免费观看| 在线免费观看一区| 久久久精品影视| 亚洲成在人线免费| 成人久久久精品乱码一区二区三区| 欧美日韩国产综合一区二区| 中文字幕av资源一区| 免费日韩伦理电影| 欧美亚洲图片小说| 国产精品女主播av| 精品写真视频在线观看| 欧美天堂一区二区三区| 国产精品对白交换视频| 国产精品自拍av| 欧美一区二区久久| 亚洲国产欧美一区二区三区丁香婷| 国产精品一区二区三区乱码| 337p亚洲精品色噜噜狠狠| 一区二区三区不卡视频| 成人黄色免费短视频| 精品成人一区二区三区四区| 日韩成人精品在线观看| 精品视频1区2区| 亚洲老妇xxxxxx| 91亚洲资源网| 最新欧美精品一区二区三区| 国产一区二区电影| 欧美变态tickle挠乳网站| 日日夜夜精品视频天天综合网| 在线观看日韩毛片| 一区二区三区 在线观看视频| av在线播放不卡| 国产精品毛片a∨一区二区三区| 国产乱子伦视频一区二区三区| 日韩免费一区二区| 麻豆91精品视频| 精品女同一区二区| 精品制服美女久久| 精品久久免费看| 国产一区二区福利| 欧美国产禁国产网站cc| 成人aaaa免费全部观看| 亚洲欧美日韩国产成人精品影院| av不卡在线播放| 亚洲美女一区二区三区|