Text.java index and createWordlist methode cleanup
This commit is contained in:
parent
caec2257e1
commit
c565fffbff
|
@ -158,13 +158,13 @@ public class Text {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method counts all Words in text and adds them together with the paragraph where the word is been used to a Hashmap.
|
* This method counts all Words in text and adds the count together with the paragraph where the word is been used to a Hashmap.
|
||||||
*
|
*
|
||||||
* @return HashMap<String, ArrayList < Integer>>
|
* @return HashMap<String, ArrayList < Integer>>
|
||||||
*/
|
*/
|
||||||
private HashMap<String, ArrayList<Integer>> createWordlist() {
|
private HashMap<String, ArrayList<Integer>> createWordlist() {
|
||||||
int counter;
|
int counter;
|
||||||
ArrayList<Integer> zahlenListe;
|
ArrayList<Integer> numbersList;
|
||||||
String firstLetter;
|
String firstLetter;
|
||||||
String restLetters;
|
String restLetters;
|
||||||
for (int i = 0; i < text.size(); i++) {
|
for (int i = 0; i < text.size(); i++) {
|
||||||
|
@ -175,20 +175,20 @@ public class Text {
|
||||||
restLetters = word.substring(1);
|
restLetters = word.substring(1);
|
||||||
word = firstLetter.toUpperCase() + restLetters;
|
word = firstLetter.toUpperCase() + restLetters;
|
||||||
if (wordbook.containsKey(word)) {
|
if (wordbook.containsKey(word)) {
|
||||||
zahlenListe = wordbook.get(word);
|
numbersList = wordbook.get(word);
|
||||||
counter = zahlenListe.get(0);
|
counter = numbersList.get(0);
|
||||||
zahlenListe.remove(0);
|
numbersList.remove(0);
|
||||||
zahlenListe.add(0, counter + 1);
|
numbersList.add(0, counter + 1);
|
||||||
|
|
||||||
if (zahlenListe.get(zahlenListe.size() - 1) < i + 1) {
|
if (numbersList.get(numbersList.size() - 1) < i + 1) {
|
||||||
zahlenListe.add(i + 1);
|
numbersList.add(i + 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
zahlenListe = new ArrayList<>();
|
numbersList = new ArrayList<>();
|
||||||
zahlenListe.add(counter);
|
numbersList.add(counter);
|
||||||
zahlenListe.add(i + 1);
|
numbersList.add(i + 1);
|
||||||
}
|
}
|
||||||
wordbook.put(word, zahlenListe);
|
wordbook.put(word, numbersList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return wordbook;
|
return wordbook;
|
||||||
|
|
Loading…
Reference in New Issue