Skip to content

Commit b82b4ee

Browse files
committed
Add wordnet version level to 'splits' dictionary
1 parent 87bb3dd commit b82b4ee

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

nltk/corpus/reader/wordnet.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,7 @@ def __init__(self, root, omw_reader):
12081208
# load the exception file data into memory
12091209
self._load_exception_map()
12101210

1211-
self.nomap = []
1211+
self.nomap = {}
12121212
self.splits = {}
12131213

12141214
# map from WordNet 3.0 for OMW data
@@ -1249,8 +1249,10 @@ def map_to_many(self, version="wordnet"):
12491249
synset_to_many[source].append(target)
12501250
return synset_to_many
12511251

1252-
def map_to_one(self):
1253-
synset_to_many = self.map_to_many()
1252+
def map_to_one(self, version="wordnet"):
1253+
self.nomap[version] = []
1254+
self.splits[version] = {}
1255+
synset_to_many = self.map_to_many(version)
12541256
synset_to_one = {}
12551257
for source in synset_to_many:
12561258
candidates_bag = synset_to_many[source]
@@ -1262,15 +1264,15 @@ def map_to_one(self):
12621264
counts = []
12631265
for candidate in candidates_set:
12641266
counts.append((candidates_bag.count(candidate), candidate))
1265-
self.splits[source] = counts
1267+
self.splits[version][source] = counts
12661268
target = max(counts)[1]
12671269
synset_to_one[source] = target
12681270
if source[-1] == "s":
12691271
# Add a mapping from "a" to target for applications like omw,
12701272
# where only Lithuanian and Slovak use the "s" ss_type.
12711273
synset_to_one[f"{source[:-1]}a"] = target
12721274
else:
1273-
self.nomap.append(source)
1275+
self.nomap[version].append(source)
12741276
return synset_to_one
12751277

12761278
def map_wn30(self):

0 commit comments

Comments
 (0)