Skip to content

Latest commit

 

History

History
57 lines (45 loc) · 4.57 KB

README.md

File metadata and controls

57 lines (45 loc) · 4.57 KB

Program translation retrieval system

Program translation is a growing demand in software engineering. Manual program translation requires programming expertise in source and target language. One way to automate this process is to make use of the big data of programs. However, existing code retrieval techniques lack the design to cover cross-language code retrieval. Other data-driven approaches require human efforts in constructing cross-language parallel datasets to train translation models. We built a code translation retrieval system. We use a lightweight but informative program representation, which can be generalized to all imperative PLs. Furthermore, we implement our customized index structure and hierarchical filtering mechanism for efficient code retrieval from a big data.

workflow

Dependencies

  • Python3
  • MongoDB
  • pymongo
  • ANTLR (Java target)

Create a feature database

In the offline phase, system constructs feature reapresentation for each program in the database and save it in a feature database for use.

sh create_feature_db.sh path_to_your_database

Create index

System constructs path-type-bucket-index for the featrue representations.

python3 create_index.py

User can specify maximum bucket size in bucket_size.json.

Retrieve translation for a program

sh translate.sh path_to_input_code target_language

In this repository, we add 4 programming languages: Python, Java, C++, JavaScript.

If you want more languages support, just simply run ANTLR parser in your desired language and enrich the lang_collection list in each file.

Evaluations

Comparison with Data-driven Program Translation

We compare the results of effectiveness and efficiency of our system with the following state-of-the-art baselines:

  • 1pSMT: phrase-based SMT on sequential programs.
  • mppSMT: multi-phase phrase-based SMT.
  • Tree2tree: tree-to-tree neural networks.
  • TransCoder: weakly-supervise translation model.

eval1