Iterate through corrected words

86 views Asked by At

having in mind this question,

how can we not only extract the first element from the correction match, but extract the whole list and store it into the StringBuffer[].

I want to do that in order to be able then to compare every element of this corrected list with a user input and use whichever element matches the list.

So, for example, user enters: Sain Nicolaa.

The corrected words are:

[main, said, San, gain, skin, Spain, pain, rain, spin, sail, saint, slain, vain, Cain, Jain, stain, satin, shin, Sabin, ain, fain, swain, sin, lain, wain, s ain]

and

 [Nicolas, Nicola]

So, I want to compare my input to each one of these corrected words and use whatever it matches.

We will need a second loop on the match:

for (RuleMatch match : matches) {

    correctSentence.replace(match.getFromPos() - offset, match.getToPos() - offset, match.getSuggestedReplacements().get(0));
    offset += (match.getToPos() - match.getFromPos() - match.getSuggestedReplacements().get(0).length());

}

but I am not sure how to handle this, what kind of type must be.

0

There are 0 answers