完成适配器化改造,所有上报数据统一、接口调用等都改成通过不同消息源的适配器来完成,插件和消息源的耦合

This commit is contained in:
Richard Chien
2017-02-15 15:52:18 +08:00
parent ecd446f057
commit 3508db348d
17 changed files with 383 additions and 221 deletions

View File

@ -19,12 +19,13 @@ def as_processor(keywords=None):
def parse_potential_commands(sentence):
segmentation = list(jieba.posseg.cut(sentence=sentence))
print('分词结果:', segmentation)
print('分词结果:', ['[' + s.flag + ']' + s.word for s in segmentation])
potential_commands = []
for processor in _processors:
processed = False
for regex in processor[0]:
for word, flag in segmentation:
for s in segmentation:
word, flag = s.word, s.flag
if re.search(regex, word):
result = processor[1](sentence, segmentation)
if result: