I have text and I will do some filtering based on the number of words of each phrase.
I was thinking about using the Map, in the key in which I put the phrase, int value, the number of words, iterating on the map and deleting lines that are of little importance than something that was mentioned earlier.
- There is a map where I can store duplicate entries (phrase and quantity)?
- Can I get from the card in the order in which I placed the elements? This is because it is text, so the order of phrases is important.
Example
Original text
My name is Renato | 4
Today is Tuesday | 3
I live in Brazil | 4
My name is Renato | 4
20 years | 2
StackOverflow is a fantastic website | 5
Filter removal of phrases with less than 4 words
Final text
My name is Renato
I live in Brazil
My name is Renato
StackOverflow is a fantastic website
source share