Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/hotfixes' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
fit-alessandro-berti committed Mar 6, 2024
2 parents e83f918 + fe1d77e commit 8c44673
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RUN apt-get -y install libtool flex bison pkg-config g++ libssl-dev automake
RUN apt-get -y install libjemalloc-dev libboost-dev libboost-filesystem-dev libboost-system-dev libboost-regex-dev python3-dev autoconf flex bison cmake
RUN apt-get -y install libxml2-dev libxslt-dev libfreetype6-dev libsuitesparse-dev
RUN pip install -U wheel six pytest
RUN pip install colorama==0.4.6 contourpy==1.2.0 cycler==0.12.1 deprecation==2.1.0 fonttools==4.49.0 graphviz==0.20.1 intervaltree==3.1.0 kiwisolver==1.4.5 lxml==5.1.0 matplotlib==3.8.3 networkx==3.2.1 numpy==1.26.4 packaging==23.2 pandas==2.2.1 pillow==10.2.0 pydotplus==2.0.2 pyparsing==3.1.1 python-dateutil==2.9.0.post0 pytz==2024.1 scipy==1.12.0 six==1.16.0 sortedcontainers==2.4.0 StringDist==1.0.9 tqdm==4.66.2 tzdata==2024.1
RUN pip install colorama==0.4.6 contourpy==1.2.0 cycler==0.12.1 deprecation==2.1.0 fonttools==4.49.0 graphviz==0.20.1 intervaltree==3.1.0 kiwisolver==1.4.5 lxml==5.1.0 matplotlib==3.8.3 networkx==3.2.1 numpy==1.26.4 packaging==23.2 pandas==2.2.1 pillow==10.2.0 pydotplus==2.0.2 pyparsing==3.1.1 python-dateutil==2.9.0.post0 pytz==2024.1 scipy==1.12.0 six==1.16.0 sortedcontainers==2.4.0 tqdm==4.66.2 tzdata==2024.1

COPY . /app
RUN cd /app && python setup.py install
5 changes: 2 additions & 3 deletions pm4py/algo/label_splitting/variants/contextual.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
import pandas as pd
from enum import Enum
from pm4py.util import constants, xes_constants, exec_utils, pandas_utils, nx_utils
from pm4py.util import regex
import stringdist
from pm4py.util import regex, string_distance


class Parameters(Enum):
Expand Down Expand Up @@ -56,7 +55,7 @@ def __normalized_edit_distance(s1: str, s2: str) -> float:
"""
ned = 0
if len(s1) > 0 or len(s2) > 0:
ed = stringdist.levenshtein(s1, s2)
ed = string_distance.levenshtein(s1, s2)
ned = ed / max(len(s1), len(s2))
return ned

Expand Down
29 changes: 27 additions & 2 deletions pm4py/util/string_distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,36 @@
along with PM4Py. If not, see <https://www.gnu.org/licenses/>.
'''
import sys
import importlib.util
from typing import List, Union

import stringdist

levenshtein = lambda stru1, stru2: stringdist.levenshtein(stru1, stru2)
def levenshtein_distance(s1, s2):
if len(s1) < len(s2):
return levenshtein_distance(s2, s1)

if len(s2) == 0:
return len(s1)

previous_row = range(len(s2) + 1)
for i, c1 in enumerate(s1):
current_row = [i + 1]
for j, c2 in enumerate(s2):
insertions = previous_row[j + 1] + 1
deletions = current_row[j] + 1
substitutions = previous_row[j] + (c1 != c2)
current_row.append(min(insertions, deletions, substitutions))
previous_row = current_row

return previous_row[-1]


def levenshtein(stru1, stru2):
if importlib.util.find_spec("stringdist"):
import stringdist
return stringdist.levenshtein(stru1, stru2)

return levenshtein_distance(stru1, stru2)


def argmin_levenshtein(stru: str, list_stri: List[str]) -> Union[str, None]:
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ pandas
pydotplus
pytz
scipy
stringdist
tqdm
1 change: 0 additions & 1 deletion requirements_complete.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@ pytz
scipy
six
sortedcontainers
StringDist
tqdm
tzdata
1 change: 0 additions & 1 deletion requirements_stable.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@ pytz==2024.1
scipy==1.12.0
six==1.16.0
sortedcontainers==2.4.0
StringDist==1.0.9
tqdm==4.66.2
tzdata==2024.1
1 change: 0 additions & 1 deletion third_party/LICENSES_TRANSITIVE.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,5 @@ libraries are added/removed.
| scipy | https://pypi.org/project/scipy | BSD License | 1.12.0 |
| six | https://pypi.org/project/six | MIT License (MIT) | 1.16.0 |
| sortedcontainers | https://pypi.org/project/sortedcontainers | Apache Software License (Apache 2.0) | 2.4.0 |
| StringDist | https://pypi.org/project/StringDist | MIT License (MIT) | 1.0.9 |
| tqdm | https://pypi.org/project/tqdm | MIT License, Mozilla Public License 2.0 (MPL 2.0) (MPL-2.0 AND MIT) | 4.66.2 |
| tzdata | https://pypi.org/project/tzdata | Apache Software License (Apache-2.0) | 2024.1 |
21 changes: 0 additions & 21 deletions third_party/stringdist.LICENSE

This file was deleted.

0 comments on commit 8c44673

Please sign in to comment.