uhh-lt / sensegram

Making sense embedding out of word embeddings using graph-based word sense induction
http://uhh-lt.github.io/sensegram
212 stars 50 forks source link

Recieving error 'Graph' object has no attribute 'node' #27

Closed samutamm closed 2 years ago

samutamm commented 4 years ago

I am using Python 3.7 and I installed dependencies, defined in requirements.txt.

I got following error, when launching the training with bash train.sh.

  File "train.py", line 114, in <module>
    main()
  File "train.py", line 87, in main
    word_sense_induction(neighbours_fpath, clusters_fpath, args.n, args.threads)
  File "train.py", line 19, in word_sense_induction
    ego_network_clustering(neighbours_fpath, clusters_fpath, max_related=n, num_cores=threads)
  File "/e/datasets/disambiguation/sensegram/word_sense_induction.py", line 82, in ego_network_clustering
    ["{}:{:.4f}".format(n,w) for w, n in sorted([(ego_network.node[c_node]["weight"]/WEIGHT_COEF, c_node) for c_node in cluster], reverse=True)]
  File "/e/datasets/disambiguation/sensegram/word_sense_induction.py", line 82, in <listcomp>
    ["{}:{:.4f}".format(n,w) for w, n in sorted([(ego_network.node[c_node]["weight"]/WEIGHT_COEF, c_node) for c_node in cluster], reverse=True)]
AttributeError: 'Graph' object has no attribute 'node'

It turns out that there is a newer version of NetworkX in chinese_whispers package. Now Graph.node is renamed to Graph.nodes.

Once I added that extra s, the training works as expected.