nltk
nltk copied to clipboard
Max depth of the all wordnet POS should be returned and kept as static
The _compute_max_depth()
used for lch_similarity()
returns None
regardless of POS :
from nltk.corpus import wordnet as nltk_wn
from nltk.corpus.reader.wordnet import POS_LIST
for pos in POS_LIST:
print(pos,
nltk_wn._compute_max_depth(pos, simulate_root=True),
nltk_wn._compute_max_depth(pos, simulate_root=False))
print(pos, nltk_wn._max_depth)
[out]:
n None None
n defaultdict(<class 'dict'>, {'v': 12, 'a': 0, 'r': 0, 'n': 19})
v None None
v defaultdict(<class 'dict'>, {'v': 12, 'a': 0, 'r': 0, 'n': 19})
a None None
a defaultdict(<class 'dict'>, {'v': 12, 'a': 0, 'r': 0, 'n': 19})
r None None
r defaultdict(<class 'dict'>, {'v': 12, 'a': 0, 'r': 0, 'n': 19})
The self._compute_max_depth
doesn't return anything, my suggestion is to expose it as a public function and let it return the depth while setting the max depth.
Another point is that the max_depth
will call the all_synsets()
once and this is costly, it could be saved as static value from the start and access to the integer would be much simpler.
Can I start working on this?
Any update on this?
Actually this is already fixed in https://github.com/nltk/wordnet , we're still looking at how to integrate the stand-alone library without breaking existing usage in the main nltk library.
@alvations So why is this not closed then?