File size: 887 Bytes
c98d4a9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import gradio as gr
import subprocess
import sys

# Clone the repository
repo_url = "https://github.com/KyuDan1/TeXBLEU.git"
repo_name = "TeXBLEU"
subprocess.run(["git", "clone", repo_url])

# Add the cloned repository to Python path
sys.path.append(repo_name)

# Import the texbleu function
from new_metric import texbleu

def calculate_texbleu(reference, candidate):
    # Calculate TeXBLEU score
    result = texbleu(reference, candidate)
    return f"TeXBLEU Score: {result}"

# Gradio interface setup
demo = gr.Interface(
    fn=calculate_texbleu,
    inputs=[
        gr.Textbox(label="Reference Text", lines=5),
        gr.Textbox(label="Candidate Text", lines=5)
    ],
    outputs="text",
    title="TeXBLEU Score Calculator",
    description="Enter a reference text and a candidate text to calculate the TeXBLEU score."
)

if __name__ == "__main__":
    demo.launch(share=True)