Skip to content

Instantly share code, notes, and snippets.

@NesrineSF
Last active March 31, 2021 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NesrineSF/f04e5712c061d5d0b6c4041e0cc0b7c9 to your computer and use it in GitHub Desktop.
Save NesrineSF/f04e5712c061d5d0b6c4041e0cc0b7c9 to your computer and use it in GitHub Desktop.
#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
print (f'\t \033[1mOutput of the second 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 second sentence
for token in output_2.tokens:
print (f'{object_verb[token.start:token.end]:{20}} {token.pos:{6}}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment