I am trying to run the pretrained weights for keyphrase extraction on string, trying to follow the example from inference.ipynb. I kept all the parameters as same in the jupiter notebook, besides explicitly passing the text_to_extract as defined below. I downloaded the pretrained weights from the link in the readme.
Running the method:
text_to_extract="Anything that threatens a company's ability to meet its target or achieve its financial goals is called business risk. These risks come from a variety of sources, so it's not always the company head or a manager who's to blame. Instead, the risks may come from other sources within the firm or they may be external—from regulations to the overall economy. While a company may not be able to shelter itself from risk completely, there are ways it can help protect itself from the effects of business risk, primarily by adopting a risk management strategy"
scores, predictions = translator.translate(
src=[text_to_extract],tgt=None,src_dir=opt.src_dir,batch_size=opt.batch_size,attn_debug=opt.attn_debug,opt=opt)
Error:
It looks like the translator method can only accept json files since it uses keyphrase_dataset.py for reading the input rather than datareader_base.py
Traceback (most recent call last):
File "<stdin>", line 7, in <module>
File "/home/ayush/OpenNMT-kpg-release/onmt/translate/translator.py", line 335, in translate
filter_pred=self._filter_pred
File "/home/ayush/OpenNMT-kpg-release/onmt/inputters/keyphrase_dataset.py", line 92, in __init__
for ex_dict in starmap(_join_dicts, zip(*read_iters)):
File "/home/ayush/OpenNMT-kpg-release/onmt/inputters/keyphrase_dataset.py", line 155, in read
json_line = json_line.decode("utf-8")
AttributeError: 'str' object has no attribute 'decode'
What's the best approach to run the pretrained weights on input string ?
I am trying to run the pretrained weights for keyphrase extraction on string, trying to follow the example from inference.ipynb. I kept all the parameters as same in the jupiter notebook, besides explicitly passing the text_to_extract as defined below. I downloaded the pretrained weights from the link in the readme.
Running the method:
Error: It looks like the translator method can only accept json files since it uses keyphrase_dataset.py for reading the input rather than datareader_base.py
What's the best approach to run the pretrained weights on input string ?