Git Product home page Git Product logo

Comments (5)

Vossip avatar Vossip commented on August 9, 2024 2

Found the solution!
I had to use model.similarity("/c/en/coffee_pot", "/c/en/tea_kettle")

from conceptnet-numberbatch.

zhanwenchen avatar zhanwenchen commented on August 9, 2024 1

Thanks for the usage example

from conceptnet-numberbatch.

Vossip avatar Vossip commented on August 9, 2024

UPDATE:
If i iterate over the multilangual file and look for words coffee_pot and tea_kettle, I get matches.

wordsList = []
with open("numberbatch-en-17.06.txt") as fp:
    line = fp.readline()
    while line:
        #wordsList.append(line.strip())
        if "coffee_pot" in line or "tea_kettle" in line:
            print(line)
            wordsList.append(line.strip())
        line = fp.readline()

Result:

coffee_pot -0.0230 0.0046 0.0981 0.1118 -0.0274 -0.0430 0.0668 -0.1377 0.1417 -0.0054 -0.1251 0.0249 -0.0319 -0.0386 -0.0870 0.1135 0.0580 0.0420 -0.0394 -0.0855 -0.1048 -0.0423 -0.0198 0.0363 0.0809 -0.0504 -0.0459 0.0026 -0.1134 -0.0098 0.0396 0.0257 0.0578 0.0409 0.1037 0.0127 0.0631 0.0111 0.0341 -0.0565 0.0457 -0.0754 0.0174 0.0017 0.0379 0.0919 0.0048 -0.0303 0.1128 -0.0517 -0.0679 0.0375 0.0068 0.0612 -0.0367 -0.0346 0.0093 0.0608 0.0587 0.0321 0.0465 -0.0551 -0.0880 -0.0569 -0.0324 0.0402 0.0586 0.0173 -0.0797 -0.0163 -0.0103 -0.0142 -0.0537 -0.0697 0.1746 -0.0507 0.0150 -0.0284 -0.1064 -0.0054 -0.0395 -0.0012 0.0224 -0.0276 -0.0227 0.0777 0.0406 0.0460 0.0104 -0.0124 -0.0179 -0.0581 0.0546 0.0230 0.1200 -0.0507 0.1206 0.0995 0.1138 0.1081 0.1309 0.1133 0.0837 0.0106 0.1533 -0.0413 0.0384 0.0320 -0.0448 0.0390 -0.0273 -0.0037 0.0100 0.1070 0.1078 -0.0111 -0.0051 -0.1064 -0.0507 -0.0184 -0.0077 -0.0425 -0.0462 0.0528 0.0964 -0.0050 0.0147 -0.0723 -0.0232 0.0427 -0.1352 0.0433 -0.0277 -0.0064 0.0547 -0.0011 0.0105 0.0018 -0.0281 -0.0369 0.0138 -0.0069 0.0185 0.0368 0.0152 0.0851 -0.0760 0.0149 0.0127 -0.0212 0.0215 -0.0758 -0.0211 -0.0327 0.0059 0.0646 0.0738 -0.0097 0.0307 -0.0074 -0.0192 0.0750 0.0092 -0.0525 0.0939 0.0345 0.0386 -0.0119 -0.0113 0.0230 0.0050 0.0099 0.0856 0.0425 -0.0634 -0.0230 0.0607 -0.0060 -0.0486 0.1053 0.0487 -0.0081 0.0836 -0.0040 0.0138 -0.1171 0.0372 0.0944 0.0219 -0.0437 0.0506 0.0204 0.1172 0.0622 -0.0056 0.0303 -0.0120 -0.0067 0.0493 -0.0059 -0.0535 -0.0646 0.0731 0.0510 -0.0589 0.0143 -0.0261 -0.1250 0.0329 -0.0203 -0.0688 -0.0065 0.0075 0.0406 -0.0259 0.0218 0.0851 0.1140 0.0471 -0.0155 -0.0035 0.0228 0.0486 -0.0672 -0.0486 -0.0427 0.0194 0.1313 -0.0559 0.1879 0.0610 0.0066 -0.0540 0.0240 0.0789 0.0820 -0.0753 0.0255 -0.0801 -0.0039 0.0454 -0.0655 0.0078 -0.0493 -0.0665 -0.0217 0.0398 0.0206 0.0275 -0.1553 0.0141 -0.0150 -0.0216 -0.0092 0.0282 0.0306 0.0238 0.0245 -0.0251 -0.0183 0.0438 0.0267 -0.0379 0.0549 0.0149 -0.0172 -0.0228 0.0316 0.0067 0.0254 0.0174 -0.0269 -0.0616 0.0822 0.0304 -0.0101 0.0323 -0.0698 0.0373 0.0479 -0.0292 0.0060 0.0129 -0.0062 -0.0005 0.0549 -0.0928 0.0237 0.0139 -0.0256 -0.0110 -0.0107 0.0545 -0.0719 -0.0023 -0.0257 -0.0343 0.0371 -0.0116 -0.1188

