-
Notifications
You must be signed in to change notification settings - Fork 4
/
lookup_irish.py
executable file
·44 lines (40 loc) · 1.5 KB
/
lookup_irish.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import argparse
from teanglann import get_teanglann_senses, assign_adjectival_variants
parser = argparse.ArgumentParser(
description="Lookup English definitions of Irish words from the wonderful "
"https://www.teanglann.ie/ and https://www.focloir.ie/")
arg = parser.add_argument
arg(
'-v', '--verbose',
help='List of matching words from foclóir '
'and full definition from teanglann',
action='store_true')
arg(
'irish-word',
help="Irish word to look up")
arg(
'--focloir-sort', '--foclóir-sort',
help="Loose ordering of definitions according to importance of GA word on foclóir.ie",
action='store_true'
)
if __name__ == '__main__':
args = vars(parser.parse_args())
if args:
GA = args['irish-word']
for sense in get_teanglann_senses(GA,
verbose=args['verbose'],
sort_by_foclóir=args['focloir_sort'],
format='bash'):
if sense['definitions']:
print()
print(sense['pos'], sense['gender'])
if 'genitive-plural' in sense:
print(sense['genitive-plural'])
if 'verbal-noun' in sense:
print(sense['verbal-noun'])
if 'Adjective' in sense['pos']:
print(assign_adjectival_variants(GA))
print('\n'.join(sense['definitions']))