Spaces:
Build error
Build error
Commit
·
7c393ac
1
Parent(s):
2b108c5
Update app.py
Browse files
app.py
CHANGED
@@ -12,16 +12,9 @@ def sample_analyze_entities(text_content):
|
|
12 |
service_account_info, scopes=["https://www.googleapis.com/auth/cloud-platform"]
|
13 |
)
|
14 |
|
15 |
-
# Debug: Print or log the type and content of credentials
|
16 |
-
st.write(f"Debug - Type of credentials: {type(credentials)}")
|
17 |
-
st.write(f"Debug - Content of credentials: {credentials}")
|
18 |
-
|
19 |
# Initialize the LanguageServiceClient with the credentials
|
20 |
client = language_v1.LanguageServiceClient(credentials=credentials)
|
21 |
|
22 |
-
# Your provided function
|
23 |
-
|
24 |
-
|
25 |
type_ = language_v1.Document.Type.PLAIN_TEXT
|
26 |
language = "en"
|
27 |
document = {"content": text_content, "type_": type_, "language": language}
|
@@ -29,20 +22,6 @@ def sample_analyze_entities(text_content):
|
|
29 |
|
30 |
response = client.analyze_entities(request={"document": document, "encoding_type": encoding_type})
|
31 |
|
32 |
-
for entity in response.entities:
|
33 |
-
st.write(f"Representative name for the entity: {entity.name}")
|
34 |
-
st.write(f"Entity type: {language_v1.Entity.Type(entity.type_).name}")
|
35 |
-
st.write(f"Salience score: {entity.salience}")
|
36 |
-
|
37 |
-
for metadata_name, metadata_value in entity.metadata.items():
|
38 |
-
st.write(f"{metadata_name}: {metadata_value}")
|
39 |
-
|
40 |
-
for mention in entity.mentions:
|
41 |
-
st.write(f"Mention text: {mention.text.content}")
|
42 |
-
st.write(f"Mention type: {language_v1.EntityMention.Type(mention.type_).name}")
|
43 |
-
|
44 |
-
st.write(f"Language of the text: {response.language}")
|
45 |
-
|
46 |
# Create an empty list to hold the results
|
47 |
entities_list = []
|
48 |
|
@@ -83,4 +62,5 @@ def sample_analyze_entities(text_content):
|
|
83 |
st.write("**Mentions**: ")
|
84 |
st.json(entity["Mentions"])
|
85 |
|
86 |
-
|
|
|
|
12 |
service_account_info, scopes=["https://www.googleapis.com/auth/cloud-platform"]
|
13 |
)
|
14 |
|
|
|
|
|
|
|
|
|
15 |
# Initialize the LanguageServiceClient with the credentials
|
16 |
client = language_v1.LanguageServiceClient(credentials=credentials)
|
17 |
|
|
|
|
|
|
|
18 |
type_ = language_v1.Document.Type.PLAIN_TEXT
|
19 |
language = "en"
|
20 |
document = {"content": text_content, "type_": type_, "language": language}
|
|
|
22 |
|
23 |
response = client.analyze_entities(request={"document": document, "encoding_type": encoding_type})
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
# Create an empty list to hold the results
|
26 |
entities_list = []
|
27 |
|
|
|
62 |
st.write("**Mentions**: ")
|
63 |
st.json(entity["Mentions"])
|
64 |
|
65 |
+
|
66 |
+
st.write(f"### Language of the text: {response.language}")
|