blazingbunny commited on
Commit
0553e73
·
1 Parent(s): 3fec030

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -8
app.py CHANGED
@@ -3,12 +3,12 @@ import streamlit as st
3
  from google.oauth2 import service_account
4
  from google.cloud import language_v1
5
 
6
- # Function to count entities with 'mid' and '/g/' in their metadata
7
  def count_entities(entities):
8
  count = 0
9
  for entity in entities:
10
  metadata = entity.metadata
11
- if 'mid' in metadata and '/g/' in metadata['mid']:
12
  count += 1
13
  return count
14
 
@@ -40,10 +40,10 @@ def sample_analyze_entities(text_content):
40
 
41
  response = client.analyze_entities(request={"document": document, "encoding_type": encoding_type})
42
 
43
- # Count the entities with 'mid' and '/g/' in their metadata
44
  entity_count = count_entities(response.entities)
45
 
46
- st.write(f"We found {len(response.entities)} entities - {entity_count} meet your criteria")
47
  st.write("---")
48
 
49
  for i, entity in enumerate(response.entities):
@@ -55,10 +55,6 @@ def sample_analyze_entities(text_content):
55
  if entity.metadata:
56
  st.write("Metadata:")
57
  st.write(entity.metadata)
58
-
59
- if entity.mentions:
60
- st.write("Mentions:")
61
- st.write(', '.join([mention.text.content for mention in entity.mentions]))
62
 
63
  st.write("---")
64
 
 
3
  from google.oauth2 import service_account
4
  from google.cloud import language_v1
5
 
6
+ # Function to count entities with 'mid' that contains '/g/' or '/m/' in their metadata
7
  def count_entities(entities):
8
  count = 0
9
  for entity in entities:
10
  metadata = entity.metadata
11
+ if 'mid' in metadata and ('/g/' in metadata['mid'] or '/m/' in metadata['mid']):
12
  count += 1
13
  return count
14
 
 
40
 
41
  response = client.analyze_entities(request={"document": document, "encoding_type": encoding_type})
42
 
43
+ # Count the entities with 'mid' and either '/g/' or '/m/' in their metadata
44
  entity_count = count_entities(response.entities)
45
 
46
+ st.write(f"We found {len(response.entities)} entities - We found {entity_count} Google Entities")
47
  st.write("---")
48
 
49
  for i, entity in enumerate(response.entities):
 
55
  if entity.metadata:
56
  st.write("Metadata:")
57
  st.write(entity.metadata)
 
 
 
 
58
 
59
  st.write("---")
60