In processing documents, we often build something called an index, or an inverted index. This is simply a set of pairs (WORD, OCCURRENCES) where WORD is a word occurring in the document, and OCCURRENCES is a sequence of integers giving the positions (in increasing order) at which the word occurs. For example, for a document consisting of the single sentence "ask not what your country can do for you ask what you can do for your country", the index will be
ask 0 9
can 5 12
country 4 16
do 6 13
for 7 14
not 1
what 2 10
you 8 11
your 3 15
You are to write a program that reads in a document and prints the index, in lexicographic order. Your answer for the document above should be as given above, you will notice that the words in it are in lexicographical sorted order.
You should handle two more complications. Each word may have a single terminating comma or semicolon or full stop. These should be removed when making the index. Also, capitalisation of letters should be disregarded. Thus the index should not change if the input above were given as "Ask not what your COUNTRY can do for you, ask what you can
do for your country."
Finally note that the document is given as a sequence of white space separated words, with the single character word '*' being the last word. The word '*' should not be included in the index.
Answers
Answered by
3
Answer:
kiysiypsitsstistitwiwitwiyyiee69ewyosoys
Answered by
0
Wammo so much big paragraph is there I can't read (Sorry)
Similar questions
Social Sciences,
5 months ago
Social Sciences,
5 months ago
Math,
10 months ago
Geography,
10 months ago
Computer Science,
1 year ago