richylyq commited on
Commit
158e38e
·
1 Parent(s): 70251c9

try to add translation

Browse files
Files changed (1) hide show
  1. app.py +1 -26
app.py CHANGED
@@ -1,5 +1,3 @@
1
- import gradio as gr
2
-
3
  """
4
  translation program for simple text
5
  1. detect language from langdetect
@@ -16,36 +14,13 @@ Returns:
16
  string: translated string of text
17
  """
18
 
 
19
  import argparse
20
 
21
  import langid
22
- from langdetect import DetectorFactory
23
-
24
- DetectorFactory.seed = 0
25
-
26
- from langdetect import detect
27
  from transformers import pipeline
28
 
29
 
30
- def detect_lang(article, target_lang):
31
- """
32
- Language Detection using library langdetect
33
-
34
- Args:
35
- article (string): article that user wish to translate
36
- target_lang (string): language user want to translate article into
37
-
38
- Returns:
39
- string: detected language short form
40
- """
41
- result_lang = detect(article)
42
- print(result_lang)
43
- if result_lang == target_lang:
44
- return result_lang
45
- else:
46
- return result_lang
47
-
48
-
49
  def lang_detect(article, target_lang):
50
  """
51
  Language Detection using library langid
 
 
 
1
  """
2
  translation program for simple text
3
  1. detect language from langdetect
 
14
  string: translated string of text
15
  """
16
 
17
+ import gradio as gr
18
  import argparse
19
 
20
  import langid
 
 
 
 
 
21
  from transformers import pipeline
22
 
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  def lang_detect(article, target_lang):
25
  """
26
  Language Detection using library langid