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
03aaeb43
Commit
03aaeb43
authored
Mar 29, 2019
by
hxw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加 不包含 比较类型
parent
3cc3f5aa
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
316 additions
and
318 deletions
+316
-318
config.properties
config.properties
+21
-7
keywords.txt
keywords.txt
+50
-47
keywords2.txt
keywords2.txt
+19
-120
Config.java
src/main/java/com/qiwu/chatbotbackend/Config/Config.java
+13
-0
PlatformUtils.java
.../qiwu/chatbotbackend/actiongenerate/DB/PlatformUtils.java
+1
-2
BotInfo.java
...om/qiwu/chatbotbackend/actiongenerate/entity/BotInfo.java
+5
-5
ActionServlet.java
.../chatbotbackend/actiongenerate/servlet/ActionServlet.java
+11
-7
BackupServlet.java
.../chatbotbackend/actiongenerate/servlet/BackupServlet.java
+14
-10
ConfigTermServlet.java
...tbotbackend/actiongenerate/servlet/ConfigTermServlet.java
+33
-24
MacroServlet.java
...u/chatbotbackend/actiongenerate/servlet/MacroServlet.java
+8
-2
RecoveryServlet.java
...hatbotbackend/actiongenerate/servlet/RecoveryServlet.java
+7
-6
VariableServlet.java
...hatbotbackend/actiongenerate/servlet/VariableServlet.java
+9
-5
ActionUtils.java
...qiwu/chatbotbackend/actiongenerate/utils/ActionUtils.java
+16
-4
ConfigTermUtils.java
.../chatbotbackend/actiongenerate/utils/ConfigTermUtils.java
+8
-14
SqlHelper.java
src/main/java/com/qiwu/chatbotbackend/db/SqlHelper.java
+33
-5
ChatCache.java
src/main/java/com/qiwu/chatbotbackend/entity/ChatCache.java
+5
-4
CharacterConstructor.java
.../qiwu/chatbotbackend/gameDesign/CharacterConstructor.java
+14
-12
ItemConstructor.java
...a/com/qiwu/chatbotbackend/gameDesign/ItemConstructor.java
+6
-7
MapConstructor.java
...va/com/qiwu/chatbotbackend/gameDesign/MapConstructor.java
+1
-1
PlotConstructor2.java
.../com/qiwu/chatbotbackend/gameDesign/PlotConstructor2.java
+0
-0
ActionMatcher.java
...ava/com/qiwu/chatbotbackend/processing/ActionMatcher.java
+0
-4
ChatCacheController.java
...m/qiwu/chatbotbackend/processing/ChatCacheController.java
+3
-2
FormsPoster.java
.../java/com/qiwu/chatbotbackend/processing/FormsPoster.java
+19
-13
FindCacheServlet.java
...ava/com/qiwu/chatbotbackend/servlet/FindCacheServlet.java
+1
-0
GameDesignServlet.java
...va/com/qiwu/chatbotbackend/servlet/GameDesignServlet.java
+11
-10
GetAnswerServlet.java
...ava/com/qiwu/chatbotbackend/servlet/GetAnswerServlet.java
+1
-3
GameBotUtil.java
.../java/com/qiwu/chatbotbackend/task/utils/GameBotUtil.java
+5
-2
c3p0-config.xml
src/main/resources/pro/c3p0-config.xml
+2
-2
No files found.
config.properties
View file @
03aaeb43
...
...
@@ -8,20 +8,25 @@ cc_url=http://localhost:8070/api/update/data
# condition后台url
condition_backend_url
=
http://192.168.1.82:6636/api
# 数据模型url
automatch_url
=
http://dev01.centaurstech.com:5700/mermaid/?model=auto-train
# action生成指定的后台地址
service_url
=
http://192.168.1.178:8081/bot/dialog
#
#qa_url=http://localhost:59100/game
#cc_url=http://localhost:8070/api/update/data
#condition_backend_url=http://localhost:6636/api
#automatch_url=http://dev01.centaurstech.com:5700/mermaid/?model=auto-train
#service_url=http://localhost:8081/bot/dialog
chatcache_time_out
=
300000
# 数据模型url
automatch_url
=
http://dev01.centaurstech.com:5700/mermaid/?model=auto-train
condition_backend_error
=
语义关系后台异常
keyword_dir
=
keywords.txt
bot_backup_dir
=
tmp/
config_dir
=
config/
...
...
@@ -29,8 +34,10 @@ unknown_text=不好意思,我没听懂你刚才说的话,请换个别的问
location_hint
=
请到%s
game_start_hint
=
请说开始剧情或者继续剧情
game_welcome_text
=
欢迎来到%s,请说继续剧情或者重新开始
no_one_can_reply_unknown
=
此地点没人可以回答unknown
game_start_hint
=
【旁白@%正常】请说开始剧情或者继续剧情
game_welcome_text
=
【旁白@正常】欢迎来到%s,请说继续剧情或者重新开始
game_module_error
=
游戏模块出错
program_error
=
程序出现异常
...
...
@@ -56,6 +63,8 @@ star_plot_not_exist=开始剧情不存在,请到剧情列表设置
助手对应的变量
assistant
=
globalVariable_智能助手
unknown_counter_name
=
globalVariable_无匹配次数
# ------------------------助手情绪--------------
assistant_emotion
=
正常
talker_pattern
=
【%s@%s】
...
...
@@ -71,6 +80,7 @@ plot_status=剧情%s状态
plot_generation_error
=
剧情接口处理出现异常
action_text_generate_error
=
action生成失败
qa_fetch_error
=
QA处理中发生异常
默认condition
default_condition
=
yaobuyao
...
...
@@ -165,3 +175,7 @@ variable_update_format=%s---%s
# ---------------------------数据库连接获取失败--------------------------------
sql_connection_error
=
数据库连接获取失败
# -------------------------备份--------------------------------------
backup_error
=
备份失败
keywords.txt
View file @
03aaeb43
...
...
@@ -6,96 +6,99 @@
# name表示可以替换的名字,如物品名、角色名
# attrName是属性名
# qiwu就是玩家“我”
# botname是"你"
# ------------------------------------------------------------------------------
# 我在哪里
WHERE_I_AM|zainali|+在:哪里+在:哪儿+在:哪+在:位置+在:地点+在:地方+到:哪里+到:地点+到:地方
WHERE_I_AM|wenzainali|+哪:qiwu+地方:qiwu+位置:qiwu+地点:qiwu+哪里:qiwu+哪儿:qiwu+哪:landey+地方:landey+位置:landey+地点:landey+哪里:landey+哪儿:landey
WHERE_I_AM|at_where|+在:哪里+在:哪儿+在:哪+在:位置+在:地点+在:地方+到:哪里+到:地点+到:地方
WHERE_I_AM|something_where|+哪:qiwu+哪儿:qiwu+哪里:qiwu+地方:qiwu+位置:qiwu+地点:qiwu
# 我能去哪里
WHERE_CAN_I_GO|choose_gowhere|+哪里:qiwu+哪:qiwu+哪儿:qiwu+地方:qiwu+哪里:去+哪:能去+哪里:能去+哪儿:能去+地方:能去+地方:去+地方:能去+哪里:能去+哪:去+哪:能去+哪儿:去+哪:qiwu+哪:到+哪儿:到+哪里:到
WHERE_CAN_I_GO|choose_gowhere_1|+能去:哪里+能去:哪+能去:哪儿+去:哪+去:哪里+去:哪儿+能到:哪里+能到:哪儿+能到:哪+到:哪+到:哪儿+到:哪里+能到:地方+能到:地点+能到:位置+能去:地方+能去:地点+能去:位置
WHERE_CAN_I_GO|choose_gowhere_33|+qiwu:哪+qiwu:哪儿+qiwu:哪里
# 周围有什么
AROUND_THINGS|havewhat_thing|+旁边:吗+旁边:呢+这里:呢+这里:吗+附近:吗+周围:吗+地方:啊+地点:啊+周围:呀
AROUND_THINGS|place_have_something|+这里:什么
# 周围有什么人
AROUND_NPC|know_exist_what|+周围:人+旁边:人+附近:人+周围:谁+这里:谁+这里:人+有什么:人+里面:人+里面:谁+哪些:人+qiwu:人+qiwu:谁+有:谁+有:人+附近:谁+有:附近+旁边:谁
AROUND_NPC|zhiwen|+这里:谁+这里:谁+谁:在
AROUND_NPC|place_have_something|+这里:谁+里面:人+里面:谁+附近:人+附近:谁+qiwu:附近+周围:谁+周围:人+旁边:人+旁边:谁+qiwu:周围+谁:那
# 周围有什么npc类别
AROUND_NPC_CLASS|know_exist_what|+周围:name+附近:name
# 周围有什么
AROUND_THINGS|know_exist_what_mohu|+有什么:周围+有什么:附近+有什么:这里+有:哪些:这里+有谁:周围+有什么:里面+有什么:旁边+qiwu:旁边+有什么:这里+有:哪些
# 周围有什么物品
AROUND_ITEM|
know_exist_what|+周围:物品+旁边:物品+旁边:东西+周围:东西+附近:物品+附近:东西+这里:物品+这里:东西+有什么:东西+有什么:物品+哪些:物品+哪些:东西+有:东西+里面:物品
AROUND_ITEM|
nums|+有:哪些
# AROUND_ITEM|zhiwen|+附近:who+周围:who+旁边:who
AROUND_ITEM|
place_have_something|+周围:物品+旁边:物品+旁边:东西+周围:东西+附近:物品+附近:东西+这里:物品+这里:东西+qiwu:物品+里面:物品+里面:东西+里面:什么
AROUND_ITEM|
havewhat_thing|+周围:物品+旁边:物品+旁边:东西+周围:东西+附近:物品+附近:东西+这里:物品+这里:东西+qiwu:物品+里面:物品+里面:东西+里面:什么
# 周围有什么地方
AROUND_PLACE|know_exist_what|+周围:地点+周围:地方+哪些:地方+哪些:地点+旁边:地方+旁边:地点+附近:地方+附近:地点
AROUND_PLACE|havewhat_thing|+周围:地点+周围:地方+哪些:地方+哪些:地点+旁边:地方+旁边:地点+附近:地方+附近:地点
AROUND_PLACE|place_have_something|+周围:地点+周围:地方+哪些:地方+哪些:地点+旁边:地方+旁边:地点+附近:地方+附近:地点
# 周围有什么
物品
类别
AROUND_
ITEM_CLASS|know_exist_what|+周围:name+附近
:name
# 周围有什么
npc
类别
AROUND_
NPC_CLASS|havewhat_thing|+周围:name+附近:name+旁边
:name
# 我有什么
WHAT_ITEM_I_HAVE|know_exist_what_mohu|+有什么:qiwu+什么:qiwu+qiwu:东西+qiwu:地方
WHAT_ITEM_I_HAVE|know_exist_what|有什么:东西
WHAT_ITEM_I_HAVE|zhiwen|+qiwu:带
# 周围有什么物品类别
AROUND_ITEM_CLASS|havewhat_thing|+周围:name+附近:name+旁边:name
# 里面有谁
WHO_IN_THERE|shishui|+谁:里面+里面:人
# 去xx
GO_TO|yaobuyao|+去:name+到:name
#
怎么找到NPC
HOW_TO_FIND_NPC|xxx|+找到:name
#
我有什么
WHAT_ITEM_I_HAVE|place_have_something|+qiwu:什么+qiwu:东西+qiwu:物品+qiwu:装备+qiwu:补给
#
你是谁
WHO_YOU_ARE|zhiwen|+botname:谁+botname:干嘛+那个人:谁+人:谁+botname:是+人:是
#
去xx
GO_TO|do_what_vn|+去:name+到:name
# 任务是什么
TASK_IS_WHAT|shishenme|+是什么:任务+qiwu:任务
TASK_IS_WHAT|zhiwen|+qiwu:要去
# npc在哪里
NPC_LOCATION|
wenzainali|+哪里:name+哪:name+地方:name+地点
:name
NPC_LOCATION|
something_where|+哪里:name+哪:name+地方:name+地点:name+位置:name+哪儿:name+位置
:name
# 物品在哪里
ITEM_LOCATION|
wenzainali
|+哪里:name+哪:name+地方:name+地点:name+位置:name+哪儿:name+位置:name
ITEM_LOCATION|
something_where
|+哪里:name+哪:name+地方:name+地点:name+位置:name+哪儿:name+位置:name
# 怎么找到npc
HOW_FIND_NPC|want_know
_zenmezuo
|+找到:name
HOW_FIND_NPC|want_know
n_zenmezuo_vn
|+找到:name
#怎么找到物品
HOW_FIND_ITEM|want_know_zenmezuo|+找到:name
HOW_FIND_ITEM|want_known_zenmezuo_vn|+找到:name
# 怎么去XXX
HOW_TO_THERE|want_known_zenmezuo_vn|默认
# 沙滩上有什么人
WHAT_NPC_IN_LOCATION|xxx|地点
WHAT_NPC_IN_LOCATION|havewhat_thing|+name:人
WHAT_NPC_IN_LOCATION|place_have_something|+name:谁+name:人
# xx上有什么东西
WAHT_ITEM_IN_LOCATION|
xxx|地点
WAHT_ITEM_IN_LOCATION|
havewhat_thing|+name:物品+name:东西+name:地方+name:位置
# 地点上有什么
WHAT_THINGS_IN_LOCATION|xxx|地点
WHAT_THINGS_IN_LOCATION|have_what_thing|地点
# 你是谁
WHO_YOU_ARE|zhiwen|+botname:谁+botname:干嘛+那个人:谁+人:谁+botname:是+人:是
# 任务是什么
TASK_IS_WHAT|something_iswhat|+什么:任务
TASK_IS_WHAT|shenme_shi_shenme|+qiwu:任务
# npc的属性是多少
NPC_ATTR|nums|+name:attrName
NPC_ATTR|shishenme|+name:attrName
NPC_ATTR|shuliang_1|+name:attrName
# 物品的属性是多少
ITEM_ATTR|
nums
|+name:attrName
ITEM_ATTR|shishenme|+name:attrName
ITEM_ATTR|
shuliang_1
|+name:attrName
# 周围有什么物品类别
AOURND_NPC_CLASS|know_exist_what|+周围:name+附近:name
# 怎么去XXX
HOW_TO_THERE|want_know_zenmezuo|+去:name
keywords2.txt
View file @
03aaeb43
# ------------------------------------------------------------------------------
# 第一块,意图|相关的语义关系名
意图语义关系名
# 第二块, 意图|语义关系名|关键词
# ------------------------------------------------------------------------------
WHERE_I_AM|zainali|+在:哪里+在:哪儿+在:哪+在:位置+在:地点+在:地方+到:哪里+到:地点+到:地方
WHERE_I_AM|wenzainali|+哪:qiwu+地方:qiwu+位置:qiwu+地点:qiwu+哪里:qiwu+哪儿:qiwu
WHERE_CAN_I_GO|choose_gowhere|+哪里:qiwu+哪:qiwu+哪儿:qiwu+地方:qiwu+哪里:去+哪:能去+哪里:能去+哪儿:能去+地方:能去+地方:去+地方:能去+哪里:能去+哪:去+哪:能去+哪儿:去+哪:qiwu
SURROUNDING_NPC|know_exist_what|+周围:人+附近:人+周围:谁+这里:谁+这里:人+有什么:人+里面:人+里面:谁+哪些:人+qiwu:人+qiwu:谁+有:谁+有:人
SURROUNDING_THINGS|know_exist_what_mohu|+有什么:周围+有什么:附近+有什么:这里+有:哪些:这里+有谁:周围+有什么:里面
SURROUNDING_NPC_CLASS|know_exist_what|+周围:name+附近:name
SURROUNDING_ITEM|know_exist_what|+周围:name+附近:name
SURROUNDING_PLACE|know_exist_what|+周围:地点+周围:地方+哪些:地方+哪些:地点
SURROUNDING_ITEM_CLASS|know_exist_what|+周围:name+附近:name
WHAT_ITEM_I_HAVE|know_exist_what_mohu|+有什么:qiwu+什么:qiwu+qiwu:东西+qiwu:地方
WHO_IN_THERE|shishui|+谁:里面+里面:人
GO_TO|yaobuyao|+去:name+到:name
WHO_TO_FIND_NPC|xxx|+找到:name
WHO_ARE_YOU|zhiwen|+botname:谁+botname:干嘛+那个人:谁+人:谁+botname:是+人:是
TASK_IS_WHAT|shishenme|+是什么:任务+qiwu:任务
FIND_NPC_LOCATION|xxx|+哪里:name+哪:name+地方:name+地点:name
FIND_ITEM_LOCATION|xxx|+哪里:name+哪:name+地方:name+地点:name+位置:name+哪儿:name
WHAT_NPC_IN_LOCATION|xxx|地点
WAHT_ITEM_IN_LOCATION|xxx|地点
WHAT_THINGS_IN_LOCATION|xxx|地点
# --------------------------------------------------------------------------
# 地图在哪里
map_zainali|+在:哪里+在:哪儿+在:哪+在:位置+在:地点+在:地方+到:哪里+到:地点+到:地方
map_wenzainali|+哪:qiwu+地方:qiwu+位置:qiwu+地点:qiwu+哪里:qiwu+哪儿:qiwu
# 能去哪里
map_choose_gowhere|+哪里:qiwu+哪:qiwu+哪儿:qiwu+地方:qiwu+哪里:去+哪:能去+哪里:能去+哪儿:能去+地方:能去+地方:去+地方:能去+哪里:能去+哪:去+哪:能去+哪儿:去+哪:qiwu
# 周围有什么人
people_know_exist_what|+周围:人+附近:人+周围:谁+这里:谁+这里:人+有什么:人+里面:人+里面:谁+哪些:人+qiwu:人+qiwu:谁+有:谁+有:人
# 周围有什么物品
item_know_exist_what|+周围:物品+周围:东西+附近:物品+附近:东西+这里:物品+这里:东西+有什么:东西+有什么:物品+哪些:物品+哪些:东西
# 我有什么东西
item_rencheng|+qiwu:东西
# 我有什么
we_have_know_exist_what_mohu|+有什么:qiwu+什么:qiwu+qiwu:东西+qiwu:地方
# 里面的是谁
inner_shishui|+谁:里面+里面:人
# 去某个地方
map_yaobuyao|+去:name+到:name
# 你是谁
talker_zhiwen|+botname:谁+botname:干嘛+那个人:谁+人:谁+botname:是+人:是
# 任务是什么
task_shishenme|+是什么:任务+qiwu:任务
# 周围有什么
things|know_exist_what_mohu|+有什么:周围+有什么:附近+有什么:这里+有:哪些:这里+有谁:周围+有什么:里面
# 周围有什么地方
place_know_exist_what|+周围:地点+周围:地方+哪些:地方+哪些:地点
# 周围有什么npc类名
npc_class_pattern|+周围:name+附近:name
# 周围有什么item类名
item_class_pattern|+周围:name+附近:name
# 怎么找到xxx
find_pattern|+找到:name
# npc在哪里
npc_location_pattern|+哪里:name+哪:name+地方:name+地点:name
# 物品在哪里
item_location_pattern|+哪里:name+哪:name+地方:name+地点:name+位置:name+哪儿:name
# 某地点有什么
things_in_place_xxxx|+地点:什么
# 地点有什么人
NPC_in_place_xxx|+地点:什么
# 地点有什么物品
items_in_place_xxx|+地点:什么
# =====================================new add============================================
people_rencheng|+机器人:谁+那个人:谁+人:谁+机器人:干嘛
# ------------------------------------------------------------------------------
# 格式
# 意图|语义关系名字|关键词
# name表示可以替换的名字,如物品名、角色名
...
...
@@ -124,31 +12,39 @@ people_rencheng|+机器人:谁+那个人:谁+人:谁+机器人:干嘛
# ------------------------------------------------------------------------------
# 我在哪里
WHERE_I_AM|zainali|+在:哪里+在:哪儿+在:哪+在:位置+在:地点+在:地方+到:哪里+到:地点+到:地方
WHERE_I_AM|wenzainali|+哪:qiwu+地方:qiwu+位置:qiwu+地点:qiwu+哪里:qiwu+哪儿:qiwu
WHERE_I_AM|wenzainali|+哪:qiwu+地方:qiwu+位置:qiwu+地点:qiwu+哪里:qiwu+哪儿:qiwu+哪:landey+地方:landey+位置:landey+地点:landey+哪里:landey+哪儿:landey
# 我能去哪里
WHERE_CAN_I_GO|choose_gowhere|+哪里:qiwu+哪:qiwu+哪儿:qiwu+地方:qiwu+哪里:去+哪:能去+哪里:能去+哪儿:能去+地方:能去+地方:去+地方:能去+哪里:能去+哪:去+哪:能去+哪儿:去+哪:qiwu
WHERE_CAN_I_GO|choose_gowhere|+哪里:qiwu+哪:qiwu+哪儿:qiwu+地方:qiwu+哪里:去+哪:能去+哪里:能去+哪儿:能去+地方:能去+地方:去+地方:能去+哪里:能去+哪:去+哪:能去+哪儿:去+哪:qiwu
+哪:到+哪儿:到+哪里:到
# 周围有什么人
AROUND_NPC|know_exist_what|+周围:人+附近:人+周围:谁+这里:谁+这里:人+有什么:人+里面:人+里面:谁+哪些:人+qiwu:人+qiwu:谁+有:谁+有:人
AROUND_NPC|know_exist_what|+周围:人+旁边:人+附近:人+周围:谁+这里:谁+这里:人+有什么:人+里面:人+里面:谁+哪些:人+qiwu:人+qiwu:谁+有:谁+有:人+附近:谁+有:附近+旁边:谁
AROUND_NPC|zhiwen|+这里:谁+这里:谁+谁:在
# 周围有什么npc类别
AROUND_NPC_CLASS|know_exist_what|+周围:name+附近:name
# 周围有什么
AROUND_THINGS|know_exist_what_mohu|+有什么:周围+有什么:附近+有什么:这里+有:哪些:这里+有谁:周围+有什么:里面
AROUND_THINGS|know_exist_what_mohu|+有什么:周围+有什么:附近+有什么:这里+有:哪些:这里+有谁:周围+有什么:里面
+有什么:旁边+qiwu:旁边+有什么:这里+有:哪些
# 周围有什么物品
AROUND_ITEM|know_exist_what|+周围:物品+周围:东西+附近:物品+附近:东西+这里:物品+这里:东西+有什么:东西+有什么:物品+哪些:物品+哪些:东西
AROUND_ITEM|know_exist_what|+周围:物品+旁边:物品+旁边:东西+周围:东西+附近:物品+附近:东西+这里:物品+这里:东西+有什么:东西+有什么:物品+哪些:物品+哪些:东西+有:东西+里面:物品
AROUND_ITEM|nums|+有:哪些
# AROUND_ITEM|zhiwen|+附近:who+周围:who+旁边:who
# 周围有什么地方
AROUND_PLACE|know_exist_what|+周围:地点+周围:地方+哪些:地方+哪些:地点
AROUND_PLACE|know_exist_what|+周围:地点+周围:地方+哪些:地方+哪些:地点
+旁边:地方+旁边:地点+附近:地方+附近:地点
# 周围有什么物品类别
AROUND_ITEM_CLASS|know_exist_what|+周围:name+附近:name
# 我有什么
WHAT_ITEM_I_HAVE|know_exist_what_mohu|+有什么:qiwu+什么:qiwu+qiwu:东西+qiwu:地方
WHAT_ITEM_I_HAVE|know_exist_what|有什么:东西
WHAT_ITEM_I_HAVE|zhiwen|+qiwu:带
# 里面有谁
WHO_IN_THERE|shishui|+谁:里面+里面:人
...
...
@@ -165,12 +61,14 @@ WHO_YOU_ARE|zhiwen|+botname:谁+botname:干嘛+那个人:谁+人:谁+botname:是
# 任务是什么
TASK_IS_WHAT|shishenme|+是什么:任务+qiwu:任务
TASK_IS_WHAT|zhiwen|+qiwu:要去
# npc在哪里
NPC_LOCATION|wenzainali|+哪里:name+哪:name+地方:name+地点:name
# 物品在哪里
ITEM_LOCATION|wenzainali|+哪里:name+哪:name+地方:name+地点:name+位置:name+哪儿:name
ITEM_LOCATION|wenzainali|+哪里:name+哪:name+地方:name+地点:name+位置:name+哪儿:name+位置:name
# 怎么找到npc
HOW_FIND_NPC|want_know_zenmezuo|+找到:name
...
...
@@ -198,5 +96,6 @@ ITEM_ATTR|shishenme|+name:attrName
AOURND_NPC_CLASS|know_exist_what|+周围:name+附近:name
# 怎么去XXX
HOW_TO_THERE|want_know_zenmezuo|默认
HOW_TO_THERE|want_know_zenmezuo|+去:name
src/main/java/com/qiwu/chatbotbackend/Config/Config.java
View file @
03aaeb43
...
...
@@ -10,6 +10,10 @@ public class Config {
public
static
String
QA_URL
=
null
;
public
static
String
CC_URL
=
null
;
public
static
String
NO_ONE_CAN_REPLY_UNKNOWN
;
public
static
String
KEYWORD_DIR
=
null
;
//名字,地址
public
static
String
GAME_BOT_CATEGORY
=
null
;
...
...
@@ -167,6 +171,15 @@ public class Config {
public
static
String
BACKUP_PATH
=
null
;
public
static
String
UNKNOWN_COUNTER_NAME
=
null
;
public
static
String
BACKUP_ERROR
=
null
;
public
static
String
QA_FETCH_ERROR
=
null
;
public
static
long
CHATCACHE_TIME_OUT
;
}
src/main/java/com/qiwu/chatbotbackend/actiongenerate/DB/PlatformUtils.java
View file @
03aaeb43
...
...
@@ -32,12 +32,11 @@ public class PlatformUtils {
}
public
List
<
Integer
>
queryConditionIdByTypetreeId
(
List
typetreeIdList
){
String
sql
=
"select conditionId from typetreeNcondition where typetreeId in (
?
)"
;
String
sql
=
"select conditionId from typetreeNcondition where typetreeId in (
"
+
Joiner
.
on
(
","
).
join
(
typetreeIdList
)
+
"
)"
;
String
keywordText
=
""
;
List
<
Integer
>
idList
=
new
ArrayList
<
Integer
>();
try
{
PreparedStatement
ps
=
conn
.
prepareStatement
(
sql
);
ps
.
setString
(
1
,
Joiner
.
on
(
","
).
join
(
typetreeIdList
));
ResultSet
rs
=
ps
.
executeQuery
();
while
(
rs
.
next
()){
idList
.
add
(
rs
.
getInt
(
"conditionId"
));
...
...
src/main/java/com/qiwu/chatbotbackend/actiongenerate/entity/BotInfo.java
View file @
03aaeb43
package
com
.
qiwu
.
chatbotbackend
.
actiongenerate
.
entity
;
public
class
BotInfo
{
Integer
botId
;
String
welcomeText
;
String
goodbyeText
;
String
postURL
;
String
defaultConfigCategory
;
Integer
botId
=
0
;
String
welcomeText
=
""
;
String
goodbyeText
=
""
;
String
postURL
=
""
;
String
defaultConfigCategory
=
""
;
String
bothValue
;
String
queryTextTransfer
;
...
...
src/main/java/com/qiwu/chatbotbackend/actiongenerate/servlet/ActionServlet.java
View file @
03aaeb43
...
...
@@ -28,6 +28,8 @@ public class ActionServlet extends HttpServlet {
JSONObject
responseJSONObject
=
new
JSONObject
();
Boolean
flag
=
true
;
Integer
botId
;
EngineUtils
engine
=
null
;
SqlHelper
helper
=
null
;
...
...
@@ -47,8 +49,8 @@ public class ActionServlet extends HttpServlet {
try
{
EngineUtils
engine
=
new
EngineUtils
();
SqlHelper
helper
=
new
SqlHelper
();
engine
=
new
EngineUtils
();
helper
=
new
SqlHelper
();
ActionUtils
actionUtils
=
new
ActionUtils
(
engine
,
helper
);
...
...
@@ -68,9 +70,6 @@ public class ActionServlet extends HttpServlet {
case
"update_condition_display_order"
:
actionUtils
.
updateConditionDisplayOrder
(
receiveParameters
);
break
;
case
"update_bot_info"
:
actionUtils
.
updateBotInfo
(
receiveParameters
);
break
;
case
"update_goodbye"
:
actionUtils
.
updateGoodbye
(
receiveParameters
);
break
;
...
...
@@ -98,6 +97,9 @@ public class ActionServlet extends HttpServlet {
case
"update_condition_name"
:
actionUtils
.
updateConditionName
(
receiveParameters
);
break
;
case
"update_bot_info"
:
actionUtils
.
updateBotInfo
(
receiveParameters
);
break
;
}
if
(
actionUtils
.
intervalStatus
.
getStatus
()
==
1
)
actionUtils
.
query4post
(
receiveParameters
);
...
...
@@ -105,8 +107,7 @@ public class ActionServlet extends HttpServlet {
}
helper
.
destroy
();
engine
.
destroy
();
switch
(
actionUtils
.
intervalStatus
.
getStatus
()){
case
1
:
...
...
@@ -121,6 +122,9 @@ public class ActionServlet extends HttpServlet {
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
finally
{
helper
.
destroy
();
engine
.
destroy
();
}
}
else
{
...
...
src/main/java/com/qiwu/chatbotbackend/actiongenerate/servlet/BackupServlet.java
View file @
03aaeb43
...
...
@@ -23,6 +23,7 @@ import java.sql.SQLException;
import
java.util.ArrayList
;
import
java.util.List
;
import
static
com
.
qiwu
.
chatbotbackend
.
Config
.
Config
.
BACKUP_ERROR
;
import
static
com
.
qiwu
.
chatbotbackend
.
Config
.
Config
.
BOT_BACKUP_DIR
;
import
static
com
.
qiwu
.
chatbotbackend
.
Config
.
Config
.
SQL_CONNECTION_ERROR
;
...
...
@@ -40,6 +41,8 @@ public class BackupServlet extends HttpServlet {
JSONObject
responseJSONObject
=
new
JSONObject
();
Boolean
flag
=
true
;
Integer
botId
=
0
,
categoryIndex
;
EngineUtils
engine
=
null
;
SqlHelper
helper
=
null
;
if
(
jsonStr
!=
null
&&
!
jsonStr
.
equals
(
""
))
{
...
...
@@ -56,8 +59,8 @@ public class BackupServlet extends HttpServlet {
botCategoryName
=
receiveParameters
.
getString
(
"catName"
);
EngineUtils
engine
=
new
EngineUtils
();
SqlHelper
helper
=
new
SqlHelper
();
engine
=
new
EngineUtils
();
helper
=
new
SqlHelper
();
BotInfo
botInfo
=
null
;
List
<
Condition
>
conditionList
=
new
ArrayList
<
Condition
>();
List
<
ConfigTerm
>
configTermList
=
new
ArrayList
<
ConfigTerm
>();
...
...
@@ -71,12 +74,12 @@ public class BackupServlet extends HttpServlet {
//actionUtils.
//如果需要保存condition,查询所有condition
if
(
receiveParameters
.
containsKey
(
"saveCondition"
)
&&
receiveParameters
.
getBoolean
(
"saveCondition"
)){
if
(
receiveParameters
.
containsKey
(
"saveCondition"
)
&&
receiveParameters
.
getBoolean
(
"saveCondition"
))
{
conditionList
=
helper
.
queryConditionAll
(
botId
);
}
//如果需要保存配置文件,则从根目录开始保存配置文件
if
(
receiveParameters
.
containsKey
(
"saveConfig"
)
&&
receiveParameters
.
getBoolean
(
"saveConfig"
))
{
if
(
receiveParameters
.
containsKey
(
"saveConfig"
)
&&
receiveParameters
.
getBoolean
(
"saveConfig"
))
{
categoryIndex
=
receiveParameters
.
getInteger
(
"indexCategory"
);
//查询某个类别下的所有类别
...
...
@@ -86,7 +89,7 @@ public class BackupServlet extends HttpServlet {
}
if
(!
receiveParameters
.
containsKey
(
"saveVariable"
)
||
receiveParameters
.
getBoolean
(
"saveVariable"
))
{
if
(!
receiveParameters
.
containsKey
(
"saveVariable"
)
||
receiveParameters
.
getBoolean
(
"saveVariable"
))
{
variablesList
=
helper
.
queryVariableAll
(
botId
);
}
...
...
@@ -98,21 +101,22 @@ public class BackupServlet extends HttpServlet {
//backupFile.put("botId");
try
{
writeFile
(
BOT_BACKUP_DIR
+
botId
+
".backup"
,
JSON
.
toJSONString
(
backup
));
writeFile
(
BOT_BACKUP_DIR
+
botId
+
".backup"
,
JSON
.
toJSONString
(
backup
));
// ReadFile("D:\\8.json");
System
.
out
.
println
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
helper
.
destroy
();
engine
.
destroy
();
}
catch
(
IOException
e
){
intervalStatus
=
new
IntervalStatus
(
0
,
BACKUP_ERROR
);
}
catch
(
SQLException
e
)
{
intervalStatus
=
new
IntervalStatus
(
0
,
SQL_CONNECTION_ERROR
);
}
finally
{
helper
.
destroy
();
engine
.
destroy
();
}
}
...
...
src/main/java/com/qiwu/chatbotbackend/actiongenerate/servlet/ConfigTermServlet.java
View file @
03aaeb43
...
...
@@ -16,7 +16,6 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.sql.SQLException
;
import
static
com
.
qiwu
.
chatbotbackend
.
Config
.
Config
.
JSON_FORMAT_ERROR
;
...
...
@@ -42,12 +41,15 @@ public class ConfigTermServlet extends HttpServlet {
operationType
=
receiveParaneters
.
getString
(
"type"
);
botId
=
receiveParaneters
.
getInteger
(
"botId"
);
EngineUtils
engine
=
null
;
ConfigTermUtils
configUtils
=
null
;
SqlHelper
helper
=
null
;
try
{
//EngineUtils engine = new EngineUtils();
SqlHelper
helper
=
new
SqlHelper
();
EngineUtils
engine
=
null
;
ConfigTermUtils
configUtils
=
null
;
helper
=
new
SqlHelper
();
IntervalStatus
intervalStatus
=
null
;
...
...
@@ -67,23 +69,28 @@ public class ConfigTermServlet extends HttpServlet {
}
else
if
(
operationType
.
endsWith
(
"config"
)){
engine
=
new
EngineUtils
();
botAccount
=
engine
.
queryBotAccountByBotId
(
botId
);
System
.
out
.
println
(
"botAccount"
+
botAccount
);
configUtils
=
new
ConfigTermUtils
(
botAccount
,
helper
,
context
);
switch
(
operationType
){
case
"insert_config"
:
configUtils
.
insertConfigTerm
(
receiveParaneters
);
break
;
case
"update_config"
:
configUtils
.
updateConfig
(
receiveParaneters
);
break
;
case
"delete_config"
:
configUtils
.
deleteConfig
(
receiveParaneters
);
break
;
try
{
engine
=
new
EngineUtils
();
botAccount
=
engine
.
queryBotAccountByBotId
(
botId
);
System
.
out
.
println
(
"botAccount"
+
botAccount
);
configUtils
=
new
ConfigTermUtils
(
botAccount
,
helper
,
context
);
switch
(
operationType
)
{
case
"insert_config"
:
configUtils
.
insertConfigTerm
(
receiveParaneters
);
break
;
case
"update_config"
:
configUtils
.
updateConfig
(
receiveParaneters
);
break
;
case
"delete_config"
:
configUtils
.
deleteConfig
(
receiveParaneters
);
break
;
}
intervalStatus
=
configUtils
.
intervalStatus
;
engine
.
destroy
();
}
catch
(
Exception
e
){
engine
.
destroy
();
throw
(
new
Exception
());
}
intervalStatus
=
configUtils
.
intervalStatus
;
engine
.
destroy
();
}
else
{
categoryUtils
=
new
CategoryUtils
(
helper
);
switch
(
operationType
)
{
...
...
@@ -103,7 +110,6 @@ public class ConfigTermServlet extends HttpServlet {
}
intervalStatus
=
categoryUtils
.
intervalStatus
;
}
helper
.
destroy
();
...
...
@@ -118,10 +124,13 @@ public class ConfigTermServlet extends HttpServlet {
break
;
}
}
catch
(
SQLException
e
)
{
}
catch
(
Exception
e
){
System
.
out
.
println
(
e
.
getMessage
());
e
.
printStackTrace
();
responseJSONObject
.
put
(
"status"
,
0
);
responseJSONObject
.
put
(
"parameter"
,
e
.
getMessage
());
}
finally
{
helper
.
destroy
();
}
...
...
src/main/java/com/qiwu/chatbotbackend/actiongenerate/servlet/MacroServlet.java
View file @
03aaeb43
...
...
@@ -43,10 +43,13 @@ public class MacroServlet extends HttpServlet {
operationType
=
receiveParameters
.
getString
(
"type"
);
botId
=
receiveParameters
.
getInteger
(
"botId"
);
SqlHelper
helper
=
null
;
EngineUtils
engine
=
null
;
try
{
SqlHelper
helper
=
new
SqlHelper
();
EngineUtils
engine
=
new
EngineUtils
();
helper
=
new
SqlHelper
();
engine
=
new
EngineUtils
();
botAccount
=
engine
.
queryBotAccountByBotId
(
botId
);
VariableUtils
variableUtils
=
null
;
...
...
@@ -66,6 +69,9 @@ public class MacroServlet extends HttpServlet {
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
finally
{
helper
.
destroy
();
engine
.
destroy
();
}
...
...
src/main/java/com/qiwu/chatbotbackend/actiongenerate/servlet/RecoveryServlet.java
View file @
03aaeb43
...
...
@@ -56,7 +56,8 @@ public class RecoveryServlet extends HttpServlet {
botAccount
=
receiveParameters
.
getString
(
"botName"
);
botName
=
receiveParameters
.
getString
(
"botName_yhm"
);
SqlHelper
helper
=
null
;
EngineUtils
engine
=
null
;
...
...
@@ -75,8 +76,8 @@ public class RecoveryServlet extends HttpServlet {
List
<
Variable
>
originVariableList
,
variableList
=
data
.
getJSONArray
(
"variablesList"
).
toJavaList
(
Variable
.
class
);
BotInfo
botInfo
=
data
.
getJSONObject
(
"botInfo"
).
toJavaObject
(
BotInfo
.
class
);
SqlHelper
helper
=
new
SqlHelper
();
EngineUtils
engine
=
new
EngineUtils
();
helper
=
new
SqlHelper
();
engine
=
new
EngineUtils
();
ActionUtils
actionUtils
=
new
ActionUtils
(
engine
,
helper
);
VariableUtils
variableUtils
=
new
VariableUtils
(
helper
);
...
...
@@ -172,13 +173,13 @@ public class RecoveryServlet extends HttpServlet {
intervalStatus
=
actionUtils
.
intervalStatus
;
}
engine
.
destroy
();
helper
.
destroy
();
}
catch
(
SQLException
e
){
intervalStatus
=
new
IntervalStatus
(
0
,
SQL_CONNECTION_ERROR
);
}
finally
{
engine
.
destroy
();
helper
.
destroy
();
}
}
...
...
src/main/java/com/qiwu/chatbotbackend/actiongenerate/servlet/VariableServlet.java
View file @
03aaeb43
...
...
@@ -43,10 +43,14 @@ public class VariableServlet extends HttpServlet {
operationType
=
receiveParameters
.
getString
(
"type"
);
botId
=
receiveParameters
.
getInteger
(
"botId"
);
SqlHelper
helper
=
null
;
EngineUtils
engine
=
null
;
try
{
SqlHelper
helper
=
new
SqlHelper
();
EngineUtils
engine
=
new
EngineUtils
();
helper
=
new
SqlHelper
();
engine
=
new
EngineUtils
();
botAccount
=
engine
.
queryBotAccountByBotId
(
botId
);
VariableUtils
variableUtils
=
null
;
...
...
@@ -90,12 +94,12 @@ public class VariableServlet extends HttpServlet {
break
;
}
helper
.
destroy
();
engine
.
destroy
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
finally
{
helper
.
destroy
();
engine
.
destroy
();
}
...
...
src/main/java/com/qiwu/chatbotbackend/actiongenerate/utils/ActionUtils.java
View file @
03aaeb43
...
...
@@ -390,9 +390,17 @@ public class ActionUtils {
relationHead
=
condition
.
getString
(
"relationHead"
);
if
(
relationHead
.
equals
(
""
))
relationHead
=
"#visitorname"
;
//不是问号,没有加号,且不是星号,则添加问号
else
if
(!
relationHead
.
equals
(
"?"
)
&&
!
relationHead
.
startsWith
(
"+"
)
&&
!
relationHead
.
equals
(
"*"
))
relationHead
=
"+"
+
relationHead
;
relationTail
=
condition
.
getString
(
"relationTail"
);
if
(
relationTail
.
equals
(
""
))
relationTail
=
"#visitorname"
;
else
if
(!
relationTail
.
equals
(
"?"
)
&&
!
relationTail
.
startsWith
(
"+"
)
&&
!
relationHead
.
equals
(
"*"
))
relationTail
=
"+"
+
relationTail
;
relationName
=
condition
.
getString
(
"relationName"
);
//condition的属性 number、string、location
...
...
@@ -429,7 +437,7 @@ public class ActionUtils {
repeatElem
=
repeatList
.
getJSONObject
(
i
);
if
(!
repeatElem
.
getString
(
"repeatKeywords"
).
startsWith
(
"+"
))
if
(!
repeatElem
.
getString
(
"repeatKeywords"
).
startsWith
(
"+"
)
&&
!
repeatElem
.
getString
(
"repeatKeywords"
).
equals
(
""
)
)
repeatElem
.
put
(
"repeatKeywords"
,
"+"
+
repeatElem
.
getString
(
"repeatKeywords"
));
repeatText
.
append
(
repeatElem
.
getString
(
"repeatString"
)).
append
(
"="
).
append
(
repeatElem
.
getString
(
"repeatKeywords"
));
...
...
@@ -743,6 +751,8 @@ public class ActionUtils {
case
401
:
intervalStatus
=
new
IntervalStatus
(
0
,
TOKEN_TIME_OUT
);
break
;
case
500
:
intervalStatus
=
new
IntervalStatus
(
0
,
CONDITION_BACKEND_ERROR
);
default
:
intervalStatus
=
new
IntervalStatus
(
0
,
CONDITION_BACKEND_ERROR
);
}
...
...
@@ -765,7 +775,7 @@ public class ActionUtils {
try
{
platformUtils
=
new
PlatformUtils
();
helper
.
deleteUserData
(
botId
);
//
helper.deleteUserData(botId);
idList
=
platformUtils
.
queryConditionIdByTypetreeId
(
parameters
.
getJSONArray
(
"conditionCategories"
));
...
...
@@ -778,6 +788,8 @@ public class ActionUtils {
patternConditionJson
.
put
(
"active"
,
false
);
patternConditionJson
.
put
(
"conditionCategory"
,
"0:默认"
);
relationName
=
patternConditionJson
.
getString
(
"relationName"
).
replace
(
"0"
,
"a0"
).
replace
(
"-"
,
"b0"
);
conditionExtraKeywords
.
putIfAbsent
(
DEFAULT_CONDITION
+
"_head"
,
new
HashSet
<
String
>());
conditionExtraKeywords
.
putIfAbsent
(
DEFAULT_CONDITION
+
"_tail"
,
new
HashSet
<
String
>());
for
(
int
i
=
1
;
i
<
10
;
i
++){
//给condition的名字添加后缀,因为游戏中可能用到condition的复制,但值域和名字不一样
...
...
@@ -850,12 +862,12 @@ public class ActionUtils {
}
}
platformUtils
.
destroy
();
}
catch
(
SQLException
e
){
intervalStatus
=
new
IntervalStatus
(
0
,
ACTION_TEXT_GENERATE_ERROR
);
System
.
out
.
println
(
e
.
getMessage
());
}
finally
{
platformUtils
.
destroy
();
}
}
...
...
src/main/java/com/qiwu/chatbotbackend/actiongenerate/utils/ConfigTermUtils.java
View file @
03aaeb43
...
...
@@ -14,10 +14,7 @@ import com.qiwu.chatbotbackend.processing.UserInfoController;
import
javax.servlet.ServletContext
;
import
java.io.IOException
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
import
static
com
.
qiwu
.
chatbotbackend
.
Config
.
Config
.
CONFIG_INSERT_ERROR
;
...
...
@@ -90,15 +87,12 @@ public class ConfigTermUtils {
List
<
Premise
>
curPremiseList
=
new
ArrayList
<
Premise
>();
List
<
Premise
>
hisPremiseList
=
new
ArrayList
<
Premise
>();
Map
<
String
,
String
>
updateKnowledge
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
punctReplaceMap
=
new
HashMap
<
String
,
String
>(){
{
put
(
","
,
","
);
put
(
"|"
,
""
);
put
(
"\r\n"
,
""
);
put
(
"\n"
,
""
);
put
(
"\t"
,
""
);
}
};
Map
<
String
,
String
>
punctReplaceMap
=
new
LinkedHashMap
<
String
,
String
>();
punctReplaceMap
.
put
(
","
,
","
);
punctReplaceMap
.
put
(
"|"
,
""
);
punctReplaceMap
.
put
(
"\r\n"
,
""
);
punctReplaceMap
.
put
(
"\n"
,
""
);
punctReplaceMap
.
put
(
"\t"
,
""
);
//解析当前信息的前置条件
...
...
@@ -307,7 +301,7 @@ public class ConfigTermUtils {
* @param replaceMap
* @return
*/
public
String
textReplace
(
String
text
,
Map
<
String
,
String
>
replaceMap
){
public
static
String
textReplace
(
String
text
,
Map
<
String
,
String
>
replaceMap
){
for
(
String
key:
replaceMap
.
keySet
()){
text
=
text
.
replace
(
key
,
replaceMap
.
get
(
key
));
}
...
...
src/main/java/com/qiwu/chatbotbackend/db/SqlHelper.java
View file @
03aaeb43
...
...
@@ -798,14 +798,15 @@ public class SqlHelper {
boolean
b
;
try
{
String
sql
=
"update chatbot_condition set conditionData = ?, actionText = ?, categoryInfo = ?, active = ? where botId = ? and conditionId=?"
;
String
sql
=
"update chatbot_condition set conditionData = ?, actionText = ?, categoryInfo = ?, active = ?
, displayOrder = ?
where botId = ? and conditionId=?"
;
PreparedStatement
ps1
=
conn
.
prepareStatement
(
sql
);
ps1
.
setString
(
1
,
condition
.
getConditionJsonText
());
ps1
.
setString
(
2
,
condition
.
getActionText
());
ps1
.
setString
(
3
,
condition
.
getCategory
());
ps1
.
setString
(
4
,
condition
.
getActive
());
ps1
.
setInt
(
5
,
condition
.
getBotId
());
ps1
.
setInt
(
6
,
condition
.
getConditionId
());
ps1
.
setInt
(
5
,
condition
.
getDisplayOrder
());
ps1
.
setInt
(
6
,
condition
.
getBotId
());
ps1
.
setInt
(
7
,
condition
.
getConditionId
());
b
=
ps1
.
executeUpdate
()
==
1
;
ps1
.
close
();
...
...
@@ -1085,6 +1086,29 @@ public class SqlHelper {
}
}
public
boolean
deleteConditionByBotId
(
int
botId
)
{
String
sql
=
"delete from chatbot_condition where botId= ?"
;
boolean
b
;
try
{
PreparedStatement
ps
=
conn
.
prepareStatement
(
sql
);
ps
.
setString
(
1
,
String
.
valueOf
(
botId
));
b
=
ps
.
executeUpdate
()
==
1
;
ps
.
close
();
return
b
;
}
catch
(
SQLException
e
)
{
System
.
out
.
println
(
DELETE_OLD_CATEGORY_ERROR
);
e
.
printStackTrace
();
return
false
;
}
}
public
boolean
batchInsertVariableByBotId
(
int
botId
,
ElementConstructor
constructor
)
{
int
count
[];
...
...
@@ -1103,6 +1127,10 @@ public class SqlHelper {
while
(
iit
.
hasNext
())
{
varName
=
iit
.
next
();
varValue
=
constructor
.
getVarInitialMap
().
get
(
varName
);
//unknown文本可能特别长,就不插入数据库了
if
(
varValue
.
length
()
>
8000
)
continue
;
if
(
constructor
.
getConditionDescription
().
get
(
varName
)
==
null
)
description
=
""
;
else
...
...
@@ -1303,7 +1331,7 @@ public class SqlHelper {
varName
=
iit
.
next
();
nameList
.
add
(
varName
);
ps
.
set
String
(
1
,
String
.
valueOf
(
botId
)
);
ps
.
set
Int
(
1
,
botId
);
ps
.
setString
(
2
,
varName
);
ps
.
addBatch
();
}
...
...
@@ -1348,7 +1376,7 @@ public class SqlHelper {
}
public
JSONObject
queryGameElementsBy
Bo
tId
(
int
id
)
{
public
JSONObject
queryGameElementsBy
Projec
tId
(
int
id
)
{
String
sql
=
"select * from generate_json_tb where project_id = ?"
;
String
userName
=
""
;
String
result
=
"{}"
;
...
...
src/main/java/com/qiwu/chatbotbackend/entity/ChatCache.java
View file @
03aaeb43
...
...
@@ -93,6 +93,10 @@ public class ChatCache implements DisposableBean {
}
public
ChatCache
(
UserInfo
userInfo
,
String
userKey
,
String
randKey
,
String
botType
)
throws
Exception
{
String
k
;
this
.
botAccount
=
userInfo
.
botAccount
;
this
.
infoPoint
=
new
HashMap
<
String
,
String
>();
if
(
botType
.
equals
(
"game"
))
{
try
{
...
...
@@ -100,15 +104,12 @@ public class ChatCache implements DisposableBean {
System
.
out
.
println
(
"初始化时:"
+
this
.
gameEnv
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
ENV_ERROR
);
this
.
infoPoint
.
put
(
"error_message"
,
ENV_ERROR
);
e
.
printStackTrace
();
}
}
String
k
;
this
.
botAccount
=
userInfo
.
botAccount
;
this
.
infoPoint
=
new
HashMap
<
String
,
String
>();
Iterator
<
String
>
iit
=
userInfo
.
varInitialMap
.
keySet
().
iterator
();
while
(
iit
.
hasNext
())
{
k
=
iit
.
next
();
...
...
src/main/java/com/qiwu/chatbotbackend/gameDesign/CharacterConstructor.java
View file @
03aaeb43
...
...
@@ -3,10 +3,12 @@ package com.qiwu.chatbotbackend.gameDesign;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.qiwu.chatbotbackend.db.SqlHelper
;
import
com.qiwu.chatbotbackend.entity.ConfigTermText
;
import
com.qiwu.chatbotbackend.entity.UserInfo
;
import
java.util.*
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
public
class
CharacterConstructor
extends
ElementConstructor
{
...
...
@@ -39,7 +41,7 @@ public class CharacterConstructor extends ElementConstructor {
copyPattern
(
"HOW_FIND_NPC"
);
copyPattern
(
"NPC_LOCATION"
);
copyPattern
(
"A
OUR
ND_NPC_CLASS"
);
copyPattern
(
"A
ROU
ND_NPC_CLASS"
);
copyPattern
(
"NPC_ATTR"
);
copyPattern
(
"WHO_YOU_ARE"
);
...
...
@@ -94,7 +96,7 @@ public class CharacterConstructor extends ElementConstructor {
classSet
.
add
(
className
);
//替换后的名字改为类名
replaceList
.
get
(
0
)[
1
]
=
className
;
appendReplacedKeyword
(
"A
OUR
ND_NPC_CLASS"
,
replaceList
);
appendReplacedKeyword
(
"A
ROU
ND_NPC_CLASS"
,
replaceList
);
}
...
...
@@ -129,13 +131,13 @@ public class CharacterConstructor extends ElementConstructor {
//同时识别zainali和wenzainali
configTermText
=
new
ConfigTermText
(
"zainali::match-Include="
+
keywordMap
.
get
(
"WHERE_I_AM_zainali"
)
+
","
+
"wenzainali::match-Keyword="
+
keywordMap
.
get
(
"NPC_LOCATION_wenzainali"
).
toString
(),
" "
,
"match,return-0"
,
""
,
"yaobuyao"
,
"npc_query:queryLocationByConditionName:wenzainali"
);
ConfigTermText
.
activateCopy
(
configTermText
,
configTermTextList
,
"npc"
);
//
//同时识别zainali和wenzainali
//
configTermText = new ConfigTermText(
//
"zainali::match-Include=" + keywordMap.get("WHERE_I_AM_zainali") + "," +
//
"wenzainali::match-Keyword=" + keywordMap.get("NPC_LOCATION_wenzainali").toString(), " ",
//
"match,return-0", "", "yaobuyao", "npc_query:queryLocationByConditionName:wenzainali"
//
);
//
ConfigTermText.activateCopy(configTermText, configTermTextList, "npc");
//根据根据NPC的名字查询地点
queryTypeConfigTermGenerate
(
keywordMap
,
"NPC_LOCATION"
,
"npc"
,
"queryLocationByConditionName"
);
...
...
@@ -145,7 +147,7 @@ public class CharacterConstructor extends ElementConstructor {
//根据根据NPC类别和地点属性查询所有NPC实例
queryTypeConfigTermGenerate
(
keywordMap
,
"A
OUR
ND_NPC_CLASS"
,
"npc"
,
"queryAroundNpcByClassName"
);
queryTypeConfigTermGenerate
(
keywordMap
,
"A
ROU
ND_NPC_CLASS"
,
"npc"
,
"queryAroundNpcByClassName"
);
//根据类名查询周围所有实例
...
...
src/main/java/com/qiwu/chatbotbackend/gameDesign/ItemConstructor.java
View file @
03aaeb43
...
...
@@ -3,7 +3,6 @@ package com.qiwu.chatbotbackend.gameDesign;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.qiwu.chatbotbackend.db.SqlHelper
;
import
com.qiwu.chatbotbackend.entity.ConfigTermText
;
import
com.qiwu.chatbotbackend.entity.UserInfo
;
import
java.util.*
;
...
...
@@ -100,12 +99,12 @@ public class ItemConstructor extends ElementConstructor {
}
configTermText
=
new
ConfigTermText
(
"zainali::match-Include="
+
keywordMap
.
get
(
"WHERE_I_AM_zainali"
)
+
","
+
"wenzainali::match-Keyword="
+
keywordMap
.
get
(
"ITEM_LOCATION_wenzainali"
).
toString
(),
" "
,
"match,return-0"
,
""
,
"yaobuyao"
,
"goods_query:queryLocationByConditionName:wenzainali"
);
ConfigTermText
.
activateCopy
(
configTermText
,
configTermTextList
,
"item"
);
//
configTermText = new ConfigTermText(
//
"zainali::match-Include=" + keywordMap.get("WHERE_I_AM_zainali") + "," +
//
"wenzainali::match-Keyword=" + keywordMap.get("ITEM_LOCATION_wenzainali").toString(), " ",
//
"match,return-0", "", "yaobuyao", "goods_query:queryLocationByConditionName:wenzainali"
//
);
//
ConfigTermText.activateCopy(configTermText, configTermTextList, "item");
queryTypeConfigTermGenerate
(
keywordMap
,
"ITEM_LOCATION"
,
"goods"
,
"queryLocationByConditionName"
);
...
...
src/main/java/com/qiwu/chatbotbackend/gameDesign/MapConstructor.java
View file @
03aaeb43
...
...
@@ -141,7 +141,7 @@ public class MapConstructor extends ElementConstructor {
queryTypeConfigTermGenerate
(
keywordMap
,
"AROUND_THINGS"
,
"map"
,
"queryAroundAllBySite"
);
queryTypeConfigTermGenerate
(
keywordMap
,
"AROUND_PLACE"
,
"map"
,
"queryAroundPlace"
);
queryTypeConfigTermGenerate
(
keywordMap
,
"WHO_IN_THERE"
,
"map"
,
"queryInnerNpcBySite"
);
//
queryTypeConfigTermGenerate(keywordMap, "WHO_IN_THERE", "map", "queryInnerNpcBySite");
queryTypeConfigTermGenerate
(
keywordMap
,
"TASK_IS_WHAT"
,
"map"
,
"queryTaskDescription"
);
queryTypeConfigTermGenerate
(
keywordMap
,
"WHAT_THINGS_IN_LOCATION"
,
"map"
,
"queryItemsInPlace"
);
...
...
src/main/java/com/qiwu/chatbotbackend/gameDesign/PlotConstructor2.java
View file @
03aaeb43
This diff is collapsed.
Click to expand it.
src/main/java/com/qiwu/chatbotbackend/processing/ActionMatcher.java
View file @
03aaeb43
...
...
@@ -19,10 +19,6 @@ public class ActionMatcher {
Map
<
Integer
,
Action
>
activatedMap
=
new
HashMap
<
Integer
,
Action
>();
static
String
POST_DATA_ERROR
=
"post数据有误"
;
static
String
POST_ERROR
=
"数据post时出错了"
;
static
String
API_ERROR
=
"api处理过程中出错了"
;
public
LogWriter
logWriter
=
null
;
public
UserInfo
userinfo
=
null
;
...
...
src/main/java/com/qiwu/chatbotbackend/processing/ChatCacheController.java
View file @
03aaeb43
...
...
@@ -17,9 +17,10 @@ import java.util.HashMap;
import
java.util.Iterator
;
import
java.util.Map
;
import
static
com
.
qiwu
.
chatbotbackend
.
Config
.
Config
.
CHATCACHE_TIME_OUT
;
public
class
ChatCacheController
{
public
static
long
TIME_OUT
=
300000
;
public
static
String
CHAT_CACHE_DIR
=
"ChatCache/"
;
...
...
@@ -198,7 +199,7 @@ public class ChatCacheController {
history
=
chatCacheMap
.
get
(
sessionKey
).
getInfoPoint
();
lastChatTime
=
Long
.
valueOf
(
history
.
get
(
"lastUpdateTime"
));
now
=
System
.
currentTimeMillis
();
if
(
now
-
lastChatTime
>
C
hatCacheController
.
TIME_OUT
)
{
if
(
now
-
lastChatTime
>
C
HATCACHE_
TIME_OUT
)
{
chatCache
=
chatCacheMap
.
get
(
sessionKey
);
if
(
chatCache
!=
null
&&
!
chatCache
.
getRandKey
().
equals
(
chatCache
.
getUserKey
())
&&
chatCache
.
isGameStart
())
{
...
...
src/main/java/com/qiwu/chatbotbackend/processing/FormsPoster.java
View file @
03aaeb43
...
...
@@ -16,6 +16,8 @@ import java.util.*;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
static
com
.
qiwu
.
chatbotbackend
.
Config
.
Config
.
QA_FETCH_ERROR
;
public
class
FormsPoster
{
...
...
@@ -63,7 +65,6 @@ public class FormsPoster {
while
(
k_iter
.
hasNext
())
{
key
=
k_iter
.
next
();
if
(
curInfoPoint
.
get
(
key
)
!=
null
&&
!
curInfoPoint
.
get
(
key
).
equals
(
""
))
//infoMap.put(key + "_cur", curInfoPoint.get(key)[0]);
pairList
.
add
(
new
BasicNameValuePair
(
key
,
curInfoPoint
.
get
(
key
)));
}
...
...
@@ -217,29 +218,34 @@ public class FormsPoster {
String
text
,
score
,
site
=
historyInfoPoint
.
get
(
"site"
),
npc
;
System
.
out
.
println
(
jobj
.
toJSONString
());
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
);
for
(
JSONArray
pair:
candidates
){
List
textscore
=
JSON
.
toJavaObject
(
pair
,
List
.
class
);
try
{
for
(
JSONArray
pair
:
candidates
)
{
List
textscore
=
JSON
.
toJavaObject
(
pair
,
List
.
class
);
Pattern
findTalker
=
Pattern
.
compile
(
TALKER
);
Pattern
findTalker
=
Pattern
.
compile
(
TALKER
);
if
((
Integer
)
textscore
.
get
(
1
)
>
90
)
{
Matcher
m
=
findTalker
.
matcher
((
String
)
textscore
.
get
(
0
));
if
(
m
.
find
())
{
npc
=
m
.
group
(
1
);
if
((
Integer
)
textscore
.
get
(
1
)
>
90
)
{
Matcher
m
=
findTalker
.
matcher
((
String
)
textscore
.
get
(
0
));
if
(
m
.
find
())
{
npc
=
m
.
group
(
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
(
"qa_score"
,
String
.
valueOf
(
textscore
.
get
(
1
)));
break
;
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
(
"qa_score"
,
String
.
valueOf
(
textscore
.
get
(
1
)));
break
;
}
}
}
}
}
catch
(
Exception
e
){
historyInfoPoint
.
put
(
"common_answer"
,
QA_FETCH_ERROR
);
historyInfoPoint
.
put
(
"qa_score"
,
"99"
);
}
}
}
else
{
...
...
src/main/java/com/qiwu/chatbotbackend/servlet/FindCacheServlet.java
View file @
03aaeb43
...
...
@@ -28,6 +28,7 @@ public class FindCacheServlet extends HttpServlet {
exist
=
ChatCacheController
.
findChatCache
(
userKey
,
context
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
exist
=
false
;
}
JSONObject
responseJSONObject
=
new
JSONObject
();
...
...
src/main/java/com/qiwu/chatbotbackend/servlet/GameDesignServlet.java
View file @
03aaeb43
...
...
@@ -27,13 +27,12 @@ import java.util.*;
import
static
com
.
qiwu
.
chatbotbackend
.
Config
.
Config
.
GAME_CONDITION_CATEGORY
;
import
static
com
.
qiwu
.
chatbotbackend
.
Config
.
Config
.
GAME_WELCOME_TEXT
;
import
static
com
.
qiwu
.
chatbotbackend
.
Config
.
Config
.
KEYWORD_DIR
;
@WebServlet
(
name
=
"GameDesignServlet"
,
urlPatterns
=
{
"/gameDesign"
})
public
class
GameDesignServlet
extends
HttpServlet
{
String
POST_URL
=
"http://localhost:1111/conditionProcess"
;
String
KEYWORD_DIR
=
"keywords.txt"
;
//分组及其相应的id,id初始化为0, 新建分组成功后id会更新。
HashMap
<
String
,
Integer
>
categoryMap
=
new
HashMap
<
String
,
Integer
>(){
{
...
...
@@ -89,7 +88,7 @@ public class GameDesignServlet extends HttpServlet {
JSONObject
receiveParaneters
=
JSONObject
.
parseObject
(
jsonStr
);
dataId
=
(
Integer
)
receiveParaneters
.
get
(
"id"
);
JSONObject
gameElements
=
helper
.
queryGameElementsBy
Bo
tId
(
dataId
);
JSONObject
gameElements
=
helper
.
queryGameElementsBy
Projec
tId
(
dataId
);
gameElements
.
put
(
"auth"
,
request
.
getHeader
(
"authorization"
));
//System.out.println(gameElements.toJSONString());
...
...
@@ -172,6 +171,8 @@ public class GameDesignServlet extends HttpServlet {
}
helper
.
batchInsertConfigByBotId
(
botId
,
jsonList
,
idList
,
categoryMap
.
get
(
moduleName2
));
constructor
.
postProcessing
(
idList
,
categoryMap
.
get
(
moduleName2
));
constructor
.
generateConfigText
(
idList
);
...
...
@@ -214,10 +215,6 @@ public class GameDesignServlet extends HttpServlet {
}
}
helper
.
destroy
();
}
else
{
returnStatus
=
0
;
...
...
@@ -225,6 +222,8 @@ public class GameDesignServlet extends HttpServlet {
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
finally
{
helper
.
destroy
();
}
...
...
@@ -261,8 +260,10 @@ public class GameDesignServlet extends HttpServlet {
public
boolean
botInit
(
int
botId
,
String
botAccount
,
UserInfo
userInfo
,
SqlHelper
helper
)
throws
SQLException
,
IOException
{
boolean
deleteConfigFlag
=
helper
.
deleteConfigByBotId
(
botId
);
boolean
deleteVariableFlag
=
helper
.
deleteVariableByBotId
(
botId
);
boolean
deleteCategoryFlag
=
helper
.
deleteCategoryByBotId
(
botId
);
boolean
batchInsertCategoryFlag
=
helper
.
batchInsertCategoryByBotId
(
botId
,
categoryMap
);
boolean
insertCategoryFlag
=
helper
.
batchInsertCategoryByBotId
(
botId
,
categoryMap
);
boolean
deteteConditionFlag
=
helper
.
deleteConditionByBotId
(
botId
);
boolean
deleteArchiveFlag
=
ChatCacheController
.
deleteChatCache
(
helper
,
botAccount
);
...
...
@@ -295,8 +296,8 @@ public class GameDesignServlet extends HttpServlet {
actionPostData
.
put
(
"relationKeywords"
,
additionalKeywords
);
actionPostData
.
put
(
"botId"
,
gameElements
.
getInteger
(
"botId"
));
if
(
gameElements
.
getJSONArray
(
"conditionCategor
yIdList
"
)
!=
null
){
actionPostData
.
put
(
"conditionCategories"
,
gameElements
.
getJSONArray
(
"conditionCategor
yIdList
"
));
if
(
gameElements
.
getJSONArray
(
"conditionCategor
ies
"
)
!=
null
){
actionPostData
.
put
(
"conditionCategories"
,
gameElements
.
getJSONArray
(
"conditionCategor
ies
"
));
}
else
{
actionPostData
.
put
(
"conditionCategories"
,
new
JSONArray
(){
{
...
...
src/main/java/com/qiwu/chatbotbackend/servlet/GetAnswerServlet.java
View file @
03aaeb43
...
...
@@ -154,8 +154,6 @@ public class GetAnswerServlet extends HttpServlet {
matcher
.
appendDebugInfo
(
bestMatch
,
context
);
}
//if(userinfo.varInitialMap.get("infoTransferTime") != null && userinfo.varInitialMap.get("infoTransferTime").equals("after"))
matcher
.
infoTransfer
(
bestMatch
,
context
,
debugFlag
);
...
...
@@ -163,7 +161,7 @@ public class GetAnswerServlet extends HttpServlet {
//清理超时的用户数据
if
(
context
.
getAttribute
(
"cacheUpdateTime"
)
==
null
)
context
.
setAttribute
(
"cacheUpdateTime"
,
System
.
currentTimeMillis
());
if
(
System
.
currentTimeMillis
()
-
(
long
)
context
.
getAttribute
(
"cacheUpdateTime"
)
>
C
hatCacheController
.
TIME_OUT
)
{
if
(
System
.
currentTimeMillis
()
-
(
long
)
context
.
getAttribute
(
"cacheUpdateTime"
)
>
C
HATCACHE_
TIME_OUT
)
{
ChatCacheController
.
updateChatCache4Delete
(
chatKey
,
context
,
userinfo
);
context
.
setAttribute
(
"cacheUpdateTime"
,
System
.
currentTimeMillis
());
}
...
...
src/main/java/com/qiwu/chatbotbackend/task/utils/GameBotUtil.java
View file @
03aaeb43
...
...
@@ -156,9 +156,10 @@ public class GameBotUtil extends BasicBotUtil{
if
(
nameSeries
.
length
==
4
){
keyword
=
chatCache
.
getGameEnv
().
queryNpcAttrByNpcName
(
nameSeries
[
2
],
nameSeries
[
3
]);
}
else
if
(
nameSeries
.
length
==
3
){
if
(
nameSeries
[
1
].
equals
(
"玩家"
)
&&
nameSeries
[
2
].
equals
(
"物品栏"
))
{
if
(
nameSeries
[
2
].
equals
(
"物品栏"
))
{
//如果是物品栏就调用专门的函数查询物品栏的所有数据
StringBuffer
sb
=
new
StringBuffer
();
List
<
String
>
goods
=
chatCache
.
getGameEnv
().
queryGoodsByNpcName
(
"玩家"
);
List
<
String
>
goods
=
chatCache
.
getGameEnv
().
queryGoodsByNpcName
(
nameSeries
[
1
]
);
for
(
String
good
:
goods
)
{
sb
.
append
(
"+"
).
append
(
good
);
}
...
...
@@ -415,6 +416,7 @@ public class GameBotUtil extends BasicBotUtil{
public
static
Matcher
findTalker
(
String
reply
){
System
.
out
.
println
(
reply
);
Pattern
findTalker
=
Pattern
.
compile
(
TALKER
);
Matcher
m
=
findTalker
.
matcher
(
reply
);
...
...
@@ -542,6 +544,7 @@ public class GameBotUtil extends BasicBotUtil{
case
"less_talker"
:
return
appendTalker
(
findRelateTalkers
(
false
).
get
(
0
),
reply
,
chatCache
.
getInfoPoint
(),
chatCache
.
getGameEnv
());
case
"to_unknown"
:
returnText
=
NO_ONE_CAN_REPLY_UNKNOWN
;
Set
<
String
>
candidates
=
new
HashSet
<
String
>();
Map
<
String
,
List
<
String
>>
npcTextMap
=
null
;
String
unknownList
=
""
,
foundNPC
;
...
...
src/main/resources/pro/c3p0-config.xml
View file @
03aaeb43
...
...
@@ -50,8 +50,8 @@
<property
name=
"password"
>
3g9^pWQs#ft7
</property>
<property
name=
"initialPoolSize"
>
3
</property>
<property
name=
"maxIdleTime"
>
30
</property>
<property
name=
"maxPoolSize"
>
1
0
</property>
<property
name=
"minPoolSize"
>
3
</property>
<property
name=
"maxPoolSize"
>
1
5
</property>
<property
name=
"minPoolSize"
>
5
</property>
<property
name=
"maxStatements"
>
200
</property>
</named-config>
...
...
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