fasttext 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +20 -1
- data/lib/fasttext.rb +3 -0
- data/lib/fasttext/classifier.rb +12 -4
- data/lib/fasttext/vectorizer.rb +1 -1
- data/lib/fasttext/version.rb +1 -1
- metadata +4 -473
- data/lib/fasttext/ext.bundle +0 -0
- data/vendor/fastText/CMakeLists.txt +0 -68
- data/vendor/fastText/CODE_OF_CONDUCT.md +0 -2
- data/vendor/fastText/CONTRIBUTING.md +0 -32
- data/vendor/fastText/MANIFEST.in +0 -5
- data/vendor/fastText/Makefile +0 -63
- data/vendor/fastText/alignment/README.md +0 -53
- data/vendor/fastText/alignment/align.py +0 -145
- data/vendor/fastText/alignment/eval.py +0 -60
- data/vendor/fastText/alignment/example.sh +0 -51
- data/vendor/fastText/alignment/unsup_align.py +0 -109
- data/vendor/fastText/alignment/utils.py +0 -154
- data/vendor/fastText/classification-example.sh +0 -41
- data/vendor/fastText/classification-results.sh +0 -94
- data/vendor/fastText/crawl/README.md +0 -26
- data/vendor/fastText/crawl/dedup.cc +0 -51
- data/vendor/fastText/crawl/download_crawl.sh +0 -57
- data/vendor/fastText/crawl/filter_dedup.sh +0 -13
- data/vendor/fastText/crawl/filter_utf8.cc +0 -105
- data/vendor/fastText/crawl/process_wet_file.sh +0 -30
- data/vendor/fastText/docs/aligned-vectors.md +0 -64
- data/vendor/fastText/docs/api.md +0 -6
- data/vendor/fastText/docs/cheatsheet.md +0 -66
- data/vendor/fastText/docs/crawl-vectors.md +0 -125
- data/vendor/fastText/docs/dataset.md +0 -6
- data/vendor/fastText/docs/english-vectors.md +0 -53
- data/vendor/fastText/docs/faqs.md +0 -63
- data/vendor/fastText/docs/language-identification.md +0 -47
- data/vendor/fastText/docs/options.md +0 -50
- data/vendor/fastText/docs/pretrained-vectors.md +0 -142
- data/vendor/fastText/docs/python-module.md +0 -314
- data/vendor/fastText/docs/references.md +0 -41
- data/vendor/fastText/docs/supervised-models.md +0 -54
- data/vendor/fastText/docs/supervised-tutorial.md +0 -349
- data/vendor/fastText/docs/support.md +0 -58
- data/vendor/fastText/docs/unsupervised-tutorials.md +0 -309
- data/vendor/fastText/eval.py +0 -95
- data/vendor/fastText/get-wikimedia.sh +0 -79
- data/vendor/fastText/python/README.md +0 -322
- data/vendor/fastText/python/README.rst +0 -406
- data/vendor/fastText/python/benchmarks/README.rst +0 -3
- data/vendor/fastText/python/benchmarks/get_word_vector.py +0 -49
- data/vendor/fastText/python/doc/examples/FastTextEmbeddingBag.py +0 -81
- data/vendor/fastText/python/doc/examples/bin_to_vec.py +0 -41
- data/vendor/fastText/python/doc/examples/compute_accuracy.py +0 -163
- data/vendor/fastText/python/doc/examples/get_vocab.py +0 -48
- data/vendor/fastText/python/doc/examples/train_supervised.py +0 -42
- data/vendor/fastText/python/doc/examples/train_unsupervised.py +0 -56
- data/vendor/fastText/python/fasttext_module/fasttext/FastText.py +0 -468
- data/vendor/fastText/python/fasttext_module/fasttext/__init__.py +0 -22
- data/vendor/fastText/python/fasttext_module/fasttext/pybind/fasttext_pybind.cc +0 -388
- data/vendor/fastText/python/fasttext_module/fasttext/tests/__init__.py +0 -14
- data/vendor/fastText/python/fasttext_module/fasttext/tests/test_configurations.py +0 -239
- data/vendor/fastText/python/fasttext_module/fasttext/tests/test_script.py +0 -629
- data/vendor/fastText/python/fasttext_module/fasttext/util/__init__.py +0 -13
- data/vendor/fastText/python/fasttext_module/fasttext/util/util.py +0 -60
- data/vendor/fastText/quantization-example.sh +0 -40
- data/vendor/fastText/runtests.py +0 -60
- data/vendor/fastText/scripts/kbcompletion/README.md +0 -19
- data/vendor/fastText/scripts/kbcompletion/data.sh +0 -69
- data/vendor/fastText/scripts/kbcompletion/eval.cpp +0 -108
- data/vendor/fastText/scripts/kbcompletion/fb15k.sh +0 -49
- data/vendor/fastText/scripts/kbcompletion/fb15k237.sh +0 -45
- data/vendor/fastText/scripts/kbcompletion/svo.sh +0 -38
- data/vendor/fastText/scripts/kbcompletion/wn18.sh +0 -49
- data/vendor/fastText/scripts/quantization/quantization-results.sh +0 -43
- data/vendor/fastText/setup.cfg +0 -2
- data/vendor/fastText/setup.py +0 -203
- data/vendor/fastText/tests/fetch_test_data.sh +0 -202
- data/vendor/fastText/website/README.md +0 -6
- data/vendor/fastText/website/blog/2016-08-18-blog-post.md +0 -42
- data/vendor/fastText/website/blog/2017-05-02-blog-post.md +0 -60
- data/vendor/fastText/website/blog/2017-10-02-blog-post.md +0 -90
- data/vendor/fastText/website/blog/2019-06-25-blog-post.md +0 -168
- data/vendor/fastText/website/core/Footer.js +0 -127
- data/vendor/fastText/website/package.json +0 -12
- data/vendor/fastText/website/pages/en/index.js +0 -286
- data/vendor/fastText/website/sidebars.json +0 -18
- data/vendor/fastText/website/siteConfig.js +0 -102
- data/vendor/fastText/website/static/docs/en/html/annotated.html +0 -115
- data/vendor/fastText/website/static/docs/en/html/annotated_dup.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/args_8cc.html +0 -113
- data/vendor/fastText/website/static/docs/en/html/args_8h.html +0 -134
- data/vendor/fastText/website/static/docs/en/html/args_8h.js +0 -14
- data/vendor/fastText/website/static/docs/en/html/args_8h_source.html +0 -139
- data/vendor/fastText/website/static/docs/en/html/bc_s.png +0 -0
- data/vendor/fastText/website/static/docs/en/html/bdwn.png +0 -0
- data/vendor/fastText/website/static/docs/en/html/classes.html +0 -121
- data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1Args-members.html +0 -140
- data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1Args.html +0 -753
- data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1Args.js +0 -40
- data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1Dictionary-members.html +0 -148
- data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1Dictionary.html +0 -1266
- data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1Dictionary.js +0 -43
- data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1FastText-members.html +0 -145
- data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1FastText.html +0 -1149
- data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1FastText.js +0 -45
- data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1Matrix-members.html +0 -123
- data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1Matrix.html +0 -610
- data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1Matrix.js +0 -23
- data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1Model-members.html +0 -150
- data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1Model.html +0 -1400
- data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1Model.js +0 -48
- data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1ProductQuantizer-members.html +0 -131
- data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1ProductQuantizer.html +0 -950
- data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1ProductQuantizer.js +0 -31
- data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1QMatrix-members.html +0 -122
- data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1QMatrix.html +0 -565
- data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1QMatrix.js +0 -22
- data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1Vector-members.html +0 -121
- data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1Vector.html +0 -542
- data/vendor/fastText/website/static/docs/en/html/classfasttext_1_1Vector.js +0 -21
- data/vendor/fastText/website/static/docs/en/html/closed.png +0 -0
- data/vendor/fastText/website/static/docs/en/html/dictionary_8cc.html +0 -116
- data/vendor/fastText/website/static/docs/en/html/dictionary_8h.html +0 -142
- data/vendor/fastText/website/static/docs/en/html/dictionary_8h.js +0 -10
- data/vendor/fastText/website/static/docs/en/html/dictionary_8h_source.html +0 -127
- data/vendor/fastText/website/static/docs/en/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html +0 -145
- data/vendor/fastText/website/static/docs/en/html/dir_68267d1309a1af8e8297ef4c3efbcdba.js +0 -29
- data/vendor/fastText/website/static/docs/en/html/doc.png +0 -0
- data/vendor/fastText/website/static/docs/en/html/doxygen.css +0 -1596
- data/vendor/fastText/website/static/docs/en/html/doxygen.png +0 -0
- data/vendor/fastText/website/static/docs/en/html/dynsections.js +0 -97
- data/vendor/fastText/website/static/docs/en/html/fasttext_8cc.html +0 -119
- data/vendor/fastText/website/static/docs/en/html/fasttext_8h.html +0 -168
- data/vendor/fastText/website/static/docs/en/html/fasttext_8h.js +0 -6
- data/vendor/fastText/website/static/docs/en/html/fasttext_8h_source.html +0 -155
- data/vendor/fastText/website/static/docs/en/html/favicon.png +0 -0
- data/vendor/fastText/website/static/docs/en/html/files.html +0 -125
- data/vendor/fastText/website/static/docs/en/html/files.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/folderclosed.png +0 -0
- data/vendor/fastText/website/static/docs/en/html/folderopen.png +0 -0
- data/vendor/fastText/website/static/docs/en/html/functions.html +0 -139
- data/vendor/fastText/website/static/docs/en/html/functions_0x7e.html +0 -112
- data/vendor/fastText/website/static/docs/en/html/functions_b.html +0 -115
- data/vendor/fastText/website/static/docs/en/html/functions_c.html +0 -143
- data/vendor/fastText/website/static/docs/en/html/functions_d.html +0 -135
- data/vendor/fastText/website/static/docs/en/html/functions_dup.js +0 -27
- data/vendor/fastText/website/static/docs/en/html/functions_e.html +0 -115
- data/vendor/fastText/website/static/docs/en/html/functions_f.html +0 -112
- data/vendor/fastText/website/static/docs/en/html/functions_func.html +0 -563
- data/vendor/fastText/website/static/docs/en/html/functions_g.html +0 -145
- data/vendor/fastText/website/static/docs/en/html/functions_h.html +0 -112
- data/vendor/fastText/website/static/docs/en/html/functions_i.html +0 -121
- data/vendor/fastText/website/static/docs/en/html/functions_k.html +0 -106
- data/vendor/fastText/website/static/docs/en/html/functions_l.html +0 -140
- data/vendor/fastText/website/static/docs/en/html/functions_m.html +0 -153
- data/vendor/fastText/website/static/docs/en/html/functions_n.html +0 -164
- data/vendor/fastText/website/static/docs/en/html/functions_o.html +0 -116
- data/vendor/fastText/website/static/docs/en/html/functions_p.html +0 -161
- data/vendor/fastText/website/static/docs/en/html/functions_q.html +0 -135
- data/vendor/fastText/website/static/docs/en/html/functions_r.html +0 -116
- data/vendor/fastText/website/static/docs/en/html/functions_s.html +0 -159
- data/vendor/fastText/website/static/docs/en/html/functions_t.html +0 -138
- data/vendor/fastText/website/static/docs/en/html/functions_u.html +0 -106
- data/vendor/fastText/website/static/docs/en/html/functions_v.html +0 -106
- data/vendor/fastText/website/static/docs/en/html/functions_vars.html +0 -486
- data/vendor/fastText/website/static/docs/en/html/functions_w.html +0 -124
- data/vendor/fastText/website/static/docs/en/html/functions_z.html +0 -104
- data/vendor/fastText/website/static/docs/en/html/globals.html +0 -170
- data/vendor/fastText/website/static/docs/en/html/globals_defs.html +0 -113
- data/vendor/fastText/website/static/docs/en/html/globals_func.html +0 -155
- data/vendor/fastText/website/static/docs/en/html/index.html +0 -100
- data/vendor/fastText/website/static/docs/en/html/jquery.js +0 -87
- data/vendor/fastText/website/static/docs/en/html/main_8cc.html +0 -582
- data/vendor/fastText/website/static/docs/en/html/main_8cc.js +0 -22
- data/vendor/fastText/website/static/docs/en/html/matrix_8cc.html +0 -114
- data/vendor/fastText/website/static/docs/en/html/matrix_8h.html +0 -121
- data/vendor/fastText/website/static/docs/en/html/matrix_8h_source.html +0 -123
- data/vendor/fastText/website/static/docs/en/html/menu.js +0 -26
- data/vendor/fastText/website/static/docs/en/html/menudata.js +0 -90
- data/vendor/fastText/website/static/docs/en/html/model_8cc.html +0 -113
- data/vendor/fastText/website/static/docs/en/html/model_8h.html +0 -183
- data/vendor/fastText/website/static/docs/en/html/model_8h.js +0 -8
- data/vendor/fastText/website/static/docs/en/html/model_8h_source.html +0 -139
- data/vendor/fastText/website/static/docs/en/html/namespacefasttext.html +0 -343
- data/vendor/fastText/website/static/docs/en/html/namespacefasttext.js +0 -13
- data/vendor/fastText/website/static/docs/en/html/namespacefasttext_1_1utils.html +0 -158
- data/vendor/fastText/website/static/docs/en/html/namespacemembers.html +0 -125
- data/vendor/fastText/website/static/docs/en/html/namespacemembers_enum.html +0 -107
- data/vendor/fastText/website/static/docs/en/html/namespacemembers_func.html +0 -110
- data/vendor/fastText/website/static/docs/en/html/namespacemembers_type.html +0 -104
- data/vendor/fastText/website/static/docs/en/html/namespaces.html +0 -106
- data/vendor/fastText/website/static/docs/en/html/namespaces.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/nav_f.png +0 -0
- data/vendor/fastText/website/static/docs/en/html/nav_g.png +0 -0
- data/vendor/fastText/website/static/docs/en/html/nav_h.png +0 -0
- data/vendor/fastText/website/static/docs/en/html/navtree.css +0 -146
- data/vendor/fastText/website/static/docs/en/html/navtree.js +0 -517
- data/vendor/fastText/website/static/docs/en/html/navtreedata.js +0 -40
- data/vendor/fastText/website/static/docs/en/html/navtreeindex0.js +0 -253
- data/vendor/fastText/website/static/docs/en/html/navtreeindex1.js +0 -139
- data/vendor/fastText/website/static/docs/en/html/open.png +0 -0
- data/vendor/fastText/website/static/docs/en/html/productquantizer_8cc.html +0 -118
- data/vendor/fastText/website/static/docs/en/html/productquantizer_8cc.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/productquantizer_8h.html +0 -124
- data/vendor/fastText/website/static/docs/en/html/productquantizer_8h_source.html +0 -133
- data/vendor/fastText/website/static/docs/en/html/qmatrix_8cc.html +0 -112
- data/vendor/fastText/website/static/docs/en/html/qmatrix_8h.html +0 -126
- data/vendor/fastText/website/static/docs/en/html/qmatrix_8h_source.html +0 -128
- data/vendor/fastText/website/static/docs/en/html/real_8h.html +0 -117
- data/vendor/fastText/website/static/docs/en/html/real_8h.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/real_8h_source.html +0 -103
- data/vendor/fastText/website/static/docs/en/html/resize.js +0 -114
- data/vendor/fastText/website/static/docs/en/html/search/all_0.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/all_0.js +0 -17
- data/vendor/fastText/website/static/docs/en/html/search/all_1.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/all_1.js +0 -8
- data/vendor/fastText/website/static/docs/en/html/search/all_10.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/all_10.js +0 -10
- data/vendor/fastText/website/static/docs/en/html/search/all_11.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/all_11.js +0 -25
- data/vendor/fastText/website/static/docs/en/html/search/all_12.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/all_12.js +0 -15
- data/vendor/fastText/website/static/docs/en/html/search/all_13.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/all_13.js +0 -7
- data/vendor/fastText/website/static/docs/en/html/search/all_14.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/all_14.js +0 -7
- data/vendor/fastText/website/static/docs/en/html/search/all_15.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/all_15.js +0 -11
- data/vendor/fastText/website/static/docs/en/html/search/all_16.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/all_16.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/search/all_17.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/all_17.js +0 -7
- data/vendor/fastText/website/static/docs/en/html/search/all_2.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/all_2.js +0 -17
- data/vendor/fastText/website/static/docs/en/html/search/all_3.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/all_3.js +0 -17
- data/vendor/fastText/website/static/docs/en/html/search/all_4.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/all_4.js +0 -10
- data/vendor/fastText/website/static/docs/en/html/search/all_5.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/all_5.js +0 -12
- data/vendor/fastText/website/static/docs/en/html/search/all_6.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/all_6.js +0 -18
- data/vendor/fastText/website/static/docs/en/html/search/all_7.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/all_7.js +0 -8
- data/vendor/fastText/website/static/docs/en/html/search/all_8.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/all_8.js +0 -11
- data/vendor/fastText/website/static/docs/en/html/search/all_9.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/all_9.js +0 -5
- data/vendor/fastText/website/static/docs/en/html/search/all_a.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/all_a.js +0 -17
- data/vendor/fastText/website/static/docs/en/html/search/all_b.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/all_b.js +0 -27
- data/vendor/fastText/website/static/docs/en/html/search/all_c.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/all_c.js +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/all_d.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/all_d.js +0 -9
- data/vendor/fastText/website/static/docs/en/html/search/all_e.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/all_e.js +0 -35
- data/vendor/fastText/website/static/docs/en/html/search/all_f.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/all_f.js +0 -16
- data/vendor/fastText/website/static/docs/en/html/search/classes_0.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/classes_0.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/search/classes_1.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/classes_1.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/search/classes_2.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/classes_2.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/search/classes_3.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/classes_3.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/search/classes_4.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/classes_4.js +0 -5
- data/vendor/fastText/website/static/docs/en/html/search/classes_5.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/classes_5.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/search/classes_6.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/classes_6.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/search/classes_7.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/classes_7.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/search/classes_8.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/classes_8.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/search/close.png +0 -0
- data/vendor/fastText/website/static/docs/en/html/search/defines_0.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/defines_0.js +0 -5
- data/vendor/fastText/website/static/docs/en/html/search/defines_1.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/defines_1.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/search/defines_2.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/defines_2.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/search/defines_3.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/defines_3.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/search/enums_0.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/enums_0.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/search/enums_1.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/enums_1.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/search/enums_2.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/enums_2.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/search/enumvalues_0.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/enumvalues_0.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/search/enumvalues_1.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/enumvalues_1.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/search/enumvalues_2.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/enumvalues_2.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/search/enumvalues_3.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/enumvalues_3.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/search/enumvalues_4.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/enumvalues_4.js +0 -6
- data/vendor/fastText/website/static/docs/en/html/search/enumvalues_5.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/enumvalues_5.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/search/files_0.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/files_0.js +0 -5
- data/vendor/fastText/website/static/docs/en/html/search/files_1.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/files_1.js +0 -5
- data/vendor/fastText/website/static/docs/en/html/search/files_2.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/files_2.js +0 -5
- data/vendor/fastText/website/static/docs/en/html/search/files_3.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/files_3.js +0 -8
- data/vendor/fastText/website/static/docs/en/html/search/files_4.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/files_4.js +0 -5
- data/vendor/fastText/website/static/docs/en/html/search/files_5.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/files_5.js +0 -5
- data/vendor/fastText/website/static/docs/en/html/search/files_6.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/files_6.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/search/files_7.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/files_7.js +0 -5
- data/vendor/fastText/website/static/docs/en/html/search/files_8.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/files_8.js +0 -5
- data/vendor/fastText/website/static/docs/en/html/search/functions_0.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/functions_0.js +0 -14
- data/vendor/fastText/website/static/docs/en/html/search/functions_1.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/functions_1.js +0 -5
- data/vendor/fastText/website/static/docs/en/html/search/functions_10.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/functions_10.js +0 -5
- data/vendor/fastText/website/static/docs/en/html/search/functions_11.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/functions_11.js +0 -18
- data/vendor/fastText/website/static/docs/en/html/search/functions_12.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/functions_12.js +0 -8
- data/vendor/fastText/website/static/docs/en/html/search/functions_13.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/functions_13.js +0 -5
- data/vendor/fastText/website/static/docs/en/html/search/functions_14.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/functions_14.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/search/functions_15.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/functions_15.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/search/functions_16.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/functions_16.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/search/functions_17.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/functions_17.js +0 -7
- data/vendor/fastText/website/static/docs/en/html/search/functions_2.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/functions_2.js +0 -11
- data/vendor/fastText/website/static/docs/en/html/search/functions_3.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/functions_3.js +0 -9
- data/vendor/fastText/website/static/docs/en/html/search/functions_4.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/functions_4.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/search/functions_5.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/functions_5.js +0 -7
- data/vendor/fastText/website/static/docs/en/html/search/functions_6.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/functions_6.js +0 -17
- data/vendor/fastText/website/static/docs/en/html/search/functions_7.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/functions_7.js +0 -5
- data/vendor/fastText/website/static/docs/en/html/search/functions_8.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/functions_8.js +0 -8
- data/vendor/fastText/website/static/docs/en/html/search/functions_9.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/functions_9.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/search/functions_a.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/functions_a.js +0 -8
- data/vendor/fastText/website/static/docs/en/html/search/functions_b.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/functions_b.js +0 -10
- data/vendor/fastText/website/static/docs/en/html/search/functions_c.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/functions_c.js +0 -10
- data/vendor/fastText/website/static/docs/en/html/search/functions_d.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/functions_d.js +0 -6
- data/vendor/fastText/website/static/docs/en/html/search/functions_e.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/functions_e.js +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/functions_f.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/functions_f.js +0 -6
- data/vendor/fastText/website/static/docs/en/html/search/mag_sel.png +0 -0
- data/vendor/fastText/website/static/docs/en/html/search/namespaces_0.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/namespaces_0.js +0 -5
- data/vendor/fastText/website/static/docs/en/html/search/nomatches.html +0 -12
- data/vendor/fastText/website/static/docs/en/html/search/search.css +0 -271
- data/vendor/fastText/website/static/docs/en/html/search/search.js +0 -791
- data/vendor/fastText/website/static/docs/en/html/search/search_l.png +0 -0
- data/vendor/fastText/website/static/docs/en/html/search/search_m.png +0 -0
- data/vendor/fastText/website/static/docs/en/html/search/search_r.png +0 -0
- data/vendor/fastText/website/static/docs/en/html/search/searchdata.js +0 -42
- data/vendor/fastText/website/static/docs/en/html/search/typedefs_0.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/typedefs_0.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/search/typedefs_1.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/typedefs_1.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/search/variables_0.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/variables_0.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/search/variables_1.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/variables_1.js +0 -6
- data/vendor/fastText/website/static/docs/en/html/search/variables_10.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/variables_10.js +0 -8
- data/vendor/fastText/website/static/docs/en/html/search/variables_11.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/variables_11.js +0 -11
- data/vendor/fastText/website/static/docs/en/html/search/variables_12.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/variables_12.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/search/variables_13.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/variables_13.js +0 -10
- data/vendor/fastText/website/static/docs/en/html/search/variables_2.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/variables_2.js +0 -9
- data/vendor/fastText/website/static/docs/en/html/search/variables_3.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/variables_3.js +0 -9
- data/vendor/fastText/website/static/docs/en/html/search/variables_4.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/variables_4.js +0 -7
- data/vendor/fastText/website/static/docs/en/html/search/variables_5.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/variables_5.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/search/variables_6.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/variables_6.js +0 -5
- data/vendor/fastText/website/static/docs/en/html/search/variables_7.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/variables_7.js +0 -5
- data/vendor/fastText/website/static/docs/en/html/search/variables_8.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/variables_8.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/search/variables_9.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/variables_9.js +0 -10
- data/vendor/fastText/website/static/docs/en/html/search/variables_a.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/variables_a.js +0 -14
- data/vendor/fastText/website/static/docs/en/html/search/variables_b.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/variables_b.js +0 -17
- data/vendor/fastText/website/static/docs/en/html/search/variables_c.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/variables_c.js +0 -6
- data/vendor/fastText/website/static/docs/en/html/search/variables_d.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/variables_d.js +0 -10
- data/vendor/fastText/website/static/docs/en/html/search/variables_e.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/variables_e.js +0 -11
- data/vendor/fastText/website/static/docs/en/html/search/variables_f.html +0 -26
- data/vendor/fastText/website/static/docs/en/html/search/variables_f.js +0 -6
- data/vendor/fastText/website/static/docs/en/html/splitbar.png +0 -0
- data/vendor/fastText/website/static/docs/en/html/structfasttext_1_1Node-members.html +0 -108
- data/vendor/fastText/website/static/docs/en/html/structfasttext_1_1Node.html +0 -194
- data/vendor/fastText/website/static/docs/en/html/structfasttext_1_1Node.js +0 -8
- data/vendor/fastText/website/static/docs/en/html/structfasttext_1_1entry-members.html +0 -107
- data/vendor/fastText/website/static/docs/en/html/structfasttext_1_1entry.html +0 -178
- data/vendor/fastText/website/static/docs/en/html/structfasttext_1_1entry.js +0 -7
- data/vendor/fastText/website/static/docs/en/html/sync_off.png +0 -0
- data/vendor/fastText/website/static/docs/en/html/sync_on.png +0 -0
- data/vendor/fastText/website/static/docs/en/html/tab_a.png +0 -0
- data/vendor/fastText/website/static/docs/en/html/tab_b.png +0 -0
- data/vendor/fastText/website/static/docs/en/html/tab_h.png +0 -0
- data/vendor/fastText/website/static/docs/en/html/tab_s.png +0 -0
- data/vendor/fastText/website/static/docs/en/html/tabs.css +0 -1
- data/vendor/fastText/website/static/docs/en/html/utils_8cc.html +0 -121
- data/vendor/fastText/website/static/docs/en/html/utils_8cc.js +0 -5
- data/vendor/fastText/website/static/docs/en/html/utils_8h.html +0 -122
- data/vendor/fastText/website/static/docs/en/html/utils_8h.js +0 -5
- data/vendor/fastText/website/static/docs/en/html/utils_8h_source.html +0 -104
- data/vendor/fastText/website/static/docs/en/html/vector_8cc.html +0 -121
- data/vendor/fastText/website/static/docs/en/html/vector_8cc.js +0 -4
- data/vendor/fastText/website/static/docs/en/html/vector_8h.html +0 -126
- data/vendor/fastText/website/static/docs/en/html/vector_8h.js +0 -5
- data/vendor/fastText/website/static/docs/en/html/vector_8h_source.html +0 -120
- data/vendor/fastText/website/static/fasttext.css +0 -48
- data/vendor/fastText/website/static/img/authors/armand_joulin.jpg +0 -0
- data/vendor/fastText/website/static/img/authors/christian_puhrsch.png +0 -0
- data/vendor/fastText/website/static/img/authors/edouard_grave.jpeg +0 -0
- data/vendor/fastText/website/static/img/authors/piotr_bojanowski.jpg +0 -0
- data/vendor/fastText/website/static/img/authors/tomas_mikolov.jpg +0 -0
- data/vendor/fastText/website/static/img/blog/2016-08-18-blog-post-img1.png +0 -0
- data/vendor/fastText/website/static/img/blog/2016-08-18-blog-post-img2.png +0 -0
- data/vendor/fastText/website/static/img/blog/2017-05-02-blog-post-img1.jpg +0 -0
- data/vendor/fastText/website/static/img/blog/2017-05-02-blog-post-img2.jpg +0 -0
- data/vendor/fastText/website/static/img/blog/2017-10-02-blog-post-img1.png +0 -0
- data/vendor/fastText/website/static/img/cbo_vs_skipgram.png +0 -0
- data/vendor/fastText/website/static/img/fasttext-icon-api.png +0 -0
- data/vendor/fastText/website/static/img/fasttext-icon-bg-web.png +0 -0
- data/vendor/fastText/website/static/img/fasttext-icon-color-square.png +0 -0
- data/vendor/fastText/website/static/img/fasttext-icon-color-web.png +0 -0
- data/vendor/fastText/website/static/img/fasttext-icon-faq.png +0 -0
- data/vendor/fastText/website/static/img/fasttext-icon-tutorial.png +0 -0
- data/vendor/fastText/website/static/img/fasttext-icon-white-web.png +0 -0
- data/vendor/fastText/website/static/img/fasttext-logo-color-web.png +0 -0
- data/vendor/fastText/website/static/img/fasttext-logo-white-web.png +0 -0
- data/vendor/fastText/website/static/img/logo-color.png +0 -0
- data/vendor/fastText/website/static/img/model-black.png +0 -0
- data/vendor/fastText/website/static/img/model-blue.png +0 -0
- data/vendor/fastText/website/static/img/model-red.png +0 -0
- data/vendor/fastText/website/static/img/ogimage.png +0 -0
- data/vendor/fastText/website/static/img/oss_logo.png +0 -0
- data/vendor/fastText/wikifil.pl +0 -57
- 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
|