Spaces:
Build error
Build error
Commit
·
a88adef
1
Parent(s):
9ddc9bf
Update app.py
Browse files
app.py
CHANGED
@@ -9,6 +9,7 @@ entity_types_to_show = [
|
|
9 |
]
|
10 |
selected_types = st.multiselect('Select entity types to show:', entity_types_to_show)
|
11 |
|
|
|
12 |
# Header and intro
|
13 |
st.title("Google Cloud NLP Entity Analyzer")
|
14 |
st.write("## Introduction to the Knowledge Graph API")
|
@@ -43,9 +44,11 @@ def sample_analyze_entities(text_content, your_query=""):
|
|
43 |
# Create an empty list to hold the results
|
44 |
entities_list = []
|
45 |
|
|
|
|
|
46 |
for entity in response.entities:
|
47 |
entity_type_name = language_v1.Entity.Type(entity.type_).name
|
48 |
-
if entity_type_name in selected_types:
|
49 |
entity_details = {
|
50 |
"Name": entity.name,
|
51 |
"Type": entity_type_name,
|
@@ -55,6 +58,9 @@ def sample_analyze_entities(text_content, your_query=""):
|
|
55 |
}
|
56 |
entities_list.append(entity_details)
|
57 |
|
|
|
|
|
|
|
58 |
if your_query:
|
59 |
st.write(f"We found {len(entities_list)} results for your query of **{your_query}**")
|
60 |
else:
|
|
|
9 |
]
|
10 |
selected_types = st.multiselect('Select entity types to show:', entity_types_to_show)
|
11 |
|
12 |
+
|
13 |
# Header and intro
|
14 |
st.title("Google Cloud NLP Entity Analyzer")
|
15 |
st.write("## Introduction to the Knowledge Graph API")
|
|
|
44 |
# Create an empty list to hold the results
|
45 |
entities_list = []
|
46 |
|
47 |
+
# ... (rest of your code above)
|
48 |
+
|
49 |
for entity in response.entities:
|
50 |
entity_type_name = language_v1.Entity.Type(entity.type_).name
|
51 |
+
if not selected_types or entity_type_name in selected_types:
|
52 |
entity_details = {
|
53 |
"Name": entity.name,
|
54 |
"Type": entity_type_name,
|
|
|
58 |
}
|
59 |
entities_list.append(entity_details)
|
60 |
|
61 |
+
# ... (rest of your code below)
|
62 |
+
|
63 |
+
|
64 |
if your_query:
|
65 |
st.write(f"We found {len(entities_list)} results for your query of **{your_query}**")
|
66 |
else:
|