吉林大学学报(信息科学版) ›› 2015, Vol. 33 ›› Issue (1): 99-104.

• 论文 • 上一篇    下一篇

 基于AST的程序代码相似性度量研究

朱波, 郑虹, 孙琳琳, 杨友星   

  1. 长春工业大学 计算机科学与工程学院, 长春 130012
  • 收稿日期:2014-08-27 出版日期:2015-01-24 发布日期:2015-03-20
  • 作者简介:朱波(1988—), 男, 山东五莲人, 长春工业大学硕士研究生, 主要从事软件工程、 人工智能研究, (Tel)86-18004301495(E-mail)xuesong_502@126.com;通讯作者: 郑虹(1974—), 女, 长春人, 长春工业大学副教授, 硕士生导师, 主要从事人工智能、 软件工程研究,(Tel)86-13039301323(E-mail)hollytz@126.com。
  • 基金资助:

    吉林省科技厅自然科学基金资助项目(20130101060JC); 吉林省教育厅“十二五”科学技术研究基金资助项目(2014132; 2014125)

Research on Similarity Measure for AST-Based Program Codes

ZHU Bo, ZHENG Hong, SUN Linlin, YANG Youxing   

  1. School of Computer Science and Engineering, Changchun University of Technology, Changchun 130012, China
  • Received:2014-08-27 Online:2015-01-24 Published:2015-03-20

摘要:

针对程序代码相似性检测度量忽略程序语义、出现无效度量的问题, 提出一种基于抽象语法树(AST:Abstract Syntax Tree)的程序代码相似性度量方法。通过预处理去除生成AST时的冗余信息, 再进行词法语法分析, 得到相应的AST; 然后通过自适应阈值的选取方式, 利用AST遍历得到的程序属性、 方法序列, 对AST进行相似度计算, 最终判定是否抄袭, 生成相似度检测报告。实验结果表明, 该方法能有效检测Java程序代码的多种抄袭行为。

关键词: 相似性度量, 抽象语法树, 相似度, 自适应阈值

Abstract:

In order to solve the program code similarity detection measurement which ignores the program semantics and the invalid measurement, we present
 an AST(Abstract Syntax Tree) based on the program code similarity measure method. Through the pretreatment redundancy removal in AST generation and the lexical grammar analysis, get the corresponding AST; and then according to the adaptive threshold method,using the AST traversal which include the sequence and process attributes to take the similarity calculation;finally,determine whether plagiarism and generate the test report.The experimental results show that this method can effectively detect a variety of plagiarism java code.

Key words: similarity measurement, abstract syntax tree (AST), similarity, adaptive threshold

中图分类号: 

  • TP311