X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=src%2Fcom%2Fhughes%2Fandroid%2Fdictionary%2Fengine%2FIndexBuilder.java;h=6f28d30ba0faee0131d2fcd533706c70e48805c9;hb=297e7670b0c1487cdddb82dd2259f902d4ed80ae;hp=32a087f47390d48e1c9ae23d928c07c4449fe735;hpb=b6bfead63fc4b123370918bea4d2899d73698038;p=DictionaryPC.git diff --git a/src/com/hughes/android/dictionary/engine/IndexBuilder.java b/src/com/hughes/android/dictionary/engine/IndexBuilder.java index 32a087f..6f28d30 100644 --- a/src/com/hughes/android/dictionary/engine/IndexBuilder.java +++ b/src/com/hughes/android/dictionary/engine/IndexBuilder.java @@ -50,7 +50,8 @@ public class IndexBuilder { tokenEntryDatas.clear(); final int indexIndex = index.sortedIndexEntries.size(); final int startRow = rows.size(); - rows.add(new TokenRow(indexIndex, rows.size(), index)); + + rows.add(new TokenRow(indexIndex, rows.size(), index, tokenData.hasMainEntry)); // System.out.println("Added TokenRow: " + rows.get(rows.size() - 1)); int numRows = 0; // System.out.println("TOKEN: " + tokenData.token); @@ -74,15 +75,15 @@ public class IndexBuilder { .normalizer().transliterate(tokenData.token), startRow, numRows)); } - final List entriesSortedByRows = new ArrayList(index.sortedIndexEntries); - Collections.sort(entriesSortedByRows, new Comparator() { + final List entriesSortedByNumRows = new ArrayList(index.sortedIndexEntries); + Collections.sort(entriesSortedByNumRows, new Comparator() { @Override public int compare(IndexEntry object1, IndexEntry object2) { return object2.numRows - object1.numRows; }}); System.out.println("Most common tokens:"); - for (int i = 0; i < 50 && i < entriesSortedByRows.size(); ++i) { - System.out.println(" " + entriesSortedByRows.get(i)); + for (int i = 0; i < 50 && i < entriesSortedByNumRows.size(); ++i) { + System.out.println(" " + entriesSortedByNumRows.get(i)); } } @@ -90,6 +91,7 @@ public class IndexBuilder { final String token; final Map> typeToEntries = new EnumMap>(EntryTypeName.class); + boolean hasMainEntry = false; TokenData(final String token) { assert token.equals(token.trim()); @@ -110,6 +112,9 @@ public class IndexBuilder { private List getOrCreateEntries(final String token, final EntryTypeName entryTypeName) { final TokenData tokenData = getOrCreateTokenData(token); List entries = tokenData.typeToEntries.get(entryTypeName); + if (entryTypeName.overridesStopList) { + tokenData.hasMainEntry = true; + } if (entries == null) { entries = new ArrayList(); tokenData.typeToEntries.put(entryTypeName, entries); @@ -124,8 +129,9 @@ public class IndexBuilder { } assert indexedEntry != null; for (final String token : tokens) { - if (entryTypeName.overridesStopList || !stoplist.contains(token)) - getOrCreateEntries(token, entryTypeName).add(indexedEntry); + if (entryTypeName.overridesStopList || !stoplist.contains(token)) { + getOrCreateEntries(token, entryTypeName).add(indexedEntry); + } } }