用词嵌入弥合自然语言和API之间的语义鸿沟
Bridging Semantic Gaps between Natural Languages and APIs with Word Embedding
摘要:
开发人员越来越依赖文本匹配工具来分析自然语言单词和API之间的关系。然而,语义差距,即单词和API之间的文本不匹配,对这些工具产生了负面影响。以往的研究都是将词或API转换为低维向量进行匹配,但由于无法同时对词和API进行建模,因此得到的结果不准确。为了解决这个问题,需要解决两个主要挑战:获取大量单词和API进行挖掘,以及对齐单词和API进行建模。因此,本研究提出Word 2API来有效地估计单词和API的相关性。Word 2API从代码存储库中收集了数百万个常用单词和API,以解决获取挑战。然后,使用混洗策略将相关单词和API转换为元组以解决对齐挑战。使用这些元组,Word 2API同时对单词和API进行建模。Word 2API在精度和NDCG方面的相关度估计优于基线10%-49.6%。Word 2API在解决典型的软件任务方面也很有效,例如,查询扩展和API文档链接。使用Word 2API扩展查询的简单系统为开发人员推荐了高达21.4%的相关API。同时,Word 2API在将问答社区中的问题链接到API文档方面,将比较算法提高了7.9%-17.4%。
英文摘要:
Developers increasingly rely on text matching tools to analyze the relation between natural language words and APIs. However, semantic gaps, namely textual mismatches between words and APIs, negatively affect these tools. Previous studies have transformed words or APIs into low-dimensional vectors for matching; however, inaccurate results were obtained due to the failure of modeling words and APIs simultaneously. To resolve this problem, two main challenges are to be addressed: the acquisition of massive words and APIs for mining and the alignment of words and APIs for modeling. Therefore, this study proposes Word2API to effectively estimate relatedness of words and APIs. Word2API collects millions of commonly used words and APIs from code repositories to address the acquisition challenge. Then, a shuffling strategy is used to transform related words and APIs into tuples to address the alignment challenge. Using these tuples, Word2API models words and APIs simultaneously. Word2API outperforms baselines by 10%-49.6% of relatedness estimation in terms of precision and NDCG. Word2API is also effective on solving typical software tasks, e.g., query expansion and API documents linking. A simple system with Word2API-expanded queries recommends up to 21.4% more related APIs for developers. Meanwhile, Word2API improves comparison algorithms by 7.9%-17.4% in linking questions in Question&Answer communities to API documents.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。