arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2601.04085cs.PLcs.AI
收藏

CSSG: 使用语义图测量代码相似性

CSSG: Measuring Code Similarity with Semantic Graphs

College of Computer Science and Artificial Intelligence(计算机科学与人工智能学院)

Yiyang Lu, Jingwen Xu, Changze Lv, Zisu Huang, Zhengkang Guo, Zhengyuan Wang, Muzhao Tian, Xuanjing Huang, Xiaoqing Zheng

AI总结:

CSSG通过语义图建模控制依赖和变量交互,有效提升代码相似性度量的准确性。

摘要:

现有的代码相似性度量方法,如BLEU、CodeBLEU和TSED,主要依赖于表层字符串重叠或抽象语法树结构,往往无法捕捉程序之间的深层语义关系。我们提出CSSG(使用语义图的代码相似性度量),这是一种新的度量方法,利用程序依赖图来显式建模控制依赖性和变量交互,提供了一种语义感知的代码表示。在CodeContests+数据集上的实验表明,CSSG在单语言和跨语言设置下都能一致地优于现有度量方法,在区分更相似的代码和更不相似的代码方面表现更佳,证明了依赖感知图表示比表层或语法基于的相似性度量更有效。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