From 7dff809b94b5a1d001aeb1e7763dbbe624865600 Mon Sep 17 00:00:00 2001 From: Emily Darrow <47046797+ejdarrow@users.noreply.github.com> Date: Mon, 22 Jun 2020 16:50:03 -0400 Subject: [PATCH] docs: add spacing for readability (#22) --- samples/v1/language_entities_text.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/samples/v1/language_entities_text.py b/samples/v1/language_entities_text.py index 9ae849f2..464a313d 100644 --- a/samples/v1/language_entities_text.py +++ b/samples/v1/language_entities_text.py @@ -54,13 +54,17 @@ def sample_analyze_entities(text_content): encoding_type = enums.EncodingType.UTF8 response = client.analyze_entities(document, encoding_type=encoding_type) + # Loop through entitites returned from the API for entity in response.entities: print(u"Representative name for the entity: {}".format(entity.name)) + # Get entity type, e.g. PERSON, LOCATION, ADDRESS, NUMBER, et al print(u"Entity type: {}".format(enums.Entity.Type(entity.type).name)) + # Get the salience score associated with the entity in the [0, 1.0] range print(u"Salience score: {}".format(entity.salience)) + # Loop over the metadata associated with entity. For many known entities, # the metadata is a Wikipedia URL (wikipedia_url) and Knowledge Graph MID (mid). # Some entity types may have additional metadata, e.g. ADDRESS entities @@ -72,6 +76,7 @@ def sample_analyze_entities(text_content): # The API currently supports proper noun mentions. for mention in entity.mentions: print(u"Mention text: {}".format(mention.text.content)) + # Get the mention type, e.g. PROPER for proper noun print( u"Mention type: {}".format(enums.EntityMention.Type(mention.type).name)