forked from slack0/fastText.py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
125 lines (98 loc) · 4.14 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
all: install test
test: test-skipgram test-cbow test-classifier
buildext:
python setup.py build_ext --inplace
.PHONY: buildext
install:
pip install -r requirements.txt
python setup.py install
.PHONY: install
# Install the pandoc(1) first to run this command
# sudo apt-get install pandoc
README.rst: README.md
pandoc --from=markdown --to=rst --output=README.rst README.md
upload: README.rst
python setup.py sdist upload
upload-to-pypitest: README.rst
python setup.py sdist upload -r pypitest
.PHONY: upload-to-pypitest
install-from-pypitest::
pip install -U --no-cache-dir -i https://testpypi.python.org/pypi fasttext
.PHONY: install-from-pypitest
install-dev: README.rst
python setup.py develop
.PHONY: install-dev
pre-test:
# Remove generated file from test
rm -f test/*.vec test/*.bin test/*_result.txt
.PHONY: pre-test
fasttext/cpp/fasttext:
rm -f fasttext/cpp/fasttext
make --directory fasttext/cpp/
# Test for skipgram model
# Redirect stdout to /dev/null to prevent exceed the log limit size from
# Travis CI
test/skipgram_params_test.bin:
./fasttext/cpp/fasttext skipgram -input test/params_test.txt -output \
test/skipgram_params_test -lr 0.025 -dim 100 -ws 5 -epoch 1 \
-minCount 1 -neg 5 -loss ns -bucket 2000000 -minn 3 -maxn 6 \
-thread 4 -lrUpdateRate 100 -t 1e-4 >> /dev/null
# Generate default value of skipgram command from fasttext(1)
test/skipgram_default_params_result.txt:
$(MAKE) skipgram_default_params_result.txt --directory test/
test-skipgram: pre-test fasttext/cpp/fasttext test/skipgram_params_test.bin \
test/skipgram_default_params_result.txt
python test/skipgram_test.py --verbose
# Test for cbow model
# Redirect stdout to /dev/null to prevent exceed the log limit size from
# Travis CI
test/cbow_params_test.bin:
./fasttext/cpp/fasttext cbow -input test/params_test.txt -output \
test/cbow_params_test -lr 0.005 -dim 50 -ws 5 -epoch 1 \
-minCount 1 -neg 5 -loss ns -bucket 2000000 -minn 3 -maxn 6 \
-thread 4 -lrUpdateRate 100 -t 1e-4 >> /dev/null
# Generate default value of cbow command from fasttext(1)
test/cbow_default_params_result.txt:
$(MAKE) cbow_default_params_result.txt --directory test/
test-cbow: pre-test fasttext/cpp/fasttext test/cbow_params_test.bin \
test/cbow_default_params_result.txt
python test/cbow_test.py --verbose
# Test for classifier
test/dbpedia.train: test/download_dbpedia.sh
sh test/download_dbpedia.sh # Download & normalize training file
# Redirect stdout to /dev/null to prevent exceed the log limit size from
# Travis CI
test/classifier.bin: test/dbpedia.train
./fasttext/cpp/fasttext supervised -input test/dbpedia.train \
-output test/classifier -dim 100 -lr 0.1 -wordNgrams 2 \
-minCount 1 -bucket 2000000 -epoch 5 -thread 4 >> /dev/null
test/classifier_test_result.txt: test/classifier.bin
./fasttext/cpp/fasttext test test/classifier.bin \
test/classifier_test.txt > test/classifier_test_result.txt
test/classifier_pred_result.txt: test/classifier.bin
./fasttext/cpp/fasttext predict test/classifier.bin \
test/classifier_pred_test.txt > \
test/classifier_pred_result.txt
test/classifier_pred_k_result.txt: test/classifier.bin
./fasttext/cpp/fasttext predict test/classifier.bin \
test/classifier_pred_test.txt 5 > \
test/classifier_pred_k_result.txt
test/classifier_pred_prob_result.txt: test/classifier.bin
./fasttext/cpp/fasttext predict-prob test/classifier.bin \
test/classifier_pred_test.txt > \
test/classifier_pred_prob_result.txt
test/classifier_pred_prob_k_result.txt: test/classifier.bin
./fasttext/cpp/fasttext predict-prob test/classifier.bin \
test/classifier_pred_test.txt 5 > \
test/classifier_pred_prob_k_result.txt
# Generate default value of classifier command from fasttext(1)
test/classifier_default_params_result.txt:
$(MAKE) classifier_default_params_result.txt --directory test/
test-classifier: pre-test fasttext/cpp/fasttext test/classifier.bin \
test/classifier_test_result.txt \
test/classifier_pred_result.txt \
test/classifier_pred_k_result.txt \
test/classifier_pred_prob_result.txt \
test/classifier_pred_prob_k_result.txt \
test/classifier_default_params_result.txt
python test/classifier_test.py --verbose