-
Notifications
You must be signed in to change notification settings - Fork 2
/
examples.py
40 lines (27 loc) · 1.02 KB
/
examples.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
import json
import pprint
from parstdex import Parstdex, settings
def examples():
# read all test inputs in Test folder
test_path = settings.ROOT_DIR + '/tests/data.json'
f = open(test_path, 'r', encoding='utf-8-sig')
test_data = json.load(f)
model = Parstdex(debug_mode=False)
result = {}
for testcase in test_data:
input_sentence = testcase['test_input']
result['sentence'] = input_sentence
# time_marker_extractor will return normalized sentence and time-date markers
spans = model.extract_span(input_sentence)
result['spans'] = spans
markers = model.extract_marker(input_sentence)
result['markers'] = markers
ners1 = model.extract_bio_tmp(input_sentence)
result['ner1'] = ners1
ners2 = model.extract_bio_dattim(input_sentence)
result['ner2'] = ners2
time_ml = model.extract_time_ml(input_sentence)
pprint.pprint(result,)
print(f"\u202b{time_ml}\u202c")
print("==" * 50)
examples()