基于Word2vec的克隆代码检测方法研究  被引量:2

Research on Clone Code Detection Method Based on Word2vec

在线阅读下载全文

作  者:贾清 杨抒[1] JIA Qing;YANG Shu(School of Computer and Information Engineering,Xinjiang Agricultural University,Urumqi 830052,China)

机构地区:[1]新疆农业大学计算机与信息工程学院,新疆乌鲁木齐830052

出  处:《计算机技术与发展》2020年第8期124-128,共5页Computer Technology and Development

基  金:新疆维吾尔自治区重大科技专项(2017A01002-5);新疆农业大学博士后科研流动站资助。

摘  要:系统中的克隆代码会增加程序员理解代码、修改代码的时间,并且在代码中一处克隆代码出现错误可能会导致系统中多个相同代位置的代码出现错误,大大增大了程序员进行软件维护的成本。为了找到系统文件中的克隆代码,利用基于Word2vec的克隆代码检测方法,针对新疆马业电商平台中的代码进行克隆检测。通过对系统源代码进行数据清洗,去除不需要的字符;Word2vec模型是一群浅并且双层的神经网络,选择Word2vec中的skip-gram模型进行训练并且构造词向量。训练完成后,模型可用来映射每个词到一个向量,用来表示词对词之间的关系。最后通过夹角余弦的方法来计算代码相似度,从而自动检测代码中的克隆代码。研究结果表明:基于Word2vec的克隆代码检测方法可以很好地检测出代码文件中的克隆代码,并且以指定的方式进行输出。The clone code in the system will increase the time for the programmer to understand the code and modify it,and the mistake of a clone code in the code may lead to the mistake of the code in the same generation position in the system,which greatly increases the cost of the programmer’s software maintenance.In order to find the clone code in the system file,we use the clone code detection method based on Word2vec to clone the code in the Xinjiang Horse Industry e-commerce platform.The unnecessary characters are removed by data cleaning of the system source code.Word2vec model is a group of shallow and double-layer neural networks.Skip-gram model in Word2vec is selected to train and construct word vectors.After training,the model can be used to map each word to a vector to express the relationship between words.At last,the code similarity is calculated by the method of Angle cosine,so that the clone code in the code can be detected automatically.The results show that Word2vec-based clone code detection method can detect the clone code in the code file effectively and output it in the specified way.

关 键 词:Word2vec 克隆代码 自动检测 相似度 软件维护 

分 类 号:TP311[自动化与计算机技术—计算机软件与理论]

 

参考文献:

正在载入数据...

 

二级参考文献:

正在载入数据...

 

耦合文献:

正在载入数据...

 

引证文献:

正在载入数据...

 

二级引证文献:

正在载入数据...

 

同被引文献:

正在载入数据...

 

相关期刊文献:

正在载入数据...

相关的主题
相关的作者对象
相关的机构对象