mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-26 01:46:28 +03:00
Merge branch 'master' of ssh://github.com/explosion/spaCy
This commit is contained in:
commit
21386aa68a
|
@ -78,7 +78,7 @@ p A simple work-around is to average the vectors of several words, and use that
|
||||||
+code.
|
+code.
|
||||||
>>> say_verbs = ['pleaded', 'confessed', 'remonstrated', 'begged', 'bragged', 'confided', 'requested']
|
>>> say_verbs = ['pleaded', 'confessed', 'remonstrated', 'begged', 'bragged', 'confided', 'requested']
|
||||||
>>> say_vector = sum(nlp.vocab[verb].vector for verb in say_verbs) / len(say_verbs)
|
>>> 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()
|
>>> words.reverse()
|
||||||
>>> print('1-20', ', '.join(w.orth_ for w in words[0:20]))
|
>>> 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
|
1-20 bragged, remonstrated, enquired, demurred, sighed, mused, intimated, retorted, entreated, motioned, ranted, confided, countersued, gestured, implored, interceded, muttered, marvelled, bickered, despaired
|
||||||
|
|
Loading…
Reference in New Issue
Block a user