首页 | 本学科首页   官方微博 | 高级检索  
相似文献
 共查询到19条相似文献,搜索用时 218 毫秒
1.
在当前的软件开发环境中,海量的低质量、无意义的代码知识为开发人员进行代码复用造成了阻碍,大大降低了软件开发效率。为了快速准确地为开发人员推荐高质量的代码知识,提出了基于SBERT(sentence-BERT)模型的代码片段推荐方法CSRSB(code snippets recommendation based on sentence-BERT)。该方法首先获取海量的高质量数据来构建代码语料库,并基于深度学习模型SBERT为代码片段对应的自然语言描述和用户输入的自然语言查询生成具有丰富语义的句向量,通过比较点积相似度来实现代码片段的推荐。使用命中率、平均倒数排名和平均准确率这三个常用推荐评估指标与现有相关研究中的方法进行对比来验证该方法的有效性。实验结果表明,CSRSB在有效提高代码片段推荐准确度的同时也能够做到快速推荐。  相似文献   

2.
已有的基于文本生成的无约束型自然语言信息隐藏方法主要利用不同的文本生成模型在秘密信息的控制下实现隐写文本的生成,它们生成的隐写文本质量较好且嵌入容量高.但这些方法大都局限于生成短隐写文本,整体的文本质量和句间语义相关性会随着句子长度增加而急剧下降.与无约束型方法不同,已有的约束型自然语言信息隐藏方法能针对特定场景实现长文本生成任务下的信息隐藏,具有更高的语言隐蔽性和安全性.为提高约束型方法面对各类应用场景的普适性,本文提出了一种通用的序列到隐写序列模型框架,该框架包含语言编码器和隐写器两部分,能实现从一种约束信息序列到另一种隐写文本序列的变换.以摘要生成为例,本文以序列到隐写序列模型为基本框架,提出了一种新颖的约束型自然语言信息隐藏方法.该方法在语言编码器中引入注意力优化单元以提升特征学习性能,在隐写器中融合复制机制和新设计的基于多候选优化的自适应隐写编码方法,使得隐写器可以根据候选单词序列的概率分布情况和待嵌入的秘密信息自适应地选择不同的输出优化策略,通过输出多个候选序列以及仅在嵌入时刻选择合适位置嵌入信息的方式来提高隐写文本质量.实验结果表明,本文提出的方法能够通过优化语言编码器和...  相似文献   

3.
陈晨  周宇  王永超  黄志球 《计算机科学》2021,48(12):100-106
在软件开发的过程中,开发人员在遇到编程困境时通常会检索合适的API来完成编程任务.情境信息和开发者画像在有效的API推荐中起着至关重要的作用,却在很大程度上被忽视了.因而文中提出了一种基于情境感知的API个性化推荐方法.该方法利用程序静态分析技术,对代码文件做抽象语法树解析,提取信息构建代码库,并对开发者API使用偏好建模.然后计算开发者当前查询语句与历史代码库中查询的语义相似度,检索出top-k个相似历史查询.最终利用查询语句信息、方法名信息、情境信息以及开发者API使用偏好信息对API进行重排序并推荐给开发者.通过模拟编程任务开发的不同阶段,使用MRR,MAP,Hit,NDCG评估指标来验证所提方法的有效性.实验结果表明,所提方法的API推荐效果优于基准方法,能够为开发者推荐更想要的API.  相似文献   

4.
胡天翔  谢睿  叶蔚  张世琨 《软件学报》2023,34(4):1695-1710
代码摘要通过生成源代码片段的简短自然语言描述, 可帮助开发人员理解代码并减少文档工作. 近期, 关于代码摘要的研究工作主要采用深度学习模型, 这些模型中的大多数都在由独立代码摘要对组成的大型数据集上进行训练. 尽管取得了良好的效果, 这些工作普遍忽略了代码片段和摘要的项目级上下文信息, 而开发人员在编写文档时往往高度依赖这些信息. 针对该问题, 研究了一种与开发者行为和代码摘要工具实现更加一致的代码摘要场景——项目级代码摘要, 其中, 创建了用于项目特定代码摘要的数据集, 该数据集包含800k方法摘要对及其生命周期信息, 用于构建特定时刻准确的项目项目上下文; 提出了一种新颖的深度学习方法, 利用高度相关的代码片段及其相应的摘要来表征上下文语义, 并通过迁移学习整合从大规模跨项目数据集中学到的常识. 实验结果表明: 基于项目级上下文的代码摘要模型不仅能够比通用代码摘要模型获得显著的性能提升, 同时, 针对特定项目能够生成更一致的摘要.  相似文献   

5.
周光有  谢琦  余啸 《软件学报》2024,35(6):2863-2879
代码搜索是当下自然语言处理和软件工程交叉领域的一个重要分支. 开发高效的代码搜索算法能够显著提高代码重用的能力, 从而有效提高软件开发人员的工作效率. 代码搜索任务是以描述代码片段功能的自然语言作为输入, 在海量代码库中搜索得到相关代码片段的过程. 基于序列模型的代码搜索方法DeepCS虽然取得了很好的效果, 但这种方法不能捕捉代码的深层语义. 基于图嵌入的代码搜索方法GraphSearchNet能缓解这个问题, 但没有对代码与文本进行细粒度匹配, 也忽视了代码图和文本图的全局关系. 为了解决以上局限性, 提出基于关系图卷积网络的代码搜索方法, 对构建的文本图和代码图编码, 从节点层面对文本查询和代码片段进行细粒度匹配, 并应用神经张量网络捕捉它们的全局关系. 在两个公开数据集上的实验结果表明, 所提方法比先进的基线模型DeepCS和GraphSearchNet搜索精度更高.  相似文献   

6.
离散序列生成广泛应用于文本生成、序列推荐等领域。目前的研究工作主要集中在提高序列生成的准确性,却忽略了生成的多样性。针对该现象,提出了一种自适应序列生成方法ECoT,设置两层元控制器,在数据层面,使用元控制器实现自适应可学习采样,自动平衡真实数据与生成数据分布得到混合数据分布;在模型层面,添加多样性约束项,并使用元控制器自适应学习最优更新梯度,提升生成模型生成多样性。此外,进一步提出融合协同训练和对抗学习的方法,提升生成模型生成准确性。与目前的主流模型进行对比实验,结果表明,在生成准确性和多样性上,自适应协同训练序列生成方法具有更均衡的准确性和多样性,同时有效缓解生成模型的模式崩溃问题。  相似文献   

7.
软件开发者在软件代码中如何正确使用API和API序列(APIs),是一个需要学习的困难过程.于是面对不熟悉函数库或像Github那样包含大量APIs的代码仓库,需要一些推荐工具或系统辅助开发者的APIs使用.目前我们所知最好的方法DeepApi能较好理解用户的查询语义,但基于RNN的模型存在问题:(1)没有考虑每个单词的权重;(2)将输入序列压缩为一个固定长度的向量,损失了较多有用信息;(3)句子过长会使关键信息丢失.为此,本文使用了一种基于注意力机制的模型,可以区分每个单词的重要程度并解决长查询输入所产生的长距离依赖问题.我们从Github上面爬取了649个Java开源项目,经过处理得到有114 364对注释-API序列的训练集.实验结果表明我们的方法比DeepApi方法对于BLUE指标在Top1、Top5、Top10上均能提升约20%以上.  相似文献   

8.
徐少峰  潘文韬  熊赟  朱扬勇 《计算机工程》2020,46(2):304-308,314
在软件开发过程中,性能良好的代码注释工具能够提高开发效率并降低维护成本。部分研究者将代码注释自动生成看作将源代码翻译成自然语言注释的翻译任务,但仅考虑源代码的序列信息而忽略了代码内部的结构特性。为此,在常见端到端翻译模型的基础上,利用代码抽象语法树将源代码的结构信息嵌入到编码器解码器翻译模型中,提出一种基于结构感知的双编码器解码器模型,该模型综合考虑源代码的序列信息与代码内部的结构特性。在真实数据集上的实验结果表明,相比PBMT、Seq2seq模型,该模型的BLEU得分较高,且生成的注释更准确和易读。  相似文献   

