Spaces:
Sleeping
Sleeping
Update Demo.py
Browse files
Demo.py
CHANGED
@@ -143,23 +143,12 @@ st.subheader("Processed output:")
|
|
143 |
results = {
|
144 |
'Document': output[0]['document'][0].result,
|
145 |
'NER Chunk': [n.result for n in output[0]['ner_chunk']],
|
146 |
-
|
147 |
-
'Confidence': [n.metadata['confidence'] for n in output[0]['ner_chunk']]
|
148 |
}
|
149 |
|
150 |
-
spark_df = spark.createDataFrame(
|
151 |
-
zip(results['NER Chunk'], results['NER Label'], results['Confidence']),
|
152 |
-
schema=['NER Chunk', 'NER Label', 'Confidence']
|
153 |
-
)
|
154 |
-
|
155 |
-
processed_df = spark_df.select(
|
156 |
-
col('NER Chunk').alias('result'),
|
157 |
-
col('NER Label').alias('entity'),
|
158 |
-
concat(round(col('Confidence').cast('float') * 100, 2), lit('%')).alias('confidence')
|
159 |
-
)
|
160 |
-
|
161 |
annotate(results)
|
|
|
162 |
with st.expander("View DataFrame"):
|
163 |
-
df =
|
164 |
df.index += 1
|
165 |
st.dataframe(df)
|
|
|
143 |
results = {
|
144 |
'Document': output[0]['document'][0].result,
|
145 |
'NER Chunk': [n.result for n in output[0]['ner_chunk']],
|
146 |
+
"NER Label": [n.metadata['entity'] for n in output[0]['ner_chunk']]
|
|
|
147 |
}
|
148 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
annotate(results)
|
150 |
+
|
151 |
with st.expander("View DataFrame"):
|
152 |
+
df = pd.DataFrame({'NER Chunk': results['NER Chunk'], 'NER Label': results['NER Label']})
|
153 |
df.index += 1
|
154 |
st.dataframe(df)
|