Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change names for legal reasons #5

Merged
merged 1 commit into from
Mar 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions samples/search/entity_search_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
def dominant_entity_lookup(subscription_key):
"""DominantEntityLookup.

This will look up a single entity (tom cruise) and print out a short description about them.
This will look up a single entity (Satya Nadella) and print out a short description about them.
"""
client = EntitySearchAPI(CognitiveServicesCredentials(subscription_key))

try:
entity_data = client.entities.search(query="tom cruise")
entity_data = client.entities.search(query="satya nadella")

if entity_data.entities.value:
# find the entity that represents the dominant one
Expand All @@ -21,10 +21,10 @@ def dominant_entity_lookup(subscription_key):
if entity.entity_presentation_info.entity_scenario == "DominantEntity"]

if main_entities:
print('Searched for "Tom Cruise" and found a dominant entity with this description:')
print('Searched for "Satya Nadella" and found a dominant entity with this description:')
print(main_entities[0].description)
else:
print("Couldn't find main entity tom cruise!")
print("Couldn't find main entity Satya Nadella!")

else:
print("Didn't see any data..")
Expand All @@ -35,12 +35,12 @@ def dominant_entity_lookup(subscription_key):
def handling_disambiguation(subscription_key):
"""HandlingDisambiguation.

"This will handle disambiguation results for an ambiguous query (harry potter)".
"This will handle disambiguation results for an ambiguous query (William Gates)".
"""
client = EntitySearchAPI(CognitiveServicesCredentials(subscription_key))

try:
entity_data = client.entities.search(query="harry potter")
entity_data = client.entities.search(query="william gates")

if entity_data.entities.value:
# find the entity that represents the dominant one
Expand All @@ -55,11 +55,11 @@ def handling_disambiguation(subscription_key):
main_entity = main_entities[0]
type_hint = main_entity.entity_presentation_info.entity_type_display_hint

print('Searched for "harry potter" and found a dominant entity {}with this description:'.format(
print('Searched for "William Gates" and found a dominant entity {}with this description:'.format(
'"with type hint "{}" '.format(type_hint) if type_hint else ''))
print(main_entity.description)
else:
print("Couldn't find a reliable dominant entity for harry potter!")
print("Couldn't find a reliable dominant entity for William Gates!")

if disambig_entities:
print("\nThis query is pretty ambiguous and can be referring to multiple things. Did you mean one of these:")
Expand All @@ -68,7 +68,7 @@ def handling_disambiguation(subscription_key):
suggestions.append("{} the {}".format(disambig_entity.name, disambig_entity.entity_presentation_info.entity_type_display_hint))
print(", or ".join(suggestions))
else:
print("We didn't find any disambiguation items for harry potter, so we must be certain what you're talking about!")
print("We didn't find any disambiguation items for William Gates, so we must be certain what you're talking about!")

else:
print("Didn't see any data..")
Expand Down Expand Up @@ -185,4 +185,4 @@ def error(subscription_key):
import sys, os.path
sys.path.append(os.path.abspath(os.path.join(__file__, "..", "..")))
from tools import execute_samples
execute_samples(globals(), SUBSCRIPTION_KEY_ENV_NAME)
execute_samples(globals(), SUBSCRIPTION_KEY_ENV_NAME)