Skip to content

Commit

Permalink
Change names for legal reasons (Azure-Samples#5)
Browse files Browse the repository at this point in the history
Tom Cruise -> Satya Nadella
Harry Potter -> William Gates
  • Loading branch information
MikeDodaro authored and lmazuel committed Mar 7, 2018
1 parent 7399919 commit c7f6cdd
Showing 1 changed file with 10 additions and 10 deletions.
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)

0 comments on commit c7f6cdd

Please sign in to comment.