Giter VIP home page Giter VIP logo

ics's Introduction

ICS

Integrating Extractive and Abstractive Models for Code Comment Generation

Requirements

The dependencies can be installed using the following command:

pip install -r requirements.txt

Original Dataset

The CodeSearchNet original dataset can be downloaded from the github repo: https://github.com/github/CodeSearchNet, and the cleaned dataset (CodeXGLUE) can be downloaded from the https://drive.google.com/open?id=1rd2Tc6oUWBo7JouwexW3ksQ0PaOhUr6h

Quick Start

Extractor

Run the Extractor_LSA/train.py to build the LSA model.

For example:

cd Extractor_LSA/
python train.py --data_dir {data_path} --saved_model_path {saved_model_path} --result_path {result_path}

{data_path} specifies the path to the training dataset.

{saved_model_path} specifies the path to the folder where the parameter files for the model are stored.

{saved_data_path} specifies the path to the folder where the output file is located.

And run the Extractor_LSA/test.py to test the LSA model:

python test.py --data_dir {data_path} --saved_model_path {saved_model_path} --result_path {result_path}

The output samples are as follows:

- output samples:
0	int matrix i height convolution width ...
1	event state listener synchronized this ...
2	t try finally write unlock ...
...

Then run the Extractor_LSA/gen.py to extract important statements based on the key tokens:

python gen.py --file_path {file_path} --ex_file_path {ex_file_path}

{file_path} specifies the path to the original dataset.

{ex_file_path} specifies the path to the key tokens file.

The output samples are as follows:

{
    "idx": 0, 
    "code_tokens": ["public", "ImageSource", "apply", ...], 
    "docstring_tokens": ["Pops", "the", "top", ...],
    ...,
    "extractive sum": ["event", "state", "listener", ...], 
    "my_pred_cleaned_seqs": [1, 0, 1, 0, 1]
}

ICS + CodeT5

cd ICS_codeT5/
python run_gen {language}

The {language} can be selected in java, python, go, php, ruby, javascript

Evaluation

After training the ICS + CodeT5 model, run the evaluation code to output Bleu, Meteor and Rouge-L:

(Switch into python 2.7)

cd Evaluation/
python evaluate.py

ics's People

Contributors

huyuling0816 avatar wssun avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.