TiberiuCristianLeon commited on
Commit
a8bd60c
·
verified ·
1 Parent(s): 0649f6a

Delete timer

Browse files
Files changed (1) hide show
  1. app.py +2 -15
app.py CHANGED
@@ -12,18 +12,6 @@ DEFAULTS = None
12
 
13
  libraries = ["langdetect", "langid", "Argos", "HPLT", "HPLT-OPUS", "Google"]
14
 
15
- def timer(func):
16
- from time import time
17
- def detection(input_text, used_libraries) -> tuple[str, str]:
18
- start_time = time()
19
- detected_lang, confidence = func(input_text, used_libraries)
20
- end_time = time()
21
- execution_time = end_time - start_time
22
- # print(f"Function {func.__name__!r} executed in {execution_time:.2f} seconds.")
23
- execution_times = f'Executed in {execution_time:.2f} seconds!'
24
- return [detected_lang, confidence, execution_times]
25
- return detection
26
-
27
  class Detect():
28
  def __init__(self, text: str) -> None:
29
  self.text: str = text
@@ -41,7 +29,6 @@ class Detect():
41
  langcode, langecode_probabilities = result
42
  return langcode, round(number=langecode_probabilities * 10, ndigits=2)
43
 
44
- @timer
45
  def detect_language(input_text: str, used_libraries: list[str]) -> tuple[str, str]:
46
  """
47
  Detects the input text from the source language to the target language using a specified model.
@@ -81,8 +68,8 @@ with gr.Blocks() as interface:
81
  # execution_time = gr.Textbox(label="Execution time:", placeholder="Display field for execution time", interactive=False, lines=1)
82
  used_libraries = gr.CheckboxGroup(choices=libraries, label="Detection libraries", info="Detection libraries")
83
  dataframe = gr.Dataframe(
84
- headers=["name", "age", "gender"],
85
- datatype=["str", "float", "str"], # type: ignore
86
  row_count=2,
87
  column_count=3,
88
  column_limits=(3, 3),
 
12
 
13
  libraries = ["langdetect", "langid", "Argos", "HPLT", "HPLT-OPUS", "Google"]
14
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  class Detect():
16
  def __init__(self, text: str) -> None:
17
  self.text: str = text
 
29
  langcode, langecode_probabilities = result
30
  return langcode, round(number=langecode_probabilities * 10, ndigits=2)
31
 
 
32
  def detect_language(input_text: str, used_libraries: list[str]) -> tuple[str, str]:
33
  """
34
  Detects the input text from the source language to the target language using a specified model.
 
68
  # execution_time = gr.Textbox(label="Execution time:", placeholder="Display field for execution time", interactive=False, lines=1)
69
  used_libraries = gr.CheckboxGroup(choices=libraries, label="Detection libraries", info="Detection libraries")
70
  dataframe = gr.Dataframe(
71
+ headers=["Language", "Score"],
72
+ datatype=["str", "float"], # type: ignore
73
  row_count=2,
74
  column_count=3,
75
  column_limits=(3, 3),