Skip to content

Commit

Permalink
add support for autojunk
Browse files Browse the repository at this point in the history
  • Loading branch information
maxbachmann committed Sep 9, 2021
1 parent b1d2e7f commit 3ba4135
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 73 deletions.
3 changes: 3 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Changelog

### v0.15.0
* Update SequenceMatcher interface to support the autojunk parameter

### v0.14.0
* Drop Python 2 support
* Fixed free of non heap object due caused by zero offset on a heap object
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
author = 'Max Bachmann'

# The full version, including alpha/beta/rc tags
release = '0.14.0'
release = '0.15.0'

# -- General configuration ---------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = Levenshtein
version = 0.14.0
version = 0.15.0
url = https://github.com/maxbachmann/Levenshtein
author = Max Bachmann
author_email = [email protected]
Expand Down
60 changes: 0 additions & 60 deletions src/Levenshtein-c/_levenshtein.c
Original file line number Diff line number Diff line change
Expand Up @@ -4171,29 +4171,6 @@ lev_opcodes_matching_blocks(size_t len1,
return mblocks;
}

/**
* lev_editops_total_cost:
* @n: Tne size of @ops.
* @ops: An array of elementary edit operations.
*
* Computes the total cost of operations in @ops.
*
* The costs of elementary operations are all 1.
*
* Returns: The total cost.
**/
size_t
lev_editops_total_cost(size_t n,
const LevEditOp *ops)
{
size_t i, sum = 0;

for (i = n; i; i--, ops++)
sum += !!ops->type;

return sum;
}

/**
* lev_editops_normalize:
* @n: The size of @ops.
Expand Down Expand Up @@ -4241,42 +4218,6 @@ lev_editops_normalize(size_t n,
return opsnorm;
}

/**
* lev_opcodes_total_cost:
* @nb: Tne size of @bops.
* @bops: An array of difflib block operation codes.
*
* Computes the total cost of operations in @bops.
*
* The costs of elementary operations are all 1.
*
* Returns: The total cost.
**/
size_t
lev_opcodes_total_cost(size_t nb,
const LevOpCode *bops)
{
size_t i, sum = 0;

for (i = nb; i; i--, bops++) {
switch (bops->type) {
case LEV_EDIT_REPLACE:
case LEV_EDIT_DELETE:
sum += (bops->send - bops->sbeg);
break;

case LEV_EDIT_INSERT:
sum += (bops->dend - bops->dbeg);
break;

default:
break;
}
}

return sum;
}

/**
* lev_editops_subtract:
* @n: The size of @ops.
Expand Down Expand Up @@ -4321,7 +4262,6 @@ lev_editops_subtract(size_t n,
return NULL;
nr -= nn;


/* subtract */
/* we could simply return NULL when nr == 0, but then it would be possible
* to subtract *any* sequence of the right length to get an empty sequence
Expand Down
8 changes: 0 additions & 8 deletions src/Levenshtein-c/_levenshtein.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,6 @@ lev_editops_to_opcodes(size_t n,
size_t len1,
size_t len2);

size_t
lev_editops_total_cost(size_t n,
const LevEditOp *ops);

size_t
lev_opcodes_total_cost(size_t nb,
const LevOpCode *bops);

LevEditOp*
lev_editops_normalize(size_t n,
const LevEditOp *ops,
Expand Down
2 changes: 1 addition & 1 deletion src/Levenshtein/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

__author__ = "Max Bachmann"
__license__ = "GPL"
__version__ = "0.14.0"
__version__ = "0.15.0"

from rapidfuzz import string_metric as _string_metric

Expand Down
2 changes: 0 additions & 2 deletions src/_levenshtein.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ static PyObject* quickmedian_py(PyObject *self, PyObject *args);
static PyObject* setmedian_py(PyObject *self, PyObject *args);
static PyObject* seqratio_py(PyObject *self, PyObject *args);
static PyObject* setratio_py(PyObject *self, PyObject *args);
static PyObject* apply_edit_py(PyObject *self, PyObject *args);
static PyObject* subtract_edit_py(PyObject *self, PyObject *args);

#define Levenshtein_DESC \
"A C extension module for fast computation of:\n" \
Expand Down

0 comments on commit 3ba4135

Please sign in to comment.