public final int REINDEXNOTE=3;
public boolean keepRunning;
private final QDomDocument doc;
- private static String regex = Global.getWordRegex();
- public String specialIndexCharacters = "";
+// private static String regex = Global.getWordRegex();
+// public String specialIndexCharacters = "";
// public boolean indexNoteBody = true;
// public boolean indexNoteTitle = true;
public boolean indexImageRecognition = true;
RTFParser parser = new RTFParser();
ParseContext context = new ParseContext();
parser.parse(input, textHandler, metadata, context);
- String[] result = textHandler.toString().split(regex);
- for (int i=0; i<result.length && keepRunning; i++) {
- addToIndex(r.getNoteGuid(), result[i], "RESOURCE");
- }
+// String[] result = textHandler.toString().split(regex);
+// for (int i=0; i<result.length && keepRunning; i++) {
+// addToIndex(r.getNoteGuid(), result[i], "RESOURCE");
+// }
+ updateResourceText(r.getGuid(), textHandler.toString());
input.close();
f.close();
OpenDocumentParser parser = new OpenDocumentParser();
ParseContext context = new ParseContext();
parser.parse(input, textHandler, metadata, context);
- String[] result = textHandler.toString().split(regex);
- for (int i=0; i<result.length && keepRunning; i++) {
- if (interrupt) {
- processInterrupt();
- }
- addToIndex(r.getNoteGuid(), result[i], "RESOURCE");
- }
+// String[] result = textHandler.toString().split(regex);
+// for (int i=0; i<result.length && keepRunning; i++) {
+// if (interrupt) {
+// processInterrupt();
+// }
+// addToIndex(r.getNoteGuid(), result[i], "RESOURCE");
+// }
+ updateResourceText(r.getGuid(), textHandler.toString());
input.close();
f.close();
OfficeParser parser = new OfficeParser();
ParseContext context = new ParseContext();
parser.parse(input, textHandler, metadata, context);
- String[] result = textHandler.toString().split(regex);
- for (int i=0; i<result.length && keepRunning; i++) {
- if (interrupt) {
- processInterrupt();
- }
- addToIndex(r.getNoteGuid(), result[i], "RESOURCE");
- }
+// String[] result = textHandler.toString().split(regex);
+// for (int i=0; i<result.length && keepRunning; i++) {
+// if (interrupt) {
+// processInterrupt();
+// }
+// addToIndex(r.getNoteGuid(), result[i], "RESOURCE");
+// }
+ updateResourceText(r.getGuid(), textHandler.toString());
input.close();
f.close();
PDFParser parser = new PDFParser();
ParseContext context = new ParseContext();
parser.parse(input, textHandler, metadata, context);
- String[] result = textHandler.toString().split(regex);
- for (int i=0; i<result.length && keepRunning; i++) {
- if (interrupt) {
- processInterrupt();
- }
- addToIndex(r.getNoteGuid(), result[i], "RESOURCE");
- }
+// String[] result = textHandler.toString().split(regex);
+// for (int i=0; i<result.length && keepRunning; i++) {
+// if (interrupt) {
+// processInterrupt();
+// }
+// addToIndex(r.getNoteGuid(), result[i], "RESOURCE");
+// }
+ updateResourceText(r.getGuid(), textHandler.toString());
input.close();
f.close();
OOXMLParser parser = new OOXMLParser();
ParseContext context = new ParseContext();
parser.parse(input, textHandler, metadata, context);
- String[] result = textHandler.toString().split(regex);
- for (int i=0; i<result.length && keepRunning; i++) {
- if (interrupt) {
- processInterrupt();
- }
- addToIndex(r.getNoteGuid(), result[i], "RESOURCE");
- }
+// String[] result = textHandler.toString().split(regex);
+// for (int i=0; i<result.length && keepRunning; i++) {
+// if (interrupt) {
+// processInterrupt();
+// }
+// addToIndex(r.getNoteGuid(), result[i], "RESOURCE");
+// }
+ updateResourceText(r.getGuid(), textHandler.toString());
input.close();
f.close();
}
- private void addToIndex(String guid, String word, String type) {
- if (foundWords.contains(word))
- return;
- StringBuffer buffer = new StringBuffer(word.toLowerCase());
- for (int i=buffer.length()-1; i>=0; i--) {
- if (!Character.isLetterOrDigit(buffer.charAt(i)) && specialIndexCharacters.indexOf(buffer.charAt(i)) == -1)
- buffer.deleteCharAt(i);
- else
- break;
- }
- buffer = buffer.reverse();
- for (int i=buffer.length()-1; i>=0; i--) {
- if (!Character.isLetterOrDigit(buffer.charAt(i)))
- buffer.deleteCharAt(i);
- else
- break;
- }
- buffer = buffer.reverse();
- if (buffer.length() > 0) {
- // We have a good word, now let's trim off junk at the beginning or end
- if (!foundWords.contains(buffer.toString())) {
- foundWords.add(buffer.toString());
- foundWords.add(word);
- conn.getWordsTable().addWordToNoteIndex(guid, buffer.toString(), type, 100);
- uncommittedCount++;
- if (uncommittedCount > 100) {
- conn.commitTransaction();
- uncommittedCount=0;
- }
- }
- }
- return;
+// private void addToIndex(String guid, String word, String type) {
+// if (foundWords.contains(word))
+// return;
+// StringBuffer buffer = new StringBuffer(word.toLowerCase());
+// for (int i=buffer.length()-1; i>=0; i--) {
+// if (!Character.isLetterOrDigit(buffer.charAt(i)) && specialIndexCharacters.indexOf(buffer.charAt(i)) == -1)
+// buffer.deleteCharAt(i);
+// else
+// break;
+// }
+// buffer = buffer.reverse();
+// for (int i=buffer.length()-1; i>=0; i--) {
+// if (!Character.isLetterOrDigit(buffer.charAt(i)))
+// buffer.deleteCharAt(i);
+// else
+// break;
+// }
+// buffer = buffer.reverse();
+// if (buffer.length() > 0) {
+// // We have a good word, now let's trim off junk at the beginning or end
+// if (!foundWords.contains(buffer.toString())) {
+// foundWords.add(buffer.toString());
+// foundWords.add(word);
+// conn.getWordsTable().addWordToNoteIndex(guid, buffer.toString(), type, 100);
+// uncommittedCount++;
+// if (uncommittedCount > 100) {
+// conn.commitTransaction();
+// uncommittedCount=0;
+// }
+// }
+// }
+// return;
+// }
+
+ // ノートリソーステーブルのリソーステキストに追加
+ private void updateResourceText(String guid, String text) {
+ conn.getNoteTable().noteResourceTable.updateResourceText(guid, text);
}
private void scanUnindexed() {