yuzhimanhua / Multi-BioNER

Cross-type Biomedical Named Entity Recognition with Deep Multi-task Learning (Bioinformatics'19)
https://arxiv.org/abs/1801.09851
Apache License 2.0
132 stars 28 forks source link

seq_wc.py not working properly. #4

Closed mittalsarthak closed 5 years ago

mittalsarthak commented 5 years ago

I am trying to use seq_wc.py to prediction using the pre-trained model provided by you but in the output file, I am not getting results. It creates 5 output files but all of them are blank. Can you help me with this?

yuzhimanhua commented 5 years ago

Hi,

Thank you for pointing out the bug! I find that seq_wc.py always misses the LAST sentence in the testing file. So I guess you only put one sentence in your testing file (then there will be nothing in the results)? I will try to fix it ASAP. If you would like a simple and quick fix, please just "pad" one random sentence at the end of your testing file.

Thanks, Yu

mittalsarthak commented 5 years ago

Hi Yu, I have padded the input file with a sentence but now I am getting this error: Traceback (most recent call last):
File "seq_wc.py", line 89, in predictor.output_batch(ner_model, feature, fout, idx) File "/home/conan/experiment/exp/Multi-BioNER/model/predictor.py", line 143, in output_batch fout.write(self.decode_str(features[ind2], l) + '\n') File "/home/conan/experiment/exp/Multi-BioNER/model/predictor.py", line 46, in decode_l return '\n'.join(map(lambda t: t[0] + ' '+ self.r_l_map[t[1]], zip(feature, label))) File "/home/conan/experiment/exp/Multi-BioNER/model/predictor.py", line 46, in return '\n'.join(map(lambda t: t[0] + ' '+ self.r_l_map[t[1]], zip(feature, label))) KeyError: tensor(0)

yuzhimanhua commented 5 years ago

May I ask what PyTorch version you are using? This repo only supports PyTorch 0.3.

mittalsarthak commented 5 years ago

Hi Yu, I am using torch 1.1.0. But I have figured out the error. In predictor.py, I have made changes in decode_l function of predict class.

   def decode_l(self, feature, label):
       return '\n'.join(map(lambda t: t[0] + ' '+ self.r_l_map[t[1].item()], zip(feature, label)))