最近想使用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

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

被折叠的 条评论
为什么被折叠?



