Spaces:
Build error
Build error
Commit
·
e67172f
1
Parent(s):
feae34c
Update app.py
Browse files
app.py
CHANGED
@@ -3,8 +3,6 @@ import streamlit as st
|
|
3 |
from google.oauth2 import service_account
|
4 |
from google.cloud import language_v1
|
5 |
|
6 |
-
|
7 |
-
|
8 |
# Header and intro
|
9 |
st.title("Google Cloud NLP Entity Analyzer")
|
10 |
st.write("## Introduction to the Knowledge Graph API")
|
@@ -31,16 +29,14 @@ def sample_analyze_entities(text_content, your_query=""):
|
|
31 |
|
32 |
entities_list = []
|
33 |
for entity in response.entities:
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
}
|
43 |
-
entities_list.append(entity_details)
|
44 |
|
45 |
if your_query:
|
46 |
st.write(f"### We found {len(entities_list)} results for your query of **{your_query}**")
|
|
|
3 |
from google.oauth2 import service_account
|
4 |
from google.cloud import language_v1
|
5 |
|
|
|
|
|
6 |
# Header and intro
|
7 |
st.title("Google Cloud NLP Entity Analyzer")
|
8 |
st.write("## Introduction to the Knowledge Graph API")
|
|
|
29 |
|
30 |
entities_list = []
|
31 |
for entity in response.entities:
|
32 |
+
entity_details = {
|
33 |
+
"Name": entity.name,
|
34 |
+
"Type": language_v1.Entity.Type(entity.type_).name,
|
35 |
+
"Salience Score": entity.salience,
|
36 |
+
"Metadata": entity.metadata,
|
37 |
+
"Mentions": [mention.text.content for mention in entity.mentions]
|
38 |
+
}
|
39 |
+
entities_list.append(entity_details)
|
|
|
|
|
40 |
|
41 |
if your_query:
|
42 |
st.write(f"### We found {len(entities_list)} results for your query of **{your_query}**")
|