diff --git a/java/wordStat/WordStatLengthSuffix.java b/java/wordStat/WordStatLengthSuffix.java index de59fdc..fab855c 100644 --- a/java/wordStat/WordStatLengthSuffix.java +++ b/java/wordStat/WordStatLengthSuffix.java @@ -27,11 +27,14 @@ public class WordStatLengthSuffix { } else { if (sb.length() > 0) { String word = sb.toString().toLowerCase(); - if (wordMap.containsKey(word)) { - wordMap.get(word).count++; - } else { - wordMap.put(word, new WordInfo(word, 1, wordIndex)); - wordIndex++; + if (word.length() != 1) { + word = word.substring(word.length() / 2); + if (wordMap.containsKey(word)) { + wordMap.get(word).count++; + } else { + wordMap.put(word, new WordInfo(word, 1, wordIndex)); + wordIndex++; + } } sb.setLength(0); } @@ -59,9 +62,7 @@ public class WordStatLengthSuffix { PrintWriter writer = new PrintWriter(outputFileName, "UTF-8"); for (WordInfo info : sortedWords) { - if (info.word.length() != 1) { - writer.println(info.word.substring(info.word.length() / 2) + " " + info.count); - } + writer.println(info.word + " " + info.count); } writer.close();