Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mading0817 opened this issue Aug 29, 2018 · 0 comments
Open

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

mading0817 opened this issue Aug 29, 2018 · 0 comments

Comments

@mading0817
Copy link

mading0817 commented Aug 29, 2018

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
Copy link
Author

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

@mading0817
Copy link
Author

mading0817 commented Aug 29, 2018

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!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant