グラフベースのシアムスネットワークを用いたソースコードの機能類似性のモデル化
Modeling Functional Similarity in Source Code with Graph-Based Siamese Networks
Modeling Functional Similarity in Source Code with Graph-Based Siamese Networks
@misc{mehrotra2020modeling,
title = {Modeling Functional Similarity in Source Code with Graph-Based Siamese Networks},
author = {Nikita Mehrotra and Navdha Agarwal and Piyush Gupta and Saket Anand and David Lo and Rahul Purandare},
year = {2020},
eprint = {2011.11228},
archivePrefix = {arXiv},
primaryClass = {cs.SE},
url = {https://arxiv.org/abs/2011.11228}
}
Mehrotra, N., Agarwal, N., Gupta, P., Anand, S., Lo, D., & Purandare, R. (2020). Modeling Functional Similarity in Source Code with Graph-Based Siamese Networks [Preprint]. arXiv. https://doi.org/10.48550/arXiv.2011.11228
MEHROTRA N, AGARWAL N, GUPTA P, et al. Modeling Functional Similarity in Source Code with Graph-Based Siamese Networks[EB/OL]. (2020-11-23)[2026-11-29]. https://arxiv.org/abs/2011.11228.
要旨
コードクローンとは、(ほぼ)同様の構文や意味を共有する重複コード断片である。コードクローン検出は、ソフトウェア保守、リファクタリング、再利用において重要な役割を果たす。過去には、クローンを検出するための研究が多数行われてきた。これらのアプローチの大部分は、クローンを検出するために構文情報と構文木(AST)などの構文構造を利用している。しかし、それらは利用可能な構造的・意味的信息を十分に活用しておらず、能力の限界となっている。最近、自然言語処理やコンピュータビジョンなどの分野における深層学習モデルの成功を契機に、研究者たちは深層学習技術を用いてコードクローンを検出する試みを行っている。これらのアプローチは、トークンなどの構文情報と、構文木などの構文構造を用いてクローンを検出する。しかし、本稿では、プログラム依存グラフと幾何学ニューラルネットワークを活用し、構造的な構文情報と意味的信息を統合することで、意味的コードクローン検出の問題に取り組む。我々は、この新しいアプローチに基づいたプロトタイプツール HOLMES を開発し、一般的なコードクローンベンチマーク上で実証的に評価を行った。結果は、HOLMES が他の最先端ツールである TBCCD に比べて著しく優れていることを示した。また、我々は未見プロジェクトで HOLMES を評価し、クロスデータセット実験を実施して HOLMES の汎用性を評価した。結果は、HOLMES が TBCCD を凌駕していることを裏付け、これは HOLMES が検出したペアの大部分が TBCCD によって検出されなかった、あるいは最適に報告されていないことに起因していることを示している。
Code clones are duplicate code fragments that share (nearly) similar syntax or semantics. Code clone detection plays an important role in software maintenance, code refactoring, and reuse. A substantial amount of research has been conducted in the past to detect clones. A majority of these approaches use lexical and syntactic information to detect clones. However, only a few of them target semantic clones. Recently, motivated by the success of deep learning models in other fields, including natural language processing and computer vision, researchers have attempted to adopt deep learning techniques to detect code clones. These approaches use lexical information (tokens) and(or) syntactic structures like abstract syntax trees (ASTs) to detect code clones. However, they do not make sufficient use of the available structural and semantic information hence, limiting their capabilities. This paper addresses the problem of semantic code clone detection using program dependency graphs and geometric neural networks, leveraging the structured syntactic and semantic information. We have developed a prototype tool HOLMES, based on our novel approach, and empirically evaluated it on popular code clone benchmarks. Our results show that HOLMES performs considerably better than the other state-of-the-art tool, TBCCD. We also evaluated HOLMES on unseen projects and performed cross dataset experiments to assess the generalizability of HOLMES. Our results affirm that HOLMES outperforms TBCCD since most of the pairs that HOLMES detected were either undetected or suboptimally reported by TBCCD.