Skip to content

Instantly share code, notes, and snippets.

@gauravbansal98
Created May 13, 2020 12:20
Show Gist options
  • Select an option

  • Save gauravbansal98/7bd72034397909ed9c3a1ee453e653aa to your computer and use it in GitHub Desktop.

Select an option

Save gauravbansal98/7bd72034397909ed9c3a1ee453e653aa to your computer and use it in GitHub Desktop.
# convert the loaded descriptions into a vocabulary of words
def to_vocabulary(descriptions):
# build a list of all description strings
all_desc = set()
for key in descriptions.keys():
[all_desc.update(d.split()) for d in descriptions[key]]
return all_desc
# summarize vocabulary
vocabulary = to_vocabulary(descriptions)
print('Vocabulary Size: %d' % len(vocabulary))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment