Skip to content

Commit

Permalink
seqeval
Browse files Browse the repository at this point in the history
  • Loading branch information
xpqiu committed May 7, 2015
1 parent bf8fa6b commit cb7d951
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 24 deletions.
60 changes: 38 additions & 22 deletions fnlp-core/src/main/java/org/fnlp/ml/eval/SeqEval.java
Original file line number Diff line number Diff line change
Expand Up @@ -525,54 +525,70 @@ public String calcByType() {
public double[] calcPRF() {

/**
* 估计的中正确的,key是字符串长度,value是这种长度的个数
* 估计的中正确的
*/
Map<String,Double> mpc = new TreeMap<String,Double>();
int mpc = 0;
/**
* 估计的,key是字符串长度,value是这种长度的个数
* 估计的
*/
Map<String,Double> mp = new TreeMap<String,Double>();
int mp = 0;
/**
* 正确的,key是字符串长度,value是这种长度的个数
* 正确的
*/
Map<String,Double> mc = new TreeMap<String,Double>();
int mc = 0;

/**
* OOV
*/
Map<String,Double> oov = new TreeMap<String,Double>();
int oov = 0;
int coov =0;

for(int i=0;i<entityCs.size();i++){
LinkedList<Entity> cList = entityCs.get(i);
LinkedList<Entity> pList = entityPs.get(i);
LinkedList<Entity> cpList = entityCinPs.get(i);

for(Entity entity:cList){

adjust(mc, "", 1.0);
if(dict!=null&&dict.size()>0){
for(Entity entity:cList){
if(dict!=null&&dict.size()>0){
String s = entity.getEntityStr();
if(!dict.contains(s)){
adjust(oov, "", 1.0);
oov++;
}
}
}

for(Entity entity:pList){
adjust(mp, "", 1.0);
for(Entity entity:cpList){
if(dict!=null&&dict.size()>0){
String s = entity.getEntityStr();
if(!dict.contains(s)){
coov++;
}
}
}

for(Entity entity:cpList){
adjust(mpc, "", 1.0);
}


mc+=cList.size();
mp+=pList.size();
mpc+=cpList.size();
}

String key = "";
double pre = (Double) mpc.get(key)/(Double) mp.get(key)*100;
double recall = (Double)mpc.get(key)/(Double)mc.get(key)*100;
double FB1 = (pre*recall*2)/(recall+pre)*100;
double pre =0;
if(mp!=0)
pre = (double) mpc/(double) mp*100;
double recall = 0;
if(mc!=0)
recall = (double)mpc/(double)mc*100;

double FB1=0;
if(recall+pre!=0)
FB1 = (pre*recall*2)/(recall+pre)*100;

double oovrecall = 0;
if(oov!=0)
oovrecall = (double)coov/(double)oov*100;

return new double[]{pre,recall,FB1};
return new double[]{pre,recall,FB1,oovrecall};

}

Expand Down
4 changes: 2 additions & 2 deletions fnlp-train/src/main/java/org/fnlp/train/seg/DICT.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public class DICT {
*/
public static void main(String[] args) throws Exception {
DICT dic = new DICT();
String file = "./tmpdata/FNLPDATA/all.cws";
String dicfile = "./tmpdata/FNLPDATA/all.dict";
String file = "D:\\项目\\9.评测\\NLPCC2015分词\\data21_No_0\\trainSeg.txt";
String dicfile = "D:\\项目\\9.评测\\NLPCC2015分词\\data21_No_0\\all.dict";
BMES2DICT(file,dicfile);

System.out.println(new Date().toString());
Expand Down

0 comments on commit cb7d951

Please sign in to comment.