Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -953,4 +953,124 @@ def create_interface():
|
|
953 |
</dl>
|
954 |
</div>
|
955 |
</details>
|
956 |
-
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
953 |
</dl>
|
954 |
</div>
|
955 |
</details>
|
956 |
+
""")
|
957 |
+
|
958 |
+
analyse_btn = gr.Button("🔍 Analyse Text", variant="primary", size="lg")
|
959 |
+
|
960 |
+
# Output sections
|
961 |
+
with gr.Row():
|
962 |
+
summary_output = gr.Markdown(label="Summary")
|
963 |
+
|
964 |
+
with gr.Row():
|
965 |
+
highlighted_output = gr.HTML(label="Highlighted Text")
|
966 |
+
|
967 |
+
# Results section
|
968 |
+
with gr.Row():
|
969 |
+
with gr.Column():
|
970 |
+
gr.Markdown("### 📋 Detailed Results")
|
971 |
+
results_output = gr.HTML(label="Entity Results")
|
972 |
+
|
973 |
+
# Connect the button to the processing function
|
974 |
+
analyse_btn.click(
|
975 |
+
fn=process_text,
|
976 |
+
inputs=[
|
977 |
+
text_input,
|
978 |
+
standard_entities,
|
979 |
+
custom_entities,
|
980 |
+
confidence_threshold,
|
981 |
+
model_dropdown
|
982 |
+
],
|
983 |
+
outputs=[summary_output, highlighted_output, results_output]
|
984 |
+
)
|
985 |
+
|
986 |
+
# Updated examples text
|
987 |
+
gr.Markdown("""
|
988 |
+
### No example text to test? No problem!
|
989 |
+
Simply click on one of the examples provided below, and the fields will be populated for you.
|
990 |
+
""")
|
991 |
+
|
992 |
+
gr.Examples(
|
993 |
+
examples=[
|
994 |
+
[
|
995 |
+
"On June 6, 1944, Allied forces launched Operation Overlord, the invasion of Normandy. General Dwight D. Eisenhower commanded the operation, while Field Marshal Bernard Montgomery led ground forces. The BBC broadcast coded messages to the French Resistance, including the famous line 'The long sobs of autumn violins.'",
|
996 |
+
["PERSON", "ORGANIZATION", "LOCATION", "DATE", "EVENT"],
|
997 |
+
"military operations, military ranks, historical battles",
|
998 |
+
0.3,
|
999 |
+
"spacy_en_core_web_trf"
|
1000 |
+
],
|
1001 |
+
[
|
1002 |
+
"In Jane Austen's 'Pride and Prejudice', Elizabeth Bennet first meets Mr. Darcy at the Meryton assembly. The novel, published in 1813, explores themes of marriage and social class in Regency England. Austen wrote to her sister Cassandra about the manuscript while staying at Chawton Cottage.",
|
1003 |
+
["PERSON", "LOCATION", "DATE", "WORK OF ART"],
|
1004 |
+
"literary themes, relationships, literary periods",
|
1005 |
+
0.3,
|
1006 |
+
"gliner_knowledgator/modern-gliner-bi-large-v1.0"
|
1007 |
+
],
|
1008 |
+
[
|
1009 |
+
"Charles Darwin arrived at the Galápagos Islands aboard HMS Beagle in September 1835. During his five-week visit, Darwin collected specimens of finches, tortoises, and mockingbirds. His observations of these species' variations across different islands later contributed to his theory of evolution by natural selection, published in 'On the Origin of Species' in 1859.",
|
1010 |
+
["PERSON", "LOCATION", "DATE", "WORK OF ART", "PRODUCT"],
|
1011 |
+
"scientific concepts, species, research methods",
|
1012 |
+
0.3,
|
1013 |
+
"flair_ner-large"
|
1014 |
+
]
|
1015 |
+
],
|
1016 |
+
inputs=[
|
1017 |
+
text_input,
|
1018 |
+
standard_entities,
|
1019 |
+
custom_entities,
|
1020 |
+
confidence_threshold,
|
1021 |
+
model_dropdown
|
1022 |
+
]
|
1023 |
+
)
|
1024 |
+
|
1025 |
+
# Add model information links
|
1026 |
+
gr.HTML("""
|
1027 |
+
<hr style="margin-top: 40px; margin-bottom: 20px;">
|
1028 |
+
<div style="background-color: #f8f9fa; padding: 20px; border-radius: 8px; margin-top: 20px;">
|
1029 |
+
<h4 style="margin-top: 0;">📚 Model Information & Documentation (incl. details on usage terms)</h4>
|
1030 |
+
<p style="font-size: 14px; margin-bottom: 15px;">Learn more about the models used in this tool:</p>
|
1031 |
+
<ul style="font-size: 14px; line-height: 1.8;">
|
1032 |
+
<li><strong>flair_ner-large:</strong>
|
1033 |
+
<a href="https://huggingface.co/flair/ner-english-large" target="_blank" style="color: #1976d2;">
|
1034 |
+
Flair NER English Large Model ↗
|
1035 |
+
</a>
|
1036 |
+
</li>
|
1037 |
+
<li><strong>spacy_en_core_web_trf:</strong>
|
1038 |
+
<a href="https://spacy.io/models/en#en_core_web_trf" target="_blank" style="color: #1976d2;">
|
1039 |
+
spaCy English Transformer Model ↗
|
1040 |
+
</a>
|
1041 |
+
</li>
|
1042 |
+
<li><strong>flair_ner-ontonotes-large:</strong>
|
1043 |
+
<a href="https://huggingface.co/flair/ner-english-ontonotes-large" target="_blank" style="color: #1976d2;">
|
1044 |
+
Flair OntoNotes Large Model ↗
|
1045 |
+
</a>
|
1046 |
+
</li>
|
1047 |
+
<li><strong>gliner_knowledgator/modern-gliner-bi-large-v1.0:</strong>
|
1048 |
+
<a href="https://github.com/urchade/GLiNER/blob/main/README_Extended.md" target="_blank" style="color: #1976d2;">
|
1049 |
+
GLiNER Extended Documentation ↗
|
1050 |
+
</a>
|
1051 |
+
</li>
|
1052 |
+
</ul>
|
1053 |
+
</div>
|
1054 |
+
|
1055 |
+
<br>
|
1056 |
+
<hr style="margin-top: 40px; margin-bottom: 20px;">
|
1057 |
+
<div style="background-color: #f8f9fa; padding: 20px; border-radius: 8px; margin-top: 20px; text-align: center;">
|
1058 |
+
<p style="font-size: 14px; line-height: 1.8; margin: 0;">
|
1059 |
+
This <strong>NER Explorer Tool</strong> was created as part of the
|
1060 |
+
<a href="https://digitalscholarship.web.ox.ac.uk/" target="_blank" style="color: #1976d2;">
|
1061 |
+
Digital Scholarship at Oxford (DiSc)
|
1062 |
+
</a>
|
1063 |
+
funded research project:<br>
|
1064 |
+
<em>Extracting Keywords from Crowdsourced Collections</em>.
|
1065 |
+
</p>
|
1066 |
+
<p style="font-size: 14px; line-height: 1.8; margin: 0;">
|
1067 |
+
The code for this tool was built with the aid of Claude Opus 4.
|
1068 |
+
</p>
|
1069 |
+
</div>
|
1070 |
+
""")
|
1071 |
+
|
1072 |
+
return demo
|
1073 |
+
|
1074 |
+
if __name__ == "__main__":
|
1075 |
+
demo = create_interface()
|
1076 |
+
demo.launch()
|