This is the replication package for MCRead model titled "MCRead: A Multi-Granularity Context-Aware Approach for Code Change Readability Assessment" including both code and datasets.
MCRead
├─core
│ ├─comp
│ │ ├─dataset_readers
│ │ │ readers.py
│ │ ├─metric
│ │ ├─nn
│ │ └─tokenizers
│ └─models
├─evaluation
├─tasks
│ │ aggre_results.py
│ │ evaluate.py
│ │ train_helper.py
│ └─configs
│ base.jsonnet
└─utils
In dataset_readers folder, readers.py implements data preprocessing. The files in the tasks folder are used for training, testing, and evaluating the model, while the configs/base.json file serves as the configuration file for the model.
You should al least install following packages to run our code:
- PyTorch: 1.8.0+cu111
- allennlp: 2.8.0
- allennlp_models: 2.8.0
- nltk: 3.5
- ...
The full list of dependencies is listed in requirements.txt.
Due to size limit, we archive our data in the Google Drive and you can download the data from this link: data.zip.
Unzip this file and move the data folder to the root of this project to finish preparation of data.
To ensure some scripts will work well, you have to do three things first:
- Open "base_global.py" and check the path of Python interpreter, you should configure the right python interpreter path here.
- Make sure you are running all the code at the root directory of the MCRead project, this is important.
- You need to download the token-level pre-trained model codebert_base and the character-level pre-trained model canine-s, and place them in the root directory of the current project using the pre-trained model names as folder names.
Execute follow command at the root of the project to run:
python tasks/train_helper.py The script will automatically do training, testing and report the final performance.