tomsoderlund commited on
Commit
1bca7c7
1 Parent(s): 374bb44

Two modes supported: "shorten", "paraphrase"

Browse files
Files changed (2) hide show
  1. README.md +4 -2
  2. app.py +12 -4
README.md CHANGED
@@ -11,8 +11,10 @@ pinned: false
11
  license: openrail
12
  models:
13
  - facebook/bart-large-cnn
 
14
  ---
15
 
16
- # Text summarizer
17
 
18
- Shortening texts using `facebook/bart-large-cnn`
 
 
11
  license: openrail
12
  models:
13
  - facebook/bart-large-cnn
14
+ - Vamsi/T5_Paraphrase_Paws
15
  ---
16
 
17
+ # Text shortener/paraphraser
18
 
19
+ - Shortening texts using `facebook/bart-large-cnn`
20
+ - Paraphrasing texts using `Vamsi/T5_Paraphrase_Paws`
app.py CHANGED
@@ -29,16 +29,24 @@ def paraphrase_text(text, min_length, max_length):
29
  print("** outputs", len(outputs), line)
30
  return line
31
 
 
 
 
 
 
 
32
  gradio_interface = gradio.Interface(
33
- fn=paraphrase_text,
34
  inputs=[
 
35
  "text",
36
  gradio.Slider(5, 200, value=30, label="Min length"),
37
  gradio.Slider(5, 500, value=130, label="Max length")
38
  ],
39
  outputs="text",
40
  examples=[
41
- ["""A beautiful golden sun is setting. The sky is on fire. A large neon sign rises into shot. It rests on top of a skyscraper and fills the frame. The building is neither past nor future in design but a bit of both.
 
42
 
43
  Slowly we pan downwards revealing the city that spreads below. A glittering conglomeration of elevated transport tubes, smaller square buildings which are merely huge, with, here and there, the comparatively minuscule relics of previous ages of architecture, pavement level awnings suggesting restaurants and shops. Transparent tubes carry whizzing transport cages past us. An elevated highway carrying traffic composed primarily of large transport lorries passes through frame.
44
 
@@ -46,8 +54,8 @@ As we descend, the sunlight is blocked out and street lights & neon signs take o
46
  Xmas decorations are everywhere. People are busy buying, ogling, discussing, choosing wisely from the goodies on display. Shoppers are going by laden with superbly packaged goods. The shop windows are full of elaborately boxed and be-ribboned who-knows-what. In one window is a bank of TV sets on the great majority of the screens is the face of Mr. Helpmann the Deputy Minister of Information. He is being interviewed. No-one bothers to listen to Helpmann.""",
47
  30, 130]
48
  ],
49
- title="Text summarizer",
50
- description="Shortening texts using `facebook/bart-large-cnn`.",
51
  article="© Tom Söderlund 2022"
52
  )
53
  gradio_interface.launch()
 
29
  print("** outputs", len(outputs), line)
30
  return line
31
 
32
+ def modify_text(mode, text, min_length, max_length):
33
+ if mode == "shorten":
34
+ return shorten_text(text, min_length, max_length)
35
+ else:
36
+ return paraphrase_text(text, min_length, max_length)
37
+
38
  gradio_interface = gradio.Interface(
39
+ fn=modify_text,
40
  inputs=[
41
+ gradio.Radio(["shorten", "paraphrase"], label="Mode"),
42
  "text",
43
  gradio.Slider(5, 200, value=30, label="Min length"),
44
  gradio.Slider(5, 500, value=130, label="Max length")
45
  ],
46
  outputs="text",
47
  examples=[
48
+ ["shorten",
49
+ """A beautiful golden sun is setting. The sky is on fire. A large neon sign rises into shot. It rests on top of a skyscraper and fills the frame. The building is neither past nor future in design but a bit of both.
50
 
51
  Slowly we pan downwards revealing the city that spreads below. A glittering conglomeration of elevated transport tubes, smaller square buildings which are merely huge, with, here and there, the comparatively minuscule relics of previous ages of architecture, pavement level awnings suggesting restaurants and shops. Transparent tubes carry whizzing transport cages past us. An elevated highway carrying traffic composed primarily of large transport lorries passes through frame.
52
 
 
54
  Xmas decorations are everywhere. People are busy buying, ogling, discussing, choosing wisely from the goodies on display. Shoppers are going by laden with superbly packaged goods. The shop windows are full of elaborately boxed and be-ribboned who-knows-what. In one window is a bank of TV sets on the great majority of the screens is the face of Mr. Helpmann the Deputy Minister of Information. He is being interviewed. No-one bothers to listen to Helpmann.""",
55
  30, 130]
56
  ],
57
+ title="Text shortener/paraphraser",
58
+ description="Shortening texts using `facebook/bart-large-cnn`, paraphrasing texts using `Vamsi/T5_Paraphrase_Paws`.",
59
  article="© Tom Söderlund 2022"
60
  )
61
  gradio_interface.launch()