Repository: nltk/nltk

Issue:
Senses lost in WordNet mappings
The Multilingual Wordnet uses WordNet 3.0 identifiers, and relies on mappings when used together with later wordnet versions.
However, a few WordNet 3.0 synsets are deprecated in these later versions, and thus _lost in the mapping_.
Presently, these cases lead to fatal errors. For example, one of the 3 senses of 'perceptible' in French was lost in WordNet 3.1, 
so the following outputs nothing, but raises a fatal error:

> from nltk.corpus import wordnet31 as wn
> print(wn.synsets('perceptible', lang='fra'))

This issue is analogous to #2982, because although only one of the 3 French senses of 'perceptible' was lost, the remaining 2 correct senses are also dropped, even when wrapping the call in a try-except construct.
However this issue is also different from #2982, and requires a different solution, because no WordNetError is raised, since the error is simply not handled by the wordnet.py module.

In WordNet 3.1, this problem occurs with the following OMW words:

| **Lang** | **Lost a sense in WordNet 3.1** |
| -------- | -------------------------------- |
| cat | endiablat, endimoniat, esperitat, posseït, possés |
| cmn | 埋伏着等待+的, 恶魔+的, 恶魔般+的, 狂暴+的, 着魔+的, 魔鬼+的 |
| fin | havaittava, pahojen_henkien_riivaama, riivattu, vaanimassa_oleva, villi |
| fra | obvie, perceptible |
| glg | frenético |
| ind | jelas, kejam, mengamuk, nyata, terang |
| ita | ovvio |
| jpn | 明らか, 明白 |
| lit | apsėstas, velniškas |
| pol | opętany |
| por | demoníaco, enlouquecido, espécie_de_alienação_com_tendência_à_prática_do_homicídio, fora_de_controle, possuído |
| ron | perceptibil, posedat |
| slk | démonický, diabolský, posadnutý, šialený, zúrivý |
| spa | obvio, perceptible |
| zsm | jelas, kejam, kena_rasuk, ketara, mengamuk, nyata, terang |


Discussion:

Resolving patch:
diff --git a/nltk/corpus/reader/wordnet.py b/nltk/corpus/reader/wordnet.py
--- a/nltk/corpus/reader/wordnet.py
+++ b/nltk/corpus/reader/wordnet.py
@@ -493,7 +493,7 @@ def lemmas(self, lang="eng"):
         """Return all the lemma objects associated with the synset"""
         if lang == "eng":
             return self._lemmas
-        else:
+        elif self._name:
             self._wordnet_corpus_reader._load_lang_data(lang)
             lemmark = []
             lemmy = self.lemma_names(lang)
@@ -1526,12 +1526,15 @@ def synset_from_pos_and_offset(self, pos, offset):
         data_file_line = data_file.readline()
         # If valid, the offset equals the 8-digit 0-padded integer found at the start of the line:
         line_offset = data_file_line[:8]
-        if line_offset.isalnum() and offset == int(line_offset):
+        if (
+            line_offset.isalnum()
+            and line_offset == f"{'0'*(8-len(str(offset)))}{str(offset)}"
+        ):
             synset = self._synset_from_pos_and_line(pos, data_file_line)
             assert synset._offset == offset
             self._synset_offset_cache[pos][offset] = synset
         else:
-            synset = None
+            synset = Synset(self)
             warnings.warn(f"No WordNet synset found for pos={pos} at offset={offset}.")
         data_file.seek(0)
         return synset


Test patch: