Skip to content

Commit 012467e

Browse files
authored
Merge pull request #29 from /issues/28
fixes for issue #28
2 parents 4a32fa8 + e02723e commit 012467e

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

quickumls.py

+2
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,8 @@ def _get_all_matches(self, ngrams):
267267
n=self.ngram_length,
268268
similarity_name=self.similarity_name
269269
)
270+
if match_similarity == 0:
271+
continue
270272

271273
if not self._is_ok_semtype(semtypes):
272274
continue

toolbox.py

+5
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ def make_ngrams(s, n):
7171

7272

7373
def get_similarity(x, y, n, similarity_name):
74+
if len(x) == 0 or len(y) == 0:
75+
# we define similarity between two strings
76+
# to be 0 if any of the two is empty.
77+
return 0.
78+
7479
X, Y = set(make_ngrams(x, n)), set(make_ngrams(y, n))
7580
intersec = len(X.intersection(Y))
7681

0 commit comments

Comments
 (0)