Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 11 additions & 18 deletions mordecai/geoparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,26 +711,19 @@ def infer_country(self, doc):
proced = self.make_country_features(doc, require_maj=False)
if not proced:
pass
feat_list = []


for loc in proced:
feat = self.make_country_matrix(loc)
#print("feat:", feat)
#labels = loc['labels']
feat_list.append(feat)
#try:
# for each potential country...
for n, i in enumerate(feat_list):
labels = i['labels']
try:
prediction = self.country_model.predict(i['matrix']).transpose()[0]
ranks = prediction.argsort()[::-1]
labels = np.asarray(labels)[ranks]
prediction = prediction[ranks]
except ValueError:
print(traceback.print_exc())
prediction = np.array([0])
labels = np.array([""])
labels = feat['labels']
try:
prediction = self.country_model.predict(feat['matrix']).transpose()[0]
ranks = prediction.argsort()[::-1]
labels = np.asarray(labels)[ranks]
prediction = prediction[ranks]
except ValueError:
print(traceback.print_exc())
prediction = np.array([0])
labels = np.array([""])

loc['country_predicted'] = labels[0]
loc['country_conf'] = prediction[0]
Expand Down