mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-15 14:17:58 +03:00
16 lines
404 B
Cython
16 lines
404 B
Cython
|
# cython: profile=True, binding=True, infer_types=True
|
||
|
from cpython.object cimport PyObject
|
||
|
from libc.stdint cimport int64_t
|
||
|
|
||
|
from typing import Optional
|
||
|
|
||
|
|
||
|
cdef extern from "polyleven.c":
|
||
|
int64_t polyleven(PyObject *o1, PyObject *o2, int64_t k)
|
||
|
|
||
|
|
||
|
cpdef int64_t levenshtein(a: str, b: str, k: Optional[int] = None):
|
||
|
if k is None:
|
||
|
k = -1
|
||
|
return polyleven(<PyObject*>a, <PyObject*>b, k)
|