提交 f4871d9f authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 7de9aac9
...@@ -11,7 +11,6 @@ import java.io.InputStreamReader; ...@@ -11,7 +11,6 @@ import java.io.InputStreamReader;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.io.RandomAccessFile; import java.io.RandomAccessFile;
import org.h2.server.web.PageParser;
import org.h2.tools.indexer.HtmlConverter; import org.h2.tools.indexer.HtmlConverter;
import org.h2.util.IOUtils; import org.h2.util.IOUtils;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
...@@ -49,15 +48,4 @@ public class PropertiesToUTF8 { ...@@ -49,15 +48,4 @@ public class PropertiesToUTF8 {
} }
} }
private static String unescapeHtml(String s) {
String codes = "&lt; < &amp; & &gt; > &Auml; \u00c4 &Ouml; \u00d6 &Uuml; \u00dc &auml; \u00e4 &ouml; \u00f6 &uuml; \u00fc &ntilde; \u00f1 &oacute; \u00f3 &Iacute; \u00cd &ccedil; \u00e7 &eagrave; \u00e8 &ecirc; \u00ea &Uacute; \u00da &aacute; \u00e1 &uacute; \u00fa &eacute; \u00e9 &egrave; \u00e8 &icirc; \u00ee";
String[] list = StringUtils.arraySplit(codes, ' ', false);
for(int i=0; i<list.length; i+=2) {
s = StringUtils.replaceAll(s, list[i], list[i+1]);
}
if(s.indexOf("&") >= 0) {
throw new Error("??? " + s);
}
return s;
}
} }
/*
* Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.tools.doc; package org.h2.tools.doc;
import java.io.File; import java.io.File;
...@@ -21,8 +25,12 @@ public class SpellChecker { ...@@ -21,8 +25,12 @@ public class SpellChecker {
private boolean debug; private boolean debug;
private boolean printDictionary; private boolean printDictionary;
private boolean addToDictionary; private boolean addToDictionary;
private static final String[] SUFFIX = new String[]{"java", "sql", "cpp", "txt", "html", "xml", "jsp", "css", "bat", "nsi", "csv", "xml", "js", "def", "dev", "h", "Driver", "properties", "win", "task", "php", "" }; private static final String[] SUFFIX = new String[]{
private static final String[] IGNORE = new String[]{"gif", "png", "odg", "ico", "sxd", "zip", "bz2", "rc", "layout", "res", "dll", "jar"}; "html", "java", "sql", "txt", "xml", "jsp", "css", "bat", "csv", "xml", "js", "Driver", "properties", "task", "php", "" };
private static final String[] IGNORE = new String[]{
"cpp", "h", "win", "dev", "def", "nsi",
"gif", "png", "odg", "ico", "sxd", "zip", "bz2", "rc", "layout", "res", "dll", "jar"};
private static final String PREFIX_IGNORE = "abc";
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
String dir = "src"; String dir = "src";
...@@ -57,27 +65,20 @@ public class SpellChecker { ...@@ -57,27 +65,20 @@ public class SpellChecker {
System.out.println("UNKNOWN WORDS"); System.out.println("UNKNOWN WORDS");
for(Iterator it = unknown.keySet().iterator(); it.hasNext();) { for(Iterator it = unknown.keySet().iterator(); it.hasNext();) {
String s = (String) it.next(); String s = (String) it.next();
int count = ((Integer) unknown.get(s)).intValue(); // int count = ((Integer) unknown.get(s)).intValue();
if(count > 5) { System.out.print(s + " ");
System.out.print(s + " ");
}
} }
System.out.println(); System.out.println();
System.out.println();
throw new IOException("spell check failed"); throw new IOException("spell check failed");
} }
} }
private void process(File file) throws IOException { private void process(File file) throws IOException {
String name = file.getCanonicalPath(); String name = file.getCanonicalPath();
if(name.endsWith(".svn")) { if(name.endsWith(".svn") || name.indexOf("_text_") > 0) {
return; return;
} }
int removeThisLater;
// if(name.indexOf("\\test\\") >= 0) {
// return;
// }
if(file.isDirectory()) { if(file.isDirectory()) {
File[] list = file.listFiles(); File[] list = file.listFiles();
for(int i=0; i<list.length; i++) { for(int i=0; i<list.length; i++) {
...@@ -112,22 +113,20 @@ public class SpellChecker { ...@@ -112,22 +113,20 @@ public class SpellChecker {
if(!ok) { if(!ok) {
throw new IOException("Unsupported suffix: " + suffix + " for file: " + fileName); throw new IOException("Unsupported suffix: " + suffix + " for file: " + fileName);
} }
if("java".equals(suffix) || "xml".equals(suffix) || "txt".equals(suffix)) { FileReader reader = null;
FileReader reader = null; String text = null;
String text = null; try {
try { reader = new FileReader(file);
reader = new FileReader(file); text = readStringAndClose(reader, -1);
text = readStringAndClose(reader, -1); } finally {
} finally { IOUtils.closeSilently(reader);
IOUtils.closeSilently(reader);
}
if(fileName.endsWith("dictionary.txt")) {
addToDictionary = true;
} else {
addToDictionary = false;
}
scan(fileName, text);
} }
if(fileName.endsWith("dictionary.txt")) {
addToDictionary = true;
} else {
addToDictionary = false;
}
scan(fileName, text);
} }
} }
...@@ -200,7 +199,10 @@ public class SpellChecker { ...@@ -200,7 +199,10 @@ public class SpellChecker {
token = token.toLowerCase(); token = token.toLowerCase();
if(!addToDictionary && debug) { if(!addToDictionary && debug) {
System.out.print(token + " "); System.out.print(token + " ");
} }
if(token.startsWith(PREFIX_IGNORE)) {
return;
}
if(addToDictionary) { if(addToDictionary) {
dictionary.add(token); dictionary.add(token);
} else { } else {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论