abdullahmubeen10 commited on
Commit
509f3e9
Β·
verified Β·
1 Parent(s): 23f4285

Update Demo.py

Browse files
Files changed (1) hide show
  1. Demo.py +3 -14
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
- 'NER Label': [n.metadata['entity'] for n in output[0]['ner_chunk']],
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 = processed_df.toPandas()
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)