-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSemanticTest.py
More file actions
34 lines (34 loc) · 1.2 KB
/
SemanticTest.py
File metadata and controls
34 lines (34 loc) · 1.2 KB
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
import contextlib
import datetime
now = datetime.datetime.now()
count_limit = 500
time_limit = float("inf")
name = f"{now.month}.{now.day} {now.hour}:{now.minute} count {count_limit} time {time_limit} TestLog.txt"
import SemanticExtraction
import CorpusBuilder
sents = CorpusBuilder.get_mixed(count_limit)
if count_limit > len(sents):
count_limit = len(sents)
import time
start_time = time.time()
count = 0
while time.time()-start_time < time_limit and count < count_limit:
print("======")
loop_time = time.time()
with open(name, 'a') as f:
with contextlib.redirect_stdout(f):
print(f"run {count}".center(50, "="))
# noinspection PyBroadException
try:
image = SemanticExtraction.extract(sents[count], True)
image_ascii = image.draw(None, None, force_ascii=True)
print(image_ascii)
print(image.to_networkx().number_of_edges())
print(image.iterate())
except Exception as e:
print(str(e))
print(f"end {time.time()-loop_time}".center(50, "="))
count += 1
print(count)
end_time = time.time()
print(f"average runtime: {(start_time-end_time)/count}")