Skip to content

Commit

Permalink
Merge pull request #156 from mammothb/build/fix-dependency
Browse files Browse the repository at this point in the history
Build/fix dependency
  • Loading branch information
mammothb authored Aug 31, 2024
2 parents 8b45841 + d4645ec commit 7326ddd
Show file tree
Hide file tree
Showing 20 changed files with 1,785 additions and 1,772 deletions.
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# format all
b0abc5ed3a37b05848ca1e2de790321d7c07fd75
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.py eol=lf
27 changes: 14 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
requires = ["setuptools>=58.0.4", "wheel"]
build-backend = "setuptools.build_meta"

[tool.isort]
profile = "black"
[tool.basedpyright]
pythonVersion = "3.8"

[tool.pylint]
[tool.pylint.'MESSAGES CONTROL']
disable = [
"logging-fstring-interpolation",
"too-many-arguments",
"too-many-branches",
"too-many-instance-attributes",
"too-many-locals",
"too-many-nested-blocks",
"too-many-statements",
]
reportUnusedCallResult = "none"

[tool.ruff]
line-length = 88
indent-width = 4

[tool.ruff.format]
docstring-code-format = false
indent-style = "space"
line-ending = "auto"
quote-style = "double"
skip-magic-trailing-comma = false
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ editdistpy>=0.1.3
# For testing
coverage==7.4.4
importlib-resources>=6.3.2
numpy>=1.19.5
pytest==8.1.1
pytest-cov==4.1.0
52 changes: 26 additions & 26 deletions symspellpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
# MIT License
#
# Copyright (c) 2022 mmb L (Python port)
# Copyright (c) 2021 Wolf Garbe (Original C# implementation)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.

"""symspellpy
.. moduleauthor:: mmb L <[email protected]>
.. moduleauthor:: Wolf Garbe <[email protected]>
"""

__version__ = "6.7.7"

from . import editdistance, helpers, logging
from .symspellpy import SymSpell
from .verbosity import Verbosity
# MIT License
#
# Copyright (c) 2022 mmb L (Python port)
# Copyright (c) 2021 Wolf Garbe (Original C# implementation)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.

"""symspellpy
.. moduleauthor:: mmb L <[email protected]>
.. moduleauthor:: Wolf Garbe <[email protected]>
"""

__version__ = "6.7.7"

from . import editdistance, helpers, logging
from .symspellpy import SymSpell
from .verbosity import Verbosity
114 changes: 57 additions & 57 deletions symspellpy/composition.py
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
# MIT License
#
# Copyright (c) 2022 mmb L (Python port)
# Copyright (c) 2021 Wolf Garbe (Original C# implementation)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.

"""
.. module:: compostiion
:synopsis: Data class for :meth:`symspellpy.symspellpy.word_segmentation`.
"""

from typing import NamedTuple


class Composition(NamedTuple):
"""Used by :meth:`word_segmentation`.
Attributes:
segmented_string: The word segmented string.
corrected_string: The spelling corrected string.
distance_sum: The sum of edit distance between input string and
corrected string
log_prob_sum: The sum of word occurrence probabilities in log
scale (a measure of how common and probable the corrected
segmentation is).
"""

segmented_string: str = ""
corrected_string: str = ""
distance_sum: int = 0
log_prob_sum: float = 0

@classmethod
def create(
cls,
composition: "Composition",
segmented_part: str,
corrected_part: str,
distance: int,
log_prob: float,
) -> "Composition":
"""Creates a Composition by appending to an existing Composition."""
return cls(
composition.segmented_string + segmented_part,
composition.corrected_string + corrected_part,
composition.distance_sum + distance,
composition.log_prob_sum + log_prob,
)
# MIT License
#
# Copyright (c) 2022 mmb L (Python port)
# Copyright (c) 2021 Wolf Garbe (Original C# implementation)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.

"""
.. module:: compostiion
:synopsis: Data class for :meth:`symspellpy.symspellpy.word_segmentation`.
"""

from typing import NamedTuple


class Composition(NamedTuple):
"""Used by :meth:`word_segmentation`.
Attributes:
segmented_string: The word segmented string.
corrected_string: The spelling corrected string.
distance_sum: The sum of edit distance between input string and
corrected string
log_prob_sum: The sum of word occurrence probabilities in log
scale (a measure of how common and probable the corrected
segmentation is).
"""

segmented_string: str = ""
corrected_string: str = ""
distance_sum: int = 0
log_prob_sum: float = 0

@classmethod
def create(
cls,
composition: "Composition",
segmented_part: str,
corrected_part: str,
distance: int,
log_prob: float,
) -> "Composition":
"""Creates a Composition by appending to an existing Composition."""
return cls(
composition.segmented_string + segmented_part,
composition.corrected_string + corrected_part,
composition.distance_sum + distance,
composition.log_prob_sum + log_prob,
)
Loading

0 comments on commit 7326ddd

Please sign in to comment.