-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.py
executable file
·39 lines (30 loc) · 1.05 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""
Encoding: utf-8
Author: April
Email: [email protected]
CreateTime: 2020-01-18 2:21
Description: test.py
Version: 1.0
"""
import time
from SensitiveWordFilter import DFAFilter
from SensitiveWordFilter import AcAutomationFilter
if __name__ == "__main__":
start_time = time.time()
"""
dfa_filter = DFAFilter()
dfa_filter.readFile("./data4sensitive/")
# dfa_filter.readFile("./data4sensitive/敏感词.txt")
# text = "在哪儿呢,你是不是傻逼,TMD找不到地方。"
text = "小爱同学你这个大傻x,这真的有气枪和炸药吗?这家微店。"
text_conver = dfa_filter.coverSensitive(text, "*")
print(text_conver)
text_check = dfa_filter.checkSentence(text)
print(text_check)
"""
ac_filter = AcAutomationFilter()
ac_filter.readFile("./data4sensitive/敏感词.txt")
text = "在哪儿新浪,你是习近平"
text_check = ac_filter.checkSentence(text)
print(text_check)
print('总共耗时:' + str(time.time() - start_time) + 's')