• R/O
  • SSH
  • HTTPS

nls: 提交


Commit MetaInfo

修订版17 (tree)
时间2011-05-16 20:04:00
作者linuxchecker

Log Message

supported loader command

更改概述

差异

--- src/org/mathsci/distance/NldCommand.java (revision 16)
+++ src/org/mathsci/distance/NldCommand.java (revision 17)
@@ -3,6 +3,9 @@
33 import org.mathsci.distance.NldCore;
44 import org.mathsci.distance.NldIndexer;
55 import org.mathsci.distance.NldSearcher;
6+import java.util.*;
7+import java.io.FileReader;
8+import java.io.BufferedReader;
69
710 public class NldCommand extends NldCore {
811
@@ -36,6 +39,33 @@
3639 NldCalc ncalc = new NldCalc();
3740 double val = ncalc.computeScore(args);
3841 System.out.println("similarity="+val);
42+ }else if("loader".equals(args[0]))
43+ {
44+ NldCalc ncalc = new NldCalc();
45+ ArrayList<String> stringBuffer = new ArrayList<String>();
46+ try
47+ {
48+ BufferedReader fp = new BufferedReader(new FileReader(args[1]));
49+ String s;
50+ while((s = fp.readLine())!=null)
51+ {
52+ stringBuffer.add(s);
53+ }
54+ }catch(Exception e)
55+ {
56+ e.printStackTrace();
57+ }
58+ String[] word = new String[3];
59+ int len = stringBuffer.size();
60+ for(int i = 0;i<len-1;++i)
61+ { word[1] = stringBuffer.get(i);
62+ for(int j=i+1; j<len;++j)
63+ {
64+ word[2] = stringBuffer.get(j);
65+ double val = ncalc.computeScore(word);
66+ System.out.println(word[1]+","+word[2]+","+val);
67+ }
68+ }
3969 }
4070 }
4171
--- bin/nld.sh (revision 16)
+++ bin/nld.sh (revision 17)
@@ -43,6 +43,10 @@
4343 fi
4444 $JAVA $OPTIONS -cp $NLD_JAR:$LIBS org.mathsci.distance.NldCommand calculator $DATA $DATA2
4545 fi
46+elif [ "X"$1 = "Xloader" ];
47+then
48+ DATA="$2"
49+ $JAVA $OPTIONS -cp $NLD_JAR:$LIBS org.mathsci.distance.NldCommand loader $DATA
4650 else
47- echo "usage: " $0 "[indexer|searcher|calculator]"
51+ echo "usage: " $0 "[indexer|searcher|calculator|loader]"
4852 fi
Show on old repository browser