Giter Site home page Giter Site logo

nashid / code-representation-graph-lstm Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yuanjianggit/code-representation-graph-lstm

0.0 0.0 0.0 12.7 MB

Hierarchical Semantic-Aware Neural Code Representation

Shell 1.63% JavaScript 47.48% Ruby 0.59% C++ 1.31% Scheme 5.05% Python 27.69% C 0.97% PHP 0.19% Java 10.34% C# 0.05% Rust 4.70%

code-representation-graph-lstm's Introduction

Code Representation

Downstream tasks of code representation

Program classification aims to classify newly added source files into different categories according to their functionalities in the software development process

Dataset

The dataset we use is OJ datasets, including OJ-Data-1, OJ-Data-2 and OJ-All.

Data Format

  1. resources/dataset/OJ-Data-*/programs.pkl is stored in pickle format. Each row in this file represents one function and its label. One row is illustrated below.

    • id: index of the example

    • Code: the code fragment

    • label index of the example

Data Statistics

Data statistics of the dataset are shown in the below table:

#Examples #Program Tasks
OJ-Data-1 52,000 104
OJ-Data-2 52,000 104
OJ-All 104,000 208

You can get data using the following command.

import os
import pandas as pd
data_path = '../resources/dataset/OJ-All/programs.pkl'
if os.path.exists(data_path):
    data = pd.read_pickle(data_path)

Pipeline-Prepare input for our grah-lstm model

We also provide a pipeline that generates inputs for our model on this task.

Dependency

  • gensim
  • networkx
  • dgl
  • nltk
  • numpy
  • pandas
  • scikit_learn
  • torch

Tree-sitter

If the built file "parser/my-languages.so" doesn't work for you, please rebuild as the following command:

cd parser1
bash build.sh
cd ..
python DataProcess/Pipline.py

Training and Evaluation Entry

We provide a script to train and evaluate our model for this task, and report Accuracy score

python Entry/train_graph_lstm.py

Result

OJ-All
[Epoch: 100/100] Train Loss: 0.0526, Val Loss: 0.0540, Train result: 0.9773022361144506, Test result: 0.9660623692625808

code-representation-graph-lstm's People

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.