[KBS] Aspect-based sentiment analysis via affective knowledge enhanced graph convolutional networks

Overview

#Sentic GCN

Introduction

This repository was used in our paper:

Aspect-Based Sentiment Analysis via Affective Knowledge Enhanced Graph Convolutional Networks
Bin Liang, Hang Su, Lin Gui, Erik Cambria, Ruifeng Xu. Knowledge-Based Systems, 2021: 107643.

Please cite our paper and kindly give a star for this repository if you use this code.

Requirements

  • Python 3.6
  • PyTorch 1.0.0
  • SpaCy 2.0.18
  • numpy 1.15.4

Usage

pip install spacy

and

python -m spacy download en
  • Generate dependency graph with
python generate_dependency_graph.py
  • Generate sentic graph with
python generate_sentic_graph.py

Training

  • Train with command, optional arguments could be found in train.py & train_bert.py

  • Run senticgcn: ./run_senticgcn.sh

  • Run senticgcn_bert: ./run_senticgcn_bert.sh

Citation

The BibTex of the citation is as follow:

@article{liang2021aspect,
  title={Aspect-based sentiment analysis via affective knowledge enhanced graph convolutional networks},
  author={Liang, Bin and Su, Hang and Gui, Lin and Cambria, Erik and Xu, Ruifeng},
  journal={Knowledge-Based Systems},
  pages={107643},
  year={2021},
  publisher={Elsevier}
}

Credits

  • The affective knowledge used in this work is from SenticNet, I would like to express my heartfelt thanks to all the authors of SenticNet.
  • The code of this repository partly relies on ASGCN & ABSA-PyTorch.
  • Here, I would like to express my gratitude to the authors of the ASGCN & ABSA-PyTorch repositories.
