code2vec的初步应用

本文详细介绍了如何在Windows环境下利用code2vec和astminer工具将代码转换为词向量。首先,通过Gradle构建astminer的jar包,然后在Git的sh.exe中运行相关命令,提取代码的AST路径和上下文信息。通过`java-jar lib-0.5.jar code2vec`等命令生成code2vec所需的输入数据,最终将代码转化为适用于机器学习模型的词向量表示。实验表明,两种不同的命令行调用方式得到的结果一致。

最近想使用code2vec这种词向量工具将代码转化为词向量,我在网上只看到了文章讲到在github上的code2vec工具的使用
文章地址
https://blog.youkuaiyun.com/qysh123/article/details/106309967#comments_15034857

基本内容如下:

code2vec(项目GitHub:https://github.com/tech-srl/code2vec)是发表在POPL 2019上的论文:

Alon, Uri, Meital Zilberstein, Omer Levy, and Eran Yahav. “code2vec: Learning distributed representations of code.” Proceedings of the ACM on Programming Languages 3, no. POPL (2019): 1-29.

发表以来也确实受到了很多关注,例如ASE 2019上就至少有两篇论文做的是follow up的工作(虽然都是在一定程度上批评,但也说明了其影响力):

Jiang, Lin, Hui Liu, and He Jiang. “Machine Learning Based Recommendation of Method Names: How Far are We.” In 2019 34th IEEE/ACM International Conference on Automated Software Engineering (ASE), pp. 602-614. IEEE, 2019.

Kang, Hong Jin, Tegawendé F. Bissyandé, and David Lo. “Assessing the Generalizability of Code2vec Token Embeddings.” In 2019 34th IEEE/ACM International Conference on Automated Software Engineering (ASE), pp. 1-12. IEEE, 2019.

今天简单总结一下怎么用现有工具来生成code2vec的输入数据,用的是astminer这个工具:

https://github.com/JetBrains-Research/astminer

这个工具实际上也有对应的论文,之前的名字还是叫PathMiner:

Kovalenko, Vladimir, Egor Bogomolov, Timofey Bryksin, and Alberto Bacchelli. “PathMiner: a library for mining of path-based representations of code.” In 2019 IEEE/ACM 16th International Conference on Mining Software Repositories (MSR), pp. 13-17. IEEE, 2019.

个人感觉改了的名字还是好一些。我这里总结一下在Windows上的运行方法:

下载其Zip或者git clo

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值