SAR:用很少的知识学习跨语言的API映射
SAR: Learning Cross-Language API Mappings with Little Knowledge
摘要:
为了节省手工工作,开发人员经常将程序从一种程序设计语言翻译成另一种,而不是从头开始实现它。将一种语言中使用的应用程序接口(API)转换为另一种语言中可用的功能等效的API是程序翻译的一个重要方面。现有方法通过自动识别跨程序设计语言的API映射来促进转换。然而,所有这些方法在准备并行程序语料库时仍然需要大量的手动工作,范围从成对的API到被认为是功能等效的不同语言的手动识别代码。为了最大限度地减少手动识别并行程序语料库和API映射的工作,本文旨在在一个自动化的方法来映射API跨语言的先验知识少得多,需要比其他现有的方法。该方法基于域自适应与代码嵌入相结合的概念的实现,它可以更好地对齐两个向量空间:以大型程序集作为输入,我们的方法首先生成程序的数字向量表示,特别是每种语言中使用的API,并适应生成对抗网络(GAN)来对齐两种语言空间的向量。为了更好地对齐,我们使用从可选的API映射种子导出的参数来初始化GAN,这些API映射种子可以通过简单的基于签名的自动匹配启发式算法来准确识别。然后,可以通过对齐的向量空间中的最近邻查询来识别跨语言API映射。
英文摘要:
To save manual effort, developers often translate programs from one programming language to another, instead of implementing it from scratch. Translating application program interfaces (APIs) used in one language to functionally equivalent ones available in another language is an important aspect of program translation. Existing approaches facilitate the translation by automatically identifying the API mappings across programming languages. However, all these approaches still require large amount of manual effort in preparing parallel program corpora, ranging from pairs of APIs, to manually identified code in different languages that are considered as functionally equivalent. To minimize the manual effort in identifying parallel program corpora and API mappings, this paper aims at an automated approach to map APIs across languages with much less knowledge a priori needed than other existing approaches. The approach is based on an realization of the notion of domain adaption combined with code embedding, which can better align two vector spaces: taking as input large sets of programs, our approach first generates numeric vector representations of the programs, especially the APIs used in each language, and it adapts generative adversarial networks (GAN) to align the vectors from the spaces of two languages. For a better alignment, we initialize the GAN with parameters derived from optional API mapping seeds that can be identified accurately with a simple automatic signature-based matching heuristic. Then the cross-language API mappings can be identified via nearest-neighbors queries in the aligned vector spaces.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。