Aspect-Based-Sentiment-Analysis
Aspect-Based-Sentiment-Analysis copied to clipboard
AttributeError with Tokenizer
I'm trying to reproduce the example in the README.
name = 'absa/classifier-rest-0.2'
model = absa.BertABSClassifier.from_pretrained(name)
tokenizer = absa.BertTokenizer.from_pretrained(name)
professor = absa.Professor() # Explained in detail later on.
text_splitter = absa.sentencizer() # The English CNN model from SpaCy.
nlp = absa.Pipeline(model, tokenizer, professor, text_splitter)
But I get an AttributeError
with the tokenizer.
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-9-c6e986c7be44> in <module>
1 name = 'absa/classifier-rest-0.2'
2 model = absa.BertABSClassifier.from_pretrained(name)
----> 3 tokenizer = absa.BertTokenizer.from_pretrained(name)
4 professor = absa.Professor() # Explained in detail later on.
5 text_splitter = absa.sentencizer() # The English CNN model from SpaCy.
AttributeError: module 'aspect_based_sentiment_analysis' has no attribute 'BertTokenizer'
Could you also clarify how the professor works. The article is missing the hyperlink in the README: "In the article [here], we discuss in detail how the model and the professor work"
Thanks in advance.
This fixes the first issue:
from transformers import BertTokenizer
tokenizer = BertTokenizer.from_pretrained(model_name)
Thank you for your solution. Now I get another error:
Traceback (most recent call last):
File "/Users/petar.ulev/Documents/prepare_sentiment_data/spacystuff.py", line 29, in
Did you experience it as well?
Can you try this?
sentences = [sent.text.strip() for sent in doc.sents]