]> gitweb.fperrin.net Git - DictionaryPC.git/blobdiff - src/com/hughes/android/dictionary/engine/IndexBuilder.java
Bug-fixes to WikiTokenizer (handle weird line-feed), update to newest
[DictionaryPC.git] / src / com / hughes / android / dictionary / engine / IndexBuilder.java
index 44bfa761daff1886f303e412ea0436872838fa7d..0d111911edcb0a3a87a9b27957c809ad8b355a58 100644 (file)
@@ -38,8 +38,8 @@ public class IndexBuilder {
 
   IndexBuilder(final DictionaryBuilder dictionaryBuilder, final String shortName, final String longName, final Language language, final String normalizerRules, final Set<String> stoplist, final boolean swapPairEntries) {
     this.dictionaryBuilder = dictionaryBuilder;
-    index = new Index(dictionaryBuilder.dictionary, shortName, longName, language, normalizerRules, swapPairEntries);
-    tokenToData = new TreeMap<String, TokenData>(new NormalizeComparator(index.normalizer(), language.getCollator()));
+    index = new Index(dictionaryBuilder.dictionary, shortName, longName, language, normalizerRules, swapPairEntries, stoplist);
+    tokenToData = new TreeMap<String, TokenData>(index.getSortComparator());
     this.stoplist = stoplist;
   }
   
@@ -58,7 +58,7 @@ public class IndexBuilder {
         index.mainTokenCount++;
       }
 //      System.out.println("Added TokenRow: " + rows.get(rows.size() - 1));
-      int numRows = 0;
+      int numRows = 0;  // off by one--doesn't count the token row!
 //      System.out.println("TOKEN: " + tokenData.token);
       for (final Map.Entry<EntryTypeName, List<IndexedEntry>> typeToEntry : tokenData.typeToEntries.entrySet()) {
         for (final IndexedEntry entryData : typeToEntry.getValue()) {
@@ -68,6 +68,7 @@ public class IndexBuilder {
           }
           if (tokenEntryDatas.add(entryData)) {
             rows.add(new PairEntry.Row(entryData.index(), rows.size(), index));
+            ++entryData.entry.entrySource.numEntries;
             ++numRows;
             
 //            System.out.print("  " + typeToEntry.getKey() + ": ");
@@ -117,7 +118,7 @@ public class IndexBuilder {
   private List<IndexedEntry> getOrCreateEntries(final String token, final EntryTypeName entryTypeName) {
     final TokenData tokenData = getOrCreateTokenData(token);
     List<IndexedEntry> entries = tokenData.typeToEntries.get(entryTypeName);
-    if (entryTypeName.overridesStopList) {
+    if (entryTypeName.mainWord) {
       tokenData.hasMainEntry = true;
     }
     if (entries == null) {