-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.py
37 lines (30 loc) · 1.05 KB
/
utils.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
import logging
import os
import re
import geocoder
os.environ["GOOGLE_API_KEY"] = "api_key_from_google_cloud_platform"
logging.basicConfig(level=logging.INFO)
class Utils:
stop_words = ['i', 'am', 'we', 'are', 'he', 'she', 'is', 'they', 'was', 'where', 'do', 'does', 'did', 'done', 'has',
'have', 'had', 'be', 'been']
@staticmethod
def regex_checker(string, reg):
prog = re.compile(reg)
return prog.match(string)
@staticmethod
def noun_resolver(string):
geonames = geocoder.geonames(string, maxRows=5, key='e_hamzei', fuzzy=1)
logging.info(geonames)
print([(r.address, r.country, r.latlng) for r in geonames])
if len(geonames) > 0:
return True
return False
# name = 'Melbourne'
# if Utils.noun_resolver(name):
# logging.info('{} is a place!'.format(name))
# name = 'Asdkq24'
# if Utils.noun_resolver(name):
# logging.info('{} is a place!'.format(name))
# name = 'green'
# if Utils.noun_resolver(name):
# logging.info('{} is a place!'.format(name))