Skip to content

Commit 650392d

Browse files
committed
新增语义分析
1 parent c63770d commit 650392d

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

semantic_analysis.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# coding=utf-8
2+
__author__ = 'zhanghe'
3+
4+
import re
5+
import json
6+
7+
8+
def compare_text(text_a, text_b):
9+
reg_a = '有(.+?)?'
10+
reg_b = '没(.+?)!'
11+
a_list = re.compile(reg_a, re.I).findall(text_a)
12+
b_list = re.compile(reg_b, re.I).findall(text_b)
13+
print json.dumps(a_list, ensure_ascii=False)
14+
print json.dumps(b_list, ensure_ascii=False)
15+
print(a_list == b_list)
16+
17+
18+
if __name__ == '__main__':
19+
compare_text('有卵用?', '没卵用!')
20+
21+
"""
22+
简单语义分析
23+
["卵用"]
24+
["卵用"]
25+
True
26+
"""

0 commit comments

Comments
 (0)