9.
搜索并重用相关代码可以有效提高软件开发效率。基于深度学习的代码搜索模型通常将代码片段和查询语句嵌入同一向量空间,通过计算余弦相似度匹配并输出相应代码片段;然而大多数模型忽略了代码片段与查询语句间的协同信息。为了更全面地表征语义信息,提出一种基于协同融合的代码搜索模型BofeCS。首先,采用BERT(Bidirectional Encoder Representations from Transformers)模型提取输入序列的语义信息并将它表征为向量;其次,构建协同融合网络提取代码片段和查询语句间分词级的协同信息;最后,构建残差网络缓解表征过程中的语义信息丢失。为验证BofeCS的有效性,在多语言数据集CodeSearchNet上进行实验。实验结果表明,相较于基线模型UNIF(embedding UNIFication)、TabCS(Two-stage attention-based model for Code Search)和MRCS(Multimodal Representation for neural Code Search),BofeCS的平均倒数排名(MRR)、归一化折损...  相似文献   

10.
为了追求精度,深度学习模型框架的结构越来越复杂,网络越来越深.参数量的增加意味着训练模型需要更多的数据.然而人工标注数据的成本是高昂的,且受客观原因所限,实际应用时可能难以获得特定领域的数据,数据不足问题非常常见.数据增强通过人为地生成新的数据增加数据量来缓解这一问题.数据增强方法在计算机视觉领域大放异彩,让人们开始关注类似方法能否应用在序列数据上.除了翻转、裁剪等在时间域进行增强的方法外,也描述了在频率域实现数据增强的方法;除了人们基于经验或知识而设计的方法以外,对一系列基于GAN的通过机器学习模型自动生成数据的方法也进行了详细的论述.介绍了应用在自然语言文本、音频信号和时间序列等多种序列数据上的数据增强方法,亦有涉及它们在医疗诊断、情绪判断等问题上的表现.尽管数据类型不同,但总结了应用在这些类型上的数据增强方法背后的相似的设计思路.以这一思路为线索,梳理应用在各类序列数据类型上的多种数据增强方法,并进行了一定的讨论和展望.  相似文献   

11.
在软件开发过程中,复用应用程序编程接口(Application Programming Interface,API)可以提高软件开发效率,但是使用不熟悉的API是一项耗时且困难的挑战。已有的研究往往将API作为用户输入的查询,通过在语料库中搜索该API的使用模式来进行推荐,但这并不符合开发人员的查询习惯。文中提出了一种基于自然语言语义相似度的API使用模式推荐方法(Semantic Similazing Based API Recommendation,SSAPIR)。该方法使用层次聚类算法来提取API使用模式,然后通过计算查询信息和API使用模式来描述信息之间的语意相似度,向开发人员推荐相关度高且被广泛使用的API使用模式。为了验证SSAPIR的有效性,文中从GitHub的高质量Java项目中提取9个流行的第三方API库的API使用模式以及API使用模式的描述信息,并根据这9个流行的第三方API库的自然语言查询进行API使用模式推荐。通过计算推荐结果的Hit@K准确率来验证SSAPIR的有效性,实验结果表明,层次聚类能有效提高推荐准确率,且SSAPIR在Hit@10平均准确率上达到了85.02%,优于现有研究工作,能够很好地完成API使用模式推荐任务,为开发人员输入的自然语言查询提供精准的API使用模式。  相似文献   

