fasttext 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (478) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/README.md +20 -1
  4. data/lib/fasttext.rb +3 -0
  5. data/lib/fasttext/classifier.rb +12 -4
  6. data/lib/fasttext/vectorizer.rb +1 -1
  7. data/lib/fasttext/version.rb +1 -1
  8. metadata +4 -473
  9. data/lib/fasttext/ext.bundle +0 -0
  10. data/vendor/fastText/CMakeLists.txt +0 -68
  11. data/vendor/fastText/CODE_OF_CONDUCT.md +0 -2
  12. data/vendor/fastText/CONTRIBUTING.md +0 -32
  13. data/vendor/fastText/MANIFEST.in +0 -5
  14. data/vendor/fastText/Makefile +0 -63
  15. data/vendor/fastText/alignment/README.md +0 -53
  16. data/vendor/fastText/alignment/align.py +0 -145
  17. data/vendor/fastText/alignment/eval.py +0 -60
  18. data/vendor/fastText/alignment/example.sh +0 -51
  19. data/vendor/fastText/alignment/unsup_align.py +0 -109
  20. data/vendor/fastText/alignment/utils.py +0 -154
  21. data/vendor/fastText/classification-example.sh +0 -41
  22. data/vendor/fastText/classification-results.sh +0 -94
  23. data/vendor/fastText/crawl/README.md +0 -26
  24. data/vendor/fastText/crawl/dedup.cc +0 -51
  25. data/vendor/fastText/crawl/download_crawl.sh +0 -57
  26. data/vendor/fastText/crawl/filter_dedup.sh +0 -13
  27. data/vendor/fastText/crawl/filter_utf8.cc +0 -105
  28. data/vendor/fastText/crawl/process_wet_file.sh +0 -30
  29. data/vendor/fastText/docs/aligned-vectors.md +0 -64
  30. data/vendor/fastText/docs/api.md +0 -6
  31. data/vendor/fastText/docs/cheatsheet.md +0 -66
  32. data/vendor/fastText/docs/crawl-vectors.md +0 -125
  33. data/vendor/fastText/docs/dataset.md +0 -6
  34. data/vendor/fastText/docs/english-vectors.md +0 -53
  35. data/vendor/fastText/docs/faqs.md +0 -63
  36. data/vendor/fastText/docs/language-identification.md +0 -47
  37. data/vendor/fastText/docs/options.md +0 -50
  38. data/vendor/fastText/docs/pretrained-vectors.md +0 -142
  39. data/vendor/fastText/docs/python-module.md +0 -314
  40. data/vendor/fastText/docs/references.md +0 -41
  41. data/vendor/fastText/docs/supervised-models.md +0 -54
  42. data/vendor/fastText/docs/supervised-tutorial.md +0 -349
  43. data/vendor/fastText/docs/support.md +0 -58
  44. data/vendor/fastText/docs/unsupervised-tutorials.md +0 -309
  45. data/vendor/fastText/eval.py +0 -95
  46. data/vendor/fastText/get-wikimedia.sh +0 -79
  47. data/vendor/fastText/python/README.md +0 -322
  48. data/vendor/fastText/python/README.rst +0 -406
  49. data/vendor/fastText/python/benchmarks/README.rst +0 -3
  50. data/vendor/fastText/python/benchmarks/get_word_vector.py +0 -49
  51. data/vendor/fastText/python/doc/examples/FastTextEmbeddingBag.py +0 -81
  52. data/vendor/fastText/python/doc/examples/bin_to_vec.py +0 -41
  53. data/vendor/fastText/python/doc/examples/compute_accuracy.py +0 -163
  54. data/vendor/fastText/python/doc/examples/get_vocab.py +0 -48
  55. data/vendor/fastText/python/doc/examples/train_supervised.py +0 -42
  56. data/vendor/fastText/python/doc/examples/train_unsupervised.py +0 -56
  57. data/vendor/fastText/python/fasttext_module/fasttext/FastText.py +0 -468
  58. data/vendor/fastText/python/fasttext_module/fasttext/__init__.py +0 -22
  59. data/vendor/fastText/python/fasttext_module/fasttext/pybind/fasttext_pybind.cc +0 -388
  60. data/vendor/fastText/python/fasttext_module/fasttext/tests/__init__.py +0 -14
  61. data/vendor/fastText/python/fasttext_module/fasttext/tests/test_configurations.py +0 -239
  62. data/vendor/fastText/python/fasttext_module/fasttext/tests/test_script.py +0 -629
  63. data/vendor/fastText/python/fasttext_module/fasttext/util/__init__.py +0 -13
  64. data/vendor/fastText/python/fasttext_module/fasttext/util/util.py +0 -60
  65. data/vendor/fastText/quantization-example.sh +0 -40
  66. data/vendor/fastText/runtests.py +0 -60
  67. data/vendor/fastText/scripts/kbcompletion/README.md +0 -19
  68. data/vendor/fastText/scripts/kbcompletion/data.sh +0 -69
  69. data/vendor/fastText/scripts/kbcompletion/eval.cpp +0 -108
  70. data/vendor/fastText/scripts/kbcompletion/fb15k.sh +0 -49
  71. data/vendor/fastText/scripts/kbcompletion/fb15k237.sh +0 -45
  72. data/vendor/fastText/scripts/kbcompletion/svo.sh +0 -38
  73. data/vendor/fastText/scripts/kbcompletion/wn18.sh +0 -49
  74. data/vendor/fastText/scripts/quantization/quantization-results.sh +0 -43
  75. data/vendor/fastText/setup.cfg +0 -2
  76. data/vendor/fastText/setup.py +0 -203
  77. data/vendor/fastText/tests/fetch_test_data.sh +0 -202
  78. data/vendor/fastText/website/README.md +0 -6
  79. data/vendor/fastText/website/blog/2016-08-18-blog-post.md +0 -42
  80. data/vendor/fastText/website/blog/2017-05-02-blog-post.md +0 -60
  81. data/vendor/fastText/website/blog/2017-10-02-blog-post.md +0 -90
  82. data/vendor/fastText/website/blog/2019-06-25-blog-post.md +0 -168
  83. data/vendor/fastText/website/core/Footer.js +0 -127
  84. data/vendor/fastText/website/package.json +0 -12
  85. data/vendor/fastText/website/pages/en/index.js +0 -286
  86. data/vendor/fastText/website/sidebars.json +0 -18
  87. data/vendor/fastText/website/siteConfig.js +0 -102
  88. data/vendor/fastText/website/static/docs/en/html/annotated.html +0 -115
  89. data/vendor/fastText/website/static/docs/en/html/annotated_dup.js +0 -4
  90. data/vendor/fastText/website/static/docs/en/html/args_8cc.html +0 -113
  91. data/vendor/fastText/website/static/docs/en/html/args_8h.html +0 -134
  92. data/vendor/fastText/website/static/docs/en/html/args_8h.js +0 -14
  93. data/vendor/fastText/website/static/docs/en/html/args_8h_source.html +0 -139
  94. data/vendor/fastText/website/static/docs/en/html/bc_s.png +0 -0
  95. data/vendor/fastText/website/static/docs/en/html/bdwn.png +0 -0
  96. data/vendor/fastText/website/static/docs/en/html/classes.html +0 -121
  97. data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1Args-members.html +0 -140
  98. data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1Args.html +0 -753
  99. data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1Args.js +0 -40
  100. data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1Dictionary-members.html +0 -148
  101. data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1Dictionary.html +0 -1266
  102. data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1Dictionary.js +0 -43
  103. data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1FastText-members.html +0 -145
  104. data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1FastText.html +0 -1149
  105. data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1FastText.js +0 -45
  106. data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1Matrix-members.html +0 -123
  107. data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1Matrix.html +0 -610
  108. data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1Matrix.js +0 -23
  109. data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1Model-members.html +0 -150
  110. data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1Model.html +0 -1400
  111. data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1Model.js +0 -48
  112. data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1ProductQuantizer-members.html +0 -131
  113. data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1ProductQuantizer.html +0 -950
  114. data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1ProductQuantizer.js +0 -31
  115. data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1QMatrix-members.html +0 -122
  116. data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1QMatrix.html +0 -565
  117. data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1QMatrix.js +0 -22
  118. data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1Vector-members.html +0 -121
  119. data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1Vector.html +0 -542
  120. data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1Vector.js +0 -21
  121. data/vendor/fastText/website/static/docs/en/html/closed.png +0 -0
  122. data/vendor/fastText/website/static/docs/en/html/dictionary_8cc.html +0 -116
  123. data/vendor/fastText/website/static/docs/en/html/dictionary_8h.html +0 -142
  124. data/vendor/fastText/website/static/docs/en/html/dictionary_8h.js +0 -10
  125. data/vendor/fastText/website/static/docs/en/html/dictionary_8h_source.html +0 -127
  126. data/vendor/fastText/website/static/docs/en/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html +0 -145
  127. data/vendor/fastText/website/static/docs/en/html/dir_68267d1309a1af8e8297ef4c3efbcdba.js +0 -29
  128. data/vendor/fastText/website/static/docs/en/html/doc.png +0 -0
  129. data/vendor/fastText/website/static/docs/en/html/doxygen.css +0 -1596
  130. data/vendor/fastText/website/static/docs/en/html/doxygen.png +0 -0
  131. data/vendor/fastText/website/static/docs/en/html/dynsections.js +0 -97
  132. data/vendor/fastText/website/static/docs/en/html/fasttext_8cc.html +0 -119
  133. data/vendor/fastText/website/static/docs/en/html/fasttext_8h.html +0 -168
  134. data/vendor/fastText/website/static/docs/en/html/fasttext_8h.js +0 -6
  135. data/vendor/fastText/website/static/docs/en/html/fasttext_8h_source.html +0 -155
  136. data/vendor/fastText/website/static/docs/en/html/favicon.png +0 -0
  137. data/vendor/fastText/website/static/docs/en/html/files.html +0 -125
  138. data/vendor/fastText/website/static/docs/en/html/files.js +0 -4
  139. data/vendor/fastText/website/static/docs/en/html/folderclosed.png +0 -0
  140. data/vendor/fastText/website/static/docs/en/html/folderopen.png +0 -0
  141. data/vendor/fastText/website/static/docs/en/html/functions.html +0 -139
  142. data/vendor/fastText/website/static/docs/en/html/functions_0x7e.html +0 -112
  143. data/vendor/fastText/website/static/docs/en/html/functions_b.html +0 -115
  144. data/vendor/fastText/website/static/docs/en/html/functions_c.html +0 -143
  145. data/vendor/fastText/website/static/docs/en/html/functions_d.html +0 -135
  146. data/vendor/fastText/website/static/docs/en/html/functions_dup.js +0 -27
  147. data/vendor/fastText/website/static/docs/en/html/functions_e.html +0 -115
  148. data/vendor/fastText/website/static/docs/en/html/functions_f.html +0 -112
  149. data/vendor/fastText/website/static/docs/en/html/functions_func.html +0 -563
  150. data/vendor/fastText/website/static/docs/en/html/functions_g.html +0 -145
  151. data/vendor/fastText/website/static/docs/en/html/functions_h.html +0 -112
  152. data/vendor/fastText/website/static/docs/en/html/functions_i.html +0 -121
  153. data/vendor/fastText/website/static/docs/en/html/functions_k.html +0 -106
  154. data/vendor/fastText/website/static/docs/en/html/functions_l.html +0 -140
  155. data/vendor/fastText/website/static/docs/en/html/functions_m.html +0 -153
  156. data/vendor/fastText/website/static/docs/en/html/functions_n.html +0 -164
  157. data/vendor/fastText/website/static/docs/en/html/functions_o.html +0 -116
  158. data/vendor/fastText/website/static/docs/en/html/functions_p.html +0 -161
  159. data/vendor/fastText/website/static/docs/en/html/functions_q.html +0 -135
  160. data/vendor/fastText/website/static/docs/en/html/functions_r.html +0 -116
  161. data/vendor/fastText/website/static/docs/en/html/functions_s.html +0 -159
  162. data/vendor/fastText/website/static/docs/en/html/functions_t.html +0 -138
  163. data/vendor/fastText/website/static/docs/en/html/functions_u.html +0 -106
  164. data/vendor/fastText/website/static/docs/en/html/functions_v.html +0 -106
  165. data/vendor/fastText/website/static/docs/en/html/functions_vars.html +0 -486
  166. data/vendor/fastText/website/static/docs/en/html/functions_w.html +0 -124
  167. data/vendor/fastText/website/static/docs/en/html/functions_z.html +0 -104
  168. data/vendor/fastText/website/static/docs/en/html/globals.html +0 -170
  169. data/vendor/fastText/website/static/docs/en/html/globals_defs.html +0 -113
  170. data/vendor/fastText/website/static/docs/en/html/globals_func.html +0 -155
  171. data/vendor/fastText/website/static/docs/en/html/index.html +0 -100
  172. data/vendor/fastText/website/static/docs/en/html/jquery.js +0 -87
  173. data/vendor/fastText/website/static/docs/en/html/main_8cc.html +0 -582
  174. data/vendor/fastText/website/static/docs/en/html/main_8cc.js +0 -22
  175. data/vendor/fastText/website/static/docs/en/html/matrix_8cc.html +0 -114
  176. data/vendor/fastText/website/static/docs/en/html/matrix_8h.html +0 -121
  177. data/vendor/fastText/website/static/docs/en/html/matrix_8h_source.html +0 -123
  178. data/vendor/fastText/website/static/docs/en/html/menu.js +0 -26
  179. data/vendor/fastText/website/static/docs/en/html/menudata.js +0 -90
  180. data/vendor/fastText/website/static/docs/en/html/model_8cc.html +0 -113
  181. data/vendor/fastText/website/static/docs/en/html/model_8h.html +0 -183
  182. data/vendor/fastText/website/static/docs/en/html/model_8h.js +0 -8
  183. data/vendor/fastText/website/static/docs/en/html/model_8h_source.html +0 -139
  184. data/vendor/fastText/website/static/docs/en/html/namespacefasttext.html +0 -343
  185. data/vendor/fastText/website/static/docs/en/html/namespacefasttext.js +0 -13
  186. data/vendor/fastText/website/static/docs/en/html/namespacefasttext_1_1utils.html +0 -158
  187. data/vendor/fastText/website/static/docs/en/html/namespacemembers.html +0 -125
  188. data/vendor/fastText/website/static/docs/en/html/namespacemembers_enum.html +0 -107
  189. data/vendor/fastText/website/static/docs/en/html/namespacemembers_func.html +0 -110
  190. data/vendor/fastText/website/static/docs/en/html/namespacemembers_type.html +0 -104
  191. data/vendor/fastText/website/static/docs/en/html/namespaces.html +0 -106
  192. data/vendor/fastText/website/static/docs/en/html/namespaces.js +0 -4
  193. data/vendor/fastText/website/static/docs/en/html/nav_f.png +0 -0
  194. data/vendor/fastText/website/static/docs/en/html/nav_g.png +0 -0
  195. data/vendor/fastText/website/static/docs/en/html/nav_h.png +0 -0
  196. data/vendor/fastText/website/static/docs/en/html/navtree.css +0 -146
  197. data/vendor/fastText/website/static/docs/en/html/navtree.js +0 -517
  198. data/vendor/fastText/website/static/docs/en/html/navtreedata.js +0 -40
  199. data/vendor/fastText/website/static/docs/en/html/navtreeindex0.js +0 -253
  200. data/vendor/fastText/website/static/docs/en/html/navtreeindex1.js +0 -139
  201. data/vendor/fastText/website/static/docs/en/html/open.png +0 -0
  202. data/vendor/fastText/website/static/docs/en/html/productquantizer_8cc.html +0 -118
  203. data/vendor/fastText/website/static/docs/en/html/productquantizer_8cc.js +0 -4
  204. data/vendor/fastText/website/static/docs/en/html/productquantizer_8h.html +0 -124
  205. data/vendor/fastText/website/static/docs/en/html/productquantizer_8h_source.html +0 -133
  206. data/vendor/fastText/website/static/docs/en/html/qmatrix_8cc.html +0 -112
  207. data/vendor/fastText/website/static/docs/en/html/qmatrix_8h.html +0 -126
  208. data/vendor/fastText/website/static/docs/en/html/qmatrix_8h_source.html +0 -128
  209. data/vendor/fastText/website/static/docs/en/html/real_8h.html +0 -117
  210. data/vendor/fastText/website/static/docs/en/html/real_8h.js +0 -4
  211. data/vendor/fastText/website/static/docs/en/html/real_8h_source.html +0 -103
  212. data/vendor/fastText/website/static/docs/en/html/resize.js +0 -114
  213. data/vendor/fastText/website/static/docs/en/html/search/all_0.html +0 -26
  214. data/vendor/fastText/website/static/docs/en/html/search/all_0.js +0 -17
  215. data/vendor/fastText/website/static/docs/en/html/search/all_1.html +0 -26
  216. data/vendor/fastText/website/static/docs/en/html/search/all_1.js +0 -8
  217. data/vendor/fastText/website/static/docs/en/html/search/all_10.html +0 -26
  218. data/vendor/fastText/website/static/docs/en/html/search/all_10.js +0 -10
  219. data/vendor/fastText/website/static/docs/en/html/search/all_11.html +0 -26
  220. data/vendor/fastText/website/static/docs/en/html/search/all_11.js +0 -25
  221. data/vendor/fastText/website/static/docs/en/html/search/all_12.html +0 -26
  222. data/vendor/fastText/website/static/docs/en/html/search/all_12.js +0 -15
  223. data/vendor/fastText/website/static/docs/en/html/search/all_13.html +0 -26
  224. data/vendor/fastText/website/static/docs/en/html/search/all_13.js +0 -7
  225. data/vendor/fastText/website/static/docs/en/html/search/all_14.html +0 -26
  226. data/vendor/fastText/website/static/docs/en/html/search/all_14.js +0 -7
  227. data/vendor/fastText/website/static/docs/en/html/search/all_15.html +0 -26
  228. data/vendor/fastText/website/static/docs/en/html/search/all_15.js +0 -11
  229. data/vendor/fastText/website/static/docs/en/html/search/all_16.html +0 -26
  230. data/vendor/fastText/website/static/docs/en/html/search/all_16.js +0 -4
  231. data/vendor/fastText/website/static/docs/en/html/search/all_17.html +0 -26
  232. data/vendor/fastText/website/static/docs/en/html/search/all_17.js +0 -7
  233. data/vendor/fastText/website/static/docs/en/html/search/all_2.html +0 -26
  234. data/vendor/fastText/website/static/docs/en/html/search/all_2.js +0 -17
  235. data/vendor/fastText/website/static/docs/en/html/search/all_3.html +0 -26
  236. data/vendor/fastText/website/static/docs/en/html/search/all_3.js +0 -17
  237. data/vendor/fastText/website/static/docs/en/html/search/all_4.html +0 -26
  238. data/vendor/fastText/website/static/docs/en/html/search/all_4.js +0 -10
  239. data/vendor/fastText/website/static/docs/en/html/search/all_5.html +0 -26
  240. data/vendor/fastText/website/static/docs/en/html/search/all_5.js +0 -12
  241. data/vendor/fastText/website/static/docs/en/html/search/all_6.html +0 -26
  242. data/vendor/fastText/website/static/docs/en/html/search/all_6.js +0 -18
  243. data/vendor/fastText/website/static/docs/en/html/search/all_7.html +0 -26
  244. data/vendor/fastText/website/static/docs/en/html/search/all_7.js +0 -8
  245. data/vendor/fastText/website/static/docs/en/html/search/all_8.html +0 -26
  246. data/vendor/fastText/website/static/docs/en/html/search/all_8.js +0 -11
  247. data/vendor/fastText/website/static/docs/en/html/search/all_9.html +0 -26
  248. data/vendor/fastText/website/static/docs/en/html/search/all_9.js +0 -5
  249. data/vendor/fastText/website/static/docs/en/html/search/all_a.html +0 -26
  250. data/vendor/fastText/website/static/docs/en/html/search/all_a.js +0 -17
  251. data/vendor/fastText/website/static/docs/en/html/search/all_b.html +0 -26
  252. data/vendor/fastText/website/static/docs/en/html/search/all_b.js +0 -27
  253. data/vendor/fastText/website/static/docs/en/html/search/all_c.html +0 -26
  254. data/vendor/fastText/website/static/docs/en/html/search/all_c.js +0 -26
  255. data/vendor/fastText/website/static/docs/en/html/search/all_d.html +0 -26
  256. data/vendor/fastText/website/static/docs/en/html/search/all_d.js +0 -9
  257. data/vendor/fastText/website/static/docs/en/html/search/all_e.html +0 -26
  258. data/vendor/fastText/website/static/docs/en/html/search/all_e.js +0 -35
  259. data/vendor/fastText/website/static/docs/en/html/search/all_f.html +0 -26
  260. data/vendor/fastText/website/static/docs/en/html/search/all_f.js +0 -16
  261. data/vendor/fastText/website/static/docs/en/html/search/classes_0.html +0 -26
  262. data/vendor/fastText/website/static/docs/en/html/search/classes_0.js +0 -4
  263. data/vendor/fastText/website/static/docs/en/html/search/classes_1.html +0 -26
  264. data/vendor/fastText/website/static/docs/en/html/search/classes_1.js +0 -4
  265. data/vendor/fastText/website/static/docs/en/html/search/classes_2.html +0 -26
  266. data/vendor/fastText/website/static/docs/en/html/search/classes_2.js +0 -4
  267. data/vendor/fastText/website/static/docs/en/html/search/classes_3.html +0 -26
  268. data/vendor/fastText/website/static/docs/en/html/search/classes_3.js +0 -4
  269. data/vendor/fastText/website/static/docs/en/html/search/classes_4.html +0 -26
  270. data/vendor/fastText/website/static/docs/en/html/search/classes_4.js +0 -5
  271. data/vendor/fastText/website/static/docs/en/html/search/classes_5.html +0 -26
  272. data/vendor/fastText/website/static/docs/en/html/search/classes_5.js +0 -4
  273. data/vendor/fastText/website/static/docs/en/html/search/classes_6.html +0 -26
  274. data/vendor/fastText/website/static/docs/en/html/search/classes_6.js +0 -4
  275. data/vendor/fastText/website/static/docs/en/html/search/classes_7.html +0 -26
  276. data/vendor/fastText/website/static/docs/en/html/search/classes_7.js +0 -4
  277. data/vendor/fastText/website/static/docs/en/html/search/classes_8.html +0 -26
  278. data/vendor/fastText/website/static/docs/en/html/search/classes_8.js +0 -4
  279. data/vendor/fastText/website/static/docs/en/html/search/close.png +0 -0
  280. data/vendor/fastText/website/static/docs/en/html/search/defines_0.html +0 -26
  281. data/vendor/fastText/website/static/docs/en/html/search/defines_0.js +0 -5
  282. data/vendor/fastText/website/static/docs/en/html/search/defines_1.html +0 -26
  283. data/vendor/fastText/website/static/docs/en/html/search/defines_1.js +0 -4
  284. data/vendor/fastText/website/static/docs/en/html/search/defines_2.html +0 -26
  285. data/vendor/fastText/website/static/docs/en/html/search/defines_2.js +0 -4
  286. data/vendor/fastText/website/static/docs/en/html/search/defines_3.html +0 -26
  287. data/vendor/fastText/website/static/docs/en/html/search/defines_3.js +0 -4
  288. data/vendor/fastText/website/static/docs/en/html/search/enums_0.html +0 -26
  289. data/vendor/fastText/website/static/docs/en/html/search/enums_0.js +0 -4
  290. data/vendor/fastText/website/static/docs/en/html/search/enums_1.html +0 -26
  291. data/vendor/fastText/website/static/docs/en/html/search/enums_1.js +0 -4
  292. data/vendor/fastText/website/static/docs/en/html/search/enums_2.html +0 -26
  293. data/vendor/fastText/website/static/docs/en/html/search/enums_2.js +0 -4
  294. data/vendor/fastText/website/static/docs/en/html/search/enumvalues_0.html +0 -26
  295. data/vendor/fastText/website/static/docs/en/html/search/enumvalues_0.js +0 -4
  296. data/vendor/fastText/website/static/docs/en/html/search/enumvalues_1.html +0 -26
  297. data/vendor/fastText/website/static/docs/en/html/search/enumvalues_1.js +0 -4
  298. data/vendor/fastText/website/static/docs/en/html/search/enumvalues_2.html +0 -26
  299. data/vendor/fastText/website/static/docs/en/html/search/enumvalues_2.js +0 -4
  300. data/vendor/fastText/website/static/docs/en/html/search/enumvalues_3.html +0 -26
  301. data/vendor/fastText/website/static/docs/en/html/search/enumvalues_3.js +0 -4
  302. data/vendor/fastText/website/static/docs/en/html/search/enumvalues_4.html +0 -26
  303. data/vendor/fastText/website/static/docs/en/html/search/enumvalues_4.js +0 -6
  304. data/vendor/fastText/website/static/docs/en/html/search/enumvalues_5.html +0 -26
  305. data/vendor/fastText/website/static/docs/en/html/search/enumvalues_5.js +0 -4
  306. data/vendor/fastText/website/static/docs/en/html/search/files_0.html +0 -26
  307. data/vendor/fastText/website/static/docs/en/html/search/files_0.js +0 -5
  308. data/vendor/fastText/website/static/docs/en/html/search/files_1.html +0 -26
  309. data/vendor/fastText/website/static/docs/en/html/search/files_1.js +0 -5
  310. data/vendor/fastText/website/static/docs/en/html/search/files_2.html +0 -26
  311. data/vendor/fastText/website/static/docs/en/html/search/files_2.js +0 -5
  312. data/vendor/fastText/website/static/docs/en/html/search/files_3.html +0 -26
  313. data/vendor/fastText/website/static/docs/en/html/search/files_3.js +0 -8
  314. data/vendor/fastText/website/static/docs/en/html/search/files_4.html +0 -26
  315. data/vendor/fastText/website/static/docs/en/html/search/files_4.js +0 -5
  316. data/vendor/fastText/website/static/docs/en/html/search/files_5.html +0 -26
  317. data/vendor/fastText/website/static/docs/en/html/search/files_5.js +0 -5
  318. data/vendor/fastText/website/static/docs/en/html/search/files_6.html +0 -26
  319. data/vendor/fastText/website/static/docs/en/html/search/files_6.js +0 -4
  320. data/vendor/fastText/website/static/docs/en/html/search/files_7.html +0 -26
  321. data/vendor/fastText/website/static/docs/en/html/search/files_7.js +0 -5
  322. data/vendor/fastText/website/static/docs/en/html/search/files_8.html +0 -26
  323. data/vendor/fastText/website/static/docs/en/html/search/files_8.js +0 -5
  324. data/vendor/fastText/website/static/docs/en/html/search/functions_0.html +0 -26
  325. data/vendor/fastText/website/static/docs/en/html/search/functions_0.js +0 -14
  326. data/vendor/fastText/website/static/docs/en/html/search/functions_1.html +0 -26
  327. data/vendor/fastText/website/static/docs/en/html/search/functions_1.js +0 -5
  328. data/vendor/fastText/website/static/docs/en/html/search/functions_10.html +0 -26
  329. data/vendor/fastText/website/static/docs/en/html/search/functions_10.js +0 -5
  330. data/vendor/fastText/website/static/docs/en/html/search/functions_11.html +0 -26
  331. data/vendor/fastText/website/static/docs/en/html/search/functions_11.js +0 -18
  332. data/vendor/fastText/website/static/docs/en/html/search/functions_12.html +0 -26
  333. data/vendor/fastText/website/static/docs/en/html/search/functions_12.js +0 -8
  334. data/vendor/fastText/website/static/docs/en/html/search/functions_13.html +0 -26
  335. data/vendor/fastText/website/static/docs/en/html/search/functions_13.js +0 -5
  336. data/vendor/fastText/website/static/docs/en/html/search/functions_14.html +0 -26
  337. data/vendor/fastText/website/static/docs/en/html/search/functions_14.js +0 -4
  338. data/vendor/fastText/website/static/docs/en/html/search/functions_15.html +0 -26
  339. data/vendor/fastText/website/static/docs/en/html/search/functions_15.js +0 -4
  340. data/vendor/fastText/website/static/docs/en/html/search/functions_16.html +0 -26
  341. data/vendor/fastText/website/static/docs/en/html/search/functions_16.js +0 -4
  342. data/vendor/fastText/website/static/docs/en/html/search/functions_17.html +0 -26
  343. data/vendor/fastText/website/static/docs/en/html/search/functions_17.js +0 -7
  344. data/vendor/fastText/website/static/docs/en/html/search/functions_2.html +0 -26
  345. data/vendor/fastText/website/static/docs/en/html/search/functions_2.js +0 -11
  346. data/vendor/fastText/website/static/docs/en/html/search/functions_3.html +0 -26
  347. data/vendor/fastText/website/static/docs/en/html/search/functions_3.js +0 -9
  348. data/vendor/fastText/website/static/docs/en/html/search/functions_4.html +0 -26
  349. data/vendor/fastText/website/static/docs/en/html/search/functions_4.js +0 -4
  350. data/vendor/fastText/website/static/docs/en/html/search/functions_5.html +0 -26
  351. data/vendor/fastText/website/static/docs/en/html/search/functions_5.js +0 -7
  352. data/vendor/fastText/website/static/docs/en/html/search/functions_6.html +0 -26
  353. data/vendor/fastText/website/static/docs/en/html/search/functions_6.js +0 -17
  354. data/vendor/fastText/website/static/docs/en/html/search/functions_7.html +0 -26
  355. data/vendor/fastText/website/static/docs/en/html/search/functions_7.js +0 -5
  356. data/vendor/fastText/website/static/docs/en/html/search/functions_8.html +0 -26
  357. data/vendor/fastText/website/static/docs/en/html/search/functions_8.js +0 -8
  358. data/vendor/fastText/website/static/docs/en/html/search/functions_9.html +0 -26
  359. data/vendor/fastText/website/static/docs/en/html/search/functions_9.js +0 -4
  360. data/vendor/fastText/website/static/docs/en/html/search/functions_a.html +0 -26
  361. data/vendor/fastText/website/static/docs/en/html/search/functions_a.js +0 -8
  362. data/vendor/fastText/website/static/docs/en/html/search/functions_b.html +0 -26
  363. data/vendor/fastText/website/static/docs/en/html/search/functions_b.js +0 -10
  364. data/vendor/fastText/website/static/docs/en/html/search/functions_c.html +0 -26
  365. data/vendor/fastText/website/static/docs/en/html/search/functions_c.js +0 -10
  366. data/vendor/fastText/website/static/docs/en/html/search/functions_d.html +0 -26
  367. data/vendor/fastText/website/static/docs/en/html/search/functions_d.js +0 -6
  368. data/vendor/fastText/website/static/docs/en/html/search/functions_e.html +0 -26
  369. data/vendor/fastText/website/static/docs/en/html/search/functions_e.js +0 -26
  370. data/vendor/fastText/website/static/docs/en/html/search/functions_f.html +0 -26
  371. data/vendor/fastText/website/static/docs/en/html/search/functions_f.js +0 -6
  372. data/vendor/fastText/website/static/docs/en/html/search/mag_sel.png +0 -0
  373. data/vendor/fastText/website/static/docs/en/html/search/namespaces_0.html +0 -26
  374. data/vendor/fastText/website/static/docs/en/html/search/namespaces_0.js +0 -5
  375. data/vendor/fastText/website/static/docs/en/html/search/nomatches.html +0 -12
  376. data/vendor/fastText/website/static/docs/en/html/search/search.css +0 -271
  377. data/vendor/fastText/website/static/docs/en/html/search/search.js +0 -791
  378. data/vendor/fastText/website/static/docs/en/html/search/search_l.png +0 -0
  379. data/vendor/fastText/website/static/docs/en/html/search/search_m.png +0 -0
  380. data/vendor/fastText/website/static/docs/en/html/search/search_r.png +0 -0
  381. data/vendor/fastText/website/static/docs/en/html/search/searchdata.js +0 -42
  382. data/vendor/fastText/website/static/docs/en/html/search/typedefs_0.html +0 -26
  383. data/vendor/fastText/website/static/docs/en/html/search/typedefs_0.js +0 -4
  384. data/vendor/fastText/website/static/docs/en/html/search/typedefs_1.html +0 -26
  385. data/vendor/fastText/website/static/docs/en/html/search/typedefs_1.js +0 -4
  386. data/vendor/fastText/website/static/docs/en/html/search/variables_0.html +0 -26
  387. data/vendor/fastText/website/static/docs/en/html/search/variables_0.js +0 -4
  388. data/vendor/fastText/website/static/docs/en/html/search/variables_1.html +0 -26
  389. data/vendor/fastText/website/static/docs/en/html/search/variables_1.js +0 -6
  390. data/vendor/fastText/website/static/docs/en/html/search/variables_10.html +0 -26
  391. data/vendor/fastText/website/static/docs/en/html/search/variables_10.js +0 -8
  392. data/vendor/fastText/website/static/docs/en/html/search/variables_11.html +0 -26
  393. data/vendor/fastText/website/static/docs/en/html/search/variables_11.js +0 -11
  394. data/vendor/fastText/website/static/docs/en/html/search/variables_12.html +0 -26
  395. data/vendor/fastText/website/static/docs/en/html/search/variables_12.js +0 -4
  396. data/vendor/fastText/website/static/docs/en/html/search/variables_13.html +0 -26
  397. data/vendor/fastText/website/static/docs/en/html/search/variables_13.js +0 -10
  398. data/vendor/fastText/website/static/docs/en/html/search/variables_2.html +0 -26
  399. data/vendor/fastText/website/static/docs/en/html/search/variables_2.js +0 -9
  400. data/vendor/fastText/website/static/docs/en/html/search/variables_3.html +0 -26
  401. data/vendor/fastText/website/static/docs/en/html/search/variables_3.js +0 -9
  402. data/vendor/fastText/website/static/docs/en/html/search/variables_4.html +0 -26
  403. data/vendor/fastText/website/static/docs/en/html/search/variables_4.js +0 -7
  404. data/vendor/fastText/website/static/docs/en/html/search/variables_5.html +0 -26
  405. data/vendor/fastText/website/static/docs/en/html/search/variables_5.js +0 -4
  406. data/vendor/fastText/website/static/docs/en/html/search/variables_6.html +0 -26
  407. data/vendor/fastText/website/static/docs/en/html/search/variables_6.js +0 -5
  408. data/vendor/fastText/website/static/docs/en/html/search/variables_7.html +0 -26
  409. data/vendor/fastText/website/static/docs/en/html/search/variables_7.js +0 -5
  410. data/vendor/fastText/website/static/docs/en/html/search/variables_8.html +0 -26
  411. data/vendor/fastText/website/static/docs/en/html/search/variables_8.js +0 -4
  412. data/vendor/fastText/website/static/docs/en/html/search/variables_9.html +0 -26
  413. data/vendor/fastText/website/static/docs/en/html/search/variables_9.js +0 -10
  414. data/vendor/fastText/website/static/docs/en/html/search/variables_a.html +0 -26
  415. data/vendor/fastText/website/static/docs/en/html/search/variables_a.js +0 -14
  416. data/vendor/fastText/website/static/docs/en/html/search/variables_b.html +0 -26
  417. data/vendor/fastText/website/static/docs/en/html/search/variables_b.js +0 -17
  418. data/vendor/fastText/website/static/docs/en/html/search/variables_c.html +0 -26
  419. data/vendor/fastText/website/static/docs/en/html/search/variables_c.js +0 -6
  420. data/vendor/fastText/website/static/docs/en/html/search/variables_d.html +0 -26
  421. data/vendor/fastText/website/static/docs/en/html/search/variables_d.js +0 -10
  422. data/vendor/fastText/website/static/docs/en/html/search/variables_e.html +0 -26
  423. data/vendor/fastText/website/static/docs/en/html/search/variables_e.js +0 -11
  424. data/vendor/fastText/website/static/docs/en/html/search/variables_f.html +0 -26
  425. data/vendor/fastText/website/static/docs/en/html/search/variables_f.js +0 -6
  426. data/vendor/fastText/website/static/docs/en/html/splitbar.png +0 -0
  427. data/vendor/fastText/website/static/docs/en/html/structfasttext_1_1Node-members.html +0 -108
  428. data/vendor/fastText/website/static/docs/en/html/structfasttext_1_1Node.html +0 -194
  429. data/vendor/fastText/website/static/docs/en/html/structfasttext_1_1Node.js +0 -8
  430. data/vendor/fastText/website/static/docs/en/html/structfasttext_1_1entry-members.html +0 -107
  431. data/vendor/fastText/website/static/docs/en/html/structfasttext_1_1entry.html +0 -178
  432. data/vendor/fastText/website/static/docs/en/html/structfasttext_1_1entry.js +0 -7
  433. data/vendor/fastText/website/static/docs/en/html/sync_off.png +0 -0
  434. data/vendor/fastText/website/static/docs/en/html/sync_on.png +0 -0
  435. data/vendor/fastText/website/static/docs/en/html/tab_a.png +0 -0
  436. data/vendor/fastText/website/static/docs/en/html/tab_b.png +0 -0
  437. data/vendor/fastText/website/static/docs/en/html/tab_h.png +0 -0
  438. data/vendor/fastText/website/static/docs/en/html/tab_s.png +0 -0
  439. data/vendor/fastText/website/static/docs/en/html/tabs.css +0 -1
  440. data/vendor/fastText/website/static/docs/en/html/utils_8cc.html +0 -121
  441. data/vendor/fastText/website/static/docs/en/html/utils_8cc.js +0 -5
  442. data/vendor/fastText/website/static/docs/en/html/utils_8h.html +0 -122
  443. data/vendor/fastText/website/static/docs/en/html/utils_8h.js +0 -5
  444. data/vendor/fastText/website/static/docs/en/html/utils_8h_source.html +0 -104
  445. data/vendor/fastText/website/static/docs/en/html/vector_8cc.html +0 -121
  446. data/vendor/fastText/website/static/docs/en/html/vector_8cc.js +0 -4
  447. data/vendor/fastText/website/static/docs/en/html/vector_8h.html +0 -126
  448. data/vendor/fastText/website/static/docs/en/html/vector_8h.js +0 -5
  449. data/vendor/fastText/website/static/docs/en/html/vector_8h_source.html +0 -120
  450. data/vendor/fastText/website/static/fasttext.css +0 -48
  451. data/vendor/fastText/website/static/img/authors/armand_joulin.jpg +0 -0
  452. data/vendor/fastText/website/static/img/authors/christian_puhrsch.png +0 -0
  453. data/vendor/fastText/website/static/img/authors/edouard_grave.jpeg +0 -0
  454. data/vendor/fastText/website/static/img/authors/piotr_bojanowski.jpg +0 -0
  455. data/vendor/fastText/website/static/img/authors/tomas_mikolov.jpg +0 -0
  456. data/vendor/fastText/website/static/img/blog/2016-08-18-blog-post-img1.png +0 -0
  457. data/vendor/fastText/website/static/img/blog/2016-08-18-blog-post-img2.png +0 -0
  458. data/vendor/fastText/website/static/img/blog/2017-05-02-blog-post-img1.jpg +0 -0
  459. data/vendor/fastText/website/static/img/blog/2017-05-02-blog-post-img2.jpg +0 -0
  460. data/vendor/fastText/website/static/img/blog/2017-10-02-blog-post-img1.png +0 -0
  461. data/vendor/fastText/website/static/img/cbo_vs_skipgram.png +0 -0
  462. data/vendor/fastText/website/static/img/fasttext-icon-api.png +0 -0
  463. data/vendor/fastText/website/static/img/fasttext-icon-bg-web.png +0 -0
  464. data/vendor/fastText/website/static/img/fasttext-icon-color-square.png +0 -0
  465. data/vendor/fastText/website/static/img/fasttext-icon-color-web.png +0 -0
  466. data/vendor/fastText/website/static/img/fasttext-icon-faq.png +0 -0
  467. data/vendor/fastText/website/static/img/fasttext-icon-tutorial.png +0 -0
  468. data/vendor/fastText/website/static/img/fasttext-icon-white-web.png +0 -0
  469. data/vendor/fastText/website/static/img/fasttext-logo-color-web.png +0 -0
  470. data/vendor/fastText/website/static/img/fasttext-logo-white-web.png +0 -0
  471. data/vendor/fastText/website/static/img/logo-color.png +0 -0
  472. data/vendor/fastText/website/static/img/model-black.png +0 -0
  473. data/vendor/fastText/website/static/img/model-blue.png +0 -0
  474. data/vendor/fastText/website/static/img/model-red.png +0 -0
  475. data/vendor/fastText/website/static/img/ogimage.png +0 -0
  476. data/vendor/fastText/website/static/img/oss_logo.png +0 -0
  477. data/vendor/fastText/wikifil.pl +0 -57
  478. data/vendor/fastText/word-vector-example.sh +0 -39
