nltk icon indicating copy to clipboard operation
nltk copied to clipboard

Max depth of the all wordnet POS should be returned and kept as static

Open alvations opened this issue 5 years ago • 4 comments

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.

alvations avatar Apr 22 '19 02:04 alvations

Can I start working on this?

EeshitaBiswas avatar Sep 30 '19 23:09 EeshitaBiswas

Any update on this?

EeshitaBiswas avatar Oct 11 '19 22:10 EeshitaBiswas

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 avatar Oct 11 '19 22:10 alvations

@alvations So why is this not closed then?

Higgs32584 avatar Dec 17 '23 18:12 Higgs32584