Skip to content

Commit 54dc31a

Browse files
committed
minor bug for checking words in paraphrase database
1 parent ba12b27 commit 54dc31a

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

monolingualWordAligner/wordsim.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env python
12

23
from config import *
34
from Resources import *
@@ -19,7 +20,7 @@ def __init__(self):
1920
Append tokens with similarity score(0.9)
2021
'''
2122

22-
23+
2324
def load_paraphraseDatabase(self, FileName = 'Resources/ppdb-1.0-xxxl-lexical.extended.synonyms.uniquepairs'):
2425

2526
file = open(FileName,'r')
@@ -33,6 +34,7 @@ def load_paraphraseDatabase(self, FileName = 'Resources/ppdb-1.0-xxxl-lexical.ex
3334
tokens[1] = tokens[1].strip()
3435
self.ppdbDict[(tokens[0], tokens[1])] = self.ppdbSim
3536
count += 1
37+
# print count
3638

3739

3840
'''
@@ -43,12 +45,11 @@ def load_paraphraseDatabase(self, FileName = 'Resources/ppdb-1.0-xxxl-lexical.ex
4345

4446
def checkWordPresentInDataBase(self, word1, word2):
4547

46-
if (word1.lower(), word2.lower()) in ppdbDict:
4748

49+
if (word1.lower(), word2.lower()) in self.ppdbDict:
4850
return True
4951

50-
if (word1.lower(), word2.lower()) in ppdbDict:
51-
52+
if (word2.lower(), word1.lower()) in self.ppdbDict:
5253
return True
5354

5455

@@ -64,6 +65,7 @@ def checkWordPresentInDataBase(self, word1, word2):
6465
vii. If both the words are present in PPDB then return then PPDBSim(similarity score)(0.9)
6566
6667
Returns: similarity score between two words
68+
6769
'''
6870

6971

@@ -82,11 +84,13 @@ def computeWordSimilarityScore(self, word1, pos1, word2, pos2):
8284
modifiedWord2 = word2.replace(',','')
8385
else:
8486
modifiedWord2 = word2
85-
87+
8688
if modifiedWord1.lower() == modifiedWord2.lower():
89+
# print "words exactly equal "
8790
return 1
8891

8992
if self.stemmer.stem(word1).lower() == self.stemmer.stem(word2).lower():
93+
# print "stemma exactly equal "
9094
return 1
9195

9296
if modifiedWord1.isdigit() and modifiedWord2.isdigit() and modifiedWord1 != modifiedWord2:
@@ -108,7 +112,7 @@ def computeWordSimilarityScore(self, word1, pos1, word2, pos2):
108112
#check words in database
109113

110114
if self.checkWordPresentInDataBase(word1.lower(), word2.lower()):
111-
return ppdbSim
115+
return self.ppdbSim
112116

113117
else:
114118
return 0

0 commit comments

Comments
 (0)