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.
Please download Glove Embedding, and put 'glove.42B.300d.txt' under the main directory.
Install SpaCy package and language models with
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
Generate sentic & dependeny graph with
python generate_sentic_dependency_graph.py
Train with command, optional arguments could be found in train.py \& train_bert.py
Please tune the argument of --seed for better performance
Run senticgcn: ./run_senticgcn.sh
Run senticgcn_bert: ./run_senticgcn_bert.sh
python infer.py
for the testing of non-BERT models.python infer_for_bert.py
for the testing of BERT-based models.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}
}
We also set several variants of our model: | Model | Decription |
---|---|---|
affectivegcn.py | Only using the affective information (i.e. Eq.2) for building graphs | |
attsenticgcn.py | Combining our model with attention mechanism | |
sdgcn.py | Interactively performing the graph convolutional operation based on dependency (i.e. Eq. 1) and affective (i.e. Eq.2) graphs |