Skip to content

Commit 557c2d0

Browse files
committed
Changes for #1
1 parent ff77605 commit 557c2d0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

wordnet/nltk.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from nltk.corpus.reader.wordnet import Synset
33
import re
44

5-
format_regexp = r'^\W*\((?P<pos>\w+)\)\W+(?P<stem>\w+)\W*\#\W*(?P<num>\d+)\W*\Z'
5+
format_regexp = r'^\W*\((?P<pos>\w+)\)\W+(?P<stem>\w.*)\W*\#\W*(?P<num>\d+)\W*\Z'
66

77
def candidates(keyword):
88
if not keyword:
@@ -18,7 +18,8 @@ def candidates(keyword):
1818

1919
def name_format(synset : Synset):
2020
data = synset.name().split(".")
21-
return f"({data[1]}) {data[0]}#{int(data[2])}"
21+
entry = ".".join(data[0:-2])
22+
return f"({data[-2]}) {entry}#{int(data[-1])}"
2223

2324
def normalize_keyword(keyword: str) -> str:
2425
matches = re.match(format_regexp, keyword)

0 commit comments

Comments
 (0)