strip-marks 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- strip_marks-1.0.0/LICENSE +20 -0
- strip_marks-1.0.0/PKG-INFO +55 -0
- strip_marks-1.0.0/README.md +43 -0
- strip_marks-1.0.0/pyproject.toml +48 -0
- strip_marks-1.0.0/setup.cfg +4 -0
- strip_marks-1.0.0/src/strip_marks/__init__.py +1 -0
- strip_marks-1.0.0/src/strip_marks/strip_marks.py +20 -0
- strip_marks-1.0.0/src/strip_marks.egg-info/PKG-INFO +55 -0
- strip_marks-1.0.0/src/strip_marks.egg-info/SOURCES.txt +10 -0
- strip_marks-1.0.0/src/strip_marks.egg-info/dependency_links.txt +1 -0
- strip_marks-1.0.0/src/strip_marks.egg-info/requires.txt +1 -0
- strip_marks-1.0.0/src/strip_marks.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright 2025 Jake W. Ireland <jakewilliami@icloud.com>
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: strip-marks
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Small Python library to strip non-spacing marks (e.g., diacritics) from a string
|
|
5
|
+
Author-email: "Jake W. Ireland" <jakewilliami@icloud.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: <4.0.0,>=3.11
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: ispunct>=1.0.0
|
|
11
|
+
Dynamic: license-file
|
|
12
|
+
|
|
13
|
+
# `strip_marks`
|
|
14
|
+
|
|
15
|
+
A small Python library for stripping non-spacing marks (e.g., diacritics; accents) from a string.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
from strip_marks import strip_marks
|
|
23
|
+
|
|
24
|
+
assert strip_marks("şéàşöñ") == "season"
|
|
25
|
+
assert strip_marks("kaderdenkesişenyollarinhikayesi.xyz") == "kaderdenkesisenyollarinhikayesi.xyz"
|
|
26
|
+
|
|
27
|
+
def identity(x): return x
|
|
28
|
+
assert strip_marks("hello world") == identity("hello world")
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Using `strip_marks` as a Library
|
|
32
|
+
|
|
33
|
+
This package is published on PyPI. You can install it with PIP:
|
|
34
|
+
|
|
35
|
+
```commandline
|
|
36
|
+
$ pip add strip_marks
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Or, if using [UV](https://github.com/astral-sh/uv/) for dependency management:
|
|
40
|
+
|
|
41
|
+
```commandline
|
|
42
|
+
$ uv add strip-marks
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Notes on Internal Functionality
|
|
46
|
+
|
|
47
|
+
This library also implements (and uses internally) functions adapted from the `utf8proc` C library to handle characters of multiple codepoints. We also use bitwise functionality from our sister package, [`ispunct`](https://github.com/jakewilliami/ispunct-py).
|
|
48
|
+
|
|
49
|
+
## Alternative Libraries
|
|
50
|
+
|
|
51
|
+
This was written mostly as a proof of concept. A more developed library with this functionality is [`unidecode`](https://pypi.org/project/Unidecode/). A curious reader may also be interested in [`unihandecode`/`pykakasi`](https://pypi.org/project/pykakasi/) or [`text-unidecode`](https://pypi.org/project/text-unidecode/).
|
|
52
|
+
|
|
53
|
+
## Citation
|
|
54
|
+
|
|
55
|
+
If your research depends on `strip_marks`, please consider giving us a formal citation: [`citation.bib`](./citation.bib).
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# `strip_marks`
|
|
2
|
+
|
|
3
|
+
A small Python library for stripping non-spacing marks (e.g., diacritics; accents) from a string.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Quick Start
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
from strip_marks import strip_marks
|
|
11
|
+
|
|
12
|
+
assert strip_marks("şéàşöñ") == "season"
|
|
13
|
+
assert strip_marks("kaderdenkesişenyollarinhikayesi.xyz") == "kaderdenkesisenyollarinhikayesi.xyz"
|
|
14
|
+
|
|
15
|
+
def identity(x): return x
|
|
16
|
+
assert strip_marks("hello world") == identity("hello world")
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Using `strip_marks` as a Library
|
|
20
|
+
|
|
21
|
+
This package is published on PyPI. You can install it with PIP:
|
|
22
|
+
|
|
23
|
+
```commandline
|
|
24
|
+
$ pip add strip_marks
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Or, if using [UV](https://github.com/astral-sh/uv/) for dependency management:
|
|
28
|
+
|
|
29
|
+
```commandline
|
|
30
|
+
$ uv add strip-marks
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Notes on Internal Functionality
|
|
34
|
+
|
|
35
|
+
This library also implements (and uses internally) functions adapted from the `utf8proc` C library to handle characters of multiple codepoints. We also use bitwise functionality from our sister package, [`ispunct`](https://github.com/jakewilliami/ispunct-py).
|
|
36
|
+
|
|
37
|
+
## Alternative Libraries
|
|
38
|
+
|
|
39
|
+
This was written mostly as a proof of concept. A more developed library with this functionality is [`unidecode`](https://pypi.org/project/Unidecode/). A curious reader may also be interested in [`unihandecode`/`pykakasi`](https://pypi.org/project/pykakasi/) or [`text-unidecode`](https://pypi.org/project/text-unidecode/).
|
|
40
|
+
|
|
41
|
+
## Citation
|
|
42
|
+
|
|
43
|
+
If your research depends on `strip_marks`, please consider giving us a formal citation: [`citation.bib`](./citation.bib).
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "strip-marks"
|
|
3
|
+
version = "1.0.0"
|
|
4
|
+
description = "Small Python library to strip non-spacing marks (e.g., diacritics) from a string"
|
|
5
|
+
authors = [
|
|
6
|
+
{ name = "Jake W. Ireland", email = "jakewilliami@icloud.com" },
|
|
7
|
+
]
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
requires-python = ">=3.11, <4.0.0"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
dependencies = [
|
|
12
|
+
"ispunct>=1.0.0",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
[dependency-groups]
|
|
16
|
+
dev = [
|
|
17
|
+
"pip-audit>=2.9.0",
|
|
18
|
+
"pre-commit>=4.3.0",
|
|
19
|
+
"pytest==8.3.4",
|
|
20
|
+
"ruff>=0.12.8",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[tool.uv.sources]
|
|
24
|
+
ispunct = { git = "https://github.com/jakewilliami/ispunct-py", tag = "v1.0.0" }
|
|
25
|
+
|
|
26
|
+
[tool.pytest.ini_options]
|
|
27
|
+
pythonpath = "src"
|
|
28
|
+
|
|
29
|
+
[tool.ruff]
|
|
30
|
+
# https://peps.python.org/pep-0008/#maximum-line-length
|
|
31
|
+
line-length = 80
|
|
32
|
+
|
|
33
|
+
[tool.ruff.lint]
|
|
34
|
+
select = [
|
|
35
|
+
"E", # pycodestyle
|
|
36
|
+
"F", # Pyflakes
|
|
37
|
+
"UP", # pyupgrade
|
|
38
|
+
"B", # flake8-bugbear
|
|
39
|
+
"SIM", # flake8-simplify
|
|
40
|
+
"I", # isort
|
|
41
|
+
]
|
|
42
|
+
ignore = [
|
|
43
|
+
# "B008", # docs.astral.sh/ruff/rules/function-call-in-default-argument/
|
|
44
|
+
]
|
|
45
|
+
fixable = ["ALL"]
|
|
46
|
+
|
|
47
|
+
[tool.ruff.lint.per-file-ignores]
|
|
48
|
+
"__init__.py" = ["F401"] # Unused imports
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from strip_marks.strip_marks import strip_marks
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import unicodedata
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def strip_marks(s: str) -> str:
|
|
5
|
+
"""
|
|
6
|
+
Strip non-spacing marks (e.g., accents) from input string.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
# Base case: return input string is only made up of combining characters
|
|
10
|
+
if all(unicodedata.combining(c) for c in s):
|
|
11
|
+
return s
|
|
12
|
+
|
|
13
|
+
# Step 1: decompose input into normal form
|
|
14
|
+
s_norm = unicodedata.normalize("NFD", s)
|
|
15
|
+
|
|
16
|
+
# Step 2: keep only base characters
|
|
17
|
+
s_base = ''.join(ch for ch in s_norm if not unicodedata.combining(ch))
|
|
18
|
+
|
|
19
|
+
# Step 3: re-compose normalised form without base characters
|
|
20
|
+
return unicodedata.normalize("NFC", s_base)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: strip-marks
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Small Python library to strip non-spacing marks (e.g., diacritics) from a string
|
|
5
|
+
Author-email: "Jake W. Ireland" <jakewilliami@icloud.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: <4.0.0,>=3.11
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: ispunct>=1.0.0
|
|
11
|
+
Dynamic: license-file
|
|
12
|
+
|
|
13
|
+
# `strip_marks`
|
|
14
|
+
|
|
15
|
+
A small Python library for stripping non-spacing marks (e.g., diacritics; accents) from a string.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
from strip_marks import strip_marks
|
|
23
|
+
|
|
24
|
+
assert strip_marks("şéàşöñ") == "season"
|
|
25
|
+
assert strip_marks("kaderdenkesişenyollarinhikayesi.xyz") == "kaderdenkesisenyollarinhikayesi.xyz"
|
|
26
|
+
|
|
27
|
+
def identity(x): return x
|
|
28
|
+
assert strip_marks("hello world") == identity("hello world")
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Using `strip_marks` as a Library
|
|
32
|
+
|
|
33
|
+
This package is published on PyPI. You can install it with PIP:
|
|
34
|
+
|
|
35
|
+
```commandline
|
|
36
|
+
$ pip add strip_marks
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Or, if using [UV](https://github.com/astral-sh/uv/) for dependency management:
|
|
40
|
+
|
|
41
|
+
```commandline
|
|
42
|
+
$ uv add strip-marks
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Notes on Internal Functionality
|
|
46
|
+
|
|
47
|
+
This library also implements (and uses internally) functions adapted from the `utf8proc` C library to handle characters of multiple codepoints. We also use bitwise functionality from our sister package, [`ispunct`](https://github.com/jakewilliami/ispunct-py).
|
|
48
|
+
|
|
49
|
+
## Alternative Libraries
|
|
50
|
+
|
|
51
|
+
This was written mostly as a proof of concept. A more developed library with this functionality is [`unidecode`](https://pypi.org/project/Unidecode/). A curious reader may also be interested in [`unihandecode`/`pykakasi`](https://pypi.org/project/pykakasi/) or [`text-unidecode`](https://pypi.org/project/text-unidecode/).
|
|
52
|
+
|
|
53
|
+
## Citation
|
|
54
|
+
|
|
55
|
+
If your research depends on `strip_marks`, please consider giving us a formal citation: [`citation.bib`](./citation.bib).
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/strip_marks/__init__.py
|
|
5
|
+
src/strip_marks/strip_marks.py
|
|
6
|
+
src/strip_marks.egg-info/PKG-INFO
|
|
7
|
+
src/strip_marks.egg-info/SOURCES.txt
|
|
8
|
+
src/strip_marks.egg-info/dependency_links.txt
|
|
9
|
+
src/strip_marks.egg-info/requires.txt
|
|
10
|
+
src/strip_marks.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ispunct>=1.0.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
strip_marks
|