Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
qwgame
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
赵国君
qwgame
Commits
778bd62c
Commit
778bd62c
authored
Sep 14, 2018
by
hxw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
8f889b97
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
18 deletions
+49
-18
ProcessQuestion.java
src/processing/ProcessQuestion.java
+48
-17
GetAnswerServlet.java
src/servlet/GetAnswerServlet.java
+1
-1
No files found.
src/processing/ProcessQuestion.java
View file @
778bd62c
...
...
@@ -108,8 +108,6 @@ public class ProcessQuestion {
public
static
Condition
buildCondition
(
Condition
condition
,
String
line
){
//System.out.println("build condition");
//System.out.println("xxxxx"+line);
String
feature
,
element
[],
pair
[],
next
[],
cur_premises
[],
history_premises
[],
premises
[],
firstCnditionName
;
line
=
line
.
split
(
"---"
)[
0
];
...
...
@@ -260,6 +258,11 @@ public class ProcessQuestion {
System
.
out
.
print
(
v
+
" "
);
}
System
.
out
.
println
();
if
(
values
[
0
].
equals
(
":"
)){
values
[
0
]
=
""
;
curInfoPoint
.
put
(
k
,
values
);
}
}
//如果引擎什么信息都没识别到,那就将上一轮的nextStep(也就是当前轮的actionName)设为unknown
...
...
@@ -479,7 +482,6 @@ public class ProcessQuestion {
}
else
if
(
cmpType
.
equals
(
"timeEarly"
)){
long
candidateA
,
candidateB
=
0
;
System
.
out
.
println
(
"1这里是:"
+
keyword
);
candidateA
=
MyFunc
.
transferToMillisecond
(
keyword
);
for
(
String
k:
keywordSet
){
...
...
@@ -492,7 +494,6 @@ public class ProcessQuestion {
}
else
if
(
cmpType
.
equals
(
"timeLater"
)){
long
candidateA
,
candidateB
=
0
;
System
.
out
.
println
(
"1这里是:"
+
keyword
);
candidateA
=
MyFunc
.
transferToMillisecond
(
keyword
);
for
(
String
k:
keywordSet
){
...
...
@@ -567,6 +568,7 @@ public class ProcessQuestion {
try
{
/*
String keyword1, keyword2;
while (it.hasNext()) {
actionName = it.next();
...
...
@@ -579,6 +581,21 @@ public class ProcessQuestion {
ans.setAnswer(ans.getAnswer().replace("{" + actionName + "-1}", keyword1));//这里
}
}
*/
it
=
historyInfoPoint
.
keySet
().
iterator
();
String
keyword1
,
keyword2
;
while
(
it
.
hasNext
())
{
actionName
=
it
.
next
();
if
(
curInfoPoint
.
get
(
actionName
)
!=
null
)
{
keyword1
=
curInfoPoint
.
get
(
actionName
)[
0
];
ans
.
setAnswer
(
ans
.
getAnswer
().
replace
(
"{"
+
actionName
+
"-1}"
,
keyword1
));
//这里
}
keyword2
=
historyInfoPoint
.
get
(
actionName
);
ans
.
setAnswer
(
ans
.
getAnswer
().
replace
(
"{"
+
actionName
+
"-2}"
,
keyword2
));
}
}
catch
(
Exception
e
){
e
.
printStackTrace
();
...
...
@@ -587,18 +604,23 @@ public class ProcessQuestion {
return
ans
;
}
public
void
infoTransition
(
Map
<
String
,
String
[]>
curInfoPoint
,
Map
<
String
,
String
>
historyInfoPoint
,
AnswerNextStep
ans
,
ServletContext
context
){
public
void
infoTransition
(
Map
<
String
,
String
[]>
curInfoPoint
,
Map
<
String
,
String
>
historyInfoPoint
,
AnswerNextStep
ans
,
ServletContext
context
,
boolean
debugFlag
){
//将当前信息点更新至历史信息点,并且替换答案中的相应变量,变量结构为{xxx-1}或者{xxx-2}
Iterator
<
String
>
it
=
curInfoPoint
.
keySet
().
iterator
();
String
actionName
;
String
actionName
,
lastReply
;
String
next
=
ans
.
getNext
().
split
(
"="
)[
1
];
//保存即将跳转的action名以供下一轮使用,nextStep的结构是nextStep=xxx
historyInfoPoint
.
put
(
"currentAction"
,
next
);
historyInfoPoint
.
put
(
"activeList"
,
historyInfoPoint
.
get
(
"activeList"
)
+
"|"
+
next
);
try
{
if
(
debugFlag
)
lastReply
=
ans
.
getAnswer
().
split
(
")"
)[
2
];
else
lastReply
=
ans
.
getAnswer
();
historyInfoPoint
.
put
(
"lastReply"
,
lastReply
);
try
{
String
keyword1
,
keyword2
;
while
(
it
.
hasNext
())
{
actionName
=
it
.
next
();
...
...
@@ -612,6 +634,23 @@ public class ProcessQuestion {
}
/*
// 根据hisInfoPoint中的key来更新历史信息,前提是在关键词单元不加simple_post
it = historyInfoPoint.keySet().iterator();
String keyword1, keyword2;
while (it.hasNext()) {
actionName = it.next();
if(curInfoPoint.get(actionName) != null){
keyword1 = curInfoPoint.get(actionName)[0];
keyword2 = historyInfoPoint.get(actionName);
if(! keyword2.equals("")){
historyInfoPoint.put(actionName, keyword1);
}
}
}
*/
ChatCacheController
.
updateChatCache4Insert
(
curInfoPoint
,
historyInfoPoint
,
context
);
//context.setAttribute("chat_key+"+userinfo.userName,historyInfoPoint);
...
...
@@ -635,6 +674,7 @@ public class ProcessQuestion {
add
(
"bot_name"
);
add
(
"action_name"
);
add
(
"chat_key"
);
add
(
"lastReply"
);
}
};
...
...
@@ -657,7 +697,7 @@ public class ProcessQuestion {
debugInfo
+=
(
" "
+
key
+
":"
+
value
+
" "
);
}
ans
.
setAnswer
(
debugInfo
+
"
)
"
+
ans
.
getAnswer
());
ans
.
setAnswer
(
debugInfo
+
"
)
"
+
ans
.
getAnswer
());
}
...
...
@@ -672,7 +712,6 @@ public class ProcessQuestion {
List
<
BasicNameValuePair
>
pairList
=
new
ArrayList
<
BasicNameValuePair
>();
Iterator
<
String
>
k_iter
=
null
;
System
.
out
.
println
(
"there"
);
for
(
String
feature:
features
){
elem
=
feature
.
split
(
"\\("
);
if
(
elem
[
0
].
contains
(
"post"
)){
...
...
@@ -823,8 +862,6 @@ public class ProcessQuestion {
if
(
feature
.
contains
(
"updateKnowledge"
)){
for
(
String
knowledge:
feature
.
split
(
"-<-"
)){
pair
=
knowledge
.
split
(
":"
);
System
.
out
.
println
(
"knowledge"
+
knowledge
);
System
.
out
.
println
(
pair
.
length
);
keyword
=
historyInfoPoint
.
get
(
pair
[
0
]);
if
(
pair
.
length
>
1
)
{
...
...
@@ -833,7 +870,6 @@ public class ProcessQuestion {
if
(
keyword
==
null
||
keyword
.
equals
(
""
))
keyword
=
"0"
;
if
(
keyword
.
matches
(
"\\d{4}年\\d{1,2}月\\d{1,2}日.*"
))
{
System
.
out
.
println
(
"这里是keyword:"
+
keyword
);
long
time
=
MyFunc
.
transferToMillisecond
(
keyword
);
int
offset
=
Integer
.
parseInt
(
pair
[
1
].
substring
(
1
));
pair
[
1
]
=
MyFunc
.
transferToStandardTime
(
time
+
(
1000
*
offset
));
...
...
@@ -841,18 +877,15 @@ public class ProcessQuestion {
int
number
=
Integer
.
parseInt
(
keyword
);
int
offset
=
Integer
.
parseInt
(
pair
[
1
].
substring
(
1
));
pair
[
1
]
=
String
.
valueOf
(
number
+
offset
);
System
.
out
.
println
(
"加一:"
+
pair
[
1
]);
}
}
else
if
(
pair
[
1
].
startsWith
(
"-"
))
{
if
(
keyword
==
null
||
keyword
.
equals
(
""
))
keyword
=
"0"
;
if
(
keyword
.
matches
(
"\\d{4}年\\d{1,2}月\\d{1,2}日.*"
))
{
System
.
out
.
println
(
"这里是keyword:"
+
keyword
);
long
time
=
MyFunc
.
transferToMillisecond
(
keyword
);
int
offset
=
Integer
.
parseInt
(
pair
[
1
].
substring
(
1
));
pair
[
1
]
=
MyFunc
.
transferToStandardTime
(
time
-
(
1000
*
offset
));
System
.
out
.
println
(
"改变后:"
+
pair
[
1
]);
}
else
if
(
StringUtils
.
isNumeric
(
keyword
)){
int
number
=
Integer
.
parseInt
(
keyword
);
int
offset
=
Integer
.
parseInt
(
pair
[
1
].
substring
(
1
));
...
...
@@ -865,9 +898,7 @@ public class ProcessQuestion {
}
else
if
(
pair
[
1
].
startsWith
(
"str-"
))
{
if
(
keyword
==
null
||
keyword
.
equals
(
""
))
keyword
=
""
;
System
.
out
.
println
(
"aa"
);
pair
[
1
]
=
keyword
.
replace
(
pair
[
1
].
substring
(
4
),
""
);
System
.
out
.
println
(
pair
[
1
]);
}
}
catch
(
Exception
e
){
e
.
printStackTrace
();
...
...
src/servlet/GetAnswerServlet.java
View file @
778bd62c
...
...
@@ -98,7 +98,7 @@ public class GetAnswerServlet extends HttpServlet {
process
.
appendDebugInfo
(
bestMatch
,
curInfoPoint
,
historyInfoPoint
,
context
);
}
process
.
infoTransition
(
curInfoPoint
,
historyInfoPoint
,
bestMatch
,
context
);
process
.
infoTransition
(
curInfoPoint
,
historyInfoPoint
,
bestMatch
,
context
,
debugFlag
);
ansJ
=
MyFunc
.
toJson
(
bestMatch
);
...
...
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