-
-
Save honnibal/664cf54cb30c48c0c977 to your computer and use it in GitHub Desktop.
from __future__ import unicode_literals | |
from __future__ import print_function | |
import plac | |
import spacy.en | |
def main(vectors_loc=None): | |
nlp = spacy.en.English() | |
if vectors_loc is not None: | |
nlp.vocab.load_vectors(vectors_loc) | |
# Quickly list some colors. The .similarity() function will use the average of these word vectors. | |
colors = nlp(u'red blue yellow green turquoise sapphire emerald ruby periwinkle umber oak charcoal ebony') | |
# We want lower-case words, that aren't too rare, sorted by their similarity to the above colors | |
words = [(lex.similarity(colors), lex.orth_) for lex in nlp.vocab | |
if lex.is_lower and lex.prob >= -20] | |
words.sort(reverse=True) | |
for i, (score, word) in enumerate(words): | |
print(i, score, word) | |
if __name__ == '__main__': | |
plac.call(main) |
Glove vectors output:
0 3.87395723519 turquoise
1 3.81783126743 yellow
2 3.74934072972 blue
3 3.74003162334 emerald
4 3.72134917579 pink
5 3.71219105108 purple
6 3.56881126256 amethyst
7 3.53722406442 sapphire
8 3.5338977891 brown
9 3.52508719696 red
10 3.49448519631 orange
11 3.46450432316 green
12 3.44438925954 garnet
13 3.40750136701 white
14 3.37292666661 violet
15 3.3686030001 aquamarine
16 3.34748098681 topaz
17 3.34234120305 ruby
18 3.3152772773 pearl
19 3.31128397829 burgundy
20 3.30942575478 black
21 3.28368459456 teal
22 3.27919208813 colored
23 3.25501919531 lilac
24 3.25401921038 grey
25 3.23096658155 silver
26 3.20777013691 gray
27 3.20412140206 reddish
28 3.19744039485 lavender
29 3.19347469396 amber
30 3.16969517955 pale
31 3.16528756293 hues
32 3.16400163358 opal
33 3.16034278217 fuchsia
34 3.15207669923 crimson
35 3.10774217816 sapphires
36 3.10093595348 beige
37 3.09839059888 peach
38 3.09668615314 onyx
39 3.0884795495 diamond
40 3.0779307923 satin
41 3.06581996239 iridescent
42 3.06472363433 greenish
43 3.05588015613 ivory
44 3.05062629551 hue
45 3.05040804143 color
46 3.04739816044 lime
47 3.03068467525 gemstone
48 3.02693619929 earrings
49 3.01975849647 aqua
50 3.01172475249 accented
51 3.00732955567 mauve
52 3.00233786367 ochre
53 2.99947677053 gold
54 2.99924936167 coloured
55 2.99406047464 faceted
56 2.98044868493 cherry
57 2.96892190548 oak
58 2.95935420273 coral
59 2.94618701376 magenta
60 2.94089170515 dark
61 2.93862445944 scarlet
62 2.92609177819 diamonds
63 2.92347453403 blue-green
64 2.91708857263 smoky
65 2.90485846061 necklace
66 2.90244943938 bluish
67 2.90196624365 olive
68 2.89681381562 jade
69 2.89296990694 shades
70 2.88725264193 pearls
71 2.88418227692 metallic
72 2.87934991203 plum
73 2.87638002505 beads
74 2.8733957592 lapis
75 2.87291067285 gemstones
76 2.87146809926 brownish
77 2.86761277939 silk
78 2.86371857348 quartz
79 2.86228403917 agate
80 2.86015993165 shade
81 2.85814995922 silvery
82 2.85621992528 mahogany
83 2.85284519015 crystal
84 2.84951707975 pinkish
85 2.84726073008 maroon
86 2.84132730527 colour
87 2.83108586479 azure
88 2.82799434488 shimmering
89 2.82199307096 yellowish
90 2.82132680799 purplish
91 2.81279489545 striped
92 2.80817585009 pastel
93 2.80712184342 pinks
94 2.80637486019 floral
95 2.80141970461 golden
96 2.79866670593 colors
97 2.79786259337 pendant
98 2.79665920514 purples
99 2.7902293279 charcoal
100 2.78933602027 pear
101 2.78233775646 translucent
102 2.78007994282 mottled
103 2.77681009425 velvet
104 2.77286006092 cobalt
105 2.7720605249 indigo
106 2.76869398825 bright
107 2.76368590644 oval
108 2.76014749584 walnut
109 2.75927573494 enamel
110 2.75764511125 tourmaline
111 2.75396672291 periwinkle
112 2.74285851648 lemon
113 2.74029274208 matte
114 2.74008222039 creamy
115 2.73949448002 tangerine
116 2.7278674572 beaded
117 2.72597122194 wood
118 2.72262044238 raspberry
119 2.71494198902 ebony
120 2.71351468159 rubies
121 2.7041493532 stone
122 2.70225336045 marble
123 2.70112397192 inlaid
124 2.6936419785 pine
125 2.69153651481 sparkling
126 2.688449127 smokey
127 2.68778297872 leather
128 2.6862100543 flower
129 2.68548111684 hued
130 2.6853321396 leaf
131 2.68287565208 chartreuse
132 2.68189727908 sterling
133 2.67146680043 reds
134 2.66722646249 dyed
135 2.66554317541 carnelian
136 2.65360795343 grayish
137 2.64848367015 crystals
138 2.64651616121 bracelet
139 2.64641917122 rhinestone
140 2.64560823732 yellows
141 2.64024332875 carat
142 2.63958006944 shimmer
143 2.63830071556 shiny
144 2.63315209683 tan
145 2.63265421481 marquise
46 2.62952121812 maple
147 2.62580441077 accents
148 2.62338247804 flecks
149 2.620271784 khaki
150 2.6186058209 glass
Output, using the default word vectors. You can get better results by iteratively going through the output and adding words to the seed set, to sharpen up the definition of a "color".
0 0.630796188812 aquamarine
1 0.630451769959 umber
2 0.62695644723 turquoise
3 0.623297164013 red-orange
4 0.61921603476 coppery
5 0.616236259621 malachite
6 0.613253326957 ochre
7 0.606508481453 russet
8 0.604026572947 blue-violet
9 0.602659094829 fuchsia
10 0.600814722859 butterscotch
11 0.600609709055 lilac
12 0.597795867899 tortoiseshell
13 0.59609539293 mother-of-pearl
14 0.596093607576 lycra
15 0.59581192373 taffeta
16 0.595181754402 spearmint
17 0.595081710554 piebald
18 0.594803346484 damask
19 0.594768152256 cowhide
20 0.594668933999 inky
21 0.594154520722 fishnet
22 0.5932768444 madder
23 0.59229876497 jet-black
24 0.592234954151 blue-gray
25 0.59216716361 sky-blue
26 0.592042786719 sallow
27 0.591558529122 papery
28 0.591378999741 buckskin
29 0.591133753171 tawny
30 0.589953554889 snakeskin
31 0.589212835857 sheepskin
32 0.587953419295 blue-green
33 0.58730848757 boxwood
34 0.587126671383 sunburst
35 0.587109171837 azurite
36 0.586531164225 raffia
37 0.585898106675 amethyst
38 0.585042161255 lazuli
39 0.584972643596 velour
40 0.58457401249 chiffon
41 0.584561990024 deerskin
42 0.583772570567 leafgreen
43 0.583505077872 red-brown
44 0.583195051051 brownish-gray
45 0.582927627686 carnelian
46 0.582685254929 flannel
47 0.582455781905 cerulean
48 0.581996363233 blackcurrant
50 0.581034013787 jadeite
51 0.580687539797 tourmaline
52 0.580157258272 sooty
53 0.579066786932 periwinkle
54 0.578564099273 gore-tex
55 0.578417580234 goatskin
56 0.577771215055 gooey
57 0.577147692915 marzipan
58 0.577040880936 longfin
59 0.576739032073 mauve
60 0.576711421805 brindle
61 0.576494056614 cyan
62 0.576170236563 silky
63 0.576066666675 lavender
64 0.575809996254 tinfoil
65 0.575513672489 whalebone
66 0.57523028487 sapphire
67 0.574110116 yellow-green
68 0.573933357759 nomex
69 0.573734128158 oolong
70 0.573731711603 sleeveless
71 0.573694623685 elderberry
72 0.573320870733 wispy
73 0.573184195597 limonite
74 0.573160903714 foxtail
75 0.572552013239 gossamer
76 0.572468981314 vermilion
77 0.572272269493 soapstone
78 0.572135099563 tinsel
79 0.571946328414 strapless
80 0.571820918691 olive-green
81 0.571678031372 blueish
82 0.571634780234 orange-red
83 0.571578509775 licorice
84 0.571428194024 electrum
85 0.571401685472 knobby
86 0.571370718595 emerald
87 0.571123447568 adamantine
88 0.570877683118 claret
89 0.570797645194 shiitake
90 0.57074185065 phosphorescent
91 0.570368381096 satin
92 0.570234277549 ebony
93 0.569957106518 woad
94 0.569938754731 fondant
95 0.569792144333 goldenrod
96 0.569791120306 treacle
97 0.569541554608 mangosteen
98 0.569374898992 codfish
99 0.56885656069 silvery
100 0.568853307364 persimmon
101 0.568809875467 gummy
102 0.568786559967 spandex
103 0.568392027396 marshmallow
104 0.568344053463 pinstripe
105 0.568287197114 calico
106 0.56810301092 off-white
107 0.56805172948 heliotrope
108 0.567412511507 downy
109 0.567408065295 onyx
110 0.566931928187 bilberry
111 0.566898010892 pendent
112 0.566810091112 warty
113 0.566512316238 gray-brown
114 0.566370336863 horsehair
115 0.566302463746 microfiber
116 0.566020569522 semitransparent
117 0.565830588327 amaranth
118 0.565726373464 topaz
119 0.565417463637 ashy
120 0.565387146921 golden-brown
121 0.565295125441 neoprene
122 0.565232444686 feathery
123 0.565089853721 dark-blue
124 0.565021004846 orange-yellow
125 0.564927432129 copal
126 0.564916885229 chalky
127 0.56487762843 soulsilver
128 0.56463535747 rufous
129 0.564538469208 sepia
130 0.564504892453 peony
131 0.56439707127 guar
132 0.564394001597 mylar
133 0.564224401494 velvety
134 0.563767288409 magenta
135 0.563459544452 pistachio
136 0.563162420807 burlap
137 0.563092047281 ironbark
138 0.563053149759 paulownia
139 0.562824786583 acanthus
140 0.562823037917 mohair
141 0.562821634922 blue
142 0.562769452911 cinnabar
143 0.562734743972 scaly
144 0.562209962267 hollowed-out
145 0.562085305674 apricot
146 0.562015880851 glittery
147 0.561958947639 muslin