Chemsseddine commited on
Commit
9239ada
·
1 Parent(s): c36f2dd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -4
app.py CHANGED
@@ -37,12 +37,25 @@ from difflib import Differ
37
  import gradio as gr
38
  demo = gr.Blocks()
39
 
 
 
 
 
 
 
40
  def diff_texts(text1, text2):
41
  d = Differ()
42
- return [
43
- (token[2:], token[0] if token[0] != " " else None)
44
- for token in d.compare(text1, text2)
45
- ]
 
 
 
 
 
 
 
46
  inp=gr.inputs.Textbox(label="Text Originale")
47
  out=gr.outputs.Textbox(label="Résumé")
48
  mx_length=gr.Slider(40, 512)
 
37
  import gradio as gr
38
  demo = gr.Blocks()
39
 
40
+ #def diff_texts(text1, text2):
41
+ # d = Differ()
42
+ # return [
43
+ # (token[2:], token[0] if token[0] != " " else None)
44
+ # for token in d.compare(text1, text2)
45
+ #
46
  def diff_texts(text1, text2):
47
  d = Differ()
48
+ # initiate the Differ object
49
+ d = difflib.Differ()
50
+
51
+ # calculate the difference between the two texts
52
+ diff = d.compare(text1.split(), text2.split())
53
+ result='\n'.join(diff).split()
54
+
55
+
56
+
57
+
58
+ return result#[(token[2:], token[0] if token[0] != " " else None)for token in d.compare(text1, text2)] ]
59
  inp=gr.inputs.Textbox(label="Text Originale")
60
  out=gr.outputs.Textbox(label="Résumé")
61
  mx_length=gr.Slider(40, 512)