Skip to content

Commit d658c43

Browse files
danieldkDaniël de Kok
authored andcommitted
Add similarity unit tests
1 parent 85a1650 commit d658c43

File tree

3 files changed

+72
-2
lines changed

3 files changed

+72
-2
lines changed

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,22 @@ install:
2424
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
2525
python3 -m venv venv
2626
source venv/bin/activate
27-
pip install cffi virtualenv
27+
pip install cffi virtualenv pytest
2828
fi
2929
- |
3030
if [ "$TRAVIS_OS_NAME" == "linux" ]; then
3131
python3.6 -m venv venv
3232
source venv/bin/activate
33-
pip install cffi virtualenv
33+
pip install cffi virtualenv pytest
3434
fi
3535
- cargo install pyo3-pack --vers 0.5.0
3636
- rustup default nightly-2019-02-07
3737
- rustup component add rustfmt
3838

3939
script:
4040
- cargo fmt --all -- --check
41+
- pyo3-pack develop
42+
- pytest
4143
- pyo3-pack build --release
4244
deploy:
4345
provider: releases

tests/similarity.fifu

16.6 KB
Binary file not shown.

tests/test_similarity.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import finalfusion
2+
3+
SIMILARITY_ORDER_STUTTGART_10 = [
4+
"Karlsruhe",
5+
"Mannheim",
6+
"München",
7+
"Darmstadt",
8+
"Heidelberg",
9+
"Wiesbaden",
10+
"Kassel",
11+
"Düsseldorf",
12+
"Leipzig",
13+
"Berlin",
14+
];
15+
16+
17+
SIMILARITY_ORDER = [
18+
"Potsdam",
19+
"Hamburg",
20+
"Leipzig",
21+
"Dresden",
22+
"München",
23+
"Düsseldorf",
24+
"Bonn",
25+
"Stuttgart",
26+
"Weimar",
27+
"Berlin-Charlottenburg",
28+
"Rostock",
29+
"Karlsruhe",
30+
"Chemnitz",
31+
"Breslau",
32+
"Wiesbaden",
33+
"Hannover",
34+
"Mannheim",
35+
"Kassel",
36+
"Köln",
37+
"Danzig",
38+
"Erfurt",
39+
"Dessau",
40+
"Bremen",
41+
"Charlottenburg",
42+
"Magdeburg",
43+
"Neuruppin",
44+
"Darmstadt",
45+
"Jena",
46+
"Wien",
47+
"Heidelberg",
48+
"Dortmund",
49+
"Stettin",
50+
"Schwerin",
51+
"Neubrandenburg",
52+
"Greifswald",
53+
"Göttingen",
54+
"Braunschweig",
55+
"Berliner",
56+
"Warschau",
57+
"Berlin-Spandau",
58+
];
59+
60+
def test_similarity_berlin_40():
61+
embeds = finalfusion.Embeddings('tests/similarity.fifu')
62+
for idx, sim in enumerate(embeds.similarity("Berlin", 40)):
63+
assert SIMILARITY_ORDER[idx] == sim.word
64+
65+
def test_similarity_stuttgart_10():
66+
embeds = finalfusion.Embeddings('tests/similarity.fifu')
67+
for idx, sim in enumerate(embeds.similarity("Stuttgart", 10)):
68+
assert SIMILARITY_ORDER_STUTTGART_10[idx] == sim.word

0 commit comments

Comments
 (0)