-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTranscoder.py
53 lines (34 loc) · 1.43 KB
/
Transcoder.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# -*- coding: utf-8 -*-
"""TranslateFUnker.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1sIkrpRnvEIkoim__nJzcuVlVEKbxrFD9
"""
import os
!pip install six
!pip install sacrebleu=="1.2.11"
!pip install submitit
!pip install clang==6.0.0.2
!git clone https://github.com/glample/fastBPE
os.chdir("fastBPE")
!python setup.py install
os.chdir("..")
! git clone https://github.com/NVIDIA/apex
os.chdir("apex")
!pip install -v --no-cache-dir ./
os.chdir("..")
!git clone https://github.com/facebookresearch/TransCoder.git
!wget https://dl.fbaipublicfiles.com/transcoder/model_2.pth
#Change the last url word to
# "model_2.pth" if you want C++ -> Python, Python -> C++ and Python -> Java
# or "model_1.pth" if you want C++ -> Java, Java -> C++ and Java -> Python
!python TransCoder/translate.py --src_lang python --tgt_lang cpp \\
--BPE_path TransCoder/data/BPE_with_comments_codes --model_path model_2.pth < test.py
# Click files and place content you want to translate beside sample_data
# If outside of standard url, the standard url is "cd /content"
#cd /content/TransCoder/preprocessing/src/ #code_tokenizer.py
#go to url and open file, line 24 og change text to:
#clang.cindex.Config.set_library_path('/usr/lib/llvm-6.0/lib')
#cd /usr/lib/llvm-6.0/lib/
#go to url and change name libclang.so.1 to libclang.so
#check at top "Runtime"-->"Change runtime type" is set to GPU