text-converters 0.2.1__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-2026 Nikos Paximadakis
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,222 @@
1
+ Metadata-Version: 2.4
2
+ Name: text_converters
3
+ Version: 0.2.1
4
+ Summary: Convert Greek, Swedish, German, French and Spanish letters to plain Latin equivalents
5
+ Author: Nikos Paximadakis
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/Nikolaos-Paximadakis/text-converters
8
+ Project-URL: Repository, https://github.com/Nikolaos-Paximadakis/text-converters
9
+ Project-URL: Issues, https://github.com/Nikolaos-Paximadakis/text-converters/issues
10
+ Project-URL: Changelog, https://github.com/Nikolaos-Paximadakis/text-converters/blob/main/CHANGELOG.md
11
+ Keywords: transliteration,greek,elot-743,diacritics,ascii,unicode
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Programming Language :: Python :: 3.15
22
+ Classifier: Topic :: Text Processing :: Linguistic
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Classifier: Typing :: Typed
25
+ Requires-Python: >=3.11
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Provides-Extra: dev
29
+ Requires-Dist: pytest>=8; extra == "dev"
30
+ Requires-Dist: pytest-cov; extra == "dev"
31
+ Requires-Dist: ruff; extra == "dev"
32
+ Requires-Dist: mypy; extra == "dev"
33
+ Requires-Dist: pyright==1.1.414; extra == "dev"
34
+ Dynamic: license-file
35
+
36
+ # Text Converters
37
+
38
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
39
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
40
+ [![Status: Beta](https://img.shields.io/badge/Status-Beta-orange.svg)](https://github.com/Nikolaos-Paximadakis/text-converters)
41
+
42
+ Small, dependency-free Python functions that replace Greek letters and accented
43
+ Swedish, German, French and Spanish letters with plain Latin (mostly ASCII)
44
+ equivalents, using one fixed character map per language.
45
+
46
+ ## Scope and limitations
47
+
48
+ Released under the MIT License and provided "as is", without warranty of any kind.
49
+ Each converter is a simple character-by-character lookup. Known limits:
50
+
51
+ - **Greek** is close to ELOT 743 for single letters, but it is not a full
52
+ implementation of ELOT 743 or ISO 843. `η` → `i` (`Θεσσαλονίκη` → `Thessaloniki`),
53
+ `ου` → `ou` (`Παπαδόπουλος` → `Papadopoulos`), and `Θ`, `Χ`, `Ψ` give `Th`, `Ch`,
54
+ `Ps`, or `TH`, `CH`, `PS` inside an all-capitals word (`ΑΘΗΝΑ` → `ATHINA`).
55
+ - Other Greek letter pairs that ELOT 743 treats specially (`αυ`, `ευ`, `μπ`, `ντ`,
56
+ `γγ`, ...) are converted letter by letter (`Ευρώ` → `Eyro`, `Μπαμπάς` → `Mpampas`).
57
+ - **German** writes umlauts as `ae`/`oe`/`ue` and `ß` as `ss`. The other converters
58
+ simply drop the accent (Swedish `ä` → `a`).
59
+ - **French** writes the ligatures `œ` and `æ` as `oe` and `ae`; like the German
60
+ umlauts, their capitals become `Oe` and `Ae` even in an all-capitals word.
61
+ - Characters missing from a language's map are returned unchanged, so the output is
62
+ not guaranteed to be ASCII (for example `¿`, `€` or Cyrillic letters).
63
+ - Conversion is one-way and loses information.
64
+
65
+ ## Installation
66
+
67
+ ```bash
68
+ pip install text-converters
69
+ ```
70
+
71
+ Or the latest development version from GitHub:
72
+
73
+ ```bash
74
+ pip install git+https://github.com/Nikolaos-Paximadakis/text-converters.git
75
+ ```
76
+
77
+ For development:
78
+
79
+ ```bash
80
+ git clone https://github.com/Nikolaos-Paximadakis/text-converters.git
81
+ cd text-converters
82
+ pip install -e ".[dev]"
83
+ ```
84
+
85
+ ## Usage
86
+
87
+ ### Basic Usage
88
+
89
+ ```python
90
+ from text_converters import convert_greek_characters_to_english
91
+
92
+ # Convert Greek text to English
93
+ greek_text = "Αθήνα"
94
+ english_text = convert_greek_characters_to_english(greek_text)
95
+ print(english_text) # Output: "Athina"
96
+ ```
97
+
98
+ ### Using the Character Converter Dictionary
99
+
100
+ ```python
101
+ from text_converters import CHARACTER_CONVERTERS
102
+
103
+ # Get a specific converter
104
+ greek_converter = CHARACTER_CONVERTERS["greek"]
105
+ result = greek_converter("Γεια σας") # "Geia sas"
106
+
107
+ # Available converters
108
+ print(CHARACTER_CONVERTERS.keys())
109
+ # dict_keys(['greek', 'swedish', 'german', 'french', 'spanish', 'none'])
110
+ ```
111
+
112
+ ### Using the Getter Function
113
+
114
+ ```python
115
+ from text_converters import get_character_converter
116
+
117
+ # Get a converter by language name
118
+ converter = get_character_converter("greek")
119
+ result = converter("Καλησπέρα") # "Kalispera"
120
+
121
+ # Handle unsupported languages
122
+ try:
123
+ converter = get_character_converter("unsupported")
124
+ except ValueError as e:
125
+ print(e) # "Unsupported language 'unsupported'. Available: greek, swedish, german, french, spanish, none"
126
+ ```
127
+
128
+ ### Multiple Language Support
129
+
130
+ ```python
131
+ from text_converters import (
132
+ convert_greek_characters_to_english,
133
+ convert_german_characters_to_english,
134
+ convert_french_characters_to_english,
135
+ )
136
+
137
+ # Greek
138
+ greek_result = convert_greek_characters_to_english("Γεια σας") # "Geia sas"
139
+
140
+ # German
141
+ german_result = convert_german_characters_to_english("Grüße") # "Gruesse"
142
+
143
+ # French
144
+ french_result = convert_french_characters_to_english("Bonjour") # "Bonjour"
145
+ ```
146
+
147
+ ## Supported Languages
148
+
149
+ | Language | Function | Example |
150
+ |----------|----------|---------|
151
+ | Greek | `convert_greek_characters_to_english` | "Αθήνα" → "Athina" |
152
+ | Swedish | `convert_swedish_characters_to_english` | "Göteborg" → "Goteborg" |
153
+ | German | `convert_german_characters_to_english` | "Grüße" → "Gruesse" |
154
+ | French | `convert_french_characters_to_english` | "Café" → "Cafe" |
155
+ | Spanish | `convert_spanish_characters_to_english` | "España" → "Espana" |
156
+ | None | `no_conversion` | "Hello" → "Hello" |
157
+
158
+ ## API Reference
159
+
160
+ ### Functions
161
+
162
+ #### `convert_greek_characters_to_english(text: str) -> str`
163
+ Convert Greek characters to English equivalents.
164
+
165
+ **Parameters:**
166
+ - `text` (str): Text containing Greek characters
167
+
168
+ **Returns:**
169
+ - `str`: Text with Greek characters converted to English equivalents
170
+
171
+ #### `get_character_converter(language: str = "none")`
172
+ Get a character converter function by language name.
173
+
174
+ **Parameters:**
175
+ - `language` (str): Language name ('greek', 'swedish', 'german', 'french', 'spanish', 'none')
176
+
177
+ **Returns:**
178
+ - Function: Character converter function
179
+
180
+ **Raises:**
181
+ - `ValueError`: If language is not supported
182
+
183
+ ### Constants
184
+
185
+ #### `CHARACTER_CONVERTERS`
186
+ Dictionary mapping language names to their respective converter functions.
187
+
188
+ ## Development
189
+
190
+ ### Running Tests
191
+
192
+ ```bash
193
+ pip install -e ".[dev]"
194
+ pytest
195
+ ```
196
+
197
+ ### Lint, Format and Type Checks
198
+
199
+ ```bash
200
+ ruff check .
201
+ ruff format --check .
202
+ mypy
203
+ pyright
204
+ ```
205
+
206
+ ## License
207
+
208
+ MIT License. See [LICENSE](https://github.com/Nikolaos-Paximadakis/text-converters/blob/main/LICENSE).
209
+
210
+ ## Contributing
211
+
212
+ When adding new language converters:
213
+
214
+ 1. Add the conversion function following the existing pattern
215
+ 2. Add the function to the `CHARACTER_CONVERTERS` dictionary
216
+ 3. Update the `__all__` list in `__init__.py`
217
+ 4. Add tests for the new converter
218
+ 5. Update this README with examples
219
+
220
+ ## Changes
221
+
222
+ See the [changelog](https://github.com/Nikolaos-Paximadakis/text-converters/blob/main/CHANGELOG.md).
@@ -0,0 +1,187 @@
1
+ # Text Converters
2
+
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
5
+ [![Status: Beta](https://img.shields.io/badge/Status-Beta-orange.svg)](https://github.com/Nikolaos-Paximadakis/text-converters)
6
+
7
+ Small, dependency-free Python functions that replace Greek letters and accented
8
+ Swedish, German, French and Spanish letters with plain Latin (mostly ASCII)
9
+ equivalents, using one fixed character map per language.
10
+
11
+ ## Scope and limitations
12
+
13
+ Released under the MIT License and provided "as is", without warranty of any kind.
14
+ Each converter is a simple character-by-character lookup. Known limits:
15
+
16
+ - **Greek** is close to ELOT 743 for single letters, but it is not a full
17
+ implementation of ELOT 743 or ISO 843. `η` → `i` (`Θεσσαλονίκη` → `Thessaloniki`),
18
+ `ου` → `ou` (`Παπαδόπουλος` → `Papadopoulos`), and `Θ`, `Χ`, `Ψ` give `Th`, `Ch`,
19
+ `Ps`, or `TH`, `CH`, `PS` inside an all-capitals word (`ΑΘΗΝΑ` → `ATHINA`).
20
+ - Other Greek letter pairs that ELOT 743 treats specially (`αυ`, `ευ`, `μπ`, `ντ`,
21
+ `γγ`, ...) are converted letter by letter (`Ευρώ` → `Eyro`, `Μπαμπάς` → `Mpampas`).
22
+ - **German** writes umlauts as `ae`/`oe`/`ue` and `ß` as `ss`. The other converters
23
+ simply drop the accent (Swedish `ä` → `a`).
24
+ - **French** writes the ligatures `œ` and `æ` as `oe` and `ae`; like the German
25
+ umlauts, their capitals become `Oe` and `Ae` even in an all-capitals word.
26
+ - Characters missing from a language's map are returned unchanged, so the output is
27
+ not guaranteed to be ASCII (for example `¿`, `€` or Cyrillic letters).
28
+ - Conversion is one-way and loses information.
29
+
30
+ ## Installation
31
+
32
+ ```bash
33
+ pip install text-converters
34
+ ```
35
+
36
+ Or the latest development version from GitHub:
37
+
38
+ ```bash
39
+ pip install git+https://github.com/Nikolaos-Paximadakis/text-converters.git
40
+ ```
41
+
42
+ For development:
43
+
44
+ ```bash
45
+ git clone https://github.com/Nikolaos-Paximadakis/text-converters.git
46
+ cd text-converters
47
+ pip install -e ".[dev]"
48
+ ```
49
+
50
+ ## Usage
51
+
52
+ ### Basic Usage
53
+
54
+ ```python
55
+ from text_converters import convert_greek_characters_to_english
56
+
57
+ # Convert Greek text to English
58
+ greek_text = "Αθήνα"
59
+ english_text = convert_greek_characters_to_english(greek_text)
60
+ print(english_text) # Output: "Athina"
61
+ ```
62
+
63
+ ### Using the Character Converter Dictionary
64
+
65
+ ```python
66
+ from text_converters import CHARACTER_CONVERTERS
67
+
68
+ # Get a specific converter
69
+ greek_converter = CHARACTER_CONVERTERS["greek"]
70
+ result = greek_converter("Γεια σας") # "Geia sas"
71
+
72
+ # Available converters
73
+ print(CHARACTER_CONVERTERS.keys())
74
+ # dict_keys(['greek', 'swedish', 'german', 'french', 'spanish', 'none'])
75
+ ```
76
+
77
+ ### Using the Getter Function
78
+
79
+ ```python
80
+ from text_converters import get_character_converter
81
+
82
+ # Get a converter by language name
83
+ converter = get_character_converter("greek")
84
+ result = converter("Καλησπέρα") # "Kalispera"
85
+
86
+ # Handle unsupported languages
87
+ try:
88
+ converter = get_character_converter("unsupported")
89
+ except ValueError as e:
90
+ print(e) # "Unsupported language 'unsupported'. Available: greek, swedish, german, french, spanish, none"
91
+ ```
92
+
93
+ ### Multiple Language Support
94
+
95
+ ```python
96
+ from text_converters import (
97
+ convert_greek_characters_to_english,
98
+ convert_german_characters_to_english,
99
+ convert_french_characters_to_english,
100
+ )
101
+
102
+ # Greek
103
+ greek_result = convert_greek_characters_to_english("Γεια σας") # "Geia sas"
104
+
105
+ # German
106
+ german_result = convert_german_characters_to_english("Grüße") # "Gruesse"
107
+
108
+ # French
109
+ french_result = convert_french_characters_to_english("Bonjour") # "Bonjour"
110
+ ```
111
+
112
+ ## Supported Languages
113
+
114
+ | Language | Function | Example |
115
+ |----------|----------|---------|
116
+ | Greek | `convert_greek_characters_to_english` | "Αθήνα" → "Athina" |
117
+ | Swedish | `convert_swedish_characters_to_english` | "Göteborg" → "Goteborg" |
118
+ | German | `convert_german_characters_to_english` | "Grüße" → "Gruesse" |
119
+ | French | `convert_french_characters_to_english` | "Café" → "Cafe" |
120
+ | Spanish | `convert_spanish_characters_to_english` | "España" → "Espana" |
121
+ | None | `no_conversion` | "Hello" → "Hello" |
122
+
123
+ ## API Reference
124
+
125
+ ### Functions
126
+
127
+ #### `convert_greek_characters_to_english(text: str) -> str`
128
+ Convert Greek characters to English equivalents.
129
+
130
+ **Parameters:**
131
+ - `text` (str): Text containing Greek characters
132
+
133
+ **Returns:**
134
+ - `str`: Text with Greek characters converted to English equivalents
135
+
136
+ #### `get_character_converter(language: str = "none")`
137
+ Get a character converter function by language name.
138
+
139
+ **Parameters:**
140
+ - `language` (str): Language name ('greek', 'swedish', 'german', 'french', 'spanish', 'none')
141
+
142
+ **Returns:**
143
+ - Function: Character converter function
144
+
145
+ **Raises:**
146
+ - `ValueError`: If language is not supported
147
+
148
+ ### Constants
149
+
150
+ #### `CHARACTER_CONVERTERS`
151
+ Dictionary mapping language names to their respective converter functions.
152
+
153
+ ## Development
154
+
155
+ ### Running Tests
156
+
157
+ ```bash
158
+ pip install -e ".[dev]"
159
+ pytest
160
+ ```
161
+
162
+ ### Lint, Format and Type Checks
163
+
164
+ ```bash
165
+ ruff check .
166
+ ruff format --check .
167
+ mypy
168
+ pyright
169
+ ```
170
+
171
+ ## License
172
+
173
+ MIT License. See [LICENSE](https://github.com/Nikolaos-Paximadakis/text-converters/blob/main/LICENSE).
174
+
175
+ ## Contributing
176
+
177
+ When adding new language converters:
178
+
179
+ 1. Add the conversion function following the existing pattern
180
+ 2. Add the function to the `CHARACTER_CONVERTERS` dictionary
181
+ 3. Update the `__all__` list in `__init__.py`
182
+ 4. Add tests for the new converter
183
+ 5. Update this README with examples
184
+
185
+ ## Changes
186
+
187
+ See the [changelog](https://github.com/Nikolaos-Paximadakis/text-converters/blob/main/CHANGELOG.md).
@@ -0,0 +1,100 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "text_converters"
7
+ version = "0.2.1"
8
+ authors = [
9
+ {name = "Nikos Paximadakis"},
10
+ ]
11
+ description = "Convert Greek, Swedish, German, French and Spanish letters to plain Latin equivalents"
12
+ readme = "README.md"
13
+ license = "MIT"
14
+ license-files = ["LICENSE"]
15
+ requires-python = ">=3.11"
16
+ keywords = ["transliteration", "greek", "elot-743", "diacritics", "ascii", "unicode"]
17
+ classifiers = [
18
+ "Development Status :: 4 - Beta",
19
+ "Intended Audience :: Developers",
20
+ "Operating System :: OS Independent",
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: Python :: 3 :: Only",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Programming Language :: Python :: 3.13",
26
+ "Programming Language :: Python :: 3.14",
27
+ "Programming Language :: Python :: 3.15",
28
+ "Topic :: Text Processing :: Linguistic",
29
+ "Topic :: Software Development :: Libraries :: Python Modules",
30
+ "Typing :: Typed",
31
+ ]
32
+ dependencies = []
33
+
34
+ [project.urls]
35
+ Homepage = "https://github.com/Nikolaos-Paximadakis/text-converters"
36
+ Repository = "https://github.com/Nikolaos-Paximadakis/text-converters"
37
+ Issues = "https://github.com/Nikolaos-Paximadakis/text-converters/issues"
38
+ Changelog = "https://github.com/Nikolaos-Paximadakis/text-converters/blob/main/CHANGELOG.md"
39
+
40
+ [project.optional-dependencies]
41
+ dev = [
42
+ "pytest>=8",
43
+ "pytest-cov",
44
+ "ruff",
45
+ "mypy",
46
+ "pyright==1.1.414",
47
+ ]
48
+
49
+ [tool.setuptools.packages.find]
50
+ where = ["."]
51
+ include = ["text_converters*"]
52
+
53
+ [tool.setuptools.package-data]
54
+ text_converters = ["py.typed"]
55
+
56
+ [tool.ruff]
57
+ target-version = "py311"
58
+ extend-exclude = ["*.md"] # README examples are documentation, not code to reformat
59
+
60
+ [tool.ruff.lint]
61
+ select = [
62
+ "E4", "E7", "E9", "F", # syntax, undefined names, unused imports
63
+ "B", # bugbear: mutable defaults, zip strict, loop closures
64
+ "S", # security, incl. assert used as a guard
65
+ "DTZ", # naive datetimes
66
+ "RUF", "SIM", "PERF", # correctness-adjacent idioms; RUF100 prunes stale noqa
67
+ "I", "UP", # import order, modern syntax
68
+ "T20", "ERA", # stray prints, commented-out code
69
+ "PTH", # pathlib
70
+ "FBT", # boolean positional arguments
71
+ ]
72
+ # Not selected on purpose: ANN (the type checkers cover it), PL and C90 (style and
73
+ # complexity counts, not defects), E501 (long explanatory comments are fine).
74
+
75
+ [tool.ruff.lint.per-file-ignores]
76
+ # Greek letters that look like Latin ones are the point of this package.
77
+ "text_converters/character_converters.py" = ["RUF001", "RUF002", "RUF003"]
78
+ # pytest asserts and parametrized flags; Greek test input.
79
+ "tests/**" = ["S101", "FBT", "RUF001", "RUF002", "RUF003"]
80
+ # A command-line check: its output is the result.
81
+ "scripts/**" = ["T201"]
82
+
83
+ [tool.mypy]
84
+ python_version = "3.11"
85
+ strict = true
86
+ files = ["text_converters", "tests", "scripts"]
87
+
88
+ [tool.pyright]
89
+ include = ["text_converters", "tests", "scripts"]
90
+ pythonVersion = "3.11"
91
+ typeCheckingMode = "strict"
92
+ enableTypeIgnoreComments = false # an ignore must name its rule: # pyright: ignore[rule]
93
+ reportUnnecessaryTypeIgnoreComment = "error"
94
+
95
+ [tool.pytest.ini_options]
96
+ minversion = "8.0"
97
+ testpaths = ["tests"]
98
+ addopts = ["--strict-markers", "--strict-config", "-ra"]
99
+ filterwarnings = ["error"]
100
+ xfail_strict = true
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+