forked from philipperemy/name-dataset
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
35 lines (28 loc) · 831 Bytes
/
main.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
import os
import sys
from evaluate import read_dict_file
from names_dataset import NameDataset
def main():
m = NameDataset()
if os.path.isfile(sys.argv[1]):
words = read_dict_file(sys.argv[1])
else:
words = [sys.argv[1]]
# cheap word tokenizer.
words = ' '.join(words).replace('.', ' ').replace('?', ' ').replace('\'', ' ').split(' ')
output = ''
for word in words:
if m.search_first_name(word, use_upper_case=True):
output += '\e[44m'
output += word
output += '\e[0m'
elif m.search_last_name(word, use_upper_case=True):
output += '\e[46m'
output += word
output += '\e[0m'
else:
output += word
output += ' '
print(output)
if __name__ == '__main__':
main()