Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Hussein committed Mar 20, 2017
1 parent db43968 commit d2f4eff
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
Empty file removed LNEx/_Dictionaries/__init__.py
Empty file.
4 changes: 2 additions & 2 deletions LNEx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ def extract(tweet):

return core.extract(tweet)

def set_connection_string(conn_str):
def elasticindex(conn_string, index_name):

osm_gazetteer.set_connection_string(conn_str)
osm_gazetteer.set_elasticindex_conn(conn_string, index_name)
26 changes: 18 additions & 8 deletions LNEx/osm_gazetteer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,34 @@
import gaz_augmentation_and_filtering

connection_string = ""
index_name = ""


def set_connection_string(cs):
def set_elasticindex_conn(cs, inn):
global connection_string
global index_name

connection_string = cs
index_name = inn


def search_index(bb):
Elasticsearch()

if connection_string == '':
raise Exception(
'You need to define the host and port of the elastic index!')
if connection_string == '' or index_name == '':

print "\n###########################################################"
print "Global ERROR: Elastic host and port or index name not defined"
print "#############################################################\n"
exit()

if not geo_calculations.is_bb_acceptable(
bb) or bb[0] > bb[2] or bb[1] > bb[3]:
raise Exception(
'The chosen Bounding Box is too big, you should choose a smaller one!')

print "\n##########################################################"
print "Global ERROR: Bounding Box is too big, choose a smaller one!"
print "############################################################\n"
exit()

connections.create_connection(hosts=[connection_string], timeout=20)

Expand All @@ -60,7 +69,7 @@ def search_index(bb):
})]

# to search with a scroll
e_search = Search(index="photon_v1").query(Q('bool', must=phrase_search))
e_search = Search(index=index_name).query(Q('bool', must=phrase_search))

try:
res = e_search.scan()
Expand Down Expand Up @@ -161,7 +170,8 @@ def build_bb_gazetteer(bb):
13.2823848224, 80.3464508057]

connection_string = '130.108.85.186:9200'
index_name = "photon_v1"

set_connection_string(connection_string)
set_elasticindex_conn(connection_string, index_name)

geo_locations, geo_info, extended_words3 = build_bb_gazetteer(chennai_bb)
1 change: 0 additions & 1 deletion release.INFO

This file was deleted.

2 changes: 1 addition & 1 deletion test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def run_test_using_files():

def run_text_using_elasticindex():

lnex.set_connection_string('130.108.85.186:9200')
lnex.elasticindex(conn_string='130.108.85.186:9200', index_name="photon_v1")

# chennai flood bounding box
chennai_bb = [12.74, 80.066986084, 13.2823848224, 80.3464508057]
Expand Down

0 comments on commit d2f4eff

Please sign in to comment.