Heiko Hotz commited on
Commit
6f26bdf
1 Parent(s): 63efbc9

Add application file

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -2,12 +2,16 @@ import gradio as gr
2
  from rouge_score import rouge_scorer
3
 
4
  def calc_rouge_score(summary, reference):
5
- score = 0.6
6
- text = "The score is %s" % (score)
7
- return text, score
 
 
 
 
8
 
9
  iface = gr.Interface(
10
  fn=calc_rouge_score,
11
  inputs=["text", "text"],
12
- outputs=["text", "number"])
13
  iface.launch()
2
  from rouge_score import rouge_scorer
3
 
4
  def calc_rouge_score(summary, reference):
5
+ scorer = rouge_scorer.RougeScorer(['rouge1', 'rouge2', 'rougeL', 'rougeLsum'], use_stemmer=True)
6
+ scores = scorer.score(summary, reference)
7
+
8
+ text = f""
9
+ for s in scores:
10
+ text += f"The {s}-score is {scores[s].fmeasure}\n"
11
+ return text
12
 
13
  iface = gr.Interface(
14
  fn=calc_rouge_score,
15
  inputs=["text", "text"],
16
+ outputs=["text"])
17
  iface.launch()