Example:
String wholeString =
"Typical models for star formation assume that every type of galaxy produces stars"
I’d like to store the splitted string and its following (+1) String in a treemap:
with windowSize = 4 (predefined):
Typi,ypic -> put into TreeMap
ypic,pica -> put into TreeMap
for windowSize = 2 it would look like this:
Ty,yp -> TreeMap
and so on.
My code so far:
Map<String, String> generateMap = new TreeMap<String, String>();
for (int i = 0; i < wholeString.length(); i++) {
generateMap
.put((wholeString.substring((i),
Math.min((i + windowSize), wholeString.length()))),
(wholeString.substring(
(i + 1),
(Math.min((i + windowSize),
wholeString.length())))));
}
If I sysprint it, I gets this:
{ Augen=Augen, Außen=Außen, Innen=Innen, Jauch=Jauch,and so on
My take: