Merge pull request #582 from pokey/patch-1

Fix small bug in code of mark-adverbs tutorial
This commit is contained in:
Matthew Honnibal 2016-10-27 01:31:50 +11:00 committed by GitHub
commit 597ea8f6ac
1 changed files with 1 additions and 1 deletions

View File

@ -78,7 +78,7 @@ p A simple work-around is to average the vectors of several words, and use that
+code.
>>> say_verbs = ['pleaded', 'confessed', 'remonstrated', 'begged', 'bragged', 'confided', 'requested']
>>> say_vector = sum(nlp.vocab[verb].vector for verb in say_verbs) / len(say_verbs)
>>> words.sort(key=lambda w: cosine(w.vector * say_vector))
>>> words.sort(key=lambda w: cosine(w.vector, say_vector))
>>> words.reverse()
>>> print('1-20', ', '.join(w.orth_ for w in words[0:20]))
1-20 bragged, remonstrated, enquired, demurred, sighed, mused, intimated, retorted, entreated, motioned, ranted, confided, countersued, gestured, implored, interceded, muttered, marvelled, bickered, despaired