jakeywu / chinese_ner

中文实体抽取
https://www.aclweb.org/anthology/N16-1030
15 stars 3 forks source link

AttributeError: 'str' object has no attribute 'tolist' #1

Open mading0817 opened 6 years ago

mading0817 commented 6 years ago

Hi @jakeywu,

Thanks for your great project, the code is quite readable and efficient! I could successfully run the train_model.py and the model can be saved successfully as well. The problem is when I tried to run predict.py, it comes out a following error message: Traceback (most recent call last): File "E:/chinese_ner-master/chinese_ner-master/predict.py", line 70, in <module> predict = ner.batch_predict_ner() File "E:/chinese_ner-master/chinese_ner-master/predict.py", line 55, in batch_predict_ner sentence_ner.append(self.source_data[i].tolist()[j]) AttributeError: 'str' object has no attribute 'tolist'

Thanks again!

mading0817 commented 6 years ago

by the way, I was using tensorflow-gpu 1.10.0 with python 3.6.5

mading0817 commented 6 years ago

Hi,

I had to change line 59 in predict.py from: sentence_ner.append(self.source_data[i].tolist()[j]) to sentence_ner.append(self.source_data[i][j])

Then it could run successfully, but the result might be wrong: [ [ "美", "国", "团", "购" ], [ "美", "国", "团", "购" ] ]

decode_tags: decode: [[2 3 0 0 0 0 0 0 0 0 0 0 0 0 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [2 3 0 0 0 0 0 0 0 0 0 0 0 0 1 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]]``

The demo only shows how it recognize ORG, could you show me about how do I change for multiple entities recognition?

Thanks!!