DexterSptizu commited on
Commit
0c62899
Β·
verified Β·
1 Parent(s): f31ddfc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -37
app.py CHANGED
@@ -77,9 +77,8 @@ def load_example(example_name):
77
  return EXAMPLES.get(example_name, "")
78
 
79
  # Create Gradio interface
80
- with gr.Blocks(title="Gensim Keyword Extraction") as demo:
81
- gr.Markdown("# πŸ“‘ Gensim Keyword Extraction")
82
- gr.Markdown("Extract keywords using Gensim's text processing capabilities")
83
 
84
  with gr.Row():
85
  with gr.Column(scale=2):
@@ -88,18 +87,19 @@ with gr.Blocks(title="Gensim Keyword Extraction") as demo:
88
  placeholder="Enter your text here...",
89
  lines=8
90
  )
91
- example_dropdown = gr.Dropdown(
92
- choices=list(EXAMPLES.keys()),
93
- label="Load Example Text"
94
- )
95
-
96
  with gr.Column(scale=1):
97
- ratio = gr.Slider(
98
  minimum=1,
99
- maximum=100,
100
- value=20,
101
  step=1,
102
- label="Keyword Ratio (%)"
 
 
 
 
 
103
  )
104
 
105
  min_length = gr.Slider(
@@ -110,15 +110,8 @@ with gr.Blocks(title="Gensim Keyword Extraction") as demo:
110
  label="Minimum Words per Keyword"
111
  )
112
 
113
- show_scores = gr.Checkbox(
114
- label="Show Relevance Scores",
115
- value=True
116
- )
117
-
118
- extract_btn = gr.Button(
119
- "Extract Keywords",
120
- variant="primary"
121
- )
122
 
123
  output_text = gr.Textbox(
124
  label="Extracted Keywords",
@@ -126,22 +119,11 @@ with gr.Blocks(title="Gensim Keyword Extraction") as demo:
126
  interactive=False
127
  )
128
 
129
- # Set up event handlers
130
- example_dropdown.change(
131
- load_example,
132
- inputs=[example_dropdown],
133
- outputs=[input_text]
134
- )
135
-
136
  extract_btn.click(
137
- extract_keywords,
138
- inputs=[
139
- input_text,
140
- ratio,
141
- show_scores,
142
- min_length
143
- ],
144
- outputs=[output_text]
145
  )
146
 
147
- demo.launch()
 
77
  return EXAMPLES.get(example_name, "")
78
 
79
  # Create Gradio interface
80
+ with gr.Blocks(title="Keyword Extraction") as demo:
81
+ gr.Markdown("# πŸ“‘ Keyword Extraction")
 
82
 
83
  with gr.Row():
84
  with gr.Column(scale=2):
 
87
  placeholder="Enter your text here...",
88
  lines=8
89
  )
90
+
 
 
 
 
91
  with gr.Column(scale=1):
92
+ num_keywords = gr.Slider(
93
  minimum=1,
94
+ maximum=20,
95
+ value=10,
96
  step=1,
97
+ label="Number of Keywords"
98
+ )
99
+
100
+ show_scores = gr.Checkbox(
101
+ label="Show Scores",
102
+ value=True
103
  )
104
 
105
  min_length = gr.Slider(
 
110
  label="Minimum Words per Keyword"
111
  )
112
 
113
+ # Define the button here, before using it
114
+ extract_btn = gr.Button("Extract Keywords", variant="primary")
 
 
 
 
 
 
 
115
 
116
  output_text = gr.Textbox(
117
  label="Extracted Keywords",
 
119
  interactive=False
120
  )
121
 
122
+ # Add the click event after the button is defined
 
 
 
 
 
 
123
  extract_btn.click(
124
+ fn=extract_keywords,
125
+ inputs=[input_text, num_keywords, show_scores, min_length],
126
+ outputs=output_text
 
 
 
 
 
127
  )
128
 
129
+ demo.launch(share=True)