论文标题
通过神经网络探索代码样式转移
Exploring Code Style Transfer with Neural Networks
论文作者
论文摘要
样式是自然语言文本的重要组成部分,反映了文本语调的变化,同时保持基础信息相同。即使编程语言具有严格的语法规则,它们也具有风格。代码可以使用相同的功能编写,但使用不同的语言功能。但是,编程样式很难量化,因此,作为这项工作的一部分,我们定义了专门针对Python的样式属性。为了构建样式的定义,我们利用层次聚类来捕获样式定义,而无需指定转换。除了定义样式外,我们还探索了预训练的代码语言模型的能力,以捕获有关代码样式的信息。为此,我们微调了预训练的代码语言模型,并在代码样式转移任务中评估了其性能。
Style is a significant component of natural language text, reflecting a change in the tone of text while keeping the underlying information the same. Even though programming languages have strict syntax rules, they also have style. Code can be written with the same functionality but using different language features. However, programming style is difficult to quantify, and thus as part of this work, we define style attributes, specifically for Python. To build a definition of style, we utilized hierarchical clustering to capture a style definition without needing to specify transformations. In addition to defining style, we explore the capability of a pre-trained code language model to capture information about code style. To do this, we fine-tuned pre-trained code-language models and evaluated their performance in code style transfer tasks.