Commit a6b85d09 by liuzhangyiding

增加参数实现准确率识别,对应修改处理流程

parent d80c569e
...@@ -13,13 +13,13 @@ ...@@ -13,13 +13,13 @@
1.0 1.0
2.0 2.0
2.0 2.0
1.0
2.0 2.0
2.0 2.0
1.0
2.0 2.0
2.0 2.0
1.0
2.0 2.0
2.0 2.0
1.0
2.0 2.0
2.0 2.0
...@@ -2,30 +2,33 @@ svm_type c_svc ...@@ -2,30 +2,33 @@ svm_type c_svc
kernel_type rbf kernel_type rbf
gamma 0.07142857142857142 gamma 0.07142857142857142
nr_class 2 nr_class 2
total_sv 22 total_sv 23
rho 0.3544510261690456 rho 0.4090245608696046
label 1 2 label 1 2
nr_sv 10 12 probA -1.6128218314376728
probB 0.14720533163949925
nr_sv 11 12
SV SV
1.0 9:3.0588936890535687 1.0 8:0.979533151778619 7:0.979533151778619 3:0.4005446203898835
1.0 8:1.5294468445267844 3:0.6609640474436812 1.0 13:1.7617809780285065 9:1.4692997276679285
0.9903141391672972 3:1.3219280948873624 0.3704443587292751 3:1.2016338611696504
1.0 3:1.3219280948873624 1.0 5:3.523561956057013
1.0 3:1.3219280948873624 1.0 3:1.2016338611696504
1.0 3:1.3219280948873624 1.0 10:3.523561956057013
1.0 10:3.6438561897747253 1.0 3:1.2016338611696504
1.0 8:1.019631229684523 7:1.019631229684523 3:0.44064269829578745 1.0 8:1.4692997276679285 3:0.6008169305848252
1.0 13:1.8219280948873626 9:1.5294468445267844 1.0 3:1.2016338611696504
1.0 5:3.6438561897747253 1.0 3:1.2016338611696504
-0.6700922884685501 14:2.643856189774725 1.0 9:2.938599455335857
-0.2563835238113437 11:3.0588936890535687 -0.34763255797023584 11:2.938599455335857
-1.0 14:1.2617809780285065 12:1.7617809780285065
-0.27060537603115437 4:2.523561956057013
-0.9876261200717943 11:2.938599455335857
-1.0 -1.0
-1.0 2:3.6438561897747253 -1.0 1:1.7617809780285065 14:1.2617809780285065
-0.07237134131172171 4:2.643856189774725 -1.0 2:3.523561956057013
-1.0 4:1.3219280948873624 7:1.5294468445267844
-1.0 1:1.8219280948873626 14:1.3219280948873624
-0.9914669855756817 11:3.0588936890535687
-1.0 14:1.3219280948873624 12:1.8219280948873626
-1.0 -1.0
-1.0 4:2.643856189774725 -1.0 4:1.2617809780285065 7:1.4692997276679285
-1.0 6:3.6438561897747253 -0.8144378826386051 14:2.523561956057013
-1.0 6:3.523561956057013
-0.9501424220174856 4:2.523561956057013
1 9:3.0588936890535687 1 8:0.979533151778619 7:0.979533151778619 3:0.4005446203898835
1 8:1.5294468445267844 3:0.6609640474436812 1 3:1.2016338611696504
1 3:1.3219280948873624 1 13:1.7617809780285065 9:1.4692997276679285
1 3:1.3219280948873624 1 3:1.2016338611696504
1 3:1.3219280948873624 1 3:1.2016338611696504
1 3:1.3219280948873624 1 5:3.523561956057013
1 3:1.3219280948873624 1 3:1.2016338611696504
1 3:1.3219280948873624 1 10:3.523561956057013
1 3:1.3219280948873624 1 3:1.2016338611696504
1 10:3.6438561897747253 1 8:1.4692997276679285 3:0.6008169305848252
1 8:1.019631229684523 7:1.019631229684523 3:0.44064269829578745 1 3:1.2016338611696504
1 13:1.8219280948873626 9:1.5294468445267844 1 3:1.2016338611696504
1 5:3.6438561897747253 1 9:2.938599455335857
2 14:2.643856189774725 2 11:2.938599455335857
2 11:3.0588936890535687 2 14:1.2617809780285065 12:1.7617809780285065
2 4:2.523561956057013
2 11:2.938599455335857
2 2
2 2:3.6438561897747253 2 1:1.7617809780285065 14:1.2617809780285065
2 4:2.643856189774725 2 2:3.523561956057013
2 4:1.3219280948873624 7:1.5294468445267844
2 1:1.8219280948873626 14:1.3219280948873624
2 11:3.0588936890535687
2 14:1.3219280948873624 12:1.8219280948873626
2 2
2 4:2.643856189774725 2 4:1.2617809780285065 7:1.4692997276679285
2 6:3.6438561897747253 2 14:2.523561956057013
2 6:3.523561956057013
2 4:2.523561956057013
...@@ -105,21 +105,21 @@ public class IdentifyService { ...@@ -105,21 +105,21 @@ public class IdentifyService {
if(matchedSkills.size()==0){ if(matchedSkills.size()==0){
matchedSkills = matchSkillByRegex(formattext,matchedSkills); matchedSkills = matchSkillByRegex(formattext,matchedSkills);
} }
Skill matchedSkill = null;
List wordList = WordUtil.getNlpSeg(text);
//TODO 匹配到一个的话直接确定意图,否则用模型进行二次识别。识别模型目前必定识别出结果,无概率计算。
if((matchedSkills.size()==1)){
matchedSkill = matchedSkills.get(0);
FakeLog.log("match only one skill:"+matchedSkill.getName() );
}else if(matchedSkills.size()>1){
String identifyBySVMResult = SVMService.predict(wordList);
matchedSkill = StringUtils.isEmpty(identifyBySVMResult)?null:skillList.getSkillByName(identifyBySVMResult);
}
//直接进行模型测试
// Skill matchedSkill = null; // Skill matchedSkill = null;
// List wordList = WordUtil.getNlpSeg(text); // List wordList = WordUtil.getNlpSeg(text);
// String identifyBySVMResult = SVMService.predict(wordList); // //TODO 匹配到一个的话直接确定意图,否则用模型进行二次识别。识别模型目前必定识别出结果,无概率计算。
// matchedSkill = StringUtils.isEmpty(identifyBySVMResult)?null:skillList.getSkillByName(identifyBySVMResult); // if((matchedSkills.size()==1)){
// matchedSkill = matchedSkills.get(0);
// FakeLog.log("match only one skill:"+matchedSkill.getName() );
// }else if(matchedSkills.size()>1){
// String identifyBySVMResult = SVMService.predict(wordList);
// matchedSkill = StringUtils.isEmpty(identifyBySVMResult)?null:skillList.getSkillByName(identifyBySVMResult);
// }
//直接进行模型测试
Skill matchedSkill = null;
List wordList = WordUtil.getNlpSeg(text);
String identifyBySVMResult = SVMService.predict(wordList);
matchedSkill = StringUtils.isEmpty(identifyBySVMResult)?null:skillList.getSkillByName(identifyBySVMResult);
if(matchedSkill == null){ if(matchedSkill == null){
FakeLog.log("无法识别:"+text); FakeLog.log("无法识别:"+text);
......
...@@ -16,7 +16,7 @@ public class comMain { ...@@ -16,7 +16,7 @@ public class comMain {
// TODO Auto-generated method stub // TODO Auto-generated method stub
String[] arg = { "model\\train.txt", // 存放SVM训练模型用的数据的路径 String[] arg = { "-b","1", "model\\train.txt", // 存放SVM训练模型用的数据的路径
"model\\model.txt" }; // 存放SVM通过训练数据训/ //练出来的模型的路径 "model\\model.txt" }; // 存放SVM通过训练数据训/ //练出来的模型的路径
......
...@@ -116,13 +116,6 @@ class svm_train { ...@@ -116,13 +116,6 @@ class svm_train {
public static void main(String argv[]) throws IOException public static void main(String argv[]) throws IOException
{ {
String model_file = argv[0];
String output_file = argv[1];
argv = new String[4];
argv[0] = model_file;
argv[1] = output_file;
svm_train t = new svm_train(); svm_train t = new svm_train();
t.run(argv); t.run(argv);
} }
......
...@@ -59,7 +59,7 @@ public class DocumentWordsCollector extends AbstractComponent { ...@@ -59,7 +59,7 @@ public class DocumentWordsCollector extends AbstractComponent {
int n = 1; int n = 1;
for(File file : files) { for(File file : files) {
String doc = file.getAbsolutePath(); String doc = file.getAbsolutePath();
//遍历文件里的每一行内容 //遍历文件里的每一行内容
BufferedReader br = null; BufferedReader br = null;
try { try {
br = new BufferedReader( br = new BufferedReader(
......
...@@ -13,8 +13,7 @@ ...@@ -13,8 +13,7 @@
"keyList": ["吃饭","外卖","科","吃"], "keyList": ["吃饭","外卖","科","吃"],
"regexeList": [ "regexeList": [
"^.*(叫|点|吃).*$", "^.*(叫|点|吃).*$",
"^.*来.*碗.*$", "^.*来.*碗.*$"
"^.*(科技).*$"
] ]
} }
] ]
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment