fasttext 0.1.0 → 0.2.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 +26 -1
- data/LICENSE.txt +18 -18
- data/README.md +39 -12
- data/ext/fasttext/ext.cpp +108 -101
- data/ext/fasttext/extconf.rb +7 -9
- data/lib/fasttext.rb +3 -0
- data/lib/fasttext/classifier.rb +25 -7
- data/lib/fasttext/vectorizer.rb +7 -2
- data/lib/fasttext/version.rb +1 -1
- data/vendor/fastText/README.md +3 -3
- data/vendor/fastText/src/args.cc +179 -6
- data/vendor/fastText/src/args.h +29 -1
- data/vendor/fastText/src/autotune.cc +477 -0
- data/vendor/fastText/src/autotune.h +89 -0
- data/vendor/fastText/src/densematrix.cc +27 -7
- data/vendor/fastText/src/densematrix.h +10 -2
- data/vendor/fastText/src/fasttext.cc +125 -114
- data/vendor/fastText/src/fasttext.h +31 -52
- data/vendor/fastText/src/main.cc +32 -13
- data/vendor/fastText/src/meter.cc +148 -2
- data/vendor/fastText/src/meter.h +24 -2
- data/vendor/fastText/src/model.cc +0 -1
- data/vendor/fastText/src/real.h +0 -1
- data/vendor/fastText/src/utils.cc +25 -0
- data/vendor/fastText/src/utils.h +29 -0
- data/vendor/fastText/src/vector.cc +0 -1
- metadata +16 -539
- 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
data/ext/fasttext/extconf.rb
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
require "mkmf-rice"
|
2
2
|
|
3
|
-
|
3
|
+
# -pthread and -O3 set by default
|
4
|
+
$CXXFLAGS << " -std=c++17 $(optflags) -funroll-loops " << with_config("optflags", "-march=native")
|
4
5
|
|
5
|
-
|
6
|
-
|
6
|
+
ext = File.expand_path(".", __dir__)
|
7
|
+
fasttext = File.expand_path("../../vendor/fastText/src", __dir__)
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
$srcs = Dir["{#{src1},#{src2}}/*.{cc,cpp}"]
|
12
|
-
$INCFLAGS << " -I$(srcdir)/../../vendor/fastText/src"
|
13
|
-
$VPATH << "$(srcdir)/../../vendor/fastText/src"
|
9
|
+
$srcs = Dir["{#{ext},#{fasttext}}/*.{cc,cpp}"]
|
10
|
+
$INCFLAGS << " -I#{fasttext}"
|
11
|
+
$VPATH << fasttext
|
14
12
|
|
15
13
|
create_makefile("fasttext/ext")
|
data/lib/fasttext.rb
CHANGED
data/lib/fasttext/classifier.rb
CHANGED
@@ -21,20 +21,38 @@ module FastText
|
|
21
21
|
verbose: 2,
|
22
22
|
pretrained_vectors: "",
|
23
23
|
save_output: false,
|
24
|
-
|
24
|
+
seed: 0,
|
25
|
+
autotune_validation_file: "",
|
26
|
+
autotune_metric: "f1",
|
27
|
+
autotune_predictions: 1,
|
28
|
+
autotune_duration: 60 * 5,
|
29
|
+
autotune_model_size: ""
|
25
30
|
}
|
26
31
|
|
27
|
-
def fit(x, y = nil)
|
32
|
+
def fit(x, y = nil, autotune_set: nil)
|
28
33
|
input = input_path(x, y)
|
29
34
|
@m ||= Ext::Model.new
|
30
|
-
|
35
|
+
opts = DEFAULT_OPTIONS.merge(@options).merge(input: input, model: "supervised")
|
36
|
+
if autotune_set
|
37
|
+
x, y = autotune_set
|
38
|
+
opts.merge!(autotune_validation_file: input_path(x, y))
|
39
|
+
end
|
40
|
+
m.train(opts)
|
31
41
|
end
|
32
42
|
|
33
|
-
# TODO support array of text
|
34
43
|
def predict(text, k: 1, threshold: 0.0)
|
35
|
-
|
36
|
-
|
37
|
-
|
44
|
+
multiple = text.is_a?(Array)
|
45
|
+
text = [text] unless multiple
|
46
|
+
|
47
|
+
# TODO predict multiple in C++ for performance
|
48
|
+
result =
|
49
|
+
text.map do |t|
|
50
|
+
m.predict(prep_text(t), k, threshold).map do |v|
|
51
|
+
[remove_prefix(v[1]), v[0]]
|
52
|
+
end.to_h
|
53
|
+
end
|
54
|
+
|
55
|
+
multiple ? result : result.first
|
38
56
|
end
|
39
57
|
|
40
58
|
def test(x, y = nil, k: 1)
|
data/lib/fasttext/vectorizer.rb
CHANGED
@@ -20,7 +20,12 @@ module FastText
|
|
20
20
|
verbose: 2,
|
21
21
|
pretrained_vectors: "",
|
22
22
|
save_output: false,
|
23
|
-
|
23
|
+
seed: 0,
|
24
|
+
autotune_validation_file: "",
|
25
|
+
autotune_metric: "f1",
|
26
|
+
autotune_predictions: 1,
|
27
|
+
autotune_duration: 60 * 5,
|
28
|
+
autotune_model_size: ""
|
24
29
|
}
|
25
30
|
|
26
31
|
def fit(x)
|
@@ -47,7 +52,7 @@ module FastText
|
|
47
52
|
else
|
48
53
|
tempfile = Tempfile.new("fasttext")
|
49
54
|
x.each do |xi|
|
50
|
-
tempfile.write(xi)
|
55
|
+
tempfile.write(xi.gsub("\n", " ")) # replace newlines in document
|
51
56
|
tempfile.write("\n")
|
52
57
|
end
|
53
58
|
tempfile.close
|
data/lib/fasttext/version.rb
CHANGED
data/vendor/fastText/README.md
CHANGED
@@ -89,9 +89,9 @@ There is also the master branch that contains all of our most recent work, but c
|
|
89
89
|
### Building fastText using make (preferred)
|
90
90
|
|
91
91
|
```
|
92
|
-
$ wget https://github.com/facebookresearch/fastText/archive/v0.9.
|
93
|
-
$ unzip v0.9.
|
94
|
-
$ cd fastText-0.9.
|
92
|
+
$ wget https://github.com/facebookresearch/fastText/archive/v0.9.2.zip
|
93
|
+
$ unzip v0.9.2.zip
|
94
|
+
$ cd fastText-0.9.2
|
95
95
|
$ make
|
96
96
|
```
|
97
97
|
|
data/vendor/fastText/src/args.cc
CHANGED
@@ -12,6 +12,8 @@
|
|
12
12
|
|
13
13
|
#include <iostream>
|
14
14
|
#include <stdexcept>
|
15
|
+
#include <string>
|
16
|
+
#include <unordered_map>
|
15
17
|
|
16
18
|
namespace fasttext {
|
17
19
|
|
@@ -36,12 +38,19 @@ Args::Args() {
|
|
36
38
|
verbose = 2;
|
37
39
|
pretrainedVectors = "";
|
38
40
|
saveOutput = false;
|
41
|
+
seed = 0;
|
39
42
|
|
40
43
|
qout = false;
|
41
44
|
retrain = false;
|
42
45
|
qnorm = false;
|
43
46
|
cutoff = 0;
|
44
47
|
dsub = 2;
|
48
|
+
|
49
|
+
autotuneValidationFile = "";
|
50
|
+
autotuneMetric = "f1";
|
51
|
+
autotunePredictions = 1;
|
52
|
+
autotuneDuration = 60 * 5; // 5 minutes
|
53
|
+
autotuneModelSize = "";
|
45
54
|
}
|
46
55
|
|
47
56
|
std::string Args::lossToString(loss_name ln) const {
|
@@ -78,6 +87,24 @@ std::string Args::modelToString(model_name mn) const {
|
|
78
87
|
return "Unknown model name!"; // should never happen
|
79
88
|
}
|
80
89
|
|
90
|
+
std::string Args::metricToString(metric_name mn) const {
|
91
|
+
switch (mn) {
|
92
|
+
case metric_name::f1score:
|
93
|
+
return "f1score";
|
94
|
+
case metric_name::f1scoreLabel:
|
95
|
+
return "f1scoreLabel";
|
96
|
+
case metric_name::precisionAtRecall:
|
97
|
+
return "precisionAtRecall";
|
98
|
+
case metric_name::precisionAtRecallLabel:
|
99
|
+
return "precisionAtRecallLabel";
|
100
|
+
case metric_name::recallAtPrecision:
|
101
|
+
return "recallAtPrecision";
|
102
|
+
case metric_name::recallAtPrecisionLabel:
|
103
|
+
return "recallAtPrecisionLabel";
|
104
|
+
}
|
105
|
+
return "Unknown metric name!"; // should never happen
|
106
|
+
}
|
107
|
+
|
81
108
|
void Args::parseArgs(const std::vector<std::string>& args) {
|
82
109
|
std::string command(args[1]);
|
83
110
|
if (command == "supervised") {
|
@@ -97,6 +124,8 @@ void Args::parseArgs(const std::vector<std::string>& args) {
|
|
97
124
|
exit(EXIT_FAILURE);
|
98
125
|
}
|
99
126
|
try {
|
127
|
+
setManual(args[ai].substr(1));
|
128
|
+
|
100
129
|
if (args[ai] == "-h") {
|
101
130
|
std::cerr << "Here is the help! Usage:" << std::endl;
|
102
131
|
printHelp();
|
@@ -157,6 +186,8 @@ void Args::parseArgs(const std::vector<std::string>& args) {
|
|
157
186
|
} else if (args[ai] == "-saveOutput") {
|
158
187
|
saveOutput = true;
|
159
188
|
ai--;
|
189
|
+
} else if (args[ai] == "-seed") {
|
190
|
+
seed = std::stoi(args.at(ai + 1));
|
160
191
|
} else if (args[ai] == "-qnorm") {
|
161
192
|
qnorm = true;
|
162
193
|
ai--;
|
@@ -170,6 +201,18 @@ void Args::parseArgs(const std::vector<std::string>& args) {
|
|
170
201
|
cutoff = std::stoi(args.at(ai + 1));
|
171
202
|
} else if (args[ai] == "-dsub") {
|
172
203
|
dsub = std::stoi(args.at(ai + 1));
|
204
|
+
} else if (args[ai] == "-autotune-validation") {
|
205
|
+
autotuneValidationFile = std::string(args.at(ai + 1));
|
206
|
+
} else if (args[ai] == "-autotune-metric") {
|
207
|
+
autotuneMetric = std::string(args.at(ai + 1));
|
208
|
+
getAutotuneMetric(); // throws exception if not able to parse
|
209
|
+
getAutotuneMetricLabel(); // throws exception if not able to parse
|
210
|
+
} else if (args[ai] == "-autotune-predictions") {
|
211
|
+
autotunePredictions = std::stoi(args.at(ai + 1));
|
212
|
+
} else if (args[ai] == "-autotune-duration") {
|
213
|
+
autotuneDuration = std::stoi(args.at(ai + 1));
|
214
|
+
} else if (args[ai] == "-autotune-modelsize") {
|
215
|
+
autotuneModelSize = std::string(args.at(ai + 1));
|
173
216
|
} else {
|
174
217
|
std::cerr << "Unknown argument: " << args[ai] << std::endl;
|
175
218
|
printHelp();
|
@@ -186,7 +229,7 @@ void Args::parseArgs(const std::vector<std::string>& args) {
|
|
186
229
|
printHelp();
|
187
230
|
exit(EXIT_FAILURE);
|
188
231
|
}
|
189
|
-
if (wordNgrams <= 1 && maxn == 0) {
|
232
|
+
if (wordNgrams <= 1 && maxn == 0 && !hasAutotune()) {
|
190
233
|
bucket = 0;
|
191
234
|
}
|
192
235
|
}
|
@@ -195,6 +238,7 @@ void Args::printHelp() {
|
|
195
238
|
printBasicHelp();
|
196
239
|
printDictionaryHelp();
|
197
240
|
printTrainingHelp();
|
241
|
+
printAutotuneHelp();
|
198
242
|
printQuantizationHelp();
|
199
243
|
}
|
200
244
|
|
@@ -227,7 +271,8 @@ void Args::printTrainingHelp() {
|
|
227
271
|
std::cerr
|
228
272
|
<< "\nThe following arguments for training are optional:\n"
|
229
273
|
<< " -lr learning rate [" << lr << "]\n"
|
230
|
-
<< " -lrUpdateRate change the rate of updates for the learning
|
274
|
+
<< " -lrUpdateRate change the rate of updates for the learning "
|
275
|
+
"rate ["
|
231
276
|
<< lrUpdateRate << "]\n"
|
232
277
|
<< " -dim size of word vectors [" << dim << "]\n"
|
233
278
|
<< " -ws size of the context window [" << ws << "]\n"
|
@@ -235,11 +280,31 @@ void Args::printTrainingHelp() {
|
|
235
280
|
<< " -neg number of negatives sampled [" << neg << "]\n"
|
236
281
|
<< " -loss loss function {ns, hs, softmax, one-vs-all} ["
|
237
282
|
<< lossToString(loss) << "]\n"
|
238
|
-
<< " -thread number of threads
|
239
|
-
|
283
|
+
<< " -thread number of threads (set to 1 to ensure "
|
284
|
+
"reproducible results) ["
|
285
|
+
<< thread << "]\n"
|
286
|
+
<< " -pretrainedVectors pretrained word vectors for supervised "
|
287
|
+
"learning ["
|
240
288
|
<< pretrainedVectors << "]\n"
|
241
289
|
<< " -saveOutput whether output params should be saved ["
|
242
|
-
<< boolToString(saveOutput) << "]\n"
|
290
|
+
<< boolToString(saveOutput) << "]\n"
|
291
|
+
<< " -seed random generator seed [" << seed << "]\n";
|
292
|
+
}
|
293
|
+
|
294
|
+
void Args::printAutotuneHelp() {
|
295
|
+
std::cerr << "\nThe following arguments are for autotune:\n"
|
296
|
+
<< " -autotune-validation validation file to be used "
|
297
|
+
"for evaluation\n"
|
298
|
+
<< " -autotune-metric metric objective {f1, "
|
299
|
+
"f1:labelname} ["
|
300
|
+
<< autotuneMetric << "]\n"
|
301
|
+
<< " -autotune-predictions number of predictions used "
|
302
|
+
"for evaluation ["
|
303
|
+
<< autotunePredictions << "]\n"
|
304
|
+
<< " -autotune-duration maximum duration in seconds ["
|
305
|
+
<< autotuneDuration << "]\n"
|
306
|
+
<< " -autotune-modelsize constraint model file size ["
|
307
|
+
<< autotuneModelSize << "] (empty = do not quantize)\n";
|
243
308
|
}
|
244
309
|
|
245
310
|
void Args::printQuantizationHelp() {
|
@@ -247,7 +312,8 @@ void Args::printQuantizationHelp() {
|
|
247
312
|
<< "\nThe following arguments for quantization are optional:\n"
|
248
313
|
<< " -cutoff number of words and ngrams to retain ["
|
249
314
|
<< cutoff << "]\n"
|
250
|
-
<< " -retrain whether embeddings are finetuned if a cutoff
|
315
|
+
<< " -retrain whether embeddings are finetuned if a cutoff "
|
316
|
+
"is applied ["
|
251
317
|
<< boolToString(retrain) << "]\n"
|
252
318
|
<< " -qnorm whether the norm is quantized separately ["
|
253
319
|
<< boolToString(qnorm) << "]\n"
|
@@ -317,4 +383,111 @@ void Args::dump(std::ostream& out) const {
|
|
317
383
|
<< " " << t << std::endl;
|
318
384
|
}
|
319
385
|
|
386
|
+
bool Args::hasAutotune() const {
|
387
|
+
return !autotuneValidationFile.empty();
|
388
|
+
}
|
389
|
+
|
390
|
+
bool Args::isManual(const std::string& argName) const {
|
391
|
+
return (manualArgs_.count(argName) != 0);
|
392
|
+
}
|
393
|
+
|
394
|
+
void Args::setManual(const std::string& argName) {
|
395
|
+
manualArgs_.emplace(argName);
|
396
|
+
}
|
397
|
+
|
398
|
+
metric_name Args::getAutotuneMetric() const {
|
399
|
+
if (autotuneMetric.substr(0, 3) == "f1:") {
|
400
|
+
return metric_name::f1scoreLabel;
|
401
|
+
} else if (autotuneMetric == "f1") {
|
402
|
+
return metric_name::f1score;
|
403
|
+
} else if (autotuneMetric.substr(0, 18) == "precisionAtRecall:") {
|
404
|
+
size_t semicolon = autotuneMetric.find(":", 18);
|
405
|
+
if (semicolon != std::string::npos) {
|
406
|
+
return metric_name::precisionAtRecallLabel;
|
407
|
+
}
|
408
|
+
return metric_name::precisionAtRecall;
|
409
|
+
} else if (autotuneMetric.substr(0, 18) == "recallAtPrecision:") {
|
410
|
+
size_t semicolon = autotuneMetric.find(":", 18);
|
411
|
+
if (semicolon != std::string::npos) {
|
412
|
+
return metric_name::recallAtPrecisionLabel;
|
413
|
+
}
|
414
|
+
return metric_name::recallAtPrecision;
|
415
|
+
}
|
416
|
+
throw std::runtime_error("Unknown metric : " + autotuneMetric);
|
417
|
+
}
|
418
|
+
|
419
|
+
std::string Args::getAutotuneMetricLabel() const {
|
420
|
+
metric_name metric = getAutotuneMetric();
|
421
|
+
std::string label;
|
422
|
+
if (metric == metric_name::f1scoreLabel) {
|
423
|
+
label = autotuneMetric.substr(3);
|
424
|
+
} else if (
|
425
|
+
metric == metric_name::precisionAtRecallLabel ||
|
426
|
+
metric == metric_name::recallAtPrecisionLabel) {
|
427
|
+
size_t semicolon = autotuneMetric.find(":", 18);
|
428
|
+
label = autotuneMetric.substr(semicolon + 1);
|
429
|
+
} else {
|
430
|
+
return label;
|
431
|
+
}
|
432
|
+
|
433
|
+
if (label.empty()) {
|
434
|
+
throw std::runtime_error("Empty metric label : " + autotuneMetric);
|
435
|
+
}
|
436
|
+
return label;
|
437
|
+
}
|
438
|
+
|
439
|
+
double Args::getAutotuneMetricValue() const {
|
440
|
+
metric_name metric = getAutotuneMetric();
|
441
|
+
double value = 0.0;
|
442
|
+
if (metric == metric_name::precisionAtRecallLabel ||
|
443
|
+
metric == metric_name::precisionAtRecall ||
|
444
|
+
metric == metric_name::recallAtPrecisionLabel ||
|
445
|
+
metric == metric_name::recallAtPrecision) {
|
446
|
+
size_t firstSemicolon = 18; // semicolon position in "precisionAtRecall:"
|
447
|
+
size_t secondSemicolon = autotuneMetric.find(":", firstSemicolon);
|
448
|
+
const std::string valueStr =
|
449
|
+
autotuneMetric.substr(firstSemicolon, secondSemicolon - firstSemicolon);
|
450
|
+
value = std::stof(valueStr) / 100.0;
|
451
|
+
}
|
452
|
+
return value;
|
453
|
+
}
|
454
|
+
|
455
|
+
int64_t Args::getAutotuneModelSize() const {
|
456
|
+
std::string modelSize = autotuneModelSize;
|
457
|
+
if (modelSize.empty()) {
|
458
|
+
return Args::kUnlimitedModelSize;
|
459
|
+
}
|
460
|
+
std::unordered_map<char, int> units = {
|
461
|
+
{'k', 1000},
|
462
|
+
{'K', 1000},
|
463
|
+
{'m', 1000000},
|
464
|
+
{'M', 1000000},
|
465
|
+
{'g', 1000000000},
|
466
|
+
{'G', 1000000000},
|
467
|
+
};
|
468
|
+
uint64_t multiplier = 1;
|
469
|
+
char lastCharacter = modelSize.back();
|
470
|
+
if (units.count(lastCharacter)) {
|
471
|
+
multiplier = units[lastCharacter];
|
472
|
+
modelSize = modelSize.substr(0, modelSize.size() - 1);
|
473
|
+
}
|
474
|
+
uint64_t size = 0;
|
475
|
+
size_t nonNumericCharacter = 0;
|
476
|
+
bool parseError = false;
|
477
|
+
try {
|
478
|
+
size = std::stol(modelSize, &nonNumericCharacter);
|
479
|
+
} catch (std::invalid_argument&) {
|
480
|
+
parseError = true;
|
481
|
+
}
|
482
|
+
if (!parseError && nonNumericCharacter != modelSize.size()) {
|
483
|
+
parseError = true;
|
484
|
+
}
|
485
|
+
if (parseError) {
|
486
|
+
throw std::invalid_argument(
|
487
|
+
"Unable to parse model size " + autotuneModelSize);
|
488
|
+
}
|
489
|
+
|
490
|
+
return size * multiplier;
|
491
|
+
}
|
492
|
+
|
320
493
|
} // namespace fasttext
|
data/vendor/fastText/src/args.h
CHANGED
@@ -11,18 +11,28 @@
|
|
11
11
|
#include <istream>
|
12
12
|
#include <ostream>
|
13
13
|
#include <string>
|
14
|
+
#include <unordered_set>
|
14
15
|
#include <vector>
|
15
16
|
|
16
17
|
namespace fasttext {
|
17
18
|
|
18
19
|
enum class model_name : int { cbow = 1, sg, sup };
|
19
20
|
enum class loss_name : int { hs = 1, ns, softmax, ova };
|
21
|
+
enum class metric_name : int {
|
22
|
+
f1score = 1,
|
23
|
+
f1scoreLabel,
|
24
|
+
precisionAtRecall,
|
25
|
+
precisionAtRecallLabel,
|
26
|
+
recallAtPrecision,
|
27
|
+
recallAtPrecisionLabel
|
28
|
+
};
|
20
29
|
|
21
30
|
class Args {
|
22
31
|
protected:
|
23
|
-
std::string lossToString(loss_name) const;
|
24
32
|
std::string boolToString(bool) const;
|
25
33
|
std::string modelToString(model_name) const;
|
34
|
+
std::string metricToString(metric_name) const;
|
35
|
+
std::unordered_set<std::string> manualArgs_;
|
26
36
|
|
27
37
|
public:
|
28
38
|
Args();
|
@@ -48,6 +58,7 @@ class Args {
|
|
48
58
|
int verbose;
|
49
59
|
std::string pretrainedVectors;
|
50
60
|
bool saveOutput;
|
61
|
+
int seed;
|
51
62
|
|
52
63
|
bool qout;
|
53
64
|
bool retrain;
|
@@ -55,14 +66,31 @@ class Args {
|
|
55
66
|
size_t cutoff;
|
56
67
|
size_t dsub;
|
57
68
|
|
69
|
+
std::string autotuneValidationFile;
|
70
|
+
std::string autotuneMetric;
|
71
|
+
int autotunePredictions;
|
72
|
+
int autotuneDuration;
|
73
|
+
std::string autotuneModelSize;
|
74
|
+
|
58
75
|
void parseArgs(const std::vector<std::string>& args);
|
59
76
|
void printHelp();
|
60
77
|
void printBasicHelp();
|
61
78
|
void printDictionaryHelp();
|
62
79
|
void printTrainingHelp();
|
80
|
+
void printAutotuneHelp();
|
63
81
|
void printQuantizationHelp();
|
64
82
|
void save(std::ostream&);
|
65
83
|
void load(std::istream&);
|
66
84
|
void dump(std::ostream&) const;
|
85
|
+
bool hasAutotune() const;
|
86
|
+
bool isManual(const std::string& argName) const;
|
87
|
+
void setManual(const std::string& argName);
|
88
|
+
std::string lossToString(loss_name) const;
|
89
|
+
metric_name getAutotuneMetric() const;
|
90
|
+
std::string getAutotuneMetricLabel() const;
|
91
|
+
double getAutotuneMetricValue() const;
|
92
|
+
int64_t getAutotuneModelSize() const;
|
93
|
+
|
94
|
+
static constexpr double kUnlimitedModelSize = -1.0;
|
67
95
|
};
|
68
96
|
} // namespace fasttext
|