coffee_pots -0.0349 -0.0209 0.0601 0.1151 -0.0160 -0.0381 0.0411 -0.1204 0.1615 -0.0167 -0.1284 0.0325 -0.0206 -0.0310 -0.0935 0.0877 0.0451 0.0455 -0.0432 -0.0820 -0.1071 -0.0281 -0.0288 0.0286 0.0721 -0.0464 -0.0439 0.0070 -0.1172 -0.0108 0.0386 0.0315 0.0522 0.0238 0.0967 0.0206 0.0648 0.0089 0.0270 -0.0498 0.0505 -0.0685 0.0055 -0.0035 0.0333 0.0844 0.0091 -0.0354 0.1053 -0.0514 -0.0697 0.0335 0.0072 0.0592 -0.0214 -0.0326 0.0099 0.0564 0.0661 0.0345 0.0396 -0.0571 -0.0783 -0.0603 -0.0347 0.0343 0.0519 0.0185 -0.0728 -0.0180 -0.0142 -0.0087 -0.0462 -0.0701 0.1772 -0.0611 0.0220 -0.0237 -0.1071 -0.0047 -0.0386 -0.0051 0.0097 -0.0324 -0.0338 0.0730 0.0473 0.0488 0.0071 -0.0116 -0.0065 -0.0510 0.0547 0.0299 0.1099 -0.0511 0.1267 0.0970 0.1113 0.1042 0.1292 0.1133 0.0799 0.0056 0.1459 -0.0488 0.0371 0.0297 -0.0459 0.0470 -0.0199 -0.0075 0.0040 0.1067 0.1147 -0.0146 -0.0063 -0.0982 -0.0576 -0.0230 -0.0033 -0.0459 -0.0584 0.0489 0.0971 0.0039 0.0209 -0.0710 -0.0189 0.0385 -0.1379 0.0366 -0.0299 -0.0035 0.0569 0.0154 0.0100 -0.0036 -0.0370 -0.0282 0.0187 -0.0063 0.0196 0.0370 0.0121 0.0881 -0.0696 0.0185 -0.0036 -0.0163 0.0253 -0.0718 -0.0246 -0.0282 0.0064 0.0743 0.0727 -0.0042 0.0244 -0.0091 -0.0209 0.0740 0.0136 -0.0588 0.0847 0.0432 0.0386 -0.0109 -0.0119 0.0097 0.0056 0.0124 0.0819 0.0390 -0.0725 -0.0145 0.0663 -0.0009 -0.0524 0.1071 0.0458 -0.0094 0.0853 -0.0014 0.0254 -0.1152 0.0416 0.1033 0.0191 -0.0388 0.0626 0.0261 0.1170 0.0534 -0.0064 0.0364 -0.0199 -0.0033 0.0587 0.0020 -0.0586 -0.0653 0.0831 0.0545 -0.0609 0.0079 -0.0294 -0.1300 0.0349 -0.0258 -0.0675 -0.0188 0.0055 0.0346 -0.0232 0.0257 0.0844 0.1191 0.0430 -0.0101 0.0127 0.0231 0.0471 -0.0640 -0.0448 -0.0453 0.0249 0.1370 -0.0598 0.1882 0.0612 0.0071 -0.0612 0.0183 0.0780 0.0776 -0.0916 0.0228 -0.0893 -0.0026 0.0548 -0.0734 0.0144 -0.0496 -0.0714 -0.0245 0.0440 0.0114 0.0344 -0.1492 0.0114 -0.0200 -0.0250 -0.0062 0.0250 0.0389 0.0346 0.0178 -0.0231 -0.0219 0.0435 0.0377 -0.0391 0.0578 0.0164 -0.0226 -0.0289 0.0260 0.0120 0.0240 0.0179 -0.0243 -0.0651 0.0925 0.0292 -0.0103 0.0320 -0.0739 0.0387 0.0480 -0.0273 0.0092 0.0155 -0.0194 -0.0067 0.0538 -0.0948 0.0311 0.0156 -0.0306 -0.0131 -0.0157 0.0593 -0.0756 0.0021 -0.0232 -0.0414 0.0295 -0.0107 -0.1248

