• R/O
  • SSH
  • HTTPS

nls: 提交


Commit MetaInfo

修订版14 (tree)
时间2011-05-16 09:12:26
作者linuxchecker

Log Message

brushed up a calculation module

更改概述

差异

--- src/org/mathsci/distance/NldCommand.java (revision 13)
+++ src/org/mathsci/distance/NldCommand.java (revision 14)
@@ -1,39 +1,9 @@
11 package org.mathsci.distance;
22
3-
4-import org.apache.commons.codec.binary.Base64;
5-
63 import org.mathsci.distance.NldCore;
74 import org.mathsci.distance.NldIndexer;
85 import org.mathsci.distance.NldSearcher;
9-import org.apache.lucene.index.IndexWriter;
10-import org.apache.lucene.store.FSDirectory;
11-import org.apache.lucene.util.Version;
126
13-import java.io.IOException;
14-import java.io.StringReader;
15-import java.io.BufferedReader;
16-import java.io.InputStreamReader;
17-import java.util.Date;
18-import java.util.Properties;
19-import java.lang.Integer;
20-
21-import org.apache.lucene.analysis.Analyzer;
22-import org.apache.lucene.analysis.standard.StandardAnalyzer;
23-import org.apache.lucene.document.Document;
24-import org.apache.lucene.document.DateTools;
25-import org.apache.lucene.document.Field;
26-import org.apache.lucene.index.FilterIndexReader;
27-import org.apache.lucene.index.IndexReader;
28-import org.apache.lucene.queryParser.QueryParser;
29-import org.apache.lucene.search.Collector;
30-import org.apache.lucene.search.IndexSearcher;
31-import org.apache.lucene.search.Query;
32-import org.apache.lucene.search.ScoreDoc;
33-import org.apache.lucene.search.Scorer;
34-import org.apache.lucene.search.TopScoreDocCollector;
35-
36-
377 public class NldCommand extends NldCore {
388
399 public NldCommand()
@@ -63,35 +33,10 @@
6333 }
6434 }else if("calculator".equals(args[0]))
6535 {
66- computeScore(args);
36+ NldCalc ncalc = new NldCalc();
37+ double val = ncalc.computeScore(args);
38+ System.out.println("similarity="+val);
6739 }
6840 }
69- public static void computeScore(String[] args)
70- {
71- double x,y,xy,lx,ly,lxy;
72- double m = max_pages;
73- Date start_time = new Date();
74- try{
7541
76- if(timewatch) System.out.println("time="+(new Date().getTime()-start_time.getTime()));
77- NldSearcher s = new NldSearcher();
78- if(timewatch) System.out.println("time="+(new Date().getTime()-start_time.getTime()));
79- x = s.searcher(args[1]);
80- if(timewatch) System.out.println("time="+(new Date().getTime()-start_time.getTime()));
81- y = s.searcher(args[2]);
82- if(timewatch) System.out.println("time="+(new Date().getTime()-start_time.getTime()));
83- xy = s.searcher(args[1]+" AND "+args[2]);
84- if(timewatch) System.out.println("time="+(new Date().getTime()-start_time.getTime()));
85- lx = Math.log(x);
86- ly = Math.log(y);
87- lxy = Math.log(xy);
88-
89- System.out.println((new String(args[1].getBytes(),"UTF-8"))+" <> "+args[2]);
90- System.out.println((Math.max(lx,ly)-lxy)/(Math.log(m)-Math.min(lx,ly)));
91- s.close();
92- }catch(Exception e){
93- e.printStackTrace();
94- }
95- }
96-
9742 }
--- src/Makefile (revision 13)
+++ src/Makefile (revision 14)
@@ -4,6 +4,7 @@
44 javac $(OPTIONS) org/mathsci/distance/NldIndexer.java
55 javac $(OPTIONS) org/mathsci/distance/NldSearcher.java
66 javac $(OPTIONS) org/mathsci/distance/NldCommand.java
7+ javac $(OPTIONS) org/mathsci/distance/NldCalc.java
78 test -e $(DEST) || mkdir $(DEST)
89 jar cvf $(DEST)/nld.jar $(SRCDIR)/*.class
910
Show on old repository browser