Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
identify-service
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liuzhangyiding
identify-service
Commits
a6b85d09
Commit
a6b85d09
authored
Mar 19, 2020
by
liuzhangyiding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加参数实现准确率识别,对应修改处理流程
parent
d80c569e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
68 additions
and
72 deletions
+68
-72
TestResult.txt
model/TestResult.txt
+2
-2
model.txt
model/model.txt
+26
-23
train.txt
model/train.txt
+23
-23
IdentifyService.java
src/main/java/com/xoado/domain/service/IdentifyService.java
+13
-13
SVMService.java
src/main/java/com/xoado/domain/service/SVMService.java
+0
-0
comMain.java
src/main/java/com/xoado/domain/svm/comMain.java
+1
-1
svm_train.java
src/main/java/com/xoado/domain/svm/svm_train.java
+0
-7
DocumentWordsCollector.java
.../document/processor/component/DocumentWordsCollector.java
+1
-1
skill.json
src/main/resources/skill.json
+2
-2
No files found.
model/TestResult.txt
View file @
a6b85d09
...
@@ -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
model/model.txt
View file @
a6b85d09
...
@@ -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 2
2
total_sv 2
3
rho 0.
354451026169045
6
rho 0.
409024560869604
6
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
model/train.txt
View file @
a6b85d09
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
src/main/java/com/xoado/domain/service/IdentifyService.java
View file @
a6b85d09
...
@@ -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
);
...
...
src/main/java/com/xoado/domain/service/SVMService.java
View file @
a6b85d09
This diff is collapsed.
Click to expand it.
src/main/java/com/xoado/domain/svm/comMain.java
View file @
a6b85d09
...
@@ -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通过训练数据训/ //练出来的模型的路径
...
...
src/main/java/com/xoado/domain/svm/svm_train.java
View file @
a6b85d09
...
@@ -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
);
}
}
...
...
src/main/java/org/shirdrn/document/processor/component/DocumentWordsCollector.java
View file @
a6b85d09
...
@@ -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
(
...
...
src/main/resources/skill.json
View file @
a6b85d09
...
@@ -13,8 +13,7 @@
...
@@ -13,8 +13,7 @@
"keyList"
:
[
"吃饭"
,
"外卖"
,
"科"
,
"吃"
],
"keyList"
:
[
"吃饭"
,
"外卖"
,
"科"
,
"吃"
],
"regexeList"
:
[
"regexeList"
:
[
"^.*(叫|点|吃).*$"
,
"^.*(叫|点|吃).*$"
,
"^.*来.*碗.*$"
,
"^.*来.*碗.*$"
"^.*(科技).*$"
]
]
}
}
]
]
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment