https://github.com/cgcl-codes/treecen
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
○codemeta.json file
-
○.zenodo.json file
-
✓DOI references
Found 3 DOI reference(s) in README -
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.7%) to scientific vocabulary
Last synced: 10 months ago
·
JSON representation
Repository
Basic Info
- Host: GitHub
- Owner: CGCL-codes
- Language: Python
- Default Branch: main
- Size: 15.6 KB
Statistics
- Stars: 10
- Watchers: 3
- Forks: 1
- Open Issues: 1
- Releases: 0
Created about 4 years ago
· Last pushed over 3 years ago
https://github.com/CGCL-codes/TreeCen/blob/main/
# TreeCen:Building Tree Graph for Scalable Semantic Code Clone Detection
TreeCen is a scalable tree-based code clone detector, which satisfies scalability while detecting semantic clones effectively.
Given the source code, we first extract ASTs based on static analysis to transform them into simple graph representations (i.e., tree graph) according to the node type, rather than traditional AST matching.
Then we treat the tree graph as a network and adopt the centrality analysis to convert it into a fix-length vector.
By this, the final vector is only 72-dimensional but contains complete structural information of the AST.
Finally, these vectors are fed into the machine learning model to detect clones.
TreeCen consists of four main phases: AST Extraction, AST Abstraction, Feature Extraction, Clone Detection:
1. AST Extraction: This phase aims to extract the AST for a method based on static analysis, whose input is the source code, and the output is an AST.
2. AST Abstraction: This phase is designed to simplify the AST while preserving its structural information.
The input is an AST, and the output is a tree graph for the AST, where each node represents a node type in the AST, and each edge conveys an edge relationship in the AST.
3. Feature Extraction:
In this phase, we assign centrality to each node within the tree graph generated in the AST abstraction phase.
The output is centrality vectors containing concrete features about the AST.
4. Clone Detection:
Given the centrality vector of a pair of codes, we concatenate them into one vector and then feed it into a machine learning model to train the detector after annotating the corresponding labels (clone or non-clone).
# Project Structure
```shell
TreeCen
|-- get_centmatrix.py // implement the first three phases: AST Extraction, AST Abstraction, and Feature Extraction
|-- classification.py // implement the Classification phase
```
### Step1: Get centrality matrices
get_centmatrix.py: The file is used to get six types of centrality measures of source code.
```
python get_centmatrix.py
```
The input is a folder containing the source code files and the output is a Json file containing a dictionary. The content of the dictionary is the feature vector of the source code obtained by each centrality measures.
### Step2: Classification
classification.py: The file is used to train the clone detector and predict the clones using each of the seven machine learning algorithms.
```
python classification.py
```
Input:
1. The Json file output by get_centmatrix.py.
2. The CSV file with source code labels (clone or non-clone).
Output is the prediction result.
# Publication
Yutao Hu, Deqing Zou, Junru Peng, Yueming Wu, Junjie Shan, and Hai Jin. 2022. TreeCen: Building Tree Graph for Scalable Semantic Code Clone Detection. In 37th IEEE/ACM International Conference on Automated Software Engineering (ASE '22), October 1014, 2022, Rochester, MI, USA. ACM, New York, NY, USA 12 Pages. https://doi.org/10.1145/3551349.3556927
If you use our dataset or source code, please kindly cite our paper:
```
@INPROCEEDINGS{treecen,
author={Hu, Yutao, and Zou, Deqing and Peng, Junru and Wu, Yueming and Shan, Junjie and Jin, Hai},
booktitle={2022 IEEE/ACM 37th International Conference on Automated Software Engineering (ASE)},
title={TreeCen: Building Tree Graph for Scalable Semantic Code Clone Detection},
year={2022},
doi={10.1145/3551349.3556927}}
```
Owner
- Name: CGCL-codes
- Login: CGCL-codes
- Kind: organization
- Website: http://grid.hust.edu.cn/
- Repositories: 35
- Profile: https://github.com/CGCL-codes
CGCL/SCTS/BDTS Lab
GitHub Events
Total
- Watch event: 2
Last Year
- Watch event: 2