++



         

- 5


}

else {

istream_iterator< string, diff_type >

input_set( infile ), eos;

copy( input_set, eos,

inserter( exclusion_set, exclusion_set.begin() ));

}

// ,

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 ];

if ( textword.size() < 3 ||

exclusion_set.count( textword ))

continue;

if ( ! word_map->count((*text_words)[ix] ))

{ // , :

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 ] = to1ower( query_text[pos] );

// query_text

if ( !word_map->count( query_text )) {

cout << "\nSorry. There are no entries for "

<< query_text << ".\n\n";