tea_kettle 0.0387 -0.0292 0.2034 0.0983 -0.0785 -0.0051 -0.0116 -0.1310 0.1573 0.0358 -0.1409 -0.0158 -0.0262 -0.0663 -0.0684 0.1487 0.0211 0.0157 0.0348 -0.1160 -0.0701 -0.0608 -0.0211 0.0731 0.1092 -0.0442 0.0256 0.0136 0.0202 0.0671 0.0546 -0.0398 0.0347 0.1572 0.0104 0.0684 0.0615 0.0011 0.0769 -0.0849 0.1121 -0.0146 0.0206 0.0890 0.0034 0.0998 -0.1155 -0.0272 0.1015 0.0245 -0.0029 0.0695 0.0315 0.0344 -0.1253 -0.0065 0.0318 0.0381 0.0714 0.1117 0.0643 0.0176 -0.0146 0.0323 -0.0121 0.0828 0.1397 0.0657 0.0341 -0.0022 -0.0808 -0.0102 -0.0376 -0.0665 0.0470 -0.0740 0.0475 -0.0439 -0.1397 -0.0080 -0.0162 -0.0080 -0.0090 0.0758 0.0810 0.0960 0.0251 0.0324 0.0364 -0.0174 0.0730 0.0455 0.0726 -0.0408 0.1600 -0.0330 0.0497 0.0386 0.0575 0.0502 0.0282 0.0694 0.0284 0.0106 0.0604 -0.0308 0.1479 0.0419 0.0148 -0.0838 0.0076 0.0850 -0.0081 0.0001 -0.0346 0.0440 0.0194 -0.0662 -0.0037 -0.0127 0.0501 -0.0037 -0.0433 0.0840 0.0849 -0.0227 -0.0348 -0.0678 0.0064 0.0069 -0.0961 0.0382 -0.0234 -0.0157 0.0476 0.0230 0.0274 -0.0948 -0.0189 -0.0320 0.0148 0.0048 0.0111 0.0164 -0.0060 0.0528 -0.0438 -0.0374 0.0483 -0.0509 -0.0621 -0.0944 0.0287 -0.0347 0.0426 0.0072 0.0636 -0.0269 0.0194 0.0125 0.0522 -0.0145 -0.0429 -0.0658 0.0550 -0.0563 0.0634 -0.0271 0.0067 0.0529 0.0446 0.0477 -0.0389 -0.0156 -0.0803 0.0096 -0.0045 0.0738 0.0082 0.1149 0.0426 0.0435 0.1527 0.0145 0.0287 0.0157 0.0240 -0.0163 0.0111 -0.1571 -0.0086 0.0315 0.1189 -0.0286 0.0136 -0.0009 -0.0022 -0.0620 -0.0087 -0.0087 0.0451 -0.0221 0.0440 0.0300 0.0246 -0.0211 0.0015 -0.0988 0.0207 0.0209 -0.0194 0.0085 0.0048 -0.0461 -0.0463 0.0118 0.0319 0.0644 0.0314 -0.0716 0.0013 0.0189 0.0017 -0.0892 -0.0420 -0.0389 0.0255 -0.0115 -0.0180 -0.0208 -0.0679 -0.0670 -0.0114 0.0184 0.0075 -0.0079 0.0893 0.1186 -0.0519 0.0240 0.0709 -0.0012 -0.0427 0.0180 -0.0194 0.0077 0.0242 0.0327 0.0736 -0.1041 0.0360 -0.0107 0.1080 -0.0048 0.0447 -0.0109 -0.0357 0.0029 0.0464 0.0288 0.0930 0.0280 -0.0380 -0.0303 0.0239 -0.0361 0.1058 0.0381 0.0397 0.0503 0.0488 -0.0014 -0.0189 0.0218 0.0538 0.0643 -0.0117 -0.0569 -0.0072 -0.0235 -0.0106 -0.0155 0.0249 0.0790 0.0974 -0.0126 -0.0214 -0.0303 -0.0031 -0.0403 -0.1275 0.0454 -0.0159 -0.0287 -0.0092 -0.0471 -0.0019 0.0183 -0.0509 -0.0412

This raises interesting question. Why do I get KeyError: "word 'coffee_pot' not in vocabulary when I try to get similarity model.similarity("coffee_pot", "tea_kettle")

from conceptnet-numberbatch.

Vossip avatar Vossip commented on August 9, 2024

UPDATE 2:

print("coffee_pot" in model)

for v in model2.vocab:
    if "/c/en/" in v:
        print(v)

Result 1:

False

Result 2:

/c/en/coffee_pot
/c/en/coffee_pots
/c/en/coffee_ring
/c/en/coffee_roll
/c/en/coffee_royal
/c/en/coffee_senna
/c/en/coffee_shop
...
etc

from conceptnet-numberbatch.

DedaDev avatar DedaDev commented on August 9, 2024

Found the solution! I had to use model.similarity("/c/en/coffee_pot", "/c/en/tea_kettle")

is there a way to exclude specific language?

from conceptnet-numberbatch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.