12.
Developers commonly make use of a web search engine such as Google to locate online resources to improve their productivity. A better understanding of what developers search for could help us understand their behaviors and the problems that they meet during the software development process. Unfortunately, we have a limited understanding of what developers frequently search for and of the search tasks that they often find challenging. To address this gap, we collected search queries from 60 developers, surveyed 235 software engineers from more than 21 countries across five continents. In particular, we asked our survey participants to rate the frequency and difficulty of 34 search tasks which are grouped along the following seven dimensions: general search, debugging and bug fixing, programming, third party code reuse, tools, database, and testing. We find that searching for explanations for unknown terminologies, explanations for exceptions/error messages (e.g., HTTP 404), reusable code snippets, solutions to common programming bugs, and suitable third-party libraries/services are the most frequent search tasks that developers perform, while searching for solutions to performance bugs, solutions to multi-threading bugs, public datasets to test newly developed algorithms or systems, reusable code snippets, best industrial practices, database optimization solutions, solutions to security bugs, and solutions to software configuration bugs are the most difficult search tasks that developers consider. Our study sheds light as to why practitioners often perform some of these tasks and why they find some of them to be challenging. We also discuss the implications of our findings to future research in several research areas, e.g., code search engines, domain-specific search engines, and automated generation and refinement of search queries.  相似文献   

13.
Source code examples are used by developers to implement unfamiliar tasks by learning from existing solutions. To better support developers in finding existing solutions, code search engines are designed to locate and rank code examples relevant to user’s queries. Essentially, a code search engine provides a ranking schema, which combines a set of ranking features to calculate the relevance between a query and candidate code examples. Consequently, the ranking schema places relevant code examples at the top of the result list. However, it is difficult to determine the configurations of the ranking schemas subjectively. In this paper, we propose a code example search approach that applies a machine learning technique to automatically train a ranking schema. We use the trained ranking schema to rank candidate code examples for new queries at run-time. We evaluate the ranking performance of our approach using a corpus of over 360,000 code snippets crawled from 586 open-source Android projects. The performance evaluation study shows that the learning-to-rank approach can effectively rank code examples, and outperform the existing ranking schemas by about 35.65 % and 48.42 % in terms of normalized discounted cumulative gain (NDCG) and expected reciprocal rank (ERR) measures respectively.  相似文献   

14.
Searching for relevant code in the local code base is a common activity during software maintenance. However, previous research indicates that 88% of manually composed search queries retrieve no relevant results. One reason that many searches fail is existing search tools’ dependence on string matching algorithms, which cannot find semantically related code. To solve this problem by helping developers compose better queries, researchers have proposed numerous query recommendation techniques, relying on a variety of dictionaries and algorithms. However, few of these techniques are empirically evaluated by usage data from real-world developers. To fill this gap, we designed a multi-recommendation system that relies on the cooperation between several query recommendation techniques. We implemented and deployed this recommendation system within the Sando code search tool and conducted a longitudinal field study. Our study shows that over 34% of all queries were adopted from recommendation; and recommended queries retrieved results 11% more often than manual queries.  相似文献   

15.
邢双双  刘名威  彭鑫 《软件学报》2022,33(11):4027-4045
开源及企业软件项目和各类软件开发网站上的代码片段是重要的软件开发资源.然而,很多开发者代码搜索需求反映的代码的高层意图和主题难以通过基于代码文本的信息检索技术来实现精准的代码搜索.因此,反映代码整体意图和主题的语义标签对于改进代码搜索、辅助代码理解都具有十分重要的作用.现有的标签生成技术主要面向文本内容或依赖于历史数据,无法满足大范围代码语义标注和辅助搜索、理解的需要.针对这一问题,提出了一种基于知识图谱的代码语义标签自动生成方法KGCodeTagger.该方法通过基于API文档和软件开发问答文本的概念和关系抽取构造软件知识图谱,作为代码语义标签生成的基础.针对给定的代码,该方法识别并抽取出通用API调用或概念提及,并链接到软件知识图谱中的相关概念上.在此基础上,该方法进一步识别与所链接的概念相关的其他概念作为候选,然后按照多样性和代表性排序,产生最终的代码语义标签.通过实验对KGCodeTagger软件知识图谱构建的各个步骤进行了评估,并通过与几个已有的基准方法的比较,对所生成的代码语义标签质量进行了评估.实验结果表明,KGCodeTagger的软件知识图谱构建步骤是合理有效的,该方法所生成的代码语义标签是高质量、有意义的,能够帮助开发人员快速理解代码的意图.  相似文献   

