提交 92a8cfac authored 作者: Thomas Mueller's avatar Thomas Mueller

Javascript index: show ignored words.

上级 96f1642d
...@@ -49,6 +49,7 @@ public class Indexer { ...@@ -49,6 +49,7 @@ public class Indexer {
private Page page; private Page page;
private boolean title; private boolean title;
private boolean heading; private boolean heading;
private String ignored;
/** /**
* This method is called when executing this application from the command * This method is called when executing this application from the command
...@@ -80,6 +81,7 @@ public class Indexer { ...@@ -80,6 +81,7 @@ public class Indexer {
readPages("", file, 0); readPages("", file, 0);
output.println("var pages=new Array();"); output.println("var pages=new Array();");
output.println("var ref=new Array();"); output.println("var ref=new Array();");
output.println("var ignored='';");
output.println("function Page(title, file) { this.title=title; this.file=file; }"); output.println("function Page(title, file) { this.title=title; this.file=file; }");
output.println("function load() {"); output.println("function load() {");
sortWords(); sortWords();
...@@ -113,7 +115,7 @@ public class Indexer { ...@@ -113,7 +115,7 @@ public class Indexer {
} }
wordList = new ArrayList<Word>(words.values()); wordList = new ArrayList<Word>(words.values());
// ignored very common words (to shrink the index) // ignored very common words (to shrink the index)
String ignored = ""; StringBuilder ignoredBuff = new StringBuilder(";");
int maxSize = pages.size() / 4; int maxSize = pages.size() / 4;
for (int i = 0; i < wordList.size(); i++) { for (int i = 0; i < wordList.size(); i++) {
Word word = wordList.get(i); Word word = wordList.get(i);
...@@ -121,14 +123,12 @@ public class Indexer { ...@@ -121,14 +123,12 @@ public class Indexer {
int idxCommon = VERY_COMMON.indexOf(search); int idxCommon = VERY_COMMON.indexOf(search);
if (word.pages.size() >= maxSize || idxCommon >= 0) { if (word.pages.size() >= maxSize || idxCommon >= 0) {
wordList.remove(i); wordList.remove(i);
if (ignored.length() > 0) { ignoredBuff.append(word.name);
ignored += ","; ignoredBuff.append(';');
}
ignored += word.name;
i--; i--;
} }
} }
// output.println("var ignored = '" + convertUTF(ignored) + "'"); ignored = ignoredBuff.toString();
// TODO support A, B, C,... class links in the index file and use them // TODO support A, B, C,... class links in the index file and use them
// for combined AND searches // for combined AND searches
Collections.sort(wordList, new Comparator<Word>() { Collections.sort(wordList, new Comparator<Word>() {
...@@ -246,6 +246,7 @@ public class Indexer { ...@@ -246,6 +246,7 @@ public class Indexer {
} }
output.println("ref['" + convertUTF(first) + "']='" + buff.toString() + "';"); output.println("ref['" + convertUTF(first) + "']='" + buff.toString() + "';");
output.println("// totalRelations: " + totalRelations); output.println("// totalRelations: " + totalRelations);
output.println("ignored='" + ignored.toLowerCase() + "';");
} }
private void readPage(File file) throws Exception { private void readPage(File file) throws Exception {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论