Spaces:
Sleeping
Sleeping
Chemsseddine
commited on
Commit
•
d7209e6
1
Parent(s):
d4eb76b
Update app.py
Browse files
app.py
CHANGED
@@ -37,25 +37,13 @@ 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 |
def diff_texts(text1, text2):
|
47 |
d = Differ()
|
48 |
-
|
49 |
-
|
|
|
50 |
|
51 |
-
# calculate the difference between the two texts
|
52 |
-
diff = d.compare(text1.split(), text2.split())
|
53 |
-
result='\n'.join(diff)
|
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)
|
|
|
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 |
|
|
|
|
|
|
|
|
|
47 |
inp=gr.inputs.Textbox(label="Text Originale")
|
48 |
out=gr.outputs.Textbox(label="Résumé")
|
49 |
mx_length=gr.Slider(40, 512)
|