forked from Pinafore/qb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidate_annotations.py
41 lines (28 loc) · 1.05 KB
/
validate_annotations.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
from qanta import qlogging
from qanta.ingestion.answer_mapping import read_wiki_titles
from qanta.ingestion.annotated_mapping import PageAssigner
log = qlogging.get('validate_annotations')
def normalize(title):
return title.replace(' ', '_')
def check_page(page, titles):
n_page = normalize(page)
if n_page not in titles:
log.error(f'Title not found: {page}')
def main():
titles = read_wiki_titles()
assigner = PageAssigner()
log.info('Checking direct protobowl mappings...')
for page in assigner.protobowl_direct.values():
check_page(page, titles)
log.info('Checking direct quizdb mappings...')
for page in assigner.quizdb_direct.values():
check_page(page, titles)
log.info('Checking unambiguous mappings...')
for page in assigner.unambiguous.values():
check_page(page, titles)
log.info('Checking ambiguous mappings...')
for entry in assigner.ambiguous.values():
for option in entry:
check_page(option['page'], titles)
if __name__ == '__main__':
main()