根据语法规则匹配句子
语法规则及交互树详见 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
- 编译语法树
- 由绿色节点content、NER结果构造AC自动机
- 由节点dropout规则生成节点nullable属性
- 对query进行匹配,得到绿色节点的匹配区间
- 在树上根据规则进行线段合并
python main.py -f data/rule.json -q data/del_demo/demo4.json
输出:
intent: 搜文章
delta: 3
query: 张宇韬是谁
match query: (张宇韬)是谁
remove node index: (151,)