-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathDiceCoefficient.test.ts
71 lines (70 loc) · 1.42 KB
/
DiceCoefficient.test.ts
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
import * as assert from 'assert'
import Cosine from '../src/core/packages/Cosine'
const cosine = new Cosine()
describe('test Cosine Similarity', () => {
describe('similarity()', () => {
const testData = [
{
first: 'french',
second: 'quebec',
expected: 0.3651483716701107,
},
{
first: 'france',
second: 'france',
expected: 1,
},
{
first: 'healed',
second: 'sealed',
expected: 0.7999999999999998,
},
{
first: 'web applications',
second: 'applications of the web',
expected: 0.9258200997725515,
},
{
first: 'a',
second: 'a',
expected: 1,
},
{
first: 'a',
second: 'b',
expected: 0,
},
{
first: '',
second: '',
expected: 1,
},
{
first: 'a',
second: '',
expected: 0,
},
{
first: '',
second: 'a',
expected: 0,
},
{
first: 'apple event',
second: 'apple event',
expected: 1,
},
{
first: 'ab',
second: 'ba',
expected: 0.9999999999999998,
},
]
testData.forEach((td) => {
it(`should be ${td.expected}`, () => {
assert.equal(cosine.similarity(td.first, td.second), td.expected)
})
})
})
describe('sortMatch()', () => {})
})