• R/O
  • SSH
  • HTTPS

nls: 提交


Commit MetaInfo

修订版18 (tree)
时间2011-05-19 20:18:51
作者linuxchecker

Log Message

implemented realy normarization version

更改概述

差异

--- src/org/mathsci/distance/NldCalc.java (revision 17)
+++ src/org/mathsci/distance/NldCalc.java (revision 18)
@@ -10,7 +10,8 @@
1010 }
1111 public double computeScore(String[] args)
1212 {
13- double x,y,xy,lx,ly,lxy;
13+ int x, y, xy;
14+ double lx,ly,lxy;
1415 double m = max_pages;
1516 double val = 0d;
1617 Date start_time = new Date();
@@ -23,21 +24,41 @@
2324 if(timewatch) System.out.println("time="+(new Date().getTime()-start_time.getTime()));
2425 y = s.searcher(args[2]);
2526 if(timewatch) System.out.println("time="+(new Date().getTime()-start_time.getTime()));
26- xy = s.searcher(args[1]+" AND "+args[2]);
27- if(timewatch) System.out.println("time="+(new Date().getTime()-start_time.getTime()));
28- lx = Math.log(x);
29- ly = Math.log(y);
30- lxy = Math.log(xy);
3127
32- if(debug_level>1)
33- {
34- System.out.println((new String(args[1].getBytes(),"UTF-8"))+" <> "+args[2]);
28+ if(y==0)
29+ {
30+ y = x;
31+ x = 0;
3532 }
36- val = (Math.max(lx,ly)-lxy)/(Math.log(m)-Math.min(lx,ly));
33+
34+ if(x==0)
35+ {
36+ if(y==0)
37+ {
38+ return(-1); // cannot compute score
39+ }else
40+ {
41+ ly = Math.log(y);
42+ val = ly/(Math.log(m)-ly);
43+ }
44+ }else
45+ {
46+ xy = s.searcher(args[1]+" AND "+args[2]);
47+ if(timewatch) System.out.println("time="+(new Date().getTime()-start_time.getTime()));
48+ lx = Math.log(x);
49+ ly = Math.log(y);
50+ lxy = Math.log(xy);
51+
52+ if(debug_level>1)
53+ {
54+ System.out.println((new String(args[1].getBytes(),"UTF-8"))+" <> "+args[2]);
55+ }
56+ val = (Math.max(lx,ly)-lxy)/(Math.log(m)-Math.min(lx,ly));
57+ }
3758 s.close();
3859 }catch(Exception e){
3960 e.printStackTrace();
4061 }
41- return(val);
62+ return(1d-Math.exp(-val));
4263 }
4364 }
--- src/org/mathsci/distance/NldSearcher.java (revision 17)
+++ src/org/mathsci/distance/NldSearcher.java (revision 18)
@@ -71,7 +71,7 @@
7171 {
7272 reader.close();
7373 }
74- public double searcher(String arg) throws Exception {
74+ public int searcher(String arg) throws Exception {
7575
7676 String field = "contents";
7777 String queries = arg;
@@ -93,11 +93,11 @@
9393 line = line.trim();
9494 Query query = parser.parse(line);
9595 System.out.println("Searching for: " + query.toString(field));
96- double numHitsTotal = doStreamingSearch(searcher, query);
96+ int numHitsTotal = doStreamingSearch(searcher, query);
9797 return(numHitsTotal);
9898 }
9999
100- public static double doStreamingSearch(final IndexSearcher searcher, Query query) throws IOException
100+ public static int doStreamingSearch(final IndexSearcher searcher, Query query) throws IOException
101101 {
102102 int hitsPerPage = searcher.maxDoc();
103103 TopScoreDocCollector streamingHitCollector = TopScoreDocCollector.create(
Show on old repository browser