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
bccbf33e
Commit
bccbf33e
authored
Apr 18, 2019
by
hxw2303632
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of 192.168.1.81:hxw2303632/webapp
parents
b8c7ebf6
0e6d2062
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
471 additions
and
439 deletions
+471
-439
ActionParser.java
...iwu/chatbotbackend/actiongenerate/utils/ActionParser.java
+130
-129
ActionUtils.java
...qiwu/chatbotbackend/actiongenerate/utils/ActionUtils.java
+12
-15
ConfigTermText.java
...n/java/com/qiwu/chatbotbackend/entity/ConfigTermText.java
+9
-6
Premise.java
src/main/java/com/qiwu/chatbotbackend/entity/Premise.java
+0
-3
ElementConstructor.java
...om/qiwu/chatbotbackend/gameDesign/ElementConstructor.java
+42
-7
PlotConstructor2.java
.../com/qiwu/chatbotbackend/gameDesign/PlotConstructor2.java
+10
-11
FormsPoster.java
.../java/com/qiwu/chatbotbackend/processing/FormsPoster.java
+268
-268
No files found.
src/main/java/com/qiwu/chatbotbackend/actiongenerate/utils/ActionParser.java
View file @
bccbf33e
package
com
.
qiwu
.
chatbotbackend
.
actiongenerate
.
utils
;
package
com
.
qiwu
.
chatbotbackend
.
actiongenerate
.
utils
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
java.util.Arrays
;
import
java.util.Arrays
;
public
class
ActionParser
{
public
class
ActionParser
{
public
static
JSONObject
parse
(
String
actionText
){
public
static
JSONObject
parse
(
String
actionText
){
String
name
;
String
name
;
JSONObject
action
=
new
JSONObject
();
JSONObject
action
=
new
JSONObject
();
for
(
String
line:
actionText
.
split
(
"\r\n"
)){
for
(
String
line:
actionText
.
split
(
"\r\n"
)){
name
=
line
.
trim
().
split
(
"="
)[
0
];
name
=
line
.
trim
().
split
(
"="
)[
0
];
if
(
name
.
equals
(
""
)
||
name
.
equals
(
"#actions"
)){
if
(
name
.
equals
(
""
)
||
name
.
equals
(
"#actions"
)){
//
//
}
else
{
}
else
{
switch
(
name
)
{
switch
(
name
)
{
case
"name"
:
case
"name"
:
//parseName(line, action);
//parseName(line, action);
break
;
break
;
case
"status"
:
case
"status"
:
parseStatus
(
line
,
action
);
parseStatus
(
line
,
action
);
break
;
break
;
case
"condition"
:
case
"condition"
:
parseCondition
(
line
,
action
);
parseCondition
(
line
,
action
);
break
;
break
;
case
"style"
:
case
"style"
:
parseStyle
(
line
,
action
);
parseStyle
(
line
,
action
);
break
;
break
;
case
"action"
:
case
"action"
:
parseAction
(
line
,
action
);
parseAction
(
line
,
action
);
break
;
break
;
case
"conflict"
:
case
"conflict"
:
break
;
break
;
case
"process"
:
case
"process"
:
break
;
break
;
default
:
default
:
;
;
}
}
}
}
}
}
if
(!
action
.
containsKey
(
"styleList"
)){
if
(!
action
.
containsKey
(
"styleList"
)){
action
.
put
(
"styleList"
,
new
JSONArray
());
action
.
put
(
"styleList"
,
new
JSONArray
());
}
}
return
action
;
return
action
;
}
}
public
static
void
parseName
(
String
text
,
JSONObject
action
){
public
static
void
parseName
(
String
text
,
JSONObject
action
){
String
elem
[]
=
text
.
split
(
"="
);
String
elem
[]
=
text
.
split
(
"="
);
action
.
put
(
"actionName"
,
elem
[
1
]);
action
.
put
(
"actionName"
,
elem
[
1
]);
}
}
public
static
void
parseAction
(
String
text
,
JSONObject
action
){
public
static
void
parseAction
(
String
text
,
JSONObject
action
){
String
elem
[]
=
text
.
split
(
"="
);
String
elem
[]
=
text
.
split
(
"="
);
action
.
put
(
"actionType"
,
elem
[
1
]);
action
.
put
(
"actionType"
,
elem
[
1
]);
}
}
public
static
void
parseStatus
(
String
text
,
JSONObject
action
){
public
static
void
parseStatus
(
String
text
,
JSONObject
action
){
String
elem
[]
=
text
.
split
(
"="
);
String
elem
[]
=
text
.
split
(
"="
);
action
.
put
(
"status"
,
elem
[
1
]);
action
.
put
(
"status"
,
elem
[
1
]);
}
}
public
static
void
parseStyle
(
String
text
,
JSONObject
action
){
public
static
void
parseStyle
(
String
text
,
JSONObject
action
){
String
elem
[]
=
text
.
split
(
"="
);
String
elem
[]
=
text
.
split
(
"="
);
String
subElem
[]
=
elem
[
1
].
split
(
","
);
String
subElem
[]
=
elem
[
1
].
split
(
","
);
action
.
put
(
"styleList"
,
new
JSONArray
(
Arrays
.
asList
(
subElem
)));
action
.
put
(
"styleList"
,
new
JSONArray
(
Arrays
.
asList
(
subElem
)));
}
}
public
static
void
parseConflict
(
String
text
,
JSONObject
action
){
public
static
void
parseConflict
(
String
text
,
JSONObject
action
){
//
//
}
}
public
static
void
parseCondition
(
String
text
,
JSONObject
action
){
public
static
void
parseCondition
(
String
text
,
JSONObject
action
){
String
elem
[]
=
text
.
split
(
"\\|"
,
4
);
String
elem
[]
=
text
.
split
(
"\\|"
,
4
);
String
condition
=
elem
[
0
];
String
condition
=
elem
[
0
];
String
relation
=
elem
[
1
];
String
relation
=
elem
[
1
];
String
questionText
=
elem
[
2
];
String
questionText
=
elem
[
2
];
String
repeatStr
=
elem
[
3
];
String
repeatStr
=
elem
[
3
];
String
conditionName
=
""
,
relationList
[],
questionElem
[];
String
conditionName
=
""
,
relationList
[],
questionElem
[];
JSONArray
questionList
=
new
JSONArray
();
JSONArray
questionList
=
new
JSONArray
();
JSONArray
repeatList
=
new
JSONArray
();
JSONArray
repeatList
=
new
JSONArray
();
String
conditionElem
[]
=
condition
.
split
(
"="
);
String
conditionElem
[]
=
condition
.
split
(
"="
);
conditionElem
=
conditionElem
[
1
].
split
(
":"
);
conditionElem
=
conditionElem
[
1
].
split
(
":"
);
action
.
put
(
"conditionName"
,
conditionElem
[
0
]);
action
.
put
(
"conditionName"
,
conditionElem
[
0
]);
if
(
conditionElem
.
length
>=
2
)
if
(
conditionElem
.
length
>=
2
)
action
.
put
(
"dataType"
,
conditionElem
[
1
]);
action
.
put
(
"dataType"
,
conditionElem
[
1
]);
relationList
=
relation
.
split
(
","
);
relationList
=
relation
.
split
(
","
);
action
.
put
(
"relationHead"
,
relationList
[
0
]);
action
.
put
(
"relationHead"
,
relationList
[
0
]);
action
.
put
(
"relationName"
,
relationList
[
1
]);
action
.
put
(
"relationName"
,
relationList
[
1
]);
action
.
put
(
"relationTail"
,
relationList
[
2
]);
action
.
put
(
"relationTail"
,
relationList
[
2
]);
for
(
String
question:
questionText
.
split
(
"~"
)){
for
(
String
question:
questionText
.
split
(
"~"
)){
questionElem
=
question
.
split
(
":"
);
questionElem
=
question
.
split
(
":"
);
JSONObject
iterDict
=
new
JSONObject
();
JSONObject
iterDict
=
new
JSONObject
();
iterDict
.
put
(
"que_start_time"
,
questionElem
[
0
]);
iterDict
.
put
(
"que_start_time"
,
questionElem
[
0
]);
iterDict
.
put
(
"que_stop_time"
,
questionElem
[
1
]);
iterDict
.
put
(
"que_stop_time"
,
questionElem
[
1
]);
iterDict
.
put
(
"que_sen"
,
questionElem
[
2
]);
//to-do 数组可能越界,数据不对
iterDict
.
put
(
"que_sen"
,
questionElem
[
2
]);
if
(
questionElem
.
length
==
4
&&
questionElem
[
3
].
equals
(
"base"
))
iterDict
.
put
(
"base"
,
1
);
if
(
questionElem
.
length
==
4
&&
questionElem
[
3
].
equals
(
"base"
))
else
iterDict
.
put
(
"base"
,
1
);
iterDict
.
put
(
"base"
,
0
);
else
iterDict
.
put
(
"base"
,
0
);
questionList
.
add
(
iterDict
);
}
questionList
.
add
(
iterDict
);
}
action
.
put
(
"questionList"
,
questionList
);
action
.
put
(
"questionList"
,
questionList
);
for
(
String
repeat:
repeatStr
.
split
(
"~"
)){
JSONObject
repeatDict
=
new
JSONObject
();
for
(
String
repeat:
repeatStr
.
split
(
"~"
)){
elem
=
repeat
.
split
(
"="
,
2
);
JSONObject
repeatDict
=
new
JSONObject
();
repeatDict
.
put
(
"repeatString"
,
elem
[
0
]);
elem
=
repeat
.
split
(
"="
,
2
);
repeatDict
.
put
(
"repeatKeywords"
,
elem
[
1
]);
repeatDict
.
put
(
"repeatString"
,
elem
[
0
]);
repeatList
.
add
(
repeatDict
);
repeatDict
.
put
(
"repeatKeywords"
,
elem
[
1
]);
}
repeatList
.
add
(
repeatDict
);
action
.
put
(
"repeatList"
,
repeatList
);
}
action
.
put
(
"repeatList"
,
repeatList
);
}
}
}
}
src/main/java/com/qiwu/chatbotbackend/actiongenerate/utils/ActionUtils.java
View file @
bccbf33e
...
@@ -362,7 +362,7 @@ public class ActionUtils {
...
@@ -362,7 +362,7 @@ public class ActionUtils {
conditionJson
=
JSONObject
.
parseObject
(
condition
.
getConditionJsonText
());
conditionJson
=
JSONObject
.
parseObject
(
condition
.
getConditionJsonText
());
conditionIdElem
=
new
JSONArray
();
conditionIdElem
=
new
JSONArray
();
conditionIdElem
.
add
(
conditionJson
.
get
(
"originConditionId"
));
conditionIdElem
.
add
(
conditionJson
.
get
(
"originConditionId"
));
conditionIdElem
.
add
(
conditionJson
.
getString
(
"relationName"
).
replace
(
"
-"
,
"b0"
).
replace
(
"0"
,
"a
0"
));
conditionIdElem
.
add
(
conditionJson
.
getString
(
"relationName"
).
replace
(
"
0"
,
"a0"
).
replace
(
"-"
,
"b
0"
));
ape
.
getConditionIdPair
().
add
(
conditionIdElem
);
ape
.
getConditionIdPair
().
add
(
conditionIdElem
);
}
}
...
@@ -845,34 +845,31 @@ public class ActionUtils {
...
@@ -845,34 +845,31 @@ public class ActionUtils {
relationName
=
patternConditionJson
.
getString
(
"relationName"
).
replace
(
"0"
,
"a0"
).
replace
(
"-"
,
"b0"
);
relationName
=
patternConditionJson
.
getString
(
"relationName"
).
replace
(
"0"
,
"a0"
).
replace
(
"-"
,
"b0"
);
conditionExtraKeywords
.
putIfAbsent
(
DEFAULT_CONDITION
+
"_head"
,
new
HashSet
<
String
>());
conditionExtraKeywords
.
putIfAbsent
(
DEFAULT_CONDITION
+
"_head"
,
new
HashSet
<
String
>());
conditionExtraKeywords
.
putIfAbsent
(
DEFAULT_CONDITION
+
"_tail"
,
new
HashSet
<
String
>());
conditionExtraKeywords
.
putIfAbsent
(
DEFAULT_CONDITION
+
"_tail"
,
new
HashSet
<
String
>());
String
condTemple
=
patternConditionJson
.
toJSONString
();
for
(
int
i
=
1
;
i
<
100
;
i
++){
for
(
int
i
=
0
;
i
<
100
;
i
++){
//给condition的名字添加后缀,因为游戏中可能用到condition的复制,但值域和名字不一样
//给condition的名字添加后缀,因为游戏中可能用到condition的复制,但值域和名字不一样
if
(
i
==
1
)
if
(
i
==
0
)
postfix
=
""
;
postfix
=
""
;
else
else
postfix
=
"_"
+
String
.
valueOf
(
i
);
postfix
=
"_"
+
String
.
valueOf
(
i
);
activeFlag
=
"0"
;
activeFlag
=
"0"
;
conditionJson
=
(
JSONObject
)
JSON
.
parse
(
condTemple
);
// conditionJson = (JSONObject) patternConditionJson.clone();
conditionName
=
conditionJson
.
getString
(
"conditionName"
)
+
postfix
;
conditionName2
=
conditionName
+
"_indep"
;
conditionJson
=
(
JSONObject
)
patternConditionJson
.
clone
();
conditionName
=
conditionJson
.
getString
(
"conditionName"
)
+
postfix
;
conditionName2
=
conditionName
+
"_indep"
;
if
(!
conditionExtraKeywords
.
containsKey
(
conditionName
+
"_tail"
)){
//如果没有用到这个condition,就跳过
if
(!
conditionExtraKeywords
.
containsKey
(
conditionName2
+
"_tail"
))
break
;
}
if
(
conditionExtraKeywords
.
containsKey
(
conditionName
+
"_tail"
))
{
if
(
conditionExtraKeywords
.
containsKey
(
conditionName
+
"_tail"
))
{
conditionJson
.
put
(
"conditionName"
,
conditionName
);
conditionJson
.
put
(
"conditionName"
,
conditionName
);
conditionAppendKeyword
(
conditionName
,
conditionJson
,
conditionExtraKeywords
,
macroAppendMap
);
conditionAppendKeyword
(
conditionName
,
conditionJson
,
conditionExtraKeywords
,
macroAppendMap
);
}
}
else
if
(
conditionExtraKeywords
.
containsKey
(
conditionName2
+
"_tail"
))
{
if
(
conditionExtraKeywords
.
containsKey
(
conditionName2
+
"_tail"
))
{
conditionJson
.
put
(
"conditionName"
,
conditionName2
);
conditionJson
.
put
(
"conditionName"
,
conditionName2
);
conditionAppendKeyword2
(
conditionName2
,
conditionJson
,
conditionExtraKeywords
,
macroAppendMap
);
conditionAppendKeyword2
(
conditionName2
,
conditionJson
,
conditionExtraKeywords
,
macroAppendMap
);
conditionName
=
conditionName2
;
conditionName
=
conditionName2
;
}
else
{
continue
;
}
}
if
(
conditionJson
.
getBoolean
(
"active"
)
&&
!
conditionName
.
equals
(
startCondition
))
if
(
conditionJson
.
getBoolean
(
"active"
)
&&
!
conditionName
.
equals
(
startCondition
))
...
...
src/main/java/com/qiwu/chatbotbackend/entity/ConfigTermText.java
View file @
bccbf33e
...
@@ -189,15 +189,18 @@ public class ConfigTermText implements Cloneable{
...
@@ -189,15 +189,18 @@ public class ConfigTermText implements Cloneable{
conditionName
.
startsWith
(
"map_"
)
||
conditionName
.
startsWith
(
"map_"
)
||
conditionName
.
startsWith
(
"start_options"
)
||
conditionName
.
startsWith
(
"start_options"
)
||
conditionName
.
startsWith
(
"load_game_by_site"
)
conditionName
.
startsWith
(
"load_game_by_site"
)
)
)
{}
{}
else
{
else
{
gNameCount
.
putIfAbsent
(
conditionName
,
0
);
Integer
count
=
gNameCount
.
get
(
conditionName
);
gNameCount
.
put
(
conditionName
,
gNameCount
.
get
(
conditionName
)
+
1
);
if
(
count
==
null
)
{
if
(
gNameCount
.
get
(
conditionName
)
>
1
&&
premise
.
getAccurateMatch
())
{
gNameCount
.
put
(
conditionName
,
0
);
premise
.
setConditionName
(
conditionName
+
"_"
+
gNameCount
.
get
(
conditionName
));
count
=
0
;
premise
.
setAccurateName
();
}
if
(
premise
.
getAccurateMatch
())
{
count
=
count
+
1
;
gNameCount
.
put
(
conditionName
,
count
);
premise
.
setConditionName
(
conditionName
+
"_"
+
count
+
"_indep"
);
}
}
}
}
...
...
src/main/java/com/qiwu/chatbotbackend/entity/Premise.java
View file @
bccbf33e
...
@@ -117,7 +117,4 @@ public class Premise {
...
@@ -117,7 +117,4 @@ public class Premise {
this
.
keyword
=
keyword
;
this
.
keyword
=
keyword
;
}
}
public
void
setAccurateName
()
{
this
.
conditionName
=
this
.
conditionName
+
"_indep"
;
}
}
}
src/main/java/com/qiwu/chatbotbackend/gameDesign/ElementConstructor.java
View file @
bccbf33e
...
@@ -95,13 +95,10 @@ public class ElementConstructor {
...
@@ -95,13 +95,10 @@ public class ElementConstructor {
*/
*/
public
void
parseKeyword
(
JSONObject
config
,
Map
<
String
,
HashSet
<
String
>>
relationKeywords
,
HashSet
<
String
>
exceptRelation
,
String
botName
){
public
void
parseKeyword
(
JSONObject
config
,
Map
<
String
,
HashSet
<
String
>>
relationKeywords
,
HashSet
<
String
>
exceptRelation
,
String
botName
){
String
conditionName
,
pair
[];
String
conditionName
,
pair
[];
for
(
Map
premise:
JSONArray
.
parseArray
(
config
.
getJSONArray
(
"currentPremiseList"
).
toJSONString
(),
Map
.
class
)){
for
(
Map
<
String
,
Object
>
premise:
JSONArray
.
parseArray
(
config
.
getJSONArray
(
"currentPremiseList"
).
toJSONString
(),
Map
.
class
)){
conditionName
=
(
String
)
premise
.
get
(
"actionName"
);
conditionName
=
(
String
)
premise
.
get
(
"actionName"
);
if
(!
exceptRelation
.
contains
(
conditionName
))
{
if
(!
exceptRelation
.
contains
(
conditionName
))
{
//初始化
//初始化
if
(!
relationKeywords
.
containsKey
(
conditionName
+
"_head"
))
{
if
(!
relationKeywords
.
containsKey
(
conditionName
+
"_head"
))
{
relationKeywords
.
put
(
conditionName
+
"_head"
,
new
HashSet
<
String
>());
relationKeywords
.
put
(
conditionName
+
"_head"
,
new
HashSet
<
String
>());
...
@@ -109,14 +106,14 @@ public class ElementConstructor {
...
@@ -109,14 +106,14 @@ public class ElementConstructor {
}
}
//visitorname和bot的替换
//visitorname和bot的替换
premise
.
put
(
"keywords"
,
((
String
)
premise
.
get
(
"keywords"
)).
replace
(
"qiwu"
,
"#visitorname"
).
replace
(
botName
,
"#botname"
));
//
premise.put("keywords", ((String)premise.get("keywords")).replace("qiwu", "#visitorname").replace(botName, "#botname"));
premise
.
put
(
"keywords"
,
replaceKeywords
((
String
)
premise
.
get
(
"keywords"
)));
for
(
String
keyword
:
((
String
)
premise
.
get
(
"keywords"
)).
split
(
"\\+"
))
{
for
(
String
keyword
:
((
String
)
premise
.
get
(
"keywords"
)).
split
(
"\\+"
))
{
if
(
keyword
.
equals
(
""
)){
if
(
keyword
.
equals
(
""
)){
continue
;
continue
;
}
else
if
(
keyword
.
contains
(
":"
)){
}
else
if
(
keyword
.
contains
(
":"
)){
//有些配置条目要求三元组两边的值都匹配,需要把两边的值分别加入题头和值域
//有些配置条目要求三元组两边的值都匹配,需要把两边的值分别加入题头和值域
pair
=
keyword
.
split
(
":"
,
2
);
pair
=
keyword
.
split
(
":"
,
2
);
...
@@ -152,8 +149,9 @@ public class ElementConstructor {
...
@@ -152,8 +149,9 @@ public class ElementConstructor {
relationKeywords
.
put
(
conditionName
+
"_tail"
,
new
HashSet
<
String
>());
relationKeywords
.
put
(
conditionName
+
"_tail"
,
new
HashSet
<
String
>());
}
}
premise
.
put
(
"keywords"
,
((
String
)
premise
.
get
(
"keywords"
)).
replace
(
"qiwu"
,
"#visitorname"
).
replace
(
botName
,
"#botname"
));
//
premise.put("keywords", ((String)premise.get("keywords")).replace("qiwu", "#visitorname").replace(botName, "#botname"));
premise
.
put
(
"keywords"
,
replaceKeywords
((
String
)
premise
.
get
(
"keywords"
)));
for
(
String
keyword
:
((
String
)
premise
.
get
(
"keywords"
)).
split
(
"\\+"
))
{
for
(
String
keyword
:
((
String
)
premise
.
get
(
"keywords"
)).
split
(
"\\+"
))
{
if
(
keyword
.
equals
(
""
)){
if
(
keyword
.
equals
(
""
)){
...
@@ -178,6 +176,43 @@ public class ElementConstructor {
...
@@ -178,6 +176,43 @@ public class ElementConstructor {
}
}
}
}
public
String
replaceKeywords
(
String
str
)
{
Boolean
startChat
=
str
.
startsWith
(
"+"
);
Map
<
String
,
String
>
keywords
=
new
HashMap
<>();
keywords
.
put
(
"qiwu"
,
"#visitorname"
);
keywords
.
put
(
"我"
,
"#visitorname"
);
keywords
.
put
(
"botName"
,
"#botname"
);
keywords
.
put
(
"你"
,
"#botname"
);
String
[]
split
=
str
.
split
(
"\\+"
);
String
_s
;
int
pos
;
String
sub1
;
String
sub2
;
for
(
int
i
=
0
;
i
<
split
.
length
;
++
i
)
{
_s
=
split
[
i
];
pos
=
_s
.
indexOf
(
":"
);
if
(
pos
==
-
1
)
{
if
(
keywords
.
get
(
_s
)
!=
null
)
{
_s
=
keywords
.
get
(
_s
);
}
}
else
{
sub1
=
_s
.
substring
(
0
,
pos
);
sub2
=
_s
.
substring
(
pos
+
1
,
_s
.
length
());
if
(
keywords
.
get
(
sub1
)
!=
null
)
{
sub1
=
keywords
.
get
(
sub1
);
}
if
(
keywords
.
get
(
sub2
)
!=
null
)
{
sub2
=
keywords
.
get
(
sub2
);
}
_s
=
sub1
+
":"
+
sub2
;
}
split
[
i
]
=
_s
;
}
str
=
String
.
join
(
"+"
,
split
);
if
(!
str
.
equals
(
""
)
&&
startChat
&&
!
str
.
startsWith
(
"+"
))
str
=
"+"
+
str
;
return
str
;
}
/**
/**
* 根据插入的数据做后处理
* 根据插入的数据做后处理
...
...
src/main/java/com/qiwu/chatbotbackend/gameDesign/PlotConstructor2.java
View file @
bccbf33e
...
@@ -591,11 +591,11 @@ public class PlotConstructor2 extends ElementConstructor {
...
@@ -591,11 +591,11 @@ public class PlotConstructor2 extends ElementConstructor {
* 4. 无论哪种情况都会跳下一步剧情
* 4. 无论哪种情况都会跳下一步剧情
*/
*/
unknownTypeConfigTermGenerate
(
"sleeping"
,
"queryskip1"
,
"qa_status::match-Include=OK,qa_score::number-Smaller=9
8
"
,
unknownTypeConfigTermGenerate
(
"sleeping"
,
"queryskip1"
,
"qa_status::match-Include=OK,qa_score::number-Smaller=9
5
"
,
"match"
,
"{临时变量reply-2}"
,
"process-nextStep:var={临时变量condition-2}"
);
"match"
,
"{临时变量reply-2}"
,
"process-nextStep:var={临时变量condition-2}"
);
unknownTypeConfigTermGenerate
(
"sleeping"
,
"queryskip2"
,
"qa_status::match-Include=OK,qa_score::number-BiggerOrEqual=9
8
"
,
unknownTypeConfigTermGenerate
(
"sleeping"
,
"queryskip2"
,
"qa_status::match-Include=OK,qa_score::number-BiggerOrEqual=9
5
"
,
"match"
,
"{临时变量reply-2}"
,
"process-nextStep:var={临时变量condition-2}"
);
"match"
,
"{临时变量reply-2}"
,
"process-nextStep:var={临时变量condition-2}"
);
...
@@ -626,16 +626,16 @@ public class PlotConstructor2 extends ElementConstructor {
...
@@ -626,16 +626,16 @@ public class PlotConstructor2 extends ElementConstructor {
"match,return-0"
,
UNKNOWN_TEXT
,
""
);
"match,return-0"
,
UNKNOWN_TEXT
,
""
);
unknownTypeConfigTermGenerate
(
"sleeping"
,
"unknown3"
,
"qa_status::match-Include=OK,qa_score::number-Smaller=9
8
,unknownText::match-Include=null"
,
unknownTypeConfigTermGenerate
(
"sleeping"
,
"unknown3"
,
"qa_status::match-Include=OK,qa_score::number-Smaller=9
5
,unknownText::match-Include=null"
,
"match,return-0"
,
UNKNOWN_TEXT
,
""
);
"match,return-0"
,
UNKNOWN_TEXT
,
""
);
unknownTypeConfigTermGenerate
(
"sleeping"
,
"unknown4"
,
"qa_status::match-Include=OK,qa_score::number-Smaller=9
8
"
,
unknownTypeConfigTermGenerate
(
"sleeping"
,
"unknown4"
,
"qa_status::match-Include=OK,qa_score::number-Smaller=9
5
"
,
"match,return-0"
,
"{unknownText-2}"
,
""
);
"match,return-0"
,
"{unknownText-2}"
,
""
);
//由于剧情跳转时地点可能发生变化, qa问答的句子可能因为npc不再同一位置而被过滤掉,所以将common_answer的字符串合并放在postprocessing中
//由于剧情跳转时地点可能发生变化, qa问答的句子可能因为npc不再同一位置而被过滤掉,所以将common_answer的字符串合并放在postprocessing中
unknownTypeConfigTermGenerate
(
"sleeping"
,
"common_answer"
,
"qa_status::match-Include=OK,qa_score::number-BiggerOrEqual=9
8
"
,
unknownTypeConfigTermGenerate
(
"sleeping"
,
"common_answer"
,
"qa_status::match-Include=OK,qa_score::number-BiggerOrEqual=9
5
"
,
"match,return-0"
,
""
,
""
);
"match,return-0"
,
""
,
""
);
//---------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------
...
@@ -774,9 +774,9 @@ public class PlotConstructor2 extends ElementConstructor {
...
@@ -774,9 +774,9 @@ public class PlotConstructor2 extends ElementConstructor {
//
//
//if()
//if()
if
(
activateFlag
){
if
(
activateFlag
){
configTermText
.
setNextStep
(
nextCondition
+
",queryskip*,map*,
item
*,npc*"
);
configTermText
.
setNextStep
(
nextCondition
+
",queryskip*,map*,
goods
*,npc*"
);
}
else
{
}
else
{
configTermText
.
setNextStep
(
"queryskip*,map*,
item
*,npc*"
);
configTermText
.
setNextStep
(
"queryskip*,map*,
goods
*,npc*"
);
}
}
//虽然激活了查询相关的配置文件,但返回给引擎的condition还是应该用剧情里的,所以
//虽然激活了查询相关的配置文件,但返回给引擎的condition还是应该用剧情里的,所以
...
@@ -969,14 +969,13 @@ public class PlotConstructor2 extends ElementConstructor {
...
@@ -969,14 +969,13 @@ public class PlotConstructor2 extends ElementConstructor {
String
feature
=
newTerm
.
getFeature
();
String
feature
=
newTerm
.
getFeature
();
feature
=
feature
+
",activate,post::gameQA("
+
QA_URL
+
")"
;
feature
=
feature
+
",activate,post::gameQA("
+
QA_URL
+
")"
;
newTerm
.
setFeature
(
feature
);
newTerm
.
setFeature
(
feature
);
newTerm
.
setNextStep
(
"map*,
item
*,npc*,"
+
stemStr
+
"_qa1,"
+
stemStr
+
"_qa2"
);
newTerm
.
setNextStep
(
"map*,
goods
*,npc*,"
+
stemStr
+
"_qa1,"
+
stemStr
+
"_qa2"
);
return
newTerm
;
return
newTerm
;
}
}
private
ConfigTermText
createTermExtra1
(
ConfigTermText
term
)
{
private
ConfigTermText
createTermExtra1
(
ConfigTermText
term
)
{
String
hPremise
=
"qa_score::number-BiggerOrEqual=9
8
"
;
String
hPremise
=
"qa_score::number-BiggerOrEqual=9
5
"
;
String
featureStr
=
"match,return-0"
;
String
featureStr
=
"match,return-0"
;
//String nextStr = "map*,item*,npc*";
String
nextStr
=
" "
;
String
nextStr
=
" "
;
String
knowledgeStr
=
UNKNOWN_COUNTER_NAME
+
":+1"
;
String
knowledgeStr
=
UNKNOWN_COUNTER_NAME
+
":+1"
;
String
configName
=
term
.
getConfigName
()+
"_qa1"
;
String
configName
=
term
.
getConfigName
()+
"_qa1"
;
...
@@ -988,7 +987,7 @@ public class PlotConstructor2 extends ElementConstructor {
...
@@ -988,7 +987,7 @@ public class PlotConstructor2 extends ElementConstructor {
private
ConfigTermText
createTermExtra2
(
ConfigTermText
term
)
{
private
ConfigTermText
createTermExtra2
(
ConfigTermText
term
)
{
String
hPremise
=
"qa_score::number-Smaller=9
8
"
;
String
hPremise
=
"qa_score::number-Smaller=9
5
"
;
// String featureStr = ",match,includeCurInfo,activate:after";
// String featureStr = ",match,includeCurInfo,activate:after";
String
configName
=
term
.
getConfigName
()+
"_qa2"
;
String
configName
=
term
.
getConfigName
()+
"_qa2"
;
String
nextStr
=
term
.
getNextStep
();
String
nextStr
=
term
.
getNextStep
();
...
...
src/main/java/com/qiwu/chatbotbackend/processing/FormsPoster.java
View file @
bccbf33e
package
com
.
qiwu
.
chatbotbackend
.
processing
;
package
com
.
qiwu
.
chatbotbackend
.
processing
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.qiwu.chatbotbackend.GameEnvironment.GameEnv
;
import
com.qiwu.chatbotbackend.GameEnvironment.GameEnv
;
import
com.qiwu.chatbotbackend.entity.Action
;
import
com.qiwu.chatbotbackend.entity.Action
;
import
com.qiwu.chatbotbackend.entity.Solution
;
import
com.qiwu.chatbotbackend.entity.Solution
;
import
com.qiwu.chatbotbackend.entity.UserInfo
;
import
com.qiwu.chatbotbackend.entity.UserInfo
;
import
com.qiwu.chatbotbackend.task.utils.GameBotUtil
;
import
com.qiwu.chatbotbackend.task.utils.GameBotUtil
;
import
org.apache.http.message.BasicNameValuePair
;
import
org.apache.http.message.BasicNameValuePair
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
java.io.UnsupportedEncodingException
;
import
java.io.UnsupportedEncodingException
;
import
java.util.*
;
import
java.util.*
;
import
java.util.regex.Matcher
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
java.util.regex.Pattern
;
import
static
com
.
qiwu
.
chatbotbackend
.
Config
.
Config
.
QA_FETCH_ERROR
;
import
static
com
.
qiwu
.
chatbotbackend
.
Config
.
Config
.
QA_FETCH_ERROR
;
public
class
FormsPoster
{
public
class
FormsPoster
{
LogWriter
logWriter
;
LogWriter
logWriter
;
public
static
String
TALKER
=
"【(.*?)@.*?】"
;
public
static
String
TALKER
=
"【(.*?)@.*?】"
;
@Value
(
"${qa.url}"
)
@Value
(
"${qa.url}"
)
public
String
QA_URL
;
public
String
QA_URL
;
public
void
setQaUrl
(
String
qaUrl
)
{
public
void
setQaUrl
(
String
qaUrl
)
{
QA_URL
=
qaUrl
;
QA_URL
=
qaUrl
;
}
}
public
FormsPoster
(
LogWriter
logWriter
)
{
public
FormsPoster
(
LogWriter
logWriter
)
{
this
.
logWriter
=
logWriter
;
this
.
logWriter
=
logWriter
;
}
}
HashSet
<
String
>
skipSet
=
new
HashSet
<
String
>()
{
HashSet
<
String
>
skipSet
=
new
HashSet
<
String
>()
{
{
{
add
(
"activeList"
);
add
(
"activeList"
);
add
(
"currentAction"
);
add
(
"currentAction"
);
add
(
"lastUpdateTime"
);
add
(
"lastUpdateTime"
);
add
(
"lastReply"
);
add
(
"lastReply"
);
}
}
};
};
/**
/**
* 提交类型为all时,会把当前信息点和历史信息点都作为post到另一个服务器,还有回答
* 提交类型为all时,会把当前信息点和历史信息点都作为post到另一个服务器,还有回答
* @param curInfoPoint
* @param curInfoPoint
* @param historyInfoPoint
* @param historyInfoPoint
* @param ans
* @param ans
* @param URL
* @param URL
* @throws UnsupportedEncodingException
* @throws UnsupportedEncodingException
*/
*/
public
void
postAll
(
Map
<
String
,
String
>
curInfoPoint
,
Map
<
String
,
String
>
historyInfoPoint
,
Solution
ans
,
String
URL
)
throws
UnsupportedEncodingException
{
public
void
postAll
(
Map
<
String
,
String
>
curInfoPoint
,
Map
<
String
,
String
>
historyInfoPoint
,
Solution
ans
,
String
URL
)
throws
UnsupportedEncodingException
{
String
key
,
keyName
;
String
key
,
keyName
;
Iterator
<
String
>
k_iter
=
null
;
Iterator
<
String
>
k_iter
=
null
;
List
<
BasicNameValuePair
>
pairList
=
new
ArrayList
<
BasicNameValuePair
>();
List
<
BasicNameValuePair
>
pairList
=
new
ArrayList
<
BasicNameValuePair
>();
k_iter
=
curInfoPoint
.
keySet
().
iterator
();
k_iter
=
curInfoPoint
.
keySet
().
iterator
();
while
(
k_iter
.
hasNext
())
{
while
(
k_iter
.
hasNext
())
{
key
=
k_iter
.
next
();
key
=
k_iter
.
next
();
if
(
curInfoPoint
.
get
(
key
)
!=
null
&&
!
curInfoPoint
.
get
(
key
).
equals
(
""
))
if
(
curInfoPoint
.
get
(
key
)
!=
null
&&
!
curInfoPoint
.
get
(
key
).
equals
(
""
))
pairList
.
add
(
new
BasicNameValuePair
(
key
,
curInfoPoint
.
get
(
key
)));
pairList
.
add
(
new
BasicNameValuePair
(
key
,
curInfoPoint
.
get
(
key
)));
}
}
k_iter
=
historyInfoPoint
.
keySet
().
iterator
();
k_iter
=
historyInfoPoint
.
keySet
().
iterator
();
while
(
k_iter
.
hasNext
())
{
while
(
k_iter
.
hasNext
())
{
key
=
k_iter
.
next
();
key
=
k_iter
.
next
();
if
(
historyInfoPoint
.
get
(
key
)
!=
null
&&
!
historyInfoPoint
.
get
(
key
).
equals
(
""
))
{
if
(
historyInfoPoint
.
get
(
key
)
!=
null
&&
!
historyInfoPoint
.
get
(
key
).
equals
(
""
))
{
if
(
skipSet
.
contains
(
key
))
if
(
skipSet
.
contains
(
key
))
continue
;
continue
;
if
(
curInfoPoint
.
get
(
key
)
==
null
||
curInfoPoint
.
equals
(
""
))
{
if
(
curInfoPoint
.
get
(
key
)
==
null
||
curInfoPoint
.
equals
(
""
))
{
pairList
.
add
(
new
BasicNameValuePair
(
key
,
historyInfoPoint
.
get
(
key
)));
pairList
.
add
(
new
BasicNameValuePair
(
key
,
historyInfoPoint
.
get
(
key
)));
}
else
{
}
else
{
pairList
.
add
(
new
BasicNameValuePair
(
key
+
"_his"
,
historyInfoPoint
.
get
(
key
)));
pairList
.
add
(
new
BasicNameValuePair
(
key
+
"_his"
,
historyInfoPoint
.
get
(
key
)));
}
}
}
}
}
}
pairList
.
add
(
new
BasicNameValuePair
(
"reply"
,
ans
.
getAnswer
()));
pairList
.
add
(
new
BasicNameValuePair
(
"reply"
,
ans
.
getAnswer
()));
logWriter
.
record
(
"提交表单的数据:<br>"
+
pairList
.
toString
(),
2
);
logWriter
.
record
(
"提交表单的数据:<br>"
+
pairList
.
toString
(),
2
);
JSONObject
jobj
=
SimpleUtil
.
postFORM
(
URL
,
pairList
);
JSONObject
jobj
=
SimpleUtil
.
postFORM
(
URL
,
pairList
);
logWriter
.
record
(
"提交表单接收到的数据:<br>"
+
jobj
.
toJSONString
(),
2
);
logWriter
.
record
(
"提交表单接收到的数据:<br>"
+
jobj
.
toJSONString
(),
2
);
if
((
Integer
)
jobj
.
get
(
"post_status"
)
==
1
){
if
((
Integer
)
jobj
.
get
(
"post_status"
)
==
1
){
Iterator
<
String
>
kit
=
jobj
.
keySet
().
iterator
();
Iterator
<
String
>
kit
=
jobj
.
keySet
().
iterator
();
while
(
kit
.
hasNext
())
{
while
(
kit
.
hasNext
())
{
keyName
=
kit
.
next
();
keyName
=
kit
.
next
();
if
(
keyName
.
equals
(
"process"
))
{
if
(
keyName
.
equals
(
"process"
))
{
ans
.
setNext
((
String
)
jobj
.
get
(
keyName
));
ans
.
setNext
((
String
)
jobj
.
get
(
keyName
));
historyInfoPoint
.
put
(
"process"
,
(
String
)
jobj
.
get
(
keyName
));
historyInfoPoint
.
put
(
"process"
,
(
String
)
jobj
.
get
(
keyName
));
}
else
if
(
keyName
.
equals
(
"solution"
))
{
}
else
if
(
keyName
.
equals
(
"solution"
))
{
ans
.
setAnswer
((
String
)
jobj
.
get
(
keyName
));
ans
.
setAnswer
((
String
)
jobj
.
get
(
keyName
));
}
else
if
(
keyName
.
equals
(
"status"
)
||
keyName
.
equals
(
"qa_candidates"
)){
}
else
if
(
keyName
.
equals
(
"status"
)
||
keyName
.
equals
(
"qa_candidates"
)){
continue
;
continue
;
}
else
{
}
else
{
historyInfoPoint
.
put
(
keyName
,
jobj
.
getString
(
keyName
));
historyInfoPoint
.
put
(
keyName
,
jobj
.
getString
(
keyName
));
}
}
}
}
}
else
{
}
else
{
if
(
URL
.
equals
(
QA_URL
))
if
(
URL
.
equals
(
QA_URL
))
ans
.
setAnswer
(
"qa_threshold, game_step, query_text 看看少了哪个"
);
ans
.
setAnswer
(
"qa_threshold, game_step, query_text 看看少了哪个"
);
else
else
ans
.
setAnswer
(
"提交表单出现异常"
);
ans
.
setAnswer
(
"提交表单出现异常"
);
}
}
}
}
/**
/**
* 提交类型为term时只会提交最佳匹配的配置条目中包含的条件和值
* 提交类型为term时只会提交最佳匹配的配置条目中包含的条件和值
* @param curInfoPoint
* @param curInfoPoint
* @param historyInfoPoint
* @param historyInfoPoint
* @param ans
* @param ans
* @param ansAction
* @param ansAction
* @param URL
* @param URL
* @throws UnsupportedEncodingException
* @throws UnsupportedEncodingException
*/
*/
public
void
postTerm
(
Map
<
String
,
String
>
curInfoPoint
,
Map
<
String
,
String
>
historyInfoPoint
,
Solution
ans
,
Action
ansAction
,
String
URL
)
throws
UnsupportedEncodingException
{
public
void
postTerm
(
Map
<
String
,
String
>
curInfoPoint
,
Map
<
String
,
String
>
historyInfoPoint
,
Solution
ans
,
Action
ansAction
,
String
URL
)
throws
UnsupportedEncodingException
{
String
key
,
keyName
;
String
key
,
keyName
;
Iterator
<
String
>
k_iter
=
null
;
Iterator
<
String
>
k_iter
=
null
;
List
<
BasicNameValuePair
>
pairList
=
new
ArrayList
<
BasicNameValuePair
>();
List
<
BasicNameValuePair
>
pairList
=
new
ArrayList
<
BasicNameValuePair
>();
pairList
.
add
(
new
BasicNameValuePair
(
"chat_key"
,
curInfoPoint
.
get
(
"chat_key"
)));
pairList
.
add
(
new
BasicNameValuePair
(
"chat_key"
,
curInfoPoint
.
get
(
"chat_key"
)));
pairList
.
add
(
new
BasicNameValuePair
(
"action_name"
,
curInfoPoint
.
get
(
"action_name"
)));
pairList
.
add
(
new
BasicNameValuePair
(
"action_name"
,
curInfoPoint
.
get
(
"action_name"
)));
pairList
.
add
(
new
BasicNameValuePair
(
"bot_name"
,
curInfoPoint
.
get
(
"bot_name"
)));
pairList
.
add
(
new
BasicNameValuePair
(
"bot_name"
,
curInfoPoint
.
get
(
"bot_name"
)));
k_iter
=
ansAction
.
getCurrentPremise
().
keySet
().
iterator
();
k_iter
=
ansAction
.
getCurrentPremise
().
keySet
().
iterator
();
while
(
k_iter
.
hasNext
())
{
while
(
k_iter
.
hasNext
())
{
key
=
k_iter
.
next
().
split
(
"::"
)[
0
];
key
=
k_iter
.
next
().
split
(
"::"
)[
0
];
if
(
curInfoPoint
.
get
(
key
)
!=
null
&&
!
curInfoPoint
.
equals
(
""
))
if
(
curInfoPoint
.
get
(
key
)
!=
null
&&
!
curInfoPoint
.
equals
(
""
))
pairList
.
add
(
new
BasicNameValuePair
(
key
,
curInfoPoint
.
get
(
key
)));
pairList
.
add
(
new
BasicNameValuePair
(
key
,
curInfoPoint
.
get
(
key
)));
}
}
k_iter
=
ansAction
.
getHistoryPremise
().
keySet
().
iterator
();
k_iter
=
ansAction
.
getHistoryPremise
().
keySet
().
iterator
();
while
(
k_iter
.
hasNext
())
{
while
(
k_iter
.
hasNext
())
{
key
=
k_iter
.
next
().
split
(
"::"
)[
0
];
key
=
k_iter
.
next
().
split
(
"::"
)[
0
];
if
(!
historyInfoPoint
.
get
(
key
).
equals
(
""
))
{
if
(!
historyInfoPoint
.
get
(
key
).
equals
(
""
))
{
if
(
curInfoPoint
.
get
(
key
)
==
null
||
curInfoPoint
.
equals
(
""
))
{
if
(
curInfoPoint
.
get
(
key
)
==
null
||
curInfoPoint
.
equals
(
""
))
{
pairList
.
add
(
new
BasicNameValuePair
(
key
,
historyInfoPoint
.
get
(
key
)));
pairList
.
add
(
new
BasicNameValuePair
(
key
,
historyInfoPoint
.
get
(
key
)));
}
else
{
}
else
{
pairList
.
add
(
new
BasicNameValuePair
(
key
+
"_his"
,
historyInfoPoint
.
get
(
key
)));
pairList
.
add
(
new
BasicNameValuePair
(
key
+
"_his"
,
historyInfoPoint
.
get
(
key
)));
}
}
}
}
}
}
logWriter
.
record
(
"提交表单的数据:<br>"
+
pairList
.
toString
(),
2
);
logWriter
.
record
(
"提交表单的数据:<br>"
+
pairList
.
toString
(),
2
);
JSONObject
jobj
=
SimpleUtil
.
postFORM
(
URL
,
pairList
);
JSONObject
jobj
=
SimpleUtil
.
postFORM
(
URL
,
pairList
);
logWriter
.
record
(
"提交表单接收到的数据:<br>"
+
jobj
.
toJSONString
(),
2
);
logWriter
.
record
(
"提交表单接收到的数据:<br>"
+
jobj
.
toJSONString
(),
2
);
if
((
Integer
)
jobj
.
get
(
"post_status"
)
==
1
){
if
((
Integer
)
jobj
.
get
(
"post_status"
)
==
1
){
Iterator
<
String
>
kit
=
jobj
.
keySet
().
iterator
();
Iterator
<
String
>
kit
=
jobj
.
keySet
().
iterator
();
while
(
kit
.
hasNext
())
{
while
(
kit
.
hasNext
())
{
keyName
=
kit
.
next
();
keyName
=
kit
.
next
();
if
(
keyName
.
equals
(
"process"
))
{
if
(
keyName
.
equals
(
"process"
))
{
ans
.
setNext
((
String
)
jobj
.
get
(
keyName
));
ans
.
setNext
((
String
)
jobj
.
get
(
keyName
));
historyInfoPoint
.
put
(
"process"
,
(
String
)
jobj
.
get
(
keyName
));
historyInfoPoint
.
put
(
"process"
,
(
String
)
jobj
.
get
(
keyName
));
}
else
if
(
keyName
.
equals
(
"solution"
))
{
}
else
if
(
keyName
.
equals
(
"solution"
))
{
ans
.
setAnswer
((
String
)
jobj
.
get
(
keyName
));
ans
.
setAnswer
((
String
)
jobj
.
get
(
keyName
));
}
else
if
(
keyName
.
equals
(
"status"
)){
}
else
if
(
keyName
.
equals
(
"status"
)){
continue
;
continue
;
}
else
{
}
else
{
historyInfoPoint
.
put
(
keyName
,
jobj
.
getString
(
keyName
));
historyInfoPoint
.
put
(
keyName
,
jobj
.
getString
(
keyName
));
}
}
}
}
}
else
{
}
else
{
ans
.
setAnswer
(
"提交表单出现异常"
);
ans
.
setAnswer
(
"提交表单出现异常"
);
}
}
}
}
/**
/**
* 游戏专用提交表单
* 游戏专用提交表单
* @param curInfoPoint
* @param curInfoPoint
* @param historyInfoPoint
* @param historyInfoPoint
* @param ans
* @param ans
* @param gameEnv
* @param gameEnv
* @param worldController
* @param worldController
* @param URL
* @param URL
* @throws UnsupportedEncodingException
* @throws UnsupportedEncodingException
*/
*/
public
void
postGameQA1
(
String
gameStep
,
Map
<
String
,
String
>
curInfoPoint
,
Map
<
String
,
String
>
historyInfoPoint
,
Solution
ans
,
GameEnv
gameEnv
,
WorldController
worldController
,
String
URL
,
UserInfo
userInfo
)
throws
UnsupportedEncodingException
{
public
void
postGameQA1
(
String
gameStep
,
Map
<
String
,
String
>
curInfoPoint
,
Map
<
String
,
String
>
historyInfoPoint
,
Solution
ans
,
GameEnv
gameEnv
,
WorldController
worldController
,
String
URL
,
UserInfo
userInfo
)
throws
UnsupportedEncodingException
{
String
key
,
keyName
;
String
key
,
keyName
;
Iterator
<
String
>
k_iter
=
null
;
Iterator
<
String
>
k_iter
=
null
;
List
<
BasicNameValuePair
>
pairList
=
new
ArrayList
<
BasicNameValuePair
>();
List
<
BasicNameValuePair
>
pairList
=
new
ArrayList
<
BasicNameValuePair
>();
String
threshold
=
"50"
;
String
threshold
=
"50"
;
if
(
historyInfoPoint
.
get
(
"qa_threshold"
)
!=
null
)
if
(
historyInfoPoint
.
get
(
"qa_threshold"
)
!=
null
)
threshold
=
historyInfoPoint
.
get
(
"qa_threshold"
);
threshold
=
historyInfoPoint
.
get
(
"qa_threshold"
);
pairList
.
add
(
new
BasicNameValuePair
(
"game_step"
,
gameStep
));
pairList
.
add
(
new
BasicNameValuePair
(
"game_step"
,
gameStep
));
pairList
.
add
(
new
BasicNameValuePair
(
"query_text"
,
curInfoPoint
.
get
(
"query_text"
)));
pairList
.
add
(
new
BasicNameValuePair
(
"query_text"
,
curInfoPoint
.
get
(
"query_text"
)));
pairList
.
add
(
new
BasicNameValuePair
(
"qa_threshold"
,
threshold
));
pairList
.
add
(
new
BasicNameValuePair
(
"qa_threshold"
,
threshold
));
//设置初始值
//设置初始值
historyInfoPoint
.
put
(
"common_answer"
,
""
);
historyInfoPoint
.
put
(
"common_answer"
,
""
);
historyInfoPoint
.
put
(
"qa_score"
,
"0"
);
historyInfoPoint
.
put
(
"qa_score"
,
"0"
);
historyInfoPoint
.
put
(
"qa_status"
,
"OK"
);
historyInfoPoint
.
put
(
"qa_status"
,
"OK"
);
logWriter
.
record
(
"提交表单的数据:<br>"
+
pairList
.
toString
(),
2
);
logWriter
.
record
(
"提交表单的数据:<br>"
+
pairList
.
toString
(),
2
);
JSONObject
jobj
=
SimpleUtil
.
postFORM
(
URL
,
pairList
);
JSONObject
jobj
=
SimpleUtil
.
postFORM
(
URL
,
pairList
);
logWriter
.
record
(
"提交表单接收到的数据:<br>"
+
jobj
.
toJSONString
(),
2
);
logWriter
.
record
(
"提交表单接收到的数据:<br>"
+
jobj
.
toJSONString
(),
2
);
String
text
,
score
,
site
=
historyInfoPoint
.
get
(
"site"
),
npc
;
String
text
,
score
,
site
=
historyInfoPoint
.
get
(
"site"
),
npc
;
System
.
out
.
println
(
jobj
.
toJSONString
());
System
.
out
.
println
(
jobj
.
toJSONString
());
if
((
Integer
)
jobj
.
get
(
"post_status"
)
==
1
){
if
((
Integer
)
jobj
.
get
(
"post_status"
)
==
1
){
if
(
jobj
.
getJSONArray
(
"qa_candidates"
)
!=
null
&&
jobj
.
get
(
"qa_status"
).
equals
(
"OK"
))
{
if
(
jobj
.
getJSONArray
(
"qa_candidates"
)
!=
null
&&
jobj
.
get
(
"qa_status"
).
equals
(
"OK"
))
{
List
<
JSONArray
>
candidates
=
JSON
.
toJavaObject
(
jobj
.
getJSONArray
(
"qa_candidates"
),
List
.
class
);
List
<
JSONArray
>
candidates
=
JSON
.
toJavaObject
(
jobj
.
getJSONArray
(
"qa_candidates"
),
List
.
class
);
try
{
try
{
for
(
JSONArray
pair
:
candidates
)
{
for
(
JSONArray
pair
:
candidates
)
{
List
textscore
=
JSON
.
toJavaObject
(
pair
,
List
.
class
);
List
textscore
=
JSON
.
toJavaObject
(
pair
,
List
.
class
);
Pattern
findTalker
=
Pattern
.
compile
(
TALKER
);
Pattern
findTalker
=
Pattern
.
compile
(
TALKER
);
if
((
Integer
)
textscore
.
get
(
1
)
>
9
8
)
{
if
((
Integer
)
textscore
.
get
(
1
)
>
9
5
)
{
Matcher
m
=
findTalker
.
matcher
((
String
)
textscore
.
get
(
0
));
Matcher
m
=
findTalker
.
matcher
((
String
)
textscore
.
get
(
0
));
if
(
m
.
find
())
{
if
(
m
.
find
())
{
npc
=
m
.
group
(
1
);
npc
=
m
.
group
(
1
);
if
((
GameBotUtil
.
sameLocation
((
String
)
textscore
.
get
(
0
),
curInfoPoint
,
historyInfoPoint
,
gameEnv
,
historyInfoPoint
.
get
(
"site"
),
logWriter
)
==
1
))
{
if
((
GameBotUtil
.
sameLocation
((
String
)
textscore
.
get
(
0
),
curInfoPoint
,
historyInfoPoint
,
gameEnv
,
historyInfoPoint
.
get
(
"site"
),
logWriter
)
==
1
))
{
historyInfoPoint
.
put
(
"common_answer"
,
(
String
)
textscore
.
get
(
0
));
historyInfoPoint
.
put
(
"common_answer"
,
(
String
)
textscore
.
get
(
0
));
historyInfoPoint
.
put
(
"qa_score"
,
String
.
valueOf
(
textscore
.
get
(
1
)));
historyInfoPoint
.
put
(
"qa_score"
,
String
.
valueOf
(
textscore
.
get
(
1
)));
break
;
break
;
}
}
}
}
}
}
}
}
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
historyInfoPoint
.
put
(
"common_answer"
,
QA_FETCH_ERROR
);
historyInfoPoint
.
put
(
"common_answer"
,
QA_FETCH_ERROR
);
historyInfoPoint
.
put
(
"qa_score"
,
"99"
);
historyInfoPoint
.
put
(
"qa_score"
,
"99"
);
}
}
}
}
}
else
{
}
else
{
historyInfoPoint
.
put
(
"error_message"
,
jobj
.
getString
(
"error_message"
));
historyInfoPoint
.
put
(
"error_message"
,
jobj
.
getString
(
"error_message"
));
}
}
}
}
public
void
postGameQA
(
Map
<
String
,
String
>
curInfoPoint
,
Map
<
String
,
String
>
historyInfoPoint
,
Solution
ans
,
GameEnv
gameEnv
,
WorldController
worldController
,
String
URL
,
UserInfo
userInfo
)
throws
UnsupportedEncodingException
{
public
void
postGameQA
(
Map
<
String
,
String
>
curInfoPoint
,
Map
<
String
,
String
>
historyInfoPoint
,
Solution
ans
,
GameEnv
gameEnv
,
WorldController
worldController
,
String
URL
,
UserInfo
userInfo
)
throws
UnsupportedEncodingException
{
postGameQA1
(
historyInfoPoint
.
get
(
"game_step"
),
curInfoPoint
,
historyInfoPoint
,
ans
,
gameEnv
,
worldController
,
URL
,
userInfo
);
postGameQA1
(
historyInfoPoint
.
get
(
"game_step"
),
curInfoPoint
,
historyInfoPoint
,
ans
,
gameEnv
,
worldController
,
URL
,
userInfo
);
if
(
historyInfoPoint
.
get
(
"common_answer"
)
!=
null
&&
(
historyInfoPoint
.
get
(
"common_answer"
).
equals
(
""
)
||
historyInfoPoint
.
get
(
"common_answer"
).
equals
(
"no answer"
))){
if
(
historyInfoPoint
.
get
(
"common_answer"
)
!=
null
&&
(
historyInfoPoint
.
get
(
"common_answer"
).
equals
(
""
)
||
historyInfoPoint
.
get
(
"common_answer"
).
equals
(
"no answer"
))){
postGameQA1
(
curInfoPoint
.
get
(
"bot_name"
),
curInfoPoint
,
historyInfoPoint
,
ans
,
gameEnv
,
worldController
,
URL
,
userInfo
);
postGameQA1
(
curInfoPoint
.
get
(
"bot_name"
),
curInfoPoint
,
historyInfoPoint
,
ans
,
gameEnv
,
worldController
,
URL
,
userInfo
);
}
}
// historyInfoPoint.put("common_answer", "【旁白@%正常】QA暂时关闭");
// historyInfoPoint.put("common_answer", "【旁白@%正常】QA暂时关闭");
// historyInfoPoint.put("qa_score", "99");
// historyInfoPoint.put("qa_score", "99");
// historyInfoPoint.put("qa_status", "OK");
// historyInfoPoint.put("qa_status", "OK");
}
}
}
}
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