Comments
  • issue with the accuracy

    issue with the accuracy

    Hi,

    I run the code using this command

    !CUDA_VISIBLE_DEVICES=1 python3 train_bert.py --model_name senticgcn_bert --dataset rest15 --save True --learning_rate 2e-5 --seed 39 --batch_size 16 --hidden_dim 768

    But I got a very low accuracy compared to the reported results in ur paper

    the obtained accuracy is 61.09% and 25.28% for f1-score and these values are the same for all the running steps and epochs !!

    Do u have any idea plz?

    Thank u

    opened by karimmahalian 15
  • SDGCN model

    SDGCN model

    Hi,

    First, thank u for sharing this great work with us.

    I have a question about this model sdgcn.py is this an implementation of this paper "Modeling Sentiment Dependencies with Graph Convolutional Networks for Aspect-level Sentiment Classification" If no could u please provide a description of this model?

    Many thanks in advance.

    opened by yassmine-lam 2
  • pkl files

    pkl files

    Hi,

    Thank u for sharing this code with us. However, I got this error when trying to run this code

    FileNotFoundError: [Errno 2] No such file or directory: 'state_dict/senticgcn_bert_rest14.pkl'

    Could u please tell us how to generate the pkl files?

    Thank u in advance

    opened by karimmahalian 0
  • 情感增强依存图的意义

    情感增强依存图的意义

    您好!阅读了您的论文之后,对于情感增强依存图的意义还不是很理解,添加了情感知识后的邻接矩阵中的数值有什么含义,在图卷积中是不是把这个数值看作两个单词间的相关性。以下面的例子为例: 例子 这句话中的方面词分别是food和service,根据依存树得到的邻接矩阵中food和delicious,以及service和terrible的边的权重为1,在senticnet词典中,food、delicious、serviceh和terrible对应的情感值分别为0.054、0.106、0.84和-0.90,加入情感知识后,food和delicious,以及service和terrible的边的权重变为2.16,和1.94,请问这个数值的含义是什么,希望能尽快得到您的回复。

    opened by cjj-sunshine 3
  • Don't we need to reconcile SpaCy and BERT tokens?

    Don't we need to reconcile SpaCy and BERT tokens?

    First of all, thank you for releasing the program on your paper. What I'm curious about is that SpaCy divides sentences into word units, but BERT divides them into WordPiece units, so I think there will be a problem that the tokens are not accurately mapped to each other. I wonder which part of the program you uploaded deals with these problems.

    opened by hjpark2017 1
  • ValueError: index can't contain negative values

    ValueError: index can't contain negative values

    您好,我用您的代码跑中文数据集出现了以下错误,请问您知道解决方案吗? Traceback (most recent call last): File "E:/Sentic-GCN-main/Sentic-GCN-main/train_bert.py", line 281, in main() File "E:/Sentic-GCN-main/Sentic-GCN-main/train_bert.py", line 276, in main ins = Instructor(opt) File "E:/Sentic-GCN-main/Sentic-GCN-main/train_bert.py", line 53, in init self.trainset = ABSADataset(opt.dataset_file['train'], tokenizer) File "E:\Sentic-GCN-main\Sentic-GCN-main\data_utils_bert.py", line 183, in init ((0,tokenizer.max_seq_len-idx2graph[graph_id].shape[0]),(0,tokenizer.max_seq_len-idx2graph[graph_id].shape[0])), 'constant') File "<array_function internals>", line 6, in pad File "D:\anaconda\envs\torch16\lib\site-packages\numpy\lib\arraypad.py", line 746, in pad pad_width = _as_pairs(pad_width, array.ndim, as_index=True) File "D:\anaconda\envs\torch16\lib\site-packages\numpy\lib\arraypad.py", line 517, in _as_pairs raise ValueError("index can't contain negative values") ValueError: index can't contain negative values

    进程已结束,退出代码 1

    opened by TJSL0715 8
  • issue with the accuracy_glove

    issue with the accuracy_glove

    Hello, after I clone your code, follow the readme file and run run_ senticgcn.sh , but the scores on the four data sets are 1-2% lower than those reported in your paper. Isn't your code the latest version. I run the code on the RTX 6000 GPU

    opened by L-shuai 1
  • Eq. 2 and 4 in your paper are inconsistent with the codes provided here.

    Eq. 2 and 4 in your paper are inconsistent with the codes provided here.

    The eq. 2 is Si,j = SenticNet(wi) + SenticNet(wj) in your paper, however, the code only computed SenticNet(wi) for S_i,j. Meanwhile w_i or w_j is a aspect word, the eq.4 need add T_ij=1 only once, however, the code here computed twice T_ij . Please check it.

    opened by HaoTyut 1
Owner
Akuchi
Akuchi
C.J. Hutto 2.8k Feb 18, 2021
Implementation of paper Does syntax matter? A strong baseline for Aspect-based Sentiment Analysis with RoBERTa.

RoBERTaABSA This repo contains the code for NAACL 2021 paper titled Does syntax matter? A strong baseline for Aspect-based Sentiment Analysis with RoB

null 106 Nov 28, 2022
A paper list for aspect based sentiment analysis.

Aspect-Based-Sentiment-Analysis A paper list for aspect based sentiment analysis. Survey [IEEE-TAC-20]: Issues and Challenges of Aspect-based Sentimen

jiangqn 419 Dec 20, 2022
MRC approach for Aspect-based Sentiment Analysis (ABSA)

B-MRC MRC approach for Aspect-based Sentiment Analysis (ABSA) Paper: Bidirectional Machine Reading Comprehension for Aspect Sentiment Triplet Extracti

Phuc Phan 1 Apr 5, 2022
Twitter-Sentiment-Analysis - Twitter sentiment analysis for india's top online retailers(2019 to 2022)

Twitter-Sentiment-Analysis Twitter sentiment analysis for india's top online retailers(2019 to 2022) Project Overview : Sentiment Analysis helps us to

Balaji R 1 Jan 1, 2022
Code for Findings of ACL 2022 Paper "Sentiment Word Aware Multimodal Refinement for Multimodal Sentiment Analysis with ASR Errors"

