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

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

?? tquery.c

?? C++Primer中文版 第三版 深入系列 Primer 第三版 著 中中文文版版潘愛民張麗譯 Addison-Wesley 中國電力出版社 www.infopower.com.cn S
?? C
字號:
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <map>
#include <set>

#include <iostream.h>
#include <fstream.h>

#include <stddef.h>
#include <ctype.h>

typedef pair<short,short>           location;
typedef vector<location,allocator>  loc;
typedef vector<string,allocator>    text;
typedef pair<text*,loc*>            text_loc;

class TextQuery {
public:
	TextQuery() { memset( this, 0, sizeof( TextQuery )); }

	static void filter_elements( string felems ) { filt_elems = felems; }

	void query_text();
	void display_map_text();
	void display_text_locations();
	void doit() {
        	retrieve_text();
        	separate_words();
        	filter_text();
        	suffix_text();
        	strip_caps();
        	build_word_map();
	}

private:
	void retrieve_text();
	void separate_words();
	void filter_text();
	void strip_caps();
	void suffix_text();
	void suffix_s( string& );
	void build_word_map();

private:
	vector<string,allocator>   		*lines_of_text;
	text_loc                   		*text_locations;
	map<string,loc*,less<string>,allocator> *word_map;
	static string				 filt_elems;
};

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

