getalp / disambiguate

Disambiguate is a tool for training and using state of the art neural WSD models
https://arxiv.org/abs/1905.05677
MIT License
58 stars 17 forks source link

How to use it in Python script instead of shell script. #22

Open mirfan899 opened 3 years ago

mirfan899 commented 3 years ago

Is there a way to use the model in Python script. I'm trying to do it but having lots of errors with modules importing etc.

mirfan899 commented 3 years ago

I have run the predict.py script successfully. But it seems there is a bug in the predictor. Here are parameters.

--data_path /home/irfan/PycharmProjects/disambiguate/model/model_wsd_train_sc_wngt_dev_random4000_clear_compress_bert_large_cased_transformer_2048_single --weights /home/irfan/PycharmProjects/disambiguate/model/model_wsd_train_sc_wngt_dev_random4000_clear_compress_bert_large_cased_transformer_2048_single/model_weights_wsd0

But when I type on the console and press enter it throws the following error.

he walked the dog

Traceback (most recent call last):
  File "/home/irfan/PycharmProjects/disambiguate/python/getalp/wsd/predict.py", line 31, in <module>
    main()
  File "/home/irfan/PycharmProjects/disambiguate/python/getalp/wsd/predict.py", line 27, in main
    predicter.predict(text)
  File "/home/irfan/PycharmProjects/disambiguate/python/getalp/wsd/predicter.py", line 67, in predict
    self.predict_and_output(ensemble, batch_x, batch_z, self.data_config.input_clear_text)
  File "/home/irfan/PycharmProjects/disambiguate/python/getalp/wsd/predicter.py", line 104, in predict_and_output
    batch_wsd = Predicter.generate_wsd_on_batch(output_wsd, batch_z)
  File "/home/irfan/PycharmProjects/disambiguate/python/getalp/wsd/predicter.py", line 166, in generate_wsd_on_batch
    batch_wsd.append(Predicter.generate_wsd_on_sample(output[i], batch_z[0][i]))
IndexError: index 1 is out of bounds for dimension 0 with size 1

Process finished with exit code 1
thornad commented 2 years ago

Same issue. How do I use it from Python to disambiguate a simple sentence like 'he walked the dog' ? Thank you.