PyScribe-学习描述 python 代码

Juncai Guo, Jin Liu, Xiao Liu, Yao Wan, Yanjie Zhao, Li Li, Kui Liu, Jacques Klein, Tegawendé F. Bissyandé
{"title":"PyScribe-学习描述 python 代码","authors":"Juncai Guo, Jin Liu, Xiao Liu, Yao Wan, Yanjie Zhao, Li Li, Kui Liu, Jacques Klein, Tegawendé F. Bissyandé","doi":"10.1002/spe.3291","DOIUrl":null,"url":null,"abstract":"Code comment generation, which attempts to summarize the functionality of source code in textual descriptions, plays an important role in automatic software development research. Currently, several structural neural networks have been exploited to preserve the syntax structure of source code based on abstract syntax trees (ASTs). However, they can not well capture both the long-distance and local relations between nodes while retaining the overall structural information of AST. To mitigate this problem, we present a prototype tool titled <span>PyScribe</span>, which extends the Transformer model to a new encoder-decoder-based framework. Particularly, the triplet position is designed and integrated into the node-level and edge-level structural features of AST for producing Python code comments automatically. This paper, to the best of our knowledge, makes the first effort to model the edges of AST as an explicit component for improved code representation. By specifying triplet positions for each node and edge, the overall structural information can be well preserved in the learning process. Moreover, the captured node and edge features go through a two-stage decoding process to yield higher qualified comments. To evaluate the effectiveness of <span>PyScribe</span>, we resort to a large dataset of code-comment pairs by mining Jupyter Notebooks from GitHub, for which we have made it publicly available to support further studies. The experimental results reveal that <span>PyScribe</span> is indeed effective, outperforming the state-ofthe-art by achieving an average BLEU score (i.e., av-BLEU) of <math altimg=\"urn:x-wiley:spe:media:spe3291:spe3291-math-0001\" display=\"inline\" location=\"graphic/spe3291-math-0001.png\" overflow=\"scroll\">\n<semantics>\n<mrow>\n<mo form=\"prefix\">≈</mo>\n</mrow>\n$$ \\approx $$</annotation>\n</semantics></math>0.28.","PeriodicalId":21899,"journal":{"name":"Software: Practice and Experience","volume":null,"pages":null},"PeriodicalIF":0.0000,"publicationDate":"2023-12-09","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":"{\"title\":\"PyScribe–Learning to describe python code\",\"authors\":\"Juncai Guo, Jin Liu, Xiao Liu, Yao Wan, Yanjie Zhao, Li Li, Kui Liu, Jacques Klein, Tegawendé F. Bissyandé\",\"doi\":\"10.1002/spe.3291\",\"DOIUrl\":null,\"url\":null,\"abstract\":\"Code comment generation, which attempts to summarize the functionality of source code in textual descriptions, plays an important role in automatic software development research. Currently, several structural neural networks have been exploited to preserve the syntax structure of source code based on abstract syntax trees (ASTs). However, they can not well capture both the long-distance and local relations between nodes while retaining the overall structural information of AST. To mitigate this problem, we present a prototype tool titled <span>PyScribe</span>, which extends the Transformer model to a new encoder-decoder-based framework. Particularly, the triplet position is designed and integrated into the node-level and edge-level structural features of AST for producing Python code comments automatically. This paper, to the best of our knowledge, makes the first effort to model the edges of AST as an explicit component for improved code representation. By specifying triplet positions for each node and edge, the overall structural information can be well preserved in the learning process. Moreover, the captured node and edge features go through a two-stage decoding process to yield higher qualified comments. To evaluate the effectiveness of <span>PyScribe</span>, we resort to a large dataset of code-comment pairs by mining Jupyter Notebooks from GitHub, for which we have made it publicly available to support further studies. The experimental results reveal that <span>PyScribe</span> is indeed effective, outperforming the state-ofthe-art by achieving an average BLEU score (i.e., av-BLEU) of <math altimg=\\\"urn:x-wiley:spe:media:spe3291:spe3291-math-0001\\\" display=\\\"inline\\\" location=\\\"graphic/spe3291-math-0001.png\\\" overflow=\\\"scroll\\\">\\n<semantics>\\n<mrow>\\n<mo form=\\\"prefix\\\">≈</mo>\\n</mrow>\\n$$ \\\\approx $$</annotation>\\n</semantics></math>0.28.\",\"PeriodicalId\":21899,\"journal\":{\"name\":\"Software: Practice and Experience\",\"volume\":null,\"pages\":null},\"PeriodicalIF\":0.0000,\"publicationDate\":\"2023-12-09\",\"publicationTypes\":\"Journal Article\",\"fieldsOfStudy\":null,\"isOpenAccess\":false,\"openAccessPdf\":\"\",\"citationCount\":\"0\",\"resultStr\":null,\"platform\":\"Semanticscholar\",\"paperid\":null,\"PeriodicalName\":\"Software: Practice and Experience\",\"FirstCategoryId\":\"1085\",\"ListUrlMain\":\"https://doi.org/10.1002/spe.3291\",\"RegionNum\":0,\"RegionCategory\":null,\"ArticlePicture\":[],\"TitleCN\":null,\"AbstractTextCN\":null,\"PMCID\":null,\"EPubDate\":\"\",\"PubModel\":\"\",\"JCR\":\"\",\"JCRName\":\"\",\"Score\":null,\"Total\":0}","platform":"Semanticscholar","paperid":null,"PeriodicalName":"Software: Practice and Experience","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1002/spe.3291","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 0

摘要

代码注释生成试图用文本描述来概括源代码的功能,在自动软件开发研究中发挥着重要作用。目前,已有一些结构神经网络被用来保存基于抽象语法树(AST)的源代码语法结构。然而,它们无法在保留 AST 整体结构信息的同时,很好地捕捉节点之间的远距离关系和局部关系。为了缓解这一问题,我们提出了一个名为 PyScribe 的原型工具,它将 Transformer 模型扩展到一个基于编码器-解码器的新框架。特别是,我们设计了三连音位置,并将其集成到 AST 的节点级和边缘级结构特征中,用于自动生成 Python 代码注释。据我们所知,本文首次尝试将 AST 的边作为显式组件建模,以改进代码表示。通过为每个节点和边缘指定三元组位置,可以在学习过程中很好地保留整体结构信息。此外,捕捉到的节点和边缘特征会经过两级解码过程,以生成更高质量的注释。为了评估 PyScribe 的有效性,我们从 GitHub 的 Jupyter Notebook 中挖掘了大量代码-注释对数据集,并将其公开以支持进一步的研究。实验结果表明,PyScribe 确实很有效,其平均 BLEU 得分(即 av-BLEU)达到了 ≈$$ \approx $$0.28,超过了现有技术。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
查看原文
分享 分享
微信好友 朋友圈 QQ好友 复制链接
本刊更多论文
PyScribe–Learning to describe python code
Code comment generation, which attempts to summarize the functionality of source code in textual descriptions, plays an important role in automatic software development research. Currently, several structural neural networks have been exploited to preserve the syntax structure of source code based on abstract syntax trees (ASTs). However, they can not well capture both the long-distance and local relations between nodes while retaining the overall structural information of AST. To mitigate this problem, we present a prototype tool titled PyScribe, which extends the Transformer model to a new encoder-decoder-based framework. Particularly, the triplet position is designed and integrated into the node-level and edge-level structural features of AST for producing Python code comments automatically. This paper, to the best of our knowledge, makes the first effort to model the edges of AST as an explicit component for improved code representation. By specifying triplet positions for each node and edge, the overall structural information can be well preserved in the learning process. Moreover, the captured node and edge features go through a two-stage decoding process to yield higher qualified comments. To evaluate the effectiveness of PyScribe, we resort to a large dataset of code-comment pairs by mining Jupyter Notebooks from GitHub, for which we have made it publicly available to support further studies. The experimental results reveal that PyScribe is indeed effective, outperforming the state-ofthe-art by achieving an average BLEU score (i.e., av-BLEU) of  $$ \approx $$ 0.28.
求助全文
通过发布文献求助,成功后即可免费获取论文全文。 去求助
来源期刊
自引率
0.00%
发文量
0
期刊最新文献
Algorithms for generating small random samples A comprehensive survey of UPPAAL‐assisted formal modeling and verification Large scale system design aided by modelling and DES simulation: A Petri net approach Empowering software startups with agile methods and practices: A design science research Space‐efficient data structures for the inference of subsumption and disjointness relations
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
现在去查看 取消
×
提示
确定
0
微信
客服QQ
Book学术公众号 扫码关注我们
反馈
×
意见反馈
请填写您的意见或建议
请填写您的手机或邮箱
已复制链接
已复制链接
快去分享给好友吧!
我知道了
×
扫码分享
扫码分享
Book学术官方微信
Book学术文献互助
Book学术文献互助群
群 号:481959085
Book学术
文献互助 智能选刊 最新文献 互助须知 联系我们:info@booksci.cn
Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。
Copyright © 2023 Book学术 All rights reserved.
ghs 京公网安备 11010802042870号 京ICP备2023020795号-1