1
+ {
2
+ "nbformat" : 4 ,
3
+ "nbformat_minor" : 0 ,
4
+ "metadata" : {
5
+ "colab" : {
6
+ "name" : " TranslateFUnker.ipynb" ,
7
+ "provenance" : [],
8
+ "collapsed_sections" : []
9
+ },
10
+ "kernelspec" : {
11
+ "name" : " python3" ,
12
+ "display_name" : " Python 3"
13
+ },
14
+ "accelerator" : " GPU"
15
+ },
16
+ "cells" : [
17
+ {
18
+ "cell_type" : " code" ,
19
+ "metadata" : {
20
+ "id" : " jw4o8r6imM0q"
21
+ },
22
+ "source" : [
23
+ " import os"
24
+ ],
25
+ "execution_count" : 1 ,
26
+ "outputs" : []
27
+ },
28
+ {
29
+ "cell_type" : " code" ,
30
+ "metadata" : {
31
+ "id" : " zQkUJe-PmO-s"
32
+ },
33
+ "source" : [
34
+ " !pip install six\n " ,
35
+ " !pip install sacrebleu==\" 1.2.11\" "
36
+ ],
37
+ "execution_count" : null ,
38
+ "outputs" : []
39
+ },
40
+ {
41
+ "cell_type" : " code" ,
42
+ "metadata" : {
43
+ "id" : " 3Mbzw1RwmP1p"
44
+ },
45
+ "source" : [
46
+ " !pip install submitit\n " ,
47
+ " !pip install clang==6.0.0.2"
48
+ ],
49
+ "execution_count" : null ,
50
+ "outputs" : []
51
+ },
52
+ {
53
+ "cell_type" : " code" ,
54
+ "metadata" : {
55
+ "id" : " qtMvtRskmO55"
56
+ },
57
+ "source" : [
58
+ " !git clone https://github.com/glample/fastBPE"
59
+ ],
60
+ "execution_count" : null ,
61
+ "outputs" : []
62
+ },
63
+ {
64
+ "cell_type" : " code" ,
65
+ "metadata" : {
66
+ "id" : " pg1HriaYmO3Q"
67
+ },
68
+ "source" : [
69
+ " os.chdir(\" fastBPE\" )"
70
+ ],
71
+ "execution_count" : 4 ,
72
+ "outputs" : []
73
+ },
74
+ {
75
+ "cell_type" : " code" ,
76
+ "metadata" : {
77
+ "id" : " Tk5doN-wmO09"
78
+ },
79
+ "source" : [
80
+ " !python setup.py install"
81
+ ],
82
+ "execution_count" : null ,
83
+ "outputs" : []
84
+ },
85
+ {
86
+ "cell_type" : " code" ,
87
+ "metadata" : {
88
+ "id" : " 6SjNvTYymOyl"
89
+ },
90
+ "source" : [
91
+ " os.chdir(\" ..\" )"
92
+ ],
93
+ "execution_count" : 6 ,
94
+ "outputs" : []
95
+ },
96
+ {
97
+ "cell_type" : " code" ,
98
+ "metadata" : {
99
+ "id" : " zISspi3RmOwc"
100
+ },
101
+ "source" : [
102
+ " ! git clone https://github.com/NVIDIA/apex"
103
+ ],
104
+ "execution_count" : null ,
105
+ "outputs" : []
106
+ },
107
+ {
108
+ "cell_type" : " code" ,
109
+ "metadata" : {
110
+ "id" : " GsIMwlCWmOuI"
111
+ },
112
+ "source" : [
113
+ " os.chdir(\" apex\" )\n " ,
114
+ " !pip install -v --no-cache-dir ./"
115
+ ],
116
+ "execution_count" : null ,
117
+ "outputs" : []
118
+ },
119
+ {
120
+ "cell_type" : " code" ,
121
+ "metadata" : {
122
+ "id" : " HuOMYDvbmOrx"
123
+ },
124
+ "source" : [
125
+ " os.chdir(\" ..\" )"
126
+ ],
127
+ "execution_count" : 9 ,
128
+ "outputs" : []
129
+ },
130
+ {
131
+ "cell_type" : " code" ,
132
+ "metadata" : {
133
+ "id" : " VDm0-16NmOpJ"
134
+ },
135
+ "source" : [
136
+ " !git clone https://github.com/facebookresearch/TransCoder.git"
137
+ ],
138
+ "execution_count" : null ,
139
+ "outputs" : []
140
+ },
141
+ {
142
+ "cell_type" : " code" ,
143
+ "metadata" : {
144
+ "id" : " tS3ZU2ntmqxY"
145
+ },
146
+ "source" : [
147
+ " !wget https://dl.fbaipublicfiles.com/transcoder/model_2.pth\n " ,
148
+ " #Change the last url word to\n " ,
149
+ " # \" model_2.pth\" if you want C++ -> Python, Python -> C++ and Python -> Java\n " ,
150
+ " # or \" model_1.pth\" if you want C++ -> Java, Java -> C++ and Java -> Python"
151
+ ],
152
+ "execution_count" : null ,
153
+ "outputs" : []
154
+ },
155
+ {
156
+ "cell_type" : " code" ,
157
+ "metadata" : {
158
+ "id" : " MuRLBOuBmqu-"
159
+ },
160
+ "source" : [
161
+ " !python TransCoder/translate.py --src_lang python --tgt_lang cpp \\\\\n " ,
162
+ " --BPE_path TransCoder/data/BPE_with_comments_codes --model_path model_2.pth < test.py"
163
+ ],
164
+ "execution_count" : null ,
165
+ "outputs" : []
166
+ },
167
+ {
168
+ "cell_type" : " code" ,
169
+ "metadata" : {
170
+ "id" : " nia-Ev2RmqsF"
171
+ },
172
+ "source" : [
173
+ " # Click files and place content you want to translate beside sample_data\n " ,
174
+ " # If outside of standard url, the standard url is \" cd /content\"\n " ,
175
+ " \n " ,
176
+ " #cd /content/TransCoder/preprocessing/src/ #code_tokenizer.py \n " ,
177
+ " #go to url and open file, line 24 og change text to:\n " ,
178
+ " #clang.cindex.Config.set_library_path('/usr/lib/llvm-6.0/lib')\n " ,
179
+ " \n " ,
180
+ " #cd /usr/lib/llvm-6.0/lib/\n " ,
181
+ " #go to url and change name libclang.so.1 to libclang.so\n " ,
182
+ " \n " ,
183
+ " #check at top \" Runtime\" -->\" Change runtime type\" is set to GPU"
184
+ ],
185
+ "execution_count" : 16 ,
186
+ "outputs" : []
187
+ }
188
+ ]
189
+ }
0 commit comments