KyuDan1 commited on
Commit
c98d4a9
·
1 Parent(s): 1b1a225
Files changed (2) hide show
  1. app.py +34 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import subprocess
3
+ import sys
4
+
5
+ # Clone the repository
6
+ repo_url = "https://github.com/KyuDan1/TeXBLEU.git"
7
+ repo_name = "TeXBLEU"
8
+ subprocess.run(["git", "clone", repo_url])
9
+
10
+ # Add the cloned repository to Python path
11
+ sys.path.append(repo_name)
12
+
13
+ # Import the texbleu function
14
+ from new_metric import texbleu
15
+
16
+ def calculate_texbleu(reference, candidate):
17
+ # Calculate TeXBLEU score
18
+ result = texbleu(reference, candidate)
19
+ return f"TeXBLEU Score: {result}"
20
+
21
+ # Gradio interface setup
22
+ demo = gr.Interface(
23
+ fn=calculate_texbleu,
24
+ inputs=[
25
+ gr.Textbox(label="Reference Text", lines=5),
26
+ gr.Textbox(label="Candidate Text", lines=5)
27
+ ],
28
+ outputs="text",
29
+ title="TeXBLEU Score Calculator",
30
+ description="Enter a reference text and a candidate text to calculate the TeXBLEU score."
31
+ )
32
+
33
+ if __name__ == "__main__":
34
+ demo.launch(share=True)
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ torch>=1.7.0
2
+ transformers>=4.0.0