@@ -1,629 +0,0 @@
1
- # Copyright (c) 2017-present, Facebook, Inc.
2
- # All rights reserved.
3
- #
4
- # This source code is licensed under the MIT license found in the
5
- # LICENSE file in the root directory of this source tree.
6
-
7
- from __future__ import absolute_import
8
- from __future__ import division
9
- from __future__ import print_function
10
- from __future__ import unicode_literals
11
-
12
- from fasttext import train_supervised
13
- from fasttext import train_unsupervised
14
- from fasttext import util
15
- import fasttext
16
- import os
17
- import subprocess
18
- import unittest
19
- import tempfile
20
- import random
21
- import sys
22
- import copy
23
- import numpy as np
24
- try:
25
- import unicode
26
- except ImportError:
27
- pass
28
- from fasttext.tests.test_configurations import get_supervised_models
29
-
30
-
31
- def eprint(cls, *args, **kwargs):
32
- print(*args, file=sys.stderr, **kwargs)
33
-
34
-
35
- def get_random_unicode(length):
36
- # See: https://stackoverflow.com/questions/1477294/generate-random-utf-8-string-in-python
37
-
38
- try:
39
- get_char = unichr
40
- except NameError:
41
- get_char = chr
42
-
43
- # Update this to include code point ranges to be sampled
44
- include_ranges = [
45
- (0x0021, 0x0021),
46
- (0x0023, 0x0026),
47
- (0x0028, 0x007E),
48
- (0x00A1, 0x00AC),
49
- (0x00AE, 0x00FF),
50
- (0x0100, 0x017F),
51
- (0x0180, 0x024F),
52
- (0x2C60, 0x2C7F),
53
- (0x16A0, 0x16F0),
54
- (0x0370, 0x0377),
55
- (0x037A, 0x037E),
56
- (0x0384, 0x038A),
57
- (0x038C, 0x038C),
58
- ]
59
-
60
- alphabet = [
61
- get_char(code_point)
62
- for current_range in include_ranges
63
- for code_point in range(current_range[0], current_range[1] + 1)
64
- ]
65
- return ''.join(random.choice(alphabet) for i in range(length))
66
-
67
-
68
- def get_random_words(N, a=1, b=20, unique=True):
69
- words = []
70
- while (len(words) < N):
71
- length = random.randint(a, b)
72
- word = get_random_unicode(length)
73
- if unique and word not in words:
74
- words.append(word)
75
- else:
76
- words.append(word)
77
- return words
78
-
79
-
80
- def get_random_data(
81
- num_lines=100,
82
- max_vocab_size=100,
83
- min_words_line=0,
84
- max_words_line=20,
85
- min_len_word=1,
86
- max_len_word=10,
87
- unique_words=True,
88
- ):
89
- random_words = get_random_words(
90
- max_vocab_size, min_len_word, max_len_word, unique=unique_words
91
- )
92
- lines = []
93
- for _ in range(num_lines):
94
- line = []
95
- line_length = random.randint(min_words_line, max_words_line)
96
- for _ in range(line_length):
97
- i = random.randint(0, max_vocab_size - 1)
98
- line.append(random_words[i])
99
- line = " ".join(line)
100
- lines.append(line)
101
- return lines
102
-
103
-
104
- def default_kwargs(kwargs):
105
- default = {"thread": 1, "epoch": 1, "minCount": 1, "bucket": 1000}
106
- for k, v in default.items():
107
- if k not in kwargs:
108
- kwargs[k] = v
109
- return kwargs
110
-
111
-
112
- def build_unsupervised_model(data, kwargs):
113
- kwargs = default_kwargs(kwargs)
114
- with tempfile.NamedTemporaryFile(delete=False) as tmpf:
115
- for line in data:
116
- tmpf.write((line + "\n").encode("UTF-8"))
117
- tmpf.flush()
118
- model = train_unsupervised(input=tmpf.name, **kwargs)
119
- return model
120
-
121
-
122
- def build_supervised_model(data, kwargs):
123
- kwargs = default_kwargs(kwargs)
124
- with tempfile.NamedTemporaryFile(delete=False) as tmpf:
125
- for line in data:
126
- line = "__label__" + line.strip() + "\n"
127
- tmpf.write(line.encode("UTF-8"))
128
- tmpf.flush()
129
- model = train_supervised(input=tmpf.name, **kwargs)
130
- return model
131
-
132
-
133
- def read_labels(data_file):
134
- labels = []
135
- lines = []
136
- with open(data_file, 'r') as f:
137
- for line in f:
138
- labels_line = []
139
- words_line = []
140
- try:
141
- line = unicode(line, "UTF-8").split()
142
- except NameError:
143
- line = line.split()
144
- for word in line:
145
- if word.startswith("__label__"):
146
- labels_line.append(word)
147
- else:
148
- words_line.append(word)
149
- labels.append(labels_line)
150
- lines.append(" ".join(words_line))
151
- return lines, labels
152
-
153
-
154
- class TestFastTextUnitPy(unittest.TestCase):
155
- # TODO: Unit test copy behavior of fasttext
156
-
157
- def gen_test_get_vector(self, kwargs):
158
- # Confirm if no subwords, OOV is zero, confirm min=10 means words < 10 get zeros
159
-
160
- f = build_unsupervised_model(get_random_data(100), kwargs)
161
- words, _ = f.get_words(include_freq=True)
162
- words += get_random_words(100)
163
- for word in words:
164
- f.get_word_vector(word)
165
-
166
- def gen_test_multi_get_line(self, kwargs):
167
- data = get_random_data(100)
168
- model1 = build_supervised_model(data, kwargs)
169
- model2 = build_unsupervised_model(data, kwargs)
170
- lines1 = []
171
- lines2 = []
172
- for line in data:
173
- words, labels = model1.get_line(line)
174
- lines1.append(words)
175
- self.assertEqual(len(labels), 0)
176
- words, labels = model2.get_line(line)
177
- lines2.append(words)
178
- self.assertEqual(len(labels), 0)
179
- all_lines1, all_labels1 = model1.get_line(data)
180
- all_lines2, all_labels2 = model2.get_line(data)
181
- self.assertEqual(lines1, all_lines1)
182
- self.assertEqual(lines2, all_lines2)
183
- for labels in all_labels1:
184
- self.assertEqual(len(labels), 0)
185
- for labels in all_labels2:
186
- self.assertEqual(len(labels), 0)
187
-
188
- def gen_test_supervised_util_test(self, kwargs):
189
- def check(data):
190
- third = int(len(data) / 3)
191
- train_data = data[:2 * third]
192
- valid_data = data[third:]
193
- with tempfile.NamedTemporaryFile(
194
- delete=False
195
- ) as tmpf, tempfile.NamedTemporaryFile(delete=False) as tmpf2:
196
- for line in train_data:
197
- tmpf.write(
198
- ("__label__" + line.strip() + "\n").encode("UTF-8")
199
- )
200
- tmpf.flush()
201
- for line in valid_data:
202
- tmpf2.write(
203
- ("__label__" + line.strip() + "\n").encode("UTF-8")
204
- )
205
- tmpf2.flush()
206
- model = train_supervised(input=tmpf.name, **kwargs)
207
- true_labels = []
208
- all_words = []
209
- with open(tmpf2.name, 'r') as fid:
210
- for line in fid:
211
- if sys.version_info < (3, 0):
212
- line = line.decode("UTF-8")
213
- if len(line.strip()) == 0:
214
- continue
215
- words, labels = model.get_line(line.strip())
216
- if len(labels) == 0:
217
- continue
218
- all_words.append(" ".join(words))
219
- true_labels += [labels]
220
- predictions, _ = model.predict(all_words)
221
- p, r = util.test(predictions, true_labels)
222
- N = len(predictions)
223
- Nt, pt, rt = model.test(tmpf2.name)
224
- self.assertEqual(N, Nt)
225
- self.assertEqual(p, pt)
226
- self.assertEqual(r, rt)
227
-
228
- # Need at least one word to have a label and a word to prevent error
229
- check(get_random_data(100, min_words_line=2))
230
-
231
- def gen_test_supervised_predict(self, kwargs):
232
- # Confirm number of labels, confirm labels for easy dataset
233
- # Confirm 1 label and 0 label dataset
234
-
235
- f = build_supervised_model(get_random_data(100), kwargs)
236
- words = get_random_words(100)
237
- for k in [1, 2, 5]:
238
- for w in words:
239
- labels, probs = f.predict(w, k)
240
- data = get_random_data(100)
241
- for line in data:
242
- labels, probs = f.predict(line, k)
243
-
244
- def gen_test_supervised_multiline_predict(self, kwargs):
245
- # Confirm number of labels, confirm labels for easy dataset
246
- # Confirm 1 label and 0 label dataset
247
-
248
- def check_predict(f):
249
- for k in [1, 2, 5]:
250
- words = get_random_words(10)
251
- agg_labels = []
252
- agg_probs = []
253
- for w in words:
254
- labels, probs = f.predict(w, k)
255
- agg_labels += [labels]
256
- agg_probs += [probs]
257
- all_labels1, all_probs1 = f.predict(words, k)
258
- data = get_random_data(10)
259
- for line in data:
260
- labels, probs = f.predict(line, k)
261
- agg_labels += [labels]
262
- agg_probs += [probs]
263
- all_labels2, all_probs2 = f.predict(data, k)
264
- all_labels = list(all_labels1) + list(all_labels2)
265
- all_probs = list(all_probs1) + list(all_probs2)
266
- for label1, label2 in zip(all_labels, agg_labels):
267
- self.assertEqual(list(label1), list(label2))
268
- for prob1, prob2 in zip(all_probs, agg_probs):
269
- self.assertEqual(list(prob1), list(prob2))
270
-
271
- check_predict(build_supervised_model(get_random_data(100), kwargs))
272
- check_predict(
273
- build_supervised_model(
274
- get_random_data(100, min_words_line=1), kwargs
275
- )
276
- )
277
-
278
- def gen_test_vocab(self, kwargs):
279
- # Confirm empty dataset, confirm all label dataset
280
-
281
- data = get_random_data(100)
282
- words_python = {}
283
- for line in data:
284
- line_words = line.split()
285
- for w in line_words:
286
- if w not in words_python:
287
- words_python[w] = 0
288
- words_python[w] += 1
289
- f = build_unsupervised_model(data, kwargs)
290
- words, freqs = f.get_words(include_freq=True)
291
- foundEOS = False
292
- for word, freq in zip(words, freqs):
293
- if word == fasttext.EOS:
294
- foundEOS = True
295
- else:
296
- self.assertEqual(words_python[word], freq)
297
- # EOS is special to fasttext, but still part of the vocab
298
- self.assertEqual(len(words_python), len(words) - 1)
299
- self.assertTrue(foundEOS)
300
-
301
- # Should cause "Empty vocabulary" error.
302
- data = get_random_data(0)
303
- gotError = False
304
- try:
305
- build_unsupervised_model(data, kwargs)
306
- except ValueError:
307
- gotError = True
308
- self.assertTrue(gotError)
309
-
310
- def gen_test_subwords(self, kwargs):
311
- # Define expected behavior
312
- f = build_unsupervised_model(get_random_data(100), kwargs)
313
- words, _ = f.get_words(include_freq=True)
314
- words += get_random_words(10, 1, 10)
315
- for w in words:
316
- f.get_subwords(w)
317
-
318
- def gen_test_tokenize(self, kwargs):
319
- self.assertEqual(["asdf", "asdb"], fasttext.tokenize("asdf asdb"))
320
- self.assertEqual(["asdf"], fasttext.tokenize("asdf"))
321
- self.assertEqual([fasttext.EOS], fasttext.tokenize("\n"))
322
- self.assertEqual(["asdf", fasttext.EOS], fasttext.tokenize("asdf\n"))
323
- self.assertEqual([], fasttext.tokenize(""))
324
- self.assertEqual([], fasttext.tokenize(" "))
325
- # An empty string is not a token (it's just whitespace)
326
- # So the minimum length must be 1
327
- words = get_random_words(100, 1, 20)
328
- self.assertEqual(words, fasttext.tokenize(" ".join(words)))
329
-
330
- def gen_test_unsupervised_dimension(self, kwargs):
331
- if "dim" in kwargs:
332
- f = build_unsupervised_model(get_random_data(100), kwargs)
333
- self.assertEqual(f.get_dimension(), kwargs["dim"])
334
-
335
- def gen_test_supervised_dimension(self, kwargs):
336
- if "dim" in kwargs:
337
- f = build_supervised_model(get_random_data(100), kwargs)
338
- self.assertEqual(f.get_dimension(), kwargs["dim"])
339
-
340
- def gen_test_subword_vector(self, kwargs):
341
- f = build_unsupervised_model(get_random_data(100), kwargs)
342
- words, _ = f.get_words(include_freq=True)
343
- words += get_random_words(100, 1, 20)
344
- input_matrix = f.get_input_matrix()
345
- for word in words:
346
- # Universal API to get word vector
347
- vec1 = f.get_word_vector(word)
348
-
349
- # Build word vector from subwords
350
- subwords, subinds = f.get_subwords(word)
351
- subvectors = list(map(lambda x: f.get_input_vector(x), subinds))
352
- if len(subvectors) == 0:
353
- vec2 = np.zeros((f.get_dimension(), ))
354
- else:
355
- subvectors = np.vstack(subvectors)
356
- vec2 = np.sum((subvectors / len(subwords)), 0)
357
-
358
- # Build word vector from subinds
359
- if len(subinds) == 0:
360
- vec3 = np.zeros((f.get_dimension(), ))
361
- else:
362
- vec3 = np.sum(input_matrix[subinds] / len(subinds), 0)
363
-
364
- # Build word vectors from word and subword ids
365
- wid = f.get_word_id(word)
366
- if wid >= 0:
367
- swids = list(map(lambda x: f.get_subword_id(x), subwords[1:]))
368
- swids.append(wid)
369
- else:
370
- swids = list(map(lambda x: f.get_subword_id(x), subwords))
371
- if len(swids) == 0:
372
- vec4 = np.zeros((f.get_dimension(), ))
373
- else:
374
- swids = np.array(swids)
375
- vec4 = np.sum(input_matrix[swids] / len(swids), 0)
376
-
377
- self.assertTrue(np.isclose(vec1, vec2, atol=1e-5, rtol=0).all())
378
- self.assertTrue(np.isclose(vec2, vec3, atol=1e-5, rtol=0).all())
379
- self.assertTrue(np.isclose(vec3, vec4, atol=1e-5, rtol=0).all())
380
- self.assertTrue(np.isclose(vec4, vec1, atol=1e-5, rtol=0).all())
381
-
382
- def gen_test_unsupervised_get_words(self, kwargs):
383
- # Check more corner cases of 0 vocab, empty file etc.
384
- f = build_unsupervised_model(get_random_data(100), kwargs)
385
- words1, freq1 = f.get_words(include_freq=True)
386
- words2 = f.get_words(include_freq=False)
387
- self.assertEqual(len(words1), len(words2))
388
- self.assertEqual(len(words1), len(freq1))
389
-
390
- def gen_test_supervised_get_words(self, kwargs):
391
- f = build_supervised_model(get_random_data(100), kwargs)
392
- words1, freq1 = f.get_words(include_freq=True)
393
- words2 = f.get_words(include_freq=False)
394
- self.assertEqual(len(words1), len(words2))
395
- self.assertEqual(len(words1), len(freq1))
396
-
397
- def gen_test_unsupervised_get_labels(self, kwargs):
398
- f = build_unsupervised_model(get_random_data(100), kwargs)
399
- labels1, freq1 = f.get_labels(include_freq=True)
400
- labels2 = f.get_labels(include_freq=False)
401
- words2 = f.get_words(include_freq=False)
402
- self.assertEqual(len(labels1), len(labels2))
403
- self.assertEqual(len(labels1), len(freq1))
404
- self.assertEqual(len(labels1), len(words2))
405
- for w1, w2 in zip(labels2, words2):
406
- self.assertEqual(w1, w2)
407
-
408
- def gen_test_supervised_get_labels(self, kwargs):
409
- f = build_supervised_model(get_random_data(100), kwargs)
410
- labels1, freq1 = f.get_labels(include_freq=True)
411
- labels2 = f.get_labels(include_freq=False)
412
- self.assertEqual(len(labels1), len(labels2))
413
- self.assertEqual(len(labels1), len(freq1))
414
-
415
- def gen_test_unsupervised_exercise_is_quant(self, kwargs):
416
- f = build_unsupervised_model(get_random_data(100), kwargs)
417
- gotError = False
418
- try:
419
- f.quantize()
420
- except ValueError:
421
- gotError = True
422
- self.assertTrue(gotError)
423
-
424
- def gen_test_supervised_exercise_is_quant(self, kwargs):
425
- f = build_supervised_model(
426
- get_random_data(1000, max_vocab_size=1000), kwargs
427
- )
428
- self.assertTrue(not f.is_quantized())
429
- f.quantize()
430
- self.assertTrue(f.is_quantized())
431
-
432
- def gen_test_newline_predict_sentence(self, kwargs):
433
- f = build_supervised_model(get_random_data(100), kwargs)
434
- sentence = " ".join(get_random_words(20))
435
- f.predict(sentence, k=5)
436
- sentence += "\n"
437
- gotError = False
438
- try:
439
- f.predict(sentence, k=5)
440
- except ValueError:
441
- gotError = True
442
- self.assertTrue(gotError)
443
-
444
- f = build_supervised_model(get_random_data(100), kwargs)
445
- sentence = " ".join(get_random_words(20))
446
- f.get_sentence_vector(sentence)
447
- sentence += "\n"
448
- gotError = False
449
- try:
450
- f.get_sentence_vector(sentence)
451
- except ValueError:
452
- gotError = True
453
- self.assertTrue(gotError)
454
-
455
-
456
- # Generate a supervised test case
457
- # The returned function will be set as an attribute to a test class
458
- def gen_sup_test(configuration, data_dir):
459
- def sup_test(self):
460
- def get_path_size(path):
461
- path_size = subprocess.check_output(["stat", "-c", "%s",
462
- path]).decode('utf-8')
463
- path_size = int(path_size)
464
- return path_size
465
-
466
- def check(model, model_filename, test, lessthan, msg_prefix=""):
467
- N_local_out, p1_local_out, r1_local_out = model.test(test["data"])
468
- self.assertEqual(
469
- N_local_out, test["n"], msg_prefix + "N: Want: " +
470
- str(test["n"]) + " Is: " + str(N_local_out)
471
- )
472
- self.assertTrue(
473
- p1_local_out >= test["p1"], msg_prefix + "p1: Want: " +
474
- str(test["p1"]) + " Is: " + str(p1_local_out)
475
- )
476
- self.assertTrue(
477
- r1_local_out >= test["r1"], msg_prefix + "r1: Want: " +
478
- str(test["r1"]) + " Is: " + str(r1_local_out)
479
- )
480
- path_size = get_path_size(model_filename)
481
- size_msg = str(test["size"]) + " Is: " + str(path_size)
482
- if lessthan:
483
- self.assertTrue(
484
- path_size <= test["size"],
485
- msg_prefix + "Size: Want at most: " + size_msg
486
- )
487
- else:
488
- self.assertTrue(
489
- path_size == test["size"],
490
- msg_prefix + "Size: Want: " + size_msg
491
- )
492
-
493
- configuration["args"]["input"] = os.path.join(
494
- data_dir, configuration["args"]["input"]
495
- )
496
- configuration["quant_args"]["input"] = configuration["args"]["input"]
497
- configuration["test"]["data"] = os.path.join(
498
- data_dir, configuration["test"]["data"]
499
- )
500
- configuration["quant_test"]["data"] = configuration["test"]["data"]
501
- output = os.path.join(tempfile.mkdtemp(), configuration["dataset"])
502
- print()
503
- model = train_supervised(**configuration["args"])
504
- model.save_model(output + ".bin")
505
- check(
506
- model,
507
- output + ".bin",
508
- configuration["test"],
509
- False,
510
- msg_prefix="Supervised: "
511
- )
512
- print()
513
- model.quantize(**configuration["quant_args"])
514
- model.save_model(output + ".ftz")
515
- check(
516
- model,
517
- output + ".ftz",
518
- configuration["quant_test"],
519
- True,
520
- msg_prefix="Quantized: "
521
- )
522
-
523
- return sup_test
524
-
525
-
526
- def gen_unit_tests(verbose=0):
527
- gen_funcs = [
528
- func for func in dir(TestFastTextUnitPy)
529
- if callable(getattr(TestFastTextUnitPy, func))
530
- if func.startswith("gen_test_")
531
- ]
532
- general_settings = [
533
- {
534
- "minn": 2,
535
- "maxn": 4,
536
- }, {
537
- "minn": 0,
538
- "maxn": 0,
539
- "bucket": 0
540
- }, {
541
- "dim": 1
542
- }, {
543
- "dim": 5
544
- }
545
- ]
546
- supervised_settings = [
547
- {
548
- "minn": 2,
549
- "maxn": 4,
550
- }, {
551
- "minn": 0,
552
- "maxn": 0,
553
- "bucket": 0
554
- }, {
555
- "dim": 1
556
- }, {
557
- "dim": 5
558
- }, {
559
- "dim": 5,
560
- "loss": "hs"
561
- }
562
- ]
563
- unsupervised_settings = [
564
- {
565
- "minn": 2,
566
- "maxn": 4,
567
- }, {
568
- "minn": 0,
569
- "maxn": 0,
570
- "bucket": 0
571
- }, {
572
- "dim": 1
573
- }, {
574
- "dim": 5,
575
- "model": "cbow"
576
- }, {
577
- "dim": 5,
578
- "model": "skipgram"
579
- }
580
- ]
581
- for gen_func in gen_funcs:
582
-
583
- def build_test(test_name, kwargs=None):
584
- if kwargs is None:
585
- kwargs = {}
586
- kwargs["verbose"] = verbose
587
-
588
- def test(self):
589
- return getattr(TestFastTextUnitPy,
590
- "gen_" + test_name)(self, copy.deepcopy(kwargs))
591
-
592
- return test
593
-
594
- test_name = gen_func[4:]
595
- if "_unsupervised_" in test_name:
596
- for i, setting in enumerate(unsupervised_settings):
597
- setattr(
598
- TestFastTextUnitPy, test_name + "_" + str(i),
599
- build_test(test_name, setting)
600
- )
601
- elif "_supervised_" in test_name:
602
- for i, setting in enumerate(supervised_settings):
603
- setattr(
604
- TestFastTextUnitPy, test_name + "_" + str(i),
605
- build_test(test_name, setting)
606
- )
607
- else:
608
- for i, setting in enumerate(general_settings):
609
- setattr(
610
- TestFastTextUnitPy, test_name + "_" + str(i),
611
- build_test(test_name, setting)
612
- )
613
-
614
- return TestFastTextUnitPy
615
-
616
-
617
- def gen_tests(data_dir, verbose=1):
618
- class TestFastTextPy(unittest.TestCase):
619
- pass
620
-
621
- i = 0
622
- for configuration in get_supervised_models(verbose=verbose):
623
- setattr(
624
- TestFastTextPy,
625
- "test_sup_" + str(i) + "_" + configuration["dataset"],
626
- gen_sup_test(configuration, data_dir)
627
- )
628
- i += 1
629
- return TestFastTextPy