Easy-to-use, high-quality target-dependent sentiment classification for news articles
Project description
NewsSentiment: easy-to-use, high-quality target-dependent sentiment classification for news articles
NewsSentiment is an easy-to-use Python library that achieves state-of-the-art performance for target-dependent sentiment classification on news articles. NewsSentiment uses the currently best performing targeted sentiment classifier for news articles. In contrast to regular sentiment classification, targeted sentiment classification allows you to provide a target in a sentence. Only for this target, the sentiment is then predicted. This is more reliable in many cases, as demonstrated by the following simplistic example: "I like Bert, but I hate Robert."
We designed NewsSentiment to serve as an easy-to-use wrapper around the sophisticated GRU-TSC model, which was trained on the NEWSMTSC dataset consisting of more than 10k labeled sentences sampled from political news articles. More information on the dataset and the model can be found here. The dataset, the model, and its source code can be viewed in our GitHub repository.
Installation
It's super easy, we promise!
NewsMTSC was tested on MacOS and Ubuntu; other OS may work, too. Let us know :-)
1. Setup the environment:
This step is optional if you have Python 3.7 installed already (run python --version
in a terminal and check the version that is printed). If you don't have Python 3.7, we
recommend using Anaconda for setting up requirements because it is very easy (but any way
of installing Python 3.7 is fine). If you do not have Anaconda yet, follow their
installation instructions.
After installing Anaconda, to setup a Python 3.7 environment (in case you don't have one yet) execute:
conda create --yes -n newsmtsc python=3.7
conda activate newsmtsc
2. Install NewsSentiment:
pip3 install NewsSentiment # without cuda support (choose this if you don't know what cuda is)
pip3 install NewsSentiment[cuda] # with cuda support
You're all set now, all required models will automatically download on-demand :-)
Note that using NewsSentiment the first time may take a few minutes before the model is fully download. This is a one-time process and future use of NewsSentiment will be much faster.
Target-dependent Sentiment Classification
from NewsSentiment import TargetSentimentClassifier
tsc = TargetSentimentClassifier()
sentiment = tsc.infer_from_text("I like" ,"Peter", ".")
print(sentiment)
How to cite
If you use the dataset or model, please cite our paper (PDF):
@InProceedings{Hamborg2021b,
author = {Hamborg, Felix and Donnay, Karsten},
title = {NewsMTSC: (Multi-)Target-dependent Sentiment Classification in News Articles},
booktitle = {Proceedings of the 16th Conference of the European Chapter of the Association for Computational Linguistics (EACL 2021)},
year = {2021},
month = {Apr.},
location = {Virtual Event},
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for NewsSentiment-1.0.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c70dff15497f00ab1a7b275494cb34a651f4642ddaa73b7efaa0e6508b2e69a6 |
|
MD5 | 0cab2ea0eca6994cd7cb02d113112464 |
|
BLAKE2b-256 | 857164a007845da662961454c37adf88356718f49b019cd4c163e22ccb8f7def |