This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
living_from_live = "She's living her best life" | |
living_from_living = "What do you do for a living?" | |
language = 'en' | |
#Request to the API | |
output = client.specific_resource_analysis( | |
body={"document": {"text": living_from_live }}, | |
params={'language': language, 'resource': 'disambiguation' | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Concept_ID for object_noun | |
print (f'\t \033[1mConcept_ID for object when NOUN \033[0m \n') | |
#to print TOKEN, POS and ID (for the concept) in bold at the beginning of the output array: | |
print (f'\033[1m{"TOKEN":{20}} {"POS":{15}} {"ID":{6}}\033[0m') | |
#Syncon stands for "Concept" that we refer to with an ID | |
for token in output.tokens: | |
print (f'{object_noun[token.start:token.end]:{20}} {token.pos:{15}} {token.syncon:{6}} ') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#POS of the first sentence | |
print (f'\t \033[1mOutput of the first sentence : \033[0m \n') | |
#to print TOKEN and POS in bold at the beginning of the output array: | |
print (f'\033[1m{"TOKEN":{20}} {"POS":{6}}\033[0m') | |
#to iterate over the tokens and assign a POS to each token for the first sentence | |
for token in output.tokens: | |
print (f'{object_noun[token.start:token.end]:{20}} {token.pos:{6}}') | |
#POS of the second sentence |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#first sentence | |
object_noun = "The object of this exercise is to raise money for the charity." | |
#second sentence | |
object_verb = "A lot of people will object to the book." | |
language = 'en' | |
#Request to the API for the first sentence | |
output = client.specific_resource_analysis( | |
body={"document": {"text": object_noun}}, | |
params={'language': language, 'resource': 'disambiguation' | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#first sentence | |
object_noun = "The object of this exercise is to raise money for the charity." | |
language = 'en' | |
#Request to the API | |
output = client.specific_resource_analysis( | |
body={"document": {"text": object_noun}}, | |
params={'language': language, 'resource': 'disambiguation' | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object_noun = "The object of this exercise is to raise money for the charity." | |
object_verb = "A lot of people will object to the book." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for token in output.tokens: | |
print (f'{text[token.start:token.end]:{20}}') | |
#we iterate on the tokens array to subdivise the compound words into the atom level | |
for atom in token.atoms: | |
print (f'\t atom:{text[atom.start:atom.end]:{20}}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
text = "CNBC has commented on the robot's lifelike skin and her ability to emulate more than 60 facial expressions." | |
language= 'en' | |
output = client.specific_resource_analysis( | |
body={"document": {"text": text}}, | |
params={'language': language, 'resource': 'disambiguation' | |
}) | |
#to print to tokens within the sentence | |
print (f'{"TOKEN":{20}} ') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
text = "CNBC has commented on the robot's lifelike skin and her ability to emulate more than 60 facial expressions." | |
tokens = text.split() | |
print('These are the tokens of the sentence', tokens) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Output arrays size | |
print("phrases array size: ", len(output.phrases)) |
NewerOlder