SWRM Code for Findings of ACL 2022 Paper "Sentiment Word Aware Multimodal Refinement for Multimodal Sentiment Analysis with ASR Errors" Clone Clone th

null 14 Jan 3, 2023
Convolutional 2D Knowledge Graph Embeddings resources

ConvE Convolutional 2D Knowledge Graph Embeddings resources. Paper: Convolutional 2D Knowledge Graph Embeddings Used in the paper, but do not use thes

Tim Dettmers 586 Dec 24, 2022
An example project using OpenPrompt under pytorch-lightning for prompt-based SST2 sentiment analysis model

pl_prompt_sst An example project using OpenPrompt under the framework of pytorch-lightning for a training prompt-based text classification model on SS

Zhiling Zhang 5 Oct 21, 2022
Simple, Pythonic, text processing--Sentiment analysis, part-of-speech tagging, noun phrase extraction, translation, and more.

TextBlob: Simplified Text Processing Homepage: https://textblob.readthedocs.io/ TextBlob is a Python (2 and 3) library for processing textual data. It

Steven Loria 8.4k Dec 26, 2022
Summarization, translation, sentiment-analysis, text-generation and more at blazing speed using a T5 version implemented in ONNX.

Summarization, translation, Q&A, text generation and more at blazing speed using a T5 version implemented in ONNX. This package is still in alpha stag

Abel 211 Dec 28, 2022
Simple, Pythonic, text processing--Sentiment analysis, part-of-speech tagging, noun phrase extraction, translation, and more.

TextBlob: Simplified Text Processing Homepage: https://textblob.readthedocs.io/ TextBlob is a Python (2 and 3) library for processing textual data. It

Steven Loria 7.5k Feb 17, 2021
Summarization, translation, sentiment-analysis, text-generation and more at blazing speed using a T5 version implemented in ONNX.

Summarization, translation, Q&A, text generation and more at blazing speed using a T5 version implemented in ONNX. This package is still in alpha stag

Abel 137 Feb 1, 2021
pysentimiento: A Python toolkit for Sentiment Analysis and Social NLP tasks

A Python multilingual toolkit for Sentiment Analysis and Social NLP tasks

null 297 Dec 29, 2022
Perform sentiment analysis and keyword extraction on Craigslist listings

craiglist-helper synopsis Perform sentiment analysis and keyword extraction on Craigslist listings Background I love Craigslist. I've found most of my

Mark Musil 1 Nov 8, 2021
A combination of autoregressors and autoencoders using XLNet for sentiment analysis

A combination of autoregressors and autoencoders using XLNet for sentiment analysis Abstract In this paper sentiment analysis has been performed in or

James Zaridis 2 Nov 20, 2021
Sentiment Analysis Project using Count Vectorizer and TF-IDF Vectorizer

Sentiment Analysis Project This project contains two sentiment analysis programs for Hotel Reviews using a Hotel Reviews dataset from Datafiniti. The

Simran Farrukh 0 Mar 28, 2022
Training code for Korean multi-class sentiment analysis

KoSentimentAnalysis Bert implementation for the Korean multi-class sentiment analysis 왜 한국어 감정 다중분류 모델은 거의 없는 것일까?에서 시작된 프로젝트 Environment: Pytorch, Da

Donghoon Shin 3 Dec 2, 2022
Machine Learning Course Project, IMDB movie review sentiment analysis by lstm, cnn, and transformer

IMDB Sentiment Analysis This is the final project of Machine Learning Courses in Huazhong University of Science and Technology, School of Artificial I

Daniel 0 Dec 27, 2021
Twitter Sentiment Analysis using #tag, words and username

Twitter Sentment Analysis Web App using #tag, words and username to fetch data finds Insides of data and Tells Sentiment of the perticular #tag, words or username.

Kumar Saksham 26 Dec 25, 2022