import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
plt.style.use('ggplot')

import gensim.downloader as api
from gensim.models import KeyedVectors
model = api.load("glove-wiki-gigaword-100")
print(type[model])

type[<gensim.models.keyedvectors.KeyedVectors object at 0x78574111bb50>]

model['bread']

array([-0.66146 , 0.94335 , -0.72214 , 0.17403 , -0.42524 , 0.36303 , 1.0135 , -0.14802 , 0.25817 , -0.20326 , -0.64338 , 0.16632 , 0.61518 , 1.397 , -0.094506 , 0.0041843, -0.18976 , -0.55421 , -0.39371 , -0.22501 , -0.34643 , 0.32076 , 0.34395 , -0.7034 , 0.23932 , 0.69951 , -0.16461 , -0.31819 , -0.34034 , -0.44906 , -0.069667 , 0.35348 , 0.17498 , -0.95057 , -0.2209 , 1.0647 , 0.23231 , 0.32569 , 0.47662 , -1.1206 , 0.28168 , -0.75172 , -0.54654 , -0.66337 , 0.34804 , -0.69058 , -0.77092 , -0.40167 , -0.069351 , -0.049238 , -0.39351 , 0.16735 , -0.14512 , 1.0083 , -1.0608 , -0.87314 , -0.29339 , 0.68278 , 0.61634 , -0.088844 , 0.88094 , 0.099809 , -0.27161 , -0.58026 , 0.50364 , -0.93814 , 0.67576 , -0.43124 , -0.10517 , -1.2404 , -0.74353 , 0.28637 , 0.29012 , 0.89377 , 0.67406 , 0.86422 , -0.30693 , -0.14718 , 0.078353 , 0.74013 , 0.32658 , -0.052579 , -1.1665 , 0.87079 , -0.69402 , -0.75977 , -0.37164 , -0.11887 , 0.18551 , 0.041883 , 0.59352 , 0.30519 , -0.54819 , -0.29424 , -1.4912 , -1.6548 , 0.98982 , 0.27325 , 1.009 , 0.94544 ], dtype=float32)

model.most_similar('banana')

[('coconut', 0.7097253203392029), ('mango', 0.7054824829101562), ('bananas', 0.6887733340263367), ('potato', 0.6629636287689209), ('pineapple', 0.6534532308578491), ('fruit', 0.6519854664802551), ('peanut', 0.6420575976371765), ('pecan', 0.6349173188209534), ('cashew', 0.6294420957565308), ('papaya', 0.6246591210365295)]

model.most_similar(negative='banana')
```이상한 단어가 등장하기도 한다.
[('shunichi', 0.49618104100227356),
 ('ieronymos', 0.4736502170562744),
 ('pengrowth', 0.4668096601963043),
 ('höss', 0.4636845588684082),
 ('damaskinos', 0.4617849290370941),
 ('yadin', 0.4617374837398529),
 ('hundertwasser', 0.4588957726955414),
 ('ncpa', 0.4577339291572571),
 ('maccormac', 0.4566109776496887),
 ('rothfeld', 0.4523947238922119)]

```python
result = model.most_similar(positive=['woman','king'],negative=['man'])
print("{}:{:.4f}".format(*result[0]))

queen:0.7699

def analogy(x1,x2,y1):
    result = model.most_similar(positive=[y1,x2], negative=[x1])
    return result[0][0]
analogy('man','king','woman')

queen

analogy('tall','tallest','long')

longest