nltk/nltk
View on GitHubMax depth of the all wordnet POS should be returned and kept as static
Open
#2,273 opened on Apr 22, 2019
enhancementgood first issuewordnet
Description
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.