hmCodeTrans: Human–Machine Interactive Code Translation
- 20 March 2024
- journal article
- research article
- Published by Institute of Electrical and Electronics Engineers (IEEE) in IEEE Transactions on Software Engineering
- Vol. 50 (5) , 1163-1181
Abstract
Code translation, i.e., translating one kind of code language to another, plays an important role in scenarios such as application modernization and multi-language versions of applications on different platforms. Even the most advanced machine-based code translation methods can not guarantee an error-free result. Therefore, the participance of software engineer is necessary. Considering both accuracy and efficiency, it is suggested to work in a human-machine collaborative way. However, in many realistic scenarios, human and machine collaborate ineffectively - model translates first and then human makes further editing, without any interaction. To solve this problem, we propose hmCodeTrans, a novel method that achieves code translation in an interactive human-machine collaborative way . It can (1) save the human effort by introducing two novel human-machine collaboration patterns: prefix-based and segment-based ones, which feed the software engineer’s sequential or scattered editing back to model and thus enabling the model to make a better retranslation; (2) reduce the response time based on two proposed modules: attention cache module that avoids duplicate prefix inference with cached attention information, and suffix splicing module that reduces invalid suffix inference by splicing a predefined suffix. The experiments are conducted on two real datasets. Results show that compared with the baselines, our approach can effectively save the human effort and reduce the response time. Last but not least, a user study involving five real software engineers is given, which validates that the proposed approach owns the lowest human effort and shows the users’ satisfaction towards the approach.Keywords
Funding Information
- National Science and Technology Major Project (2021ZD0113305)
- National Natural Science Foundation of China (61960206008, 62372381)
- National Science Fund for Distinguished Young Scholars (62025205)
This publication has 35 references indexed in Scilit:
- What do pre-trained code models know about code?2021
- Programming Language Translator For Integration Client Application With Web APIs2021
- Human–machine computingCCF Transactions on Pervasive Computing and Interaction, 2021
- Performance vs. competence in human–machine comparisonsProceedings of the National Academy of Sciences of the United States of America, 2020
- A Tool for Translating Sequential Source Code to Parallel Code Written in C++ and OpenACC2019
- Online learning for effort reduction in interactive neural machine translationComputer Speech & Language, 2019
- Agency plus automation: Designing artificial intelligence into interactive systemsProceedings of the National Academy of Sciences of the United States of America, 2019
- Interactive neural machine translationComputer Speech & Language, 2017
- Divide-and-Conquer Approach for Multi-phase Statistical Migration for Source Code (T)2015
- Target-Text Mediated Interactive Machine TranslationMachine Translation, 1997