Created
March 30, 2021 21:08
-
-
Save NesrineSF/04b75b049e4075e198f224f82e31f936 to your computer and use it in GitHub Desktop.
tokenization with expert.ai NL API
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}} ') | |
print (f'{"----":{20}}') | |
#we use the element output.tokens to subdivise the text into tokens | |
#start and end are the positions of the token in the analyzed text | |
for token in output.tokens: | |
print (f'{text[token.start:token.end]:{20}}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment