用程序依赖图衡量代码相似性,更懂代码语义。
CSSG: Measuring Code Similarity with Semantic Graphs
- 基于程序依赖图建模控制流与变量交互
- 在多语言和跨语言场景下优于现有指标
- 适合需要精准代码相似度评估的研究者
现有代码相似度度量方法如BLEU、CodeBLEU和TSED主要依赖表面字符串重叠或抽象语法树结构,难以捕捉程序间的深层语义关系。本文提出CSSG(基于语义图的代码相似性度量),利用程序依赖图显式建模控制依赖与变量交互,提供更具语义感知的代码表示。在CodeContests+数据集上的实验表明,无论在单语言还是跨语言设置下,CSSG均能更有效地区分高度相似与低度相似的代码,证明依赖感知的图表示比表层或语法基度量更优。
原文摘要 · Abstract (English)
Existing code similarity metrics, such as BLEU, CodeBLEU, and TSED, largely rely on surface-level string overlap or abstract syntax tree structures, and often fail to capture deeper semantic relationships between programs.We propose CSSG (Code Similarity using Semantic Graphs), a novel metric that leverages program dependence graphs to explicitly model control dependencies and variable interactions, providing a semantics-aware representation of code.Experiments on the CodeContests+ dataset show that CSSG consistently outperforms existing metrics in distinguishing more similar code from less similar code under both monolingual and cross-lingual settings, demonstrating that dependency-aware graph representations offer a more effective alternative to surface-level or syntax-based similarity measures.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。