File: test_jaro.py

package info (click to toggle)
textdistance 4.6.3-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 448 kB
  • sloc: python: 2,728; sh: 4; makefile: 3
file content (31 lines) | stat: -rw-r--r-- 843 bytes parent folder | download | duplicates (3)
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
# built-in
from math import isclose

# external
import pytest

# project
import textdistance


ALG = textdistance.JaroWinkler


@pytest.mark.parametrize('left, right, expected', [
    ('hello', 'haloa', 0.7333333333333334),
    ('fly', 'ant', 0.0),
    ('frog', 'fog', 0.9166666666666666),
    ('ATCG', 'TAGC', 0.8333333333333334),
    ('MARTHA', 'MARHTA', 0.944444444),
    ('DWAYNE', 'DUANE', 0.822222222),
    ('DIXON', 'DICKSONX', 0.7666666666666666),

    # https://github.com/life4/textdistance/issues/41
    ('Sint-Pietersplein 6, 9000 Gent', 'Test 10, 1010 Brussel', 0.5182539682539683),
])
def test_distance(left, right, expected):
    actual = ALG(winklerize=False, external=False)(left, right)
    assert isclose(actual, expected)

    actual = ALG(winklerize=False, external=True)(left, right)
    assert isclose(actual, expected)