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

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

?? tquery.c

?? c++ primer 源代碼
?? 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一区二区三区免费野_久草精品视频
国产欧美一区二区精品仙草咪| 久久av老司机精品网站导航| 亚洲第四色夜色| 夫妻av一区二区| 91精品国产91久久久久久一区二区| 国产免费成人在线视频| 秋霞影院一区二区| 在线精品视频小说1| 中文字幕乱码日本亚洲一区二区| 午夜精品久久久久久久蜜桃app| 国产激情精品久久久第一区二区 | 欧美日韩精品一区二区三区| 久久久久久亚洲综合| 日韩专区在线视频| 色婷婷久久综合| 中文字幕欧美区| 国产河南妇女毛片精品久久久| 欧美精品电影在线播放| 亚洲男人天堂av| 成人的网站免费观看| 国产网站一区二区三区| 日本女人一区二区三区| 欧美日韩在线免费视频| 亚洲另类在线制服丝袜| 99热在这里有精品免费| 国产嫩草影院久久久久| 成人综合婷婷国产精品久久免费| 精品国产一区久久| 捆绑变态av一区二区三区| 8x福利精品第一导航| 日日夜夜精品视频免费| 这里只有精品视频在线观看| 午夜欧美2019年伦理| 在线观看视频一区二区欧美日韩| 中文字幕制服丝袜一区二区三区 | 久久免费视频色| 日本不卡视频在线观看| 欧美日韩电影在线播放| 亚洲超丰满肉感bbw| 欧美人狂配大交3d怪物一区| 午夜久久福利影院| 欧美欧美午夜aⅴ在线观看| 午夜欧美电影在线观看| 91精品啪在线观看国产60岁| 另类小说色综合网站| 2023国产精品自拍| 国产成人精品一区二区三区四区| 中文字幕高清不卡| 91看片淫黄大片一级在线观看| 亚洲女性喷水在线观看一区| 欧美性猛交xxxxxx富婆| 日本va欧美va瓶| 国产婷婷色一区二区三区| 91在线视频播放| 亚洲图片一区二区| 欧美tickling挠脚心丨vk| 国产精品一级在线| 亚洲激情自拍偷拍| 91精品国产综合久久精品性色| 久久福利视频一区二区| 中文字幕精品一区二区精品绿巨人| 97精品视频在线观看自产线路二| 性做久久久久久免费观看| 欧美电影免费观看高清完整版在| 国产精品自拍av| 亚洲精品成人在线| 日韩精品中文字幕一区二区三区| 国产91精品入口| 午夜精品福利视频网站| 国产调教视频一区| 在线观看视频一区二区欧美日韩| 精品一区二区久久久| 亚洲色大成网站www久久九九| 欧美日韩成人综合| 国产成人免费9x9x人网站视频| 亚洲男帅同性gay1069| 日韩欧美激情在线| 99精品国产91久久久久久| 奇米亚洲午夜久久精品| 国产精品国产三级国产a| 日韩一级黄色片| 日本久久一区二区三区| 国产一区二区中文字幕| 洋洋av久久久久久久一区| 久久亚洲捆绑美女| 欧美日韩国产欧美日美国产精品| 国产成a人亚洲精品| 污片在线观看一区二区| 亚洲欧洲成人自拍| 久久一区二区视频| 日韩三级视频在线观看| 欧日韩精品视频| 91在线国内视频| 国产一区二区电影| 精品一区二区三区蜜桃| 亚洲免费观看高清完整版在线| 久久久无码精品亚洲日韩按摩| 欧美精品一二三四| 欧美自拍偷拍一区| 色综合久久久久综合体桃花网| 国产一区二区视频在线播放| 五月婷婷久久丁香| 亚洲青青青在线视频| 国产精品亲子伦对白| 久久久亚洲国产美女国产盗摄| 欧美一区欧美二区| 欧美精选一区二区| 欧美色综合影院| 日本高清不卡一区| 成人av动漫在线| 97精品久久久久中文字幕| 成人免费视频视频| caoporn国产精品| 国产乱码字幕精品高清av| 久久99精品久久久久久动态图| 日韩专区一卡二卡| 青青草国产成人av片免费| 亚洲成a人片在线不卡一二三区 | 蜜臀a∨国产成人精品| 亚洲一区二区三区免费视频| 日韩理论在线观看| 亚洲人123区| 亚洲免费在线播放| 一区二区三区四区亚洲| 亚洲男女一区二区三区| 一区二区三区欧美激情| 亚洲一区在线免费观看| 亚洲综合一二三区| 午夜精品久久久久久久| 麻豆国产欧美日韩综合精品二区| 亚洲成人免费视频| 免费成人性网站| 国产精品一区二区无线| youjizz久久| 99精品国产99久久久久久白柏| 91影院在线观看| 精品1区2区3区| 欧美日本一区二区在线观看| 欧美一区二区视频免费观看| 日韩欧美二区三区| 日本一区二区三区高清不卡| 欧美激情中文字幕一区二区| 中文字幕一区二区三区乱码在线| 亚洲精品美腿丝袜| 午夜成人免费视频| 精品一区二区三区香蕉蜜桃| 国产剧情av麻豆香蕉精品| 91猫先生在线| 欧美丰满美乳xxx高潮www| 久久精品一区二区三区四区| 一区二区视频免费在线观看| 麻豆91免费看| 成人a区在线观看| 欧美精品久久天天躁| 久久精品人人做人人综合| 亚洲精品免费在线| 国产在线精品免费av| 在线观看91视频| 久久亚洲影视婷婷| 亚洲成人综合在线| 国产91丝袜在线播放| 精品污污网站免费看| 久久蜜臀精品av| 亚洲国产美女搞黄色| 国产一区二区看久久| 欧美羞羞免费网站| 久久精品欧美日韩| 日韩高清在线观看| 99精品久久只有精品| 久久色在线视频| 视频一区二区国产| av日韩在线网站| 久久美女高清视频| 免费高清成人在线| 欧美三级三级三级爽爽爽| 欧美激情在线看| 国产一区 二区 三区一级| 欧美电影在哪看比较好| 亚洲人成人一区二区在线观看 | 91丨九色porny丨蝌蚪| 精品成人在线观看| 午夜精品一区在线观看| 在线观看网站黄不卡| 亚洲欧美一区二区三区久本道91| 国产在线播精品第三| 欧美sm极限捆绑bd| 午夜电影网亚洲视频| 欧日韩精品视频| 夜夜精品视频一区二区| 色综合天天综合网天天狠天天| 国产精品久久久爽爽爽麻豆色哟哟 | 99久久久久久| 国产视频一区在线播放| 精品亚洲免费视频| 日韩欧美卡一卡二| 日本不卡一二三| 欧美一区二区视频在线观看| 日本亚洲免费观看| 91精品国产综合久久香蕉麻豆| 午夜欧美在线一二页|