ScalaConsultants/Aspect-Based-Sentiment-Analysis

AttributeError: 'CompletedSubTask' object has no attribute 'aspect_representation'

Closed this issue · 2 comments

Hi, I have a following problem: when I start the example you provided, I manage to obtain slack and price sentiments but the problem occurs when I try to create html (html = absa.probing.explain(slack)). This command is followed by the error:

AttributeError Traceback (most recent call last)
in
----> 1 html = absa.probing.explain(slack)

~/anaconda3/envs/torch_tf2/lib/python3.7/site-packages/aspect_based_sentiment_analysis/probing/plots.py in explain(example)
47
48 def explain(example: PredictedExample):
---> 49 aspect = example.aspect_representation
50 texts = [f'Words connected with the "{example.aspect}" aspect:
']
51 texts.extend(highlight_sequence(aspect.tokens, aspect.look_at))

AttributeError: 'CompletedSubTask' object has no attribute 'aspect_representation'

See examples/pattens.ipynb.

Minimum viable example:

import aspect_based_sentiment_analysis as absa
import numpy as np

recognizer = absa.probing.AttentionGradientProduct()
nlp = absa.load('absa/classifier-rest-0.1', pattern_recognizer=recognizer)
text = ("We are great fans of Slack, but we wish the subscriptions " 
        "were more accessible to small startups.")
        
task = nlp(text, aspects=["slack", "price"])

slack_example, price_example = task.batch
slack_scores = np.round(slack_example.scores, decimals=3)
price_scores = np.round(price_example.scores, decimals=3)

print(f'Sentiment for "slack": {repr(slack_example.sentiment)}')
print(f'Scores (neutral/negative/positive): {slack_scores}')

print(f'Sentiment for "slack": {repr(price_example.sentiment)}')
print(f'Scores (neutral/negative/positive): {price_scores}')
html = absa.probing.explain(slack_example)
display(html)
html = absa.probing.explain(price_example)
display(html)

Hey folks! Thank you @visini for your reply.
I have a few things in progress but after that I will update the readme.