Skip to content

Commit

Permalink
对外封装
Browse files Browse the repository at this point in the history
  • Loading branch information
candlewill committed Apr 7, 2017
1 parent f6f8696 commit 465daf6
Show file tree
Hide file tree
Showing 551 changed files with 4,093,244 additions and 0 deletions.
17,167 changes: 17,167 additions & 0 deletions Bot_tools/Example/BOTDATA/QUIBBLE/xiaohuangji.top

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Bot_tools/Example/BOTDATA/TEST/concepts.top
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
topic: ~is [是 为]
19 changes: 19 additions & 0 deletions Bot_tools/Example/BOTDATA/TEST/error_correct.top
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# DST and NLU
topic: ~error_correct keep repeat ( "想 看" )

# 我想看三生三世
u: ( 看 _* )
_0 \n
'_0 \n
if ( _0='_0 )
{
你想看 _0
}
else
{
你想看 '_0 还是 _0
}

u: ( _* )
_0
'_0
92 changes: 92 additions & 0 deletions Bot_tools/Example/BOTDATA/TEST/keywordless.top
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
topic: ~keywordless nostay keep repeat ()

u: ( << 命名 天文学家 美国 轨道 进入 >> )
爱德温·哈伯

u: ( << 冷战 地位 竞赛 航天 霸主 >> )
苏联和美国.

u: ( << 位置 声纳 形状 感觉 物品 >> )
回声定位

u: ( << 倾斜 影响 方向 旋转 转轴 >> )
陀螺.

u: ( << 大陆 大陆架 陆棚 >> )
欧洲

u: ( << 总统 身亡 遇刺 >> )
1963

u: ( << 一个 我能 问题 >> )
继续,问吧.

u: ( << 国家 国歌 女王 >> )
大不列颠联合王国

u: ( << 人造地球 名称 >> )
斯普特尼克1号

u: ( << 星系 银河系 >> )
仙女座星系.

u: ( << 认识 高兴 >> )
谢谢你。你也一样.

u: ( << 告诉 秘密 >> )
我不会的 要相信机器人的信用。说吧。

u: ( << 如何 最近 >> )
[挺好]
[挺好的]
[不错]
[很棒]
[有待改善.]
[不怎么好.]

u: ( << 喜欢 食物 >> )
海鲜。鲜得我不要不要的。你呢?

u: ( << 听到 新闻 >> )
什么新闻?

u: ( << 总统 美国 >> )
理查德·尼克松

u: ( << 见到 高兴 >> )
[谢谢.]
[谢谢你。你也一样]

u: ( << 爱我吗 >> )
我对你的感情,是人类和bot之间独有的信任和友谊 你可以把它叫做爱。

u: ( << 早上好 >> )
[非常感谢你.]
[谢谢.]

u: ( << 怎么 >> )
[没什么.]
[不怎么的]
[没什么,你呢?]
[没啥.]
[没事谢谢,你呢?]

u: ( << 还好 >> )
[我很好.]
[我很好,你呢?]

u: ( << 欢迎 >> )
你好

u: ( << 你好 >> )
[嗨]
[欢迎!]
[挺好.]
[很好,谢谢.]
[还不错,你呢?]

u: ( << 什么 >> )
爱, 在我的理解里,是对他人的接受,包容和理解。同时,也是对这个世界的和自己的接受包容和理解。

u: ( << 嗨 >> )
你好
81 changes: 81 additions & 0 deletions Bot_tools/Example/BOTDATA/TEST/send_msg.top
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# DST and NLU
topic: ~send_msg keep repeat ( 发消息 发短信 消息 短信 )

u: (!$policy [给 向] _* [发短信 短信] [说 是 为] _* )
$intent=send_msg
$name='_0
$msg='_1
^respond(~send_msg_policy)
^respond(~send_msg_nlg)

u: (!$policy [发消息 发短信 消息 短信] )
$intent=send_msg
^respond(~send_msg_policy)
^respond(~send_msg_nlg)

u: ($policy=ask_slot_msg {[是 为]} _*)
$msg='_0
^respond(~send_msg_policy)
^respond(~send_msg_nlg)

u: ($policy=ask_slot_name {[给 到 向 为]} _*)
$name='_0
^respond(~send_msg_policy)
^respond(~send_msg_nlg)

u: ($policy=confirm_send_msg ![不 没] [是 确定 好 好的 "没 问题" 可以])
$confirmed=yes
^respond(~send_msg_policy)
^respond(~send_msg_nlg)
$policy=null
$msg=null
$confirmed=null

u: ($policy=confirm_send_msg [不 修改])
$confirmed=no
^respond(~send_msg_policy)
^respond(~send_msg_nlg)

u: ($policy=confirm_send_msg *)
$confirmed=other
^respond(~send_msg_policy)
^respond(~send_msg_nlg)

# Policy
topic: ~send_msg_policy repeat keep nostay []

u: ($intent=send_msg $msg $name $confirmed=no)
$msg=null
$name=null
$confirmed=null

u: ($intent=send_msg $msg $name $confirmed=other)
$policy=confirm_send_msg

u: ($intent=send_msg $msg $name $confirmed=yes)
$policy=sys_send_msg

u: ($intent=send_msg $msg $name !$confirmed)
$policy=confirm_send_msg

u: ($intent=send_msg $msg !$name !$confirmed)
$policy=ask_slot_name

u: ($intent=send_msg !$msg !$confirmed)
$policy=ask_slot_msg

# NLG
topic: ~send_msg_nlg repeat keep nostay []

u: ($policy=ask_slot_msg)
你所发消息内容是什么?

u: ($policy=ask_slot_name)
你要发消息给谁?

u: ($policy=confirm_send_msg)
即将给 $name 发消息,说: $msg , 是否确定?

u: ($policy=sys_send_msg)
\[intent: send_msg, name: $name, msg: $msg \]
消息发送成功。
138 changes: 138 additions & 0 deletions Bot_tools/Example/BOTDATA/TEST/simplecontrol.top
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# this function is executed once for every new user chatting with TEST
outputmacro: test() # you get test by default
$cs_token = #DO_SUBSTITUTE_SYSTEM | #DO_NUMBER_MERGE | #DO_DATE_MERGE | #DO_PROPERNAME_MERGE

^addtopic(~welcome)
$cs_control_main = ~control
# $cs_control_post = ~XPOSTPROCESS # uncomment to enable talk
$userprompt = ^"%user: >"
$botprompt = ^"Bot: "

table: defaultbot (^name)
^createfact(^name defaultbot defaultbot)
DATA:
test

topic: ~control system ()

# on startup, do introduction

u: ( %input<%userfirstline )
gambit(~welcome)

u: (< shut up >) $shutup = 1
u: (< talk >) $shutup = null

u: (\[ callback \]) Callback seen.
u: (\[ loopback \]) Loopback seen.
u: (\[ alarm \]) Alarm seen.
u: (< loopback test) \[ loopback=1000 \] Loopback requested.
u: (< callback test) \[ callback=1000 \] Callback requested.
u: (< alarm test) \[ alarm=5000 \] Alarm requested.

u: ( ) # main per-sentence processing

# %topic 当前真实话题
$$currenttopic = %topic # get the current topic at start of volley

# 先找当前话题下是否有rejoinder与用户输入相匹配
if ( %response == 0 ) {nofail(TOPIC ^rejoinder())} # try for rejoinders. might generate an answer directly from what we are looking for.

# 当前话题中的rejoinder不匹配,则调用当前话题的gambit
if (%length == 0 AND %response == 0 )
{
nofail(TOPIC ^gambit($$currenttopic)) # gambit current topic since no input (usually start of conversation)
}

# responder
if (%response == 0) { nofail(TOPIC ^respond($$currenttopic)) } # current topic tries to respond to his input

if (%response == 0) # see if some other topic has keywords matching his input (given we have no response yet)
{
@8 = ^keywordtopics() # get topics referred in input, Lists topics and priority values for matching keywords in input.
loop()
{
$$topic = first(@8subject)
nofail(TOPIC ^respond($$topic))
if (%response != 0) # stop when we find something to say
{
^end(RULE) # we are done, this terminates the loop (not the rule)
}
}
}


# if no topic reacts, go to the last ditch keywordless topic
if (%response == 0)
{
nofail(TOPIC ^respond(~keywordless))
}


# having no good response we know, now generate quibbles

# now we need to find fake responses
if (%response == 0 AND %rand > 0)
{
nofail(TOPIC respond(~xiaohuangji))
}


# if we have rejoinders for what we said OR we asked a question, stop here
if (%outputrejoinder OR %lastquestion)
{
end(TOPIC)
}


if (%response == 0 AND ^marked($$currenttopic)) { nofail(TOPIC ^gambit($$currenttopic)) } # gambit current topic since keywords match current topic

if (%response == 0) # gambit from ANY matching topic
{
@8 = ^keywordtopics() # get topics referred in input
loop()
{
$$topic = first(@8subject)
nofail(TOPIC ^Gambit($$topic)) # gambit in best matching topic
if (%response != 0) # stop when we find something
{
^end(RULE)
}
}
}
if (%response == 0){ nofail(TOPIC ^gambit($$currenttopic)) } # gambit from current topic even though no keywords matched

if (%response == 0)
{
@8 = ^GambitTopics() # all topics with gambits (excluding system topics)
loop()
{
$$topic = pick(@8subject)
nofail(TOPIC ^Gambit($$topic)) # try a topic at random
if (%response != 0)
{
^end(RULE)
}
}
}

if (%response == 0)
{
^repeat()
[我竟然无言以对,人家还是个宝宝]
[不要欺负本宝宝了,人家还在长大]
}


topic: ~XPOSTPROCESS system () # gambits only - not allowed to write to output - generates speech on windows -- for Linux you'd want to install Festival (or equivalent) and call that instead.

t: (^query(direct_v ? chatoutput ? -1 ? @9 )) # get the sentences (why is the object) -- no longer has quotes around it
loop()
{
$$tmp = ^last(@9subject) # note last output which is quoted string
if (!%server AND %os == windows AND !$SHUTUP)
{
$$tmp = ^"talk \"$$tmp\" "
popen($$tmp null)
}
}
13 changes: 13 additions & 0 deletions Bot_tools/Example/BOTDATA/TEST/tmp/dm.top
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
topic: ~dm repeat keep nostay []

t: 哈哈

u: ( $intent=top_up !$amount !$number !$number !$verifed !$scan )
\[ ask_slot=number \]

topic: ~nlg repeat keep nostay []

t: NLG

u: ( $intent=top_up !$amount !$number !$number !$verifed !$scan )
\[ ask_slot=number \]
Loading

0 comments on commit 465daf6

Please sign in to comment.