Update Demo.py
Browse files
Demo.py
CHANGED
|
@@ -143,10 +143,14 @@ output = fit_data(pipeline, text_to_analyze)
|
|
| 143 |
# Display matched sentence
|
| 144 |
st.subheader("Processed output:")
|
| 145 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
results = {
|
| 147 |
'Document': output[0]['document'][0].result,
|
| 148 |
'NER Chunk': [n.result for n in output[0]['ner_chunk']],
|
| 149 |
-
|
| 150 |
}
|
| 151 |
|
| 152 |
annotate(results)
|
|
|
|
| 143 |
# Display matched sentence
|
| 144 |
st.subheader("Processed output:")
|
| 145 |
|
| 146 |
+
# Define the abbreviation mapping
|
| 147 |
+
abbreviation_mapping = dict(zip('RGC', ['LOC', 'PER', 'MISC', 'ORG']))
|
| 148 |
+
|
| 149 |
+
# Extract the NER results
|
| 150 |
results = {
|
| 151 |
'Document': output[0]['document'][0].result,
|
| 152 |
'NER Chunk': [n.result for n in output[0]['ner_chunk']],
|
| 153 |
+
'NER Label': [abbreviation_mapping.get(n.metadata['entity'], 'UNKNOWN') for n in output[0]['ner_chunk']]
|
| 154 |
}
|
| 155 |
|
| 156 |
annotate(results)
|