• R/O
  • SSH
  • HTTPS

nls: 提交


Commit MetaInfo

修订版12 (tree)
时间2011-05-09 11:46:39
作者linuxchecker

Log Message

implemented experimental RAMDISK codes

更改概述

差异

--- src/org/mathsci/distance/NldSearcher.java (revision 11)
+++ src/org/mathsci/distance/NldSearcher.java (revision 12)
@@ -35,6 +35,8 @@
3535 import org.apache.lucene.search.Scorer;
3636 import org.apache.lucene.search.IndexSearcher;
3737 import org.apache.lucene.search.TopScoreDocCollector;
38+import org.apache.lucene.store.Directory;
39+import org.apache.lucene.store.RAMDirectory;
3840
3941 public class NldSearcher {
4042
@@ -41,6 +43,7 @@
4143 static final Properties properties = new Properties();
4244 static public String index;
4345 static File INDEX_DIR;
46+ static RAMDirectory RAM_INDEX_DIR;
4447 static public String IPADIC;
4548 static public boolean timewatch = false;
4649 static public long start_time = 0;
@@ -59,6 +62,9 @@
5962 index = properties.getProperty("lucene.index.path");
6063 INDEX_DIR = new File(index);
6164 IPADIC = properties.getProperty("ipadic.path");
65+
66+ // RAM_INDEX_DIR = new RAMDirectory();
67+
6268 if("yes".equals(properties.getProperty("lucene.timewatch")) ||
6369 "true".equals(properties.getProperty("lucene.timewatch")) )
6470 {
@@ -82,6 +88,16 @@
8288 String queries = arg;
8389 boolean paging = true;
8490
91+
92+ FSDirectory dir = FSDirectory.open(new File(index));
93+ IndexReader reader = IndexReader.open(FSDirectory.open(new File(index)), true);
94+// for (String file : dir.listAll())
95+// {
96+// dir.copy(RAM_INDEX_DIR, file, file); // newFile can be either file, or a new name
97+// }
98+// reader = IndexReader.open(RAM_INDEX_DIR, true);
99+ reader = IndexReader.open(dir, true);
100+ IndexSearcher searcher = new IndexSearcher(reader);
85101 // Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_31);
86102 Analyzer analyzer = new IpadicAnalyzer(new Tagger(IPADIC));
87103 BufferedReader in = null;
@@ -88,6 +104,7 @@
88104 if (queries != null) {
89105 in = new BufferedReader(new StringReader(queries));
90106 }
107+
91108 QueryParser parser = new QueryParser(Version.LUCENE_31, field, analyzer);
92109 String line = in.readLine();
93110 line = line.trim();
@@ -96,7 +113,6 @@
96113 double numHitsTotal = doStreamingSearch(searcher, query);
97114 return(numHitsTotal);
98115 }
99-
100116
101117 public static double doStreamingSearch(final IndexSearcher searcher, Query query) throws IOException
102118 {
--- src/org/mathsci/distance/NldCommand.java (revision 11)
+++ src/org/mathsci/distance/NldCommand.java (revision 12)
@@ -1,5 +1,7 @@
11 package org.mathsci.distance;
22
3+import org.apache.commons.codec.binary.Base64;
4+
35 import org.mathsci.distance.NldIndexer;
46 import org.mathsci.distance.NldSearcher;
57 import org.apache.lucene.index.IndexWriter;
@@ -92,6 +94,7 @@
9294 double m = max_pages;
9395 Date start_time = new Date();
9496 try{
97+
9598 if(timewatch) System.out.println("time="+(new Date().getTime()-start_time.getTime()));
9699 NldSearcher s = new NldSearcher();
97100 if(timewatch) System.out.println("time="+(new Date().getTime()-start_time.getTime()));
@@ -105,7 +108,7 @@
105108 ly = Math.log(y);
106109 lxy = Math.log(xy);
107110
108- System.out.println((new String(args[1].getBytes(),"UTF-8"))+" <> "+args[2]+"="+(Math.max(lx,ly)-lxy)/(Math.log(m)-Math.min(lx,ly)));
111+ System.out.println((new String(args[1].getBytes(),"UTF-8"))+" <> "+args[2]);
109112 System.out.println((Math.max(lx,ly)-lxy)/(Math.log(m)-Math.min(lx,ly)));
110113 s.close();
111114 }catch(Exception e){
--- bin/nld.sh (revision 11)
+++ bin/nld.sh (revision 12)
@@ -3,7 +3,7 @@
33 JAVA=`which java`
44 NLD_JAR=../bin/nld.jar
55 LIBS=../lib:../lib/lucene-core-3.1.0.jar:../lib/igo-analyzer-0.0.1.jar:../lib/igo-0.4.2.jar:../conf
6-OPTIONS=-Dfile.encoding=UTF-8
6+OPTIONS="-Dfile.encoding=UTF-8 -Xmx1048m"
77 cd nls/bin;
88 if [ "X"$1 = "Xindexer" ];
99 then
--- README.txt (revision 11)
+++ README.txt (revision 12)
@@ -16,7 +16,7 @@
1616 $ ls -l data/
1717
1818 + Lucene
19- http://ftp.jaist.ac.jp/pub/apache/lucene/java/lucene-3.1.0.tar.gz
19+ http://ftp.jaist.ac.jp/pub/apache/lucene/java/3.1.0/lucene-3.1.0.tar.gz
2020
2121 $ tar xvf lucene-3.1.0.tar.gz
2222 $ cp lucene-3.1.0/lucene-core-3.1.0.jar nls/lib/
--- Makefile (revision 11)
+++ Makefile (revision 12)
@@ -3,7 +3,7 @@
33 DEST = dest
44 LUCENE_HOME =../lib/lucene-core-3.1.0.jar
55 IGO = ../lib/igo-analyzer-0.0.1.jar:../lib/igo-0.4.2.jar
6-DEFINES = DEST=../$(DEST) LIBS=.:$(LUCENE_HOME):$(IGO) CONF=conf
6+DEFINES = DEST=../$(DEST) LIBS=.:$(LUCENE_HOME):$(IGO):../lib/commons-codec-1.5.jar CONF=conf
77 all:
88 cd src && env $(DEFINES) $(MAKE)
99
Show on old repository browser