91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

知識圖譜實戰案例完全剖析(附完整源碼和數據集)Python與Neo4j的集成

資源截圖

代碼片段和文件信息

#?-*-?coding:?utf-8?-*-
#author:zhangziliang04@sina.com
import?aiml
import?ossys
from?py2neo?import?GraphNodeRelationship
#備注:這是演示程序,主要用來演示功能的調用關系,宗旨在于跑通,可以理解成,通用意義上的Helloword,而非工程實踐
#檢索知識圖譜
def?kgquery(?input):
????#?連接數據庫
????test_graph?=?Graph(“http://localhost:7474“?username=“neo4j“?password=“zhangzl“)
????#?查找節點
????find_code_1?=?test_graph.find_one(“歌手“?property_key=“name“?property_value=?input)
????return?find_code_1

if?__name__?==?‘__main__‘:
????#切換到語料庫所在工作目錄
????mybot_path?=?‘./resource‘
????os.chdir(mybot_path)
????#
????mybot?=?aiml.Kernel()
????mybot.learn(“startup.xml“)
????mybot.respond(‘load?jackson‘)
????#處理響應
????while?True:
????????input_message?=?raw_input(“Enter?your?message?>>?“)
????????if?len(input_message)?>?60:
????????????print?mybot.respond(“input?is?too?long?>?60“)
????????????continue
????????elif?input_message.strip()?==?‘‘:
????????????print?mybot.respond(“空“)
????????????continue

????????if?input_message?==?‘q‘:
????????????exit()
????????else:
????????????response?=?mybot.respond(input_message)
????????????if?response?==?““:
????????????????ans?=?mybot.respond(‘找不到答案‘)
????????????????print?ans
????????????#通過知識圖譜查詢
????????????elif?response[0]?==?‘#‘:
????????????????if?response.__contains__(“neo4j“):
????????????????????#獲取用戶輸入的變量
????????????????????res?=?response.split(‘:‘)
????????????????????#實體
????????????????????entity?=?str(res[1]).replace(“?“““)
????????????????????#屬性
????????????????????attr?=?str(res[2]).replace(“?“““)
????????????????????print?entity+‘<---->‘+attr
????????????????????ans?=?kgquery(entity)
????????????????????print?ans
????????????????#?匹配不到模版,通用查詢
????????????????elif?response.__contains__(“NoMatchingTemplate“):
????????????????????print?“NoMatchingTemplate“
????????????????????print?“搜索引擎查詢,此功能暫不支持“

????????????????#多答案選項選擇的策略:
????????????????if?len(ans)?==?0:
????????????????????ans?=?mybot.respond(‘找不到答案‘)
????????????????????print?‘Jackson:‘?+?ans
????????????????elif?len(ans)?>1?and??type(ans)?==?list:
????????????????????print?“不確定候選答案“
????????????????????print?‘Jackson:?‘
????????????????????for?a?in?ans:
????????????????????????print?a.encode(“utf8“)
????????????????else:
????????????????????print?ans
????????????#?匹配模版
????????????else:
????????????????print?‘Jackson:‘?+?response

????????#print?mybot.respond(raw_input(“Enter?your?message?>>?“))

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件????????459??2018-01-15?18:28??源碼2\kg\code\.idea\code.iml

?????文件????????200??2018-01-15?18:28??源碼2\kg\code\.idea\encodings.xml

?????文件????????228??2018-01-15?18:28??源碼2\kg\code\.idea\inspectionProfiles\profiles_settings.xml

?????文件????????212??2018-01-15?18:28??源碼2\kg\code\.idea\misc.xml

?????文件????????260??2018-01-15?18:28??源碼2\kg\code\.idea\modules.xml

?????文件??????27935??2018-01-18?08:08??源碼2\kg\code\.idea\workspace.xml

?????文件?????????46??2018-01-15?18:52??源碼2\kg\code\Readme.txt

?????文件???????2773??2018-01-16?10:56??源碼2\kg\code\src\Jackson.py

?????文件??????32802??2017-01-05?23:24??源碼2\kg\code\src\resource\alice.aiml

?????文件????????665??2018-01-15?21:59??源碼2\kg\code\src\resource\basic_chat.aiml

?????文件??????41968??2017-01-05?23:24??源碼2\kg\code\src\resource\en\alice\ai.aiml

?????文件??????32802??2017-01-05?23:24??源碼2\kg\code\src\resource\en\alice\alice.aiml

?????文件???????2441??2017-01-05?23:24??源碼2\kg\code\src\resource\en\alice\astrology.aiml

?????文件?????407214??2017-01-05?23:24??源碼2\kg\code\src\resource\en\alice\atomic.aiml

?????文件??????94417??2017-01-05?23:24??源碼2\kg\code\src\resource\en\alice\biography.aiml

?????文件?????434764??2017-01-05?23:24??源碼2\kg\code\src\resource\en\alice\bot.aiml

?????文件???????7777??2017-01-05?23:24??源碼2\kg\code\src\resource\en\alice\bot_profile.aiml

?????文件?????165320??2017-01-05?23:24??源碼2\kg\code\src\resource\en\alice\client.aiml

?????文件??????31111??2017-01-05?23:24??源碼2\kg\code\src\resource\en\alice\client_profile.aiml

?????文件??????22108??2017-01-05?23:24??源碼2\kg\code\src\resource\en\alice\computers.aiml

?????文件???????1765??2017-01-05?23:24??源碼2\kg\code\src\resource\en\alice\continuation.aiml

?????文件???????4265??2017-01-05?23:24??源碼2\kg\code\src\resource\en\alice\date.aiml

?????文件?????668020??2017-01-05?23:24??源碼2\kg\code\src\resource\en\alice\default.aiml

?????文件???????5258??2017-01-05?23:24??源碼2\kg\code\src\resource\en\alice\drugs.aiml

?????文件??????15537??2017-01-05?23:24??源碼2\kg\code\src\resource\en\alice\emotion.aiml

?????文件???????5550??2017-01-05?23:24??源碼2\kg\code\src\resource\en\alice\food.aiml

?????文件?????165156??2017-01-05?23:24??源碼2\kg\code\src\resource\en\alice\geography.aiml

?????文件??????10476??2017-01-05?23:24??源碼2\kg\code\src\resource\en\alice\gossip.aiml

?????文件???????1787??2017-01-05?23:24??源碼2\kg\code\src\resource\en\alice\history.aiml

?????文件??????11655??2017-01-05?23:24??源碼2\kg\code\src\resource\en\alice\humor.aiml

............此處省略869個文件信息

評論

共有 條評論