ScalaConsultants / Aspect-Based-Sentiment-Analysis

💭 Aspect-Based-Sentiment-Analysis: Transformer & Explainable ML (TensorFlow)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't execute the example

Garve opened this issue · comments

Hi!

I tried to excute

import aspect_based_sentiment_analysis as absa

nlp = absa.load()
text = ("We are great fans of Slack, but we wish the subscriptions "
        "were more accessible to small startups.")

slack, price = nlp(text, aspects=['slack', 'price'])
assert price.sentiment == absa.Sentiment.negative
assert slack.sentiment == absa.Sentiment.positive

but I only get

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-1-0cd7d305f4c1> in <module>
----> 1 import aspect_based_sentiment_analysis as absa
      2 
      3 nlp = absa.load()
      4 text = ("We are great fans of Slack, but we wish the subscriptions "
      5         "were more accessible to small startups.")

~\Miniconda3\lib\site-packages\aspect_based_sentiment_analysis\__init__.py in <module>
      2 __version__ = "2.0.1"
      3 
----> 4 from .alignment import tokenize
      5 from .alignment import make_alignment
      6 from .alignment import merge_tensor

~\Miniconda3\lib\site-packages\aspect_based_sentiment_analysis\alignment.py in <module>
      7 import numpy as np
      8 
----> 9 from .data_types import TokenizedExample
     10 
     11 

~\Miniconda3\lib\site-packages\aspect_based_sentiment_analysis\data_types.py in <module>
    159 
    160 
--> 161 @dataclass(frozen=True)
    162 class InputBatch:
    163     """ The model uses these tensors to perform a prediction.

~\Miniconda3\lib\site-packages\aspect_based_sentiment_analysis\data_types.py in InputBatch()
    170     indicate first and second portions of the inputs, zeros
    171     and ones. """
--> 172     token_ids: tf.Tensor
    173     attention_mask: tf.Tensor
    174     token_type_ids: tf.Tensor

AttributeError: module 'tensorflow' has no attribute 'Tensor'

Do I need an older Tensoflow version?

Thank you!

Best regards
Robert

Please update to the version 2.0.2 - it should work now 😊