Replies: 2 comments
-
In PyABSA, sentiment polarities are typically represented as categorical labels such as 'positive', 'negative', or 'neutral'. The framework does not natively assign numerical scores to these polarities. However, you can map these categorical labels to numerical values based on your specific requirements. For instance, you might assign 'positive' to 1, 'neutral' to 0, and 'negative' to -1. |
Beta Was this translation helpful? Give feedback.
0 replies
-
from pyabsa import ABSAInstruction, available_checkpoints
myreviews = [
'I really enjoyed the place, e.g. the service and food were great',
'Nice and clean place, would go again.',
'I love the chef, he makes the best pasta'
]
quadruple_extractor = ABSAInstruction.ABSAGenerator("multilingual")
polarity_mapping = {'positive': 1, 'neutral': 0, 'negative': -1}
for review in myreviews:
quadruple_result = quadruple_extractor.predict(review, max_length=128)
for quadruple in quadruple_result['Quadruples']:
aspect = quadruple['aspect']
polarity = quadruple['polarity']
opinion = quadruple['opinion']
category = quadruple['category']
# Map the polarity to a numerical value
numerical_polarity = polarity_mapping.get(polarity, None)
print(f"Aspect: {aspect}, Polarity: {polarity} ({numerical_polarity}), Opinion: {opinion}, Category: {category}") |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am currently performing a sentiment analysis using PyABSA, using the following code:
However, my result does currently look like this:
{'text': 'I really enjoyed the place, e.g. the service and food were great', 'Quadruples': [{'aspect': 'service', 'polarity': 'positive', 'opinion': 'enjoyed', 'category': 'SERVICE#GENERAL'}, {'aspect': 'food', 'polarity': 'positive', 'opinion': 'great', 'category': 'FOOD#QUALITY'}]}
My problem is that I need the sentiment (polarity) as a figure, but I can't find any description in the documentation.
Beta Was this translation helpful? Give feedback.
All reactions