-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
executable file
·127 lines (85 loc) · 2.46 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/usr/bin/env python3
"""
Tests out functionality as it is developed.
"""
import engine
import corpus.model
import corpus.entity
import tag.model
def setup():
tag.model.Schema().create()
corpus.model.Schema().create()
def teardown():
corpus.model.Schema().nuke()
tag.model.Schema().nuke()
def run(test, show=False):
if show is False:
eval(test)
else:
eval("print(" + str(test) + ")")
print()
def tag_pos_model(show=False):
model = tag.model.Pos()
run(model.single(1), show)
run(model.all(), show)
run(model.find("ADJ"), show)
run(model.search("CCON"), show)
def tag_dependency_model(show=False):
model = tag.model.Dependency()
run(model.single(1), show)
run(model.all(), show)
run(model.find("root"), show)
run(model.search("num"), show)
def tag_entity_model(show=False):
model = tag.model.Entity()
run(model.single(1), show)
run(model.all(), show)
run(model.find("DRV"), show)
run(model.search("GPE"), show)
def corpus_title_model(show=False):
model = corpus.model.Title()
model.add("The Monkey's Paw", "W. W. Jacobs")
model.add("Thurnley Abbey", "Perceval Landon")
run(model.single(1), show)
run(model.all(), show)
run(model.find("Thurnley Abbey"), show)
run(model.search("Abbey"), show)
def corpus_token_model(show=False):
model = corpus.model.Token()
model.add("Joe", "PROPN")
model.add("the", "DET")
run(model.single(1), show)
run(model.all(), show)
run(model.find("the", "DET"), show)
run(model.search("Joe"), show)
def corpus_breakup_model(show=False):
model = corpus.model.Breakup()
model.add("Thurnley Abbey", 0, 0, 0, "Joe", "PROPN")
model.add("The Monkey's Paw", 1, 1, 1, "the", "DET")
run(model.single(1), show)
run(model.all(), show)
run(model.find("The Monkey's Paw", 1, 1, 1, "the", "DET"), show)
run(model.search("the"), show)
def entity_analyzer():
"""
Tests the analyzer engine.
"""
doc = corpus.entity.Document(title="The Monkey's Paw",
author="W. W. Jacobs")
#doc.parse("sources/the-monkeys-paw.txt")
#doc.save()
doc.load()
print(doc.text())
if __name__ == '__main__':
#teardown()
#setup()
"""
tag_pos_model()
tag_dependency_model()
tag_entity_model()
corpus_title_model()
corpus_token_model()
corpus_breakup_model()
"""
entity_analyzer()
#teardown()