Click here to Skip to main content
14,694,530 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have texts (Paragraphs) and I want to replace each of annotated wrong word in the paragraph with the correct word indicated by the position (index) number of the wrong word and i need to do it for each paragraph... So, what method should I use to search by index number? thank you


In the input file you have the following paragraph:

Computer Science are the study of principles applications, and technologies of computing & computers. It involve the studyof data and data structures...

The above text should be replaced by the following paragraph in the output file:

Computer Science is the study of principles, applications, and technologies of computing and computers. It involves the study of data and data structures...

**Note that the numbers (e.g:2 3) indicate the position (index) of the wrong word

A 2 3|||Edit||| is |||REQUIRED|||-NONE-|||0

A 12 13|||Edit||| and |||REQUIRED|||-NONE-|||0

A 15 16|||Edit||| involves |||REQUIRED|||-NONE-|||0

A 18 19|||Split|||study of|||REQUIRED|||-NONE-|||0

A 29 29|||Add_before|||.|||REQUIRED|||-NONE-|||0

1 solution

First you will need to use a StreamReader class to read the file. You will also need some way of identifiying where each paragraph ends. Once you have that then you can use the String class to split the paragraph into an array of words. That will allow you to find a specific item by index. You may need to code your own splitter method to allow for punctuation characters. You can then rebuild the paragraph from the array (after the change), and write it out to the new file. See[^] for information on the stream I/O classes.
Iris91 4-May-15 5:01am
thanks for the great explanation, can you tell me how do i search by index? what's the syntax?
Richard MacCutchan 4-May-15 5:06am
You just use the index value to address the relevant word in the array. Something like:
string oldword = arrayOfWords[index];

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900