ssa-perin / README.md
erikve's picture
Update README.md
671b9d8 verified
|
raw
history blame
1.57 kB
metadata
title: Sentiment Analysis
emoji: 🤔
colorFrom: purple
colorTo: yellow
sdk: gradio
sdk_version: 3.1.7
app_file: app.py
pinned: false

This space provides a gradio demo of a pretrained model (with an easy-to-run wrapper) for structured sentiment analysis (SSA) of Norwegian text, trained on the NoReC_fine dataset. It implements a method described in the paper Direct parsing to sentiment graphs by Samuel et al. 2022.

The model will attempt to identify the following components for a given sentence it deems to be sentiment-bearing: source expressions (the opinion holder), target expressions (what the opinion is directed towards), polar expressions (the part of the text indicating that an opinion is expressed), and finally the polarity (positive or negative).

See the code below for an example of how you can use the model yourself for predicting such sentiment tuples (along with character offsets in the text):

>>> import model_wrapper
>>> model = model_wrapper.PredictionModel()
>>> model.predict(['vi liker svart kaffe'])
[{'sent_id': '0',
  'text': 'vi liker svart kaffe',
  'opinions': [{'Source': [['vi'], ['0:2']],
    'Target': [['svart', 'kaffe'], ['9:14', '15:20']],
    'Polar_expression': [['liker'], ['3:8']],
    'Polarity': 'Positive'}]}]

To download the model and find more in-depth documentation, please see (https://huggingface.co/ltg/ssa-perin)[https://huggingface.co/ltg/ssa-perin]