int main() 
{
	TextQuery tq;
	tq.doit();
	tq.query_text();
        tq.display_map_text();
	return 0;
}

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 ));
        }
	
        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 query_text;
    
	do {
           cout << "enter a word against which to search the text.\n"
	        << "to quit, enter a single character ==>  ";
	   cin  >> query_text;

	   if ( query_text.size() < 2 ) break;

           string caps( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" );
           string::size_type pos = 0;
           while (( pos = query_text.find_first_of( caps, pos )) != string::npos )
                    query_text[ pos ] = tolower( query_text[pos] );

           // if we index into map, query_text is entered, if absent
           // not at all what we should wish for ...

	   if ( !word_map->count( query_text )) {
		cout << "\nSorry. There are no entries for " 
		     << query_text << ".\n\n";
		continue;
	    }

	   loc *ploc = (*word_map)[ query_text ];

	    set<short,less<short>,allocator> occurrence_lines;  
	    loc::iterator liter = ploc->begin(), liter_end = ploc->end();

            while ( liter != liter_end ) {
		    occurrence_lines.insert(occurrence_lines.end(), (*liter).first);
                    ++liter;
            }

	    register int size = occurrence_lines.size();
	    cout << "\n" << query_text 
		 << " occurs " << size 
		 << (size == 1 ? " time:" : " times:")
		 << "\n\n";

	    set<short,less<short>,allocator>::iterator it=occurrence_lines.begin();
	    for ( ; it != occurrence_lines.end(); ++it ) {
		  int line = *it;

		  cout << "\t( line " 
		       // don't confound user with text lines starting at 0 ...
 		       << line + 1 << " ) "       
		       << (*lines_of_text)[line] << endl;
	    }

	    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 ) {
                cout << "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 )
                             cout << ",";
                        else ++loc_cnt;

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

                        ++liter;
                }

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

        cout << 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一区二区三区免费野_久草精品视频
日本高清免费不卡视频| 国产精品福利一区二区| 国产精品天干天干在观线| 亚洲最新在线观看| aaa欧美大片| 精品久久久久久亚洲综合网| 亚洲美女精品一区| 国产高清成人在线| 26uuu另类欧美| 日韩经典一区二区| 欧美无乱码久久久免费午夜一区| 国产亚洲欧美日韩俺去了| 日本欧美久久久久免费播放网| 波多野结衣在线aⅴ中文字幕不卡| 欧美电影免费观看完整版| 一区2区3区在线看| 91免费视频网| 亚洲欧美自拍偷拍| 成人性生交大片免费看中文网站| 欧美成人a在线| 蜜桃一区二区三区在线观看| 欧美精品v国产精品v日韩精品| 一区二区三区欧美亚洲| 91视频观看免费| 亚洲乱码中文字幕| 91国产丝袜在线播放| 18涩涩午夜精品.www| 99精品视频中文字幕| 国产精品乱码人人做人人爱| 国产精品91一区二区| 欧美国产精品一区二区三区| 国产99久久久国产精品潘金网站| 精品盗摄一区二区三区| 久久国产尿小便嘘嘘| 精品剧情v国产在线观看在线| 免费人成精品欧美精品| 欧美丰满少妇xxxxx高潮对白| 亚洲综合视频在线| 欧美巨大另类极品videosbest | 最近日韩中文字幕| av激情综合网| 亚洲另类在线制服丝袜| 欧美疯狂做受xxxx富婆| 久久国产日韩欧美精品| 日本一区二区在线不卡| 91免费版在线看| 亚洲v中文字幕| 日韩精品最新网址| 高清shemale亚洲人妖| 亚洲欧洲日韩av| 欧美日韩国产一区| 麻豆精品国产传媒mv男同| 国产片一区二区| 99re8在线精品视频免费播放| 亚洲精品午夜久久久| 欧美精品电影在线播放| 国产剧情一区在线| 一区二区三区在线观看欧美| 日韩视频一区二区在线观看| 国产馆精品极品| 午夜精品久久一牛影视| 精品国产电影一区二区| 91免费在线播放| 久久99精品久久久久久动态图| 日本一区二区三区在线观看| 欧美视频你懂的| 国产毛片精品一区| 一区二区三区四区蜜桃| 精品欧美久久久| 91美女在线看| 精品一区二区三区av| 亚洲精品国产精华液| 精品久久久久久无| 久久综合色播五月| 亚洲精品一区二区三区香蕉| 精品写真视频在线观看| 亚洲欧美综合另类在线卡通| 日韩欧美亚洲国产精品字幕久久久 | 在线视频中文字幕一区二区| 麻豆精品在线观看| 亚洲视频小说图片| 精品久久久久99| 欧美性受xxxx| 成人av影视在线观看| 秋霞电影一区二区| 一区二区三区中文字幕精品精品| 精品捆绑美女sm三区| 欧美精品电影在线播放| 色婷婷国产精品综合在线观看| 国产综合久久久久影院| 日韩高清一级片| 亚洲国产成人va在线观看天堂| 国产欧美精品一区二区色综合 | 日韩伦理电影网| 久久久精品影视| 久久亚洲精品小早川怜子| 欧美日韩国产一二三| 欧美色视频在线| 色天天综合色天天久久| thepron国产精品| 成人app下载| 国产成人av电影在线播放| 国产专区欧美精品| 精品影视av免费| 麻豆成人免费电影| 免费精品99久久国产综合精品| 亚洲国产精品嫩草影院| 亚洲综合网站在线观看| 伊人婷婷欧美激情| 亚洲欧美视频在线观看视频| 综合分类小说区另类春色亚洲小说欧美| 久久青草欧美一区二区三区| 久久久久久久久久久久电影 | 这里是久久伊人| 欧美日韩黄色影视| 欧美另类z0zxhd电影| 欧美三区免费完整视频在线观看| 在线亚洲一区二区| 欧美性猛交一区二区三区精品| 欧美中文字幕一区| 欧美在线观看视频在线| 欧美日韩三级一区二区| 欧美女孩性生活视频| 欧美一区二区美女| 日韩美女一区二区三区| 久久色成人在线| 中文字幕精品一区| 亚洲乱码国产乱码精品精可以看| 亚洲午夜羞羞片| 奇米影视7777精品一区二区| 国模无码大尺度一区二区三区| 国产成人无遮挡在线视频| 99久久精品国产一区| 日本高清不卡视频| 欧美一区三区四区| 中文在线一区二区| 一区二区三区四区中文字幕| 日韩激情av在线| 国产suv一区二区三区88区| 99久久国产免费看| 欧美一区二区人人喊爽| 欧美国产一区在线| 一二三四区精品视频| 美国三级日本三级久久99| 国产99精品国产| 欧美羞羞免费网站| 国产亚洲一区二区三区在线观看| 亚洲日本va午夜在线电影| 蜜臀av性久久久久蜜臀aⅴ | 91精品婷婷国产综合久久性色 | 一区二区高清免费观看影视大全 | 免费视频最近日韩| 成人国产精品免费观看动漫| 欧美色国产精品| 国产欧美综合色| 午夜伦欧美伦电影理论片| 国产乱码字幕精品高清av| 一本色道久久综合亚洲aⅴ蜜桃 | 欧美丰满少妇xxxxx高潮对白| 日本一区二区三区dvd视频在线| 亚洲制服丝袜在线| 国产成人在线影院| 欧美精品免费视频| 综合欧美一区二区三区| 精品一区二区成人精品| 99精品欧美一区二区三区小说| 欧美视频一区二区三区四区| 久久久久久久久免费| 琪琪一区二区三区| 欧美四级电影网| 中文av一区二区| 久久精品国产精品亚洲精品| 欧美午夜宅男影院| 国产精品国产自产拍高清av王其| 久久99精品国产| 欧美精品v国产精品v日韩精品| 亚洲精品乱码久久久久久久久 | 欧美国产在线观看| 国内不卡的二区三区中文字幕 | 亚洲综合在线观看视频| 国产成人精品在线看| 精品国产91亚洲一区二区三区婷婷| 亚洲精品美国一| 日本道在线观看一区二区| 国产精品传媒入口麻豆| 国产69精品久久久久毛片| 精品国产伦一区二区三区观看方式 | 亚洲另类春色校园小说| 不卡影院免费观看| 国产欧美一区二区三区鸳鸯浴| 激情综合一区二区三区| 制服.丝袜.亚洲.中文.综合| 亚洲综合一二三区| 精品婷婷伊人一区三区三| 一区二区三区成人| 欧美色综合久久| 亚洲成a人v欧美综合天堂| 欧美日本乱大交xxxxx| 天天操天天综合网| 欧美精品一级二级三级|