check
Browse files
app.py
CHANGED
@@ -22,7 +22,9 @@ import os
|
|
22 |
# interface = gr.Interface(fn=en2zh, inputs="list", outputs="list")
|
23 |
# interface.launch()
|
24 |
|
25 |
-
translator = pipeline("translation", model=os.path.join(os.getcwd(),"test-ml-trained
|
|
|
|
|
26 |
# text-text
|
27 |
def en2zh(text):
|
28 |
pres=[]
|
@@ -36,4 +38,18 @@ def en2zh(text):
|
|
36 |
inputs=gr.TextArea(lines=10,label='请输入英文字段名',placeholder='以换行\\n为分隔符')
|
37 |
outputs=gr.TextArea(lines=10,label='转译结果')
|
38 |
interface = gr.Interface(fn=en2zh, inputs=inputs, outputs=outputs)
|
39 |
-
interface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
# interface = gr.Interface(fn=en2zh, inputs="list", outputs="list")
|
23 |
# interface.launch()
|
24 |
|
25 |
+
translator = pipeline("translation", model=os.path.join(os.getcwd(),"test-ml-trained"), max_time=5)
|
26 |
+
translator_plus = pipeline("translation", model=os.path.join(os.getcwd(),"test-ml-trained+"), max_time=5)
|
27 |
+
|
28 |
# text-text
|
29 |
def en2zh(text):
|
30 |
pres=[]
|
|
|
38 |
inputs=gr.TextArea(lines=10,label='请输入英文字段名',placeholder='以换行\\n为分隔符')
|
39 |
outputs=gr.TextArea(lines=10,label='转译结果')
|
40 |
interface = gr.Interface(fn=en2zh, inputs=inputs, outputs=outputs)
|
41 |
+
interface.launch()
|
42 |
+
|
43 |
+
def en2zh_plus(text):
|
44 |
+
pres=[]
|
45 |
+
enNames=text.split('\n')
|
46 |
+
for name in enNames:
|
47 |
+
print(translator_plus(name.replace('_',' '), ))
|
48 |
+
pre = translator_plus(name.replace('_',' '), )[0]["translation_text"]
|
49 |
+
pres.append(pre)
|
50 |
+
print(name,pre)
|
51 |
+
return '\n'.join(pres)
|
52 |
+
inputs=gr.TextArea(lines=10,label='请输入英文表名和英文字段名',placeholder='以换行\\n为分隔符')
|
53 |
+
outputs=gr.TextArea(lines=10,label='转译结果')
|
54 |
+
interface_plus = gr.Interface(fn=en2zh_plus, inputs=inputs, outputs=outputs)
|
55 |
+
interface_plus.launch()
|