16.
Many Object-Oriented Databases (OODBs) use programming languages that predate Java, such as C++, CLOS and Smalltalk. Thus, there is a growing need for interoperating these OODBs with new applications that require Java. Unfortunately, there are few mechanisms that allow software developers to easily integrate Java applications with non-Java OODBs. Although various interoperability mechanisms have been developed over the years, these approaches have some significant drawbacks in practice. They are often difficult to use, provide little, if any, automated support, and produce software that is difficult to engineer and maintain. In this paper, we describe an interoperability approach that allows application developers to seamlessly and transparently access non-Java OODBs from Java applications. We first present JOQL, a Java-based object query language that we are developing. JOQL queries are embedded in Java applications and are used to perform queries over C++-based OODBs. We also describe an accompanying toolset that processes Java programs containing JOQL queries. The toolset produces all the necessary code allowing Java applications to access and manipulate a C++-based OODB. As a result, application developers are free to work in Java without having to concern themselves with the details of interoperating with C++. Finally, we provide some preliminary experimental data that demonstrates our approach incurs a reasonable performance overhead.  相似文献   

17.
源代码注释生成旨在为源代码生成精确的自然语言注释,帮助开发者更好地理解和维护源代码.传统的研究方法利用信息检索技术来生成源代码摘要,从初始源代码选择相应的词或者改写相似代码段的摘要;最近的研究采用机器翻译的方法,选择编码器-解码器的神经网络模型生成代码段的摘要.现有的注释生成方法主要存在两个问题:一方面,基于神经网络的方法对于代码段中出现的高频词更加友好,但是往往会弱化低频词的处理;另一方面,编程语言是高度结构化的,所以不能简单地将源代码作为序列化文本处理,容易造成上下文结构信息丢失.因此,本文为了解决低频词问题提出了基于检索的神经机器翻译方法,使用训练集中检索到的相似代码段来增强神经网络模型;为了学习代码段的结构化语义信息,本文提出结构化引导的Transformer,该模型通过注意力机制将代码结构信息进行编码.经过实验,结果证明该模型在低频词和结构化语义的处理上对比当下前沿的代码注释生成的深度学习模型具有显著的优势.  相似文献   

18.
This paper discusses the development of task-specific information retrieval systems for software engineers. We discuss how software engineers interact with information and information retrieval systems and investigate to what extent a domain-specific search and recommendation system can be developed in order to support their work related activities. We have conducted a user study which is based on the “Cognitive Research Framework” to identify the relation between the information objects used during the code development (code snippets and search queries), the tasks users engage in and the associated use of search interfaces. Based on our user studies, a questionnaire and an automated observation of user interactions with the browser and software development environment, we identify that software engineers engage in a finite number of work related tasks and they also develop a finite number of “work practices”/“archetypes of behaviour”. Secondly we identify a group of domain specific behaviours that can successfully be used as a source of strong implicit relevance feedback. Based on our results, we design a snippet recommendation interface, and a code related recommendation interface which are embedded within the standard search engine.  相似文献   

19.
Searching application programming interfaces (APIs) is very important for developers to reuse software projects. Existing natural language based API search mainly faces the following challenges. 1) More accurate results are required as software projects evolve to be more heterogeneous and complex. 2) The semantic relationships between APIs (e.g., inheritances between classes, and invocations between methods) need to be illustrated so that developers can better understand their usage scenarios. To deal with these issues, we propose GeAPI, a novel graph embedding based approach for API graph search and recommendation in this paper. First, we build a software project's API graph automatically from its source code and represent each API using graph embedding methods. Second, we search the API graph with a question in natural language, and return the corresponding subgraph that is composed of relevant code elements and their associated relationships, as the best answer of the question. In experiments, we select three well-known open source projects, JodaTime, Apache Lucene and POI, as examples to perform API search tasks. The experimental results show that our approach GeAPI improves F1-score by 10% compared with the existing shortest path based API search approach, while reduces the average response time about 60 times.  相似文献   

设为首页 | 免责声明 | 关于勤云 | 加入收藏

Copyright©北京勤云科技发展有限公司  京ICP备09084417号