This repository contains the code for the paper "Multi-Feature and Multi-Channel GCNs for Aspect Based Sentiment Analysis".
Please cite our paper and kindly give a star for this repository if you use this code.
This code runs Python 3.7.0 with the following libraries:
- Pytorch 1.13.1+cu116
- Transformers 2.9.1
- spacy 2.0.18
-
Prepare data
-
Restaurants, Laptop, Tweets and MAMS dataset.
-
Downloading Glove embeddings (available at here), then run
awk '{print $1}' glove.840B.300d.txt > glove_words.txt
to get
glove_words.txt
.
-
-
Build vocabulary
bash build_vocab.sh
-
Build aspect-graph and inter-graph
-
Go to the common folder:
-
Generate aspect-focused graph with
python focused_graph.py
- Generate inter-aspect graph with
python inter_graph.py
-
-
Training
Go to Corresponding directory and run scripts:
bash run-MAMS-glove.sh bash run-MAMS-BERT.sh
-
The saved model and training logs will be stored at directory
saved_models
-
Evaluating trained models (optional)
bash eval.sh path/to/check_point path/to/dataset bash eval-BERT.sh path/to/check_point path/to/dataset
-
Notice Please remove the comments in the code to adapt it to different datasets.
The code of this repository partly relies on InterGCN & RGAT & DM-GCN.
I would like to extend my appreciation to the authors of the InterGCN, RGAT, and DMGCN repositories for their valuable contributions.