Update app.py
Browse files
app.py
CHANGED
|
@@ -192,7 +192,7 @@ def create_keyword_results_table(found_keywords_str, keywords_dict, input_text):
|
|
| 192 |
def process_text(input_text, primary1, synonyms1, primary2, synonyms2, primary3, synonyms3, primary4, synonyms4, primary5, synonyms5):
|
| 193 |
"""Main processing function with added results table"""
|
| 194 |
if not input_text.strip():
|
| 195 |
-
return "Please enter some text to
|
| 196 |
|
| 197 |
# Build keywords dictionary from separate inputs
|
| 198 |
primary_inputs = [primary1, primary2, primary3, primary4, primary5]
|
|
@@ -236,23 +236,25 @@ def process_text(input_text, primary1, synonyms1, primary2, synonyms2, primary3,
|
|
| 236 |
# Create the Gradio interface
|
| 237 |
def create_interface():
|
| 238 |
with gr.Blocks(title="Keyword Tagging Tool", theme=gr.themes.Soft()) as demo:
|
| 239 |
-
gr.
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
This tool matches text against a controlled vocabulary and returns all associated keywords.
|
| 243 |
-
Based on the keyword matching logic used for digital humanities research
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
|
|
|
|
|
|
| 250 |
""")
|
| 251 |
|
| 252 |
with gr.Row():
|
| 253 |
with gr.Column(scale=1):
|
| 254 |
text_input = gr.Textbox(
|
| 255 |
-
label="Text to
|
| 256 |
placeholder="Enter the text you want to tag with keywords...",
|
| 257 |
lines=22,
|
| 258 |
max_lines=25
|
|
@@ -393,9 +395,16 @@ def create_interface():
|
|
| 393 |
gr.HTML("<hr style='margin-top: 40px; margin-bottom: 20px;'>")
|
| 394 |
gr.HTML("""
|
| 395 |
<div style="background-color: #f8f9fa; padding: 20px; border-radius: 8px; margin-top: 20px; text-align: center;">
|
| 396 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 397 |
<p style="font-size: 14px; line-height: 1.8; margin: 0;">
|
| 398 |
-
The code for this tool was built with the aid of Claude
|
| 399 |
</p>
|
| 400 |
</div>
|
| 401 |
""")
|
|
|
|
| 192 |
def process_text(input_text, primary1, synonyms1, primary2, synonyms2, primary3, synonyms3, primary4, synonyms4, primary5, synonyms5):
|
| 193 |
"""Main processing function with added results table"""
|
| 194 |
if not input_text.strip():
|
| 195 |
+
return "Please enter some text to analyse", "", "", "No keywords found"
|
| 196 |
|
| 197 |
# Build keywords dictionary from separate inputs
|
| 198 |
primary_inputs = [primary1, primary2, primary3, primary4, primary5]
|
|
|
|
| 236 |
# Create the Gradio interface
|
| 237 |
def create_interface():
|
| 238 |
with gr.Blocks(title="Keyword Tagging Tool", theme=gr.themes.Soft()) as demo:
|
| 239 |
+
gr.HTML("""
|
| 240 |
+
<h1>Keyword Tagging Tool</h1>
|
| 241 |
+
|
| 242 |
+
<p>This tool matches text against a controlled vocabulary and returns all associated keywords.
|
| 243 |
+
Based on the keyword matching logic used for digital humanities research.</p>
|
| 244 |
+
|
| 245 |
+
<h2>How to use this tool:</h2>
|
| 246 |
+
<ol>
|
| 247 |
+
<li>π <strong>Enter your text</strong> in the left panel</li>
|
| 248 |
+
<li>π <strong>Define your keyword dictionary</strong> in the right panel - enter primary keywords and their synonyms</li>
|
| 249 |
+
<li>π <strong>Click "Find Keywords"</strong> to see results</li>
|
| 250 |
+
<li>π <strong>Copy the results</strong> to paste into your spreadsheet</li>
|
| 251 |
+
</ol>
|
| 252 |
""")
|
| 253 |
|
| 254 |
with gr.Row():
|
| 255 |
with gr.Column(scale=1):
|
| 256 |
text_input = gr.Textbox(
|
| 257 |
+
label="Text to Analyse",
|
| 258 |
placeholder="Enter the text you want to tag with keywords...",
|
| 259 |
lines=22,
|
| 260 |
max_lines=25
|
|
|
|
| 395 |
gr.HTML("<hr style='margin-top: 40px; margin-bottom: 20px;'>")
|
| 396 |
gr.HTML("""
|
| 397 |
<div style="background-color: #f8f9fa; padding: 20px; border-radius: 8px; margin-top: 20px; text-align: center;">
|
| 398 |
+
<p style="font-size: 14px; line-height: 1.8; margin: 0;">
|
| 399 |
+
This <strong>Keyword Tagging Tool</strong> was created as part of the
|
| 400 |
+
<a href="https://digitalscholarship.web.ox.ac.uk/" target="_blank" style="color: #1976d2;">
|
| 401 |
+
Digital Scholarship at Oxford (DiSc)
|
| 402 |
+
</a>
|
| 403 |
+
funded research project:<br>
|
| 404 |
+
<em>Extracting Keywords from Crowdsourced Collections</em>.
|
| 405 |
+
</p><br><br>
|
| 406 |
<p style="font-size: 14px; line-height: 1.8; margin: 0;">
|
| 407 |
+
The code for this tool was built with the aid of Claude Opus 4.
|
| 408 |
</p>
|
| 409 |
</div>
|
| 410 |
""")
|