Skip to content

wzyjerry/sentence-matcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sentence-matcher 0.3.0

根据语法规则匹配句子

语法规则及交互树详见 interactive-syntax-tree


输入

语法树,通过-f参数传入,格式如下:

{
    "type": "root",
    "children": [{
        "type":"intent",
        "weight":1,
        "intent":"intent 1",
        ...
    },
    ...]
}

待匹配的句子,已进行过NER,通过-q参数传入,格式如下:

{
  "query": "which are ORG1 DATE1 PER1 's CON2 papers related to KEY2 from done at DATE1 published on CON2",
  "entities": {
    "5bfe132cc4952f342f394a48": ["KEY2"],
    "5bfe137dc4952f342f394a49": ["ORG1"],
    "5bfe0ef9c4952f342f394a44": ["DATE1"],
    "5bfe111cc4952f342f394a45": ["CON2"],
    "5bfe127cc4952f342f394a47": ["PER1"]
  }
}

输出

intent | delta | query | match query | remove node index


算法步骤

  1. 编译语法树
  2. 由绿色节点content、NER结果构造AC自动机
  3. 由节点dropout规则生成节点nullable属性
  4. 对query进行匹配,得到绿色节点的匹配区间
  5. 在树上根据规则进行线段合并

示例

python main.py -f data/rule.json -q data/del_demo/demo4.json

输出:
intent: 搜文章
delta: 3
query: 张宇韬是谁
match query: (张宇韬)是谁
remove node index: (151,)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages