greek-conversion 1.0.0rc15__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.
Files changed (24) hide show
  1. greek_conversion-1.0.0rc15/LICENSE +21 -0
  2. greek_conversion-1.0.0rc15/PKG-INFO +293 -0
  3. greek_conversion-1.0.0rc15/README.md +262 -0
  4. greek_conversion-1.0.0rc15/pyproject.toml +85 -0
  5. greek_conversion-1.0.0rc15/setup.cfg +4 -0
  6. greek_conversion-1.0.0rc15/src/greek_conversion/__init__.py +602 -0
  7. greek_conversion-1.0.0rc15/src/greek_conversion/_bundle/greek_conversion.js +5 -0
  8. greek_conversion-1.0.0rc15/src/greek_conversion/_bundle/polyfills.js +42 -0
  9. greek_conversion-1.0.0rc15/src/greek_conversion/_engine.py +337 -0
  10. greek_conversion-1.0.0rc15/src/greek_conversion/_errors.py +108 -0
  11. greek_conversion-1.0.0rc15/src/greek_conversion/_keys.py +111 -0
  12. greek_conversion-1.0.0rc15/src/greek_conversion/_options.py +150 -0
  13. greek_conversion-1.0.0rc15/src/greek_conversion/_version.py +3 -0
  14. greek_conversion-1.0.0rc15/src/greek_conversion/py.typed +0 -0
  15. greek_conversion-1.0.0rc15/src/greek_conversion.egg-info/PKG-INFO +293 -0
  16. greek_conversion-1.0.0rc15/src/greek_conversion.egg-info/SOURCES.txt +22 -0
  17. greek_conversion-1.0.0rc15/src/greek_conversion.egg-info/dependency_links.txt +1 -0
  18. greek_conversion-1.0.0rc15/src/greek_conversion.egg-info/requires.txt +4 -0
  19. greek_conversion-1.0.0rc15/src/greek_conversion.egg-info/top_level.txt +1 -0
  20. greek_conversion-1.0.0rc15/tests/test_api.py +291 -0
  21. greek_conversion-1.0.0rc15/tests/test_keys.py +128 -0
  22. greek_conversion-1.0.0rc15/tests/test_processes.py +113 -0
  23. greek_conversion-1.0.0rc15/tests/test_readme.py +21 -0
  24. greek_conversion-1.0.0rc15/tests/test_typing.py +47 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021-2026 Antoine Boquet
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,293 @@
1
+ Metadata-Version: 2.4
2
+ Name: greek-conversion
3
+ Version: 1.0.0rc15
4
+ Summary: Convert Ancient, Byzantine, and Modern Greek between Greek script, Beta Code, and Latin script, with atomic options composed into standards-based presets, and information-loss diagnostics.
5
+ Author: Antoine Boquet
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://greek-conversion.humanites.fr/python/
8
+ Project-URL: Documentation, https://greek-conversion.humanites.fr/python/
9
+ Project-URL: Source, https://github.com/defense-humanites/greek-conversion
10
+ Project-URL: Issues, https://github.com/defense-humanites/greek-conversion/issues
11
+ Project-URL: Changelog, https://github.com/defense-humanites/greek-conversion/blob/main/CHANGELOG.md
12
+ Keywords: greek,ancient greek,byzantine greek,medieval greek,modern greek,polytonic,monotonic,beta code,betacode,transliteration,romanization,unicode,digital humanities,classics,ala-lc,bnf,iso843,elot743,sbl,tlg
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Natural Language :: Greek
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Topic :: Text Processing :: Linguistic
23
+ Classifier: Typing :: Typed
24
+ Requires-Python: >=3.11
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: quickjs-ng<1,>=0.18
28
+ Provides-Extra: v8
29
+ Requires-Dist: mini-racer>=0.12.2; extra == "v8"
30
+ Dynamic: license-file
31
+
32
+ <br>
33
+
34
+ <p align="center">
35
+ <img src="https://raw.githubusercontent.com/defense-humanites/greek-conversion/main/docs/assets/greek-conversion-logo-clair.svg" alt="greek conversion" width="240">
36
+ </p>
37
+
38
+ <p align="center">
39
+ <b>A Python library that converts Ancient, Byzantine, and Modern Greek
40
+ between Greek script, Beta Code, and Latin script, with atomic options
41
+ composed into standards-based presets, and information-loss
42
+ diagnostics.</b>
43
+ </p>
44
+
45
+ <p align="center">
46
+ <a href="https://pypi.org/project/greek-conversion/"><img src="https://img.shields.io/pypi/v/greek-conversion" alt="PyPI"></a>
47
+ <a href="https://github.com/defense-humanites/greek-conversion/actions/workflows/python.yml"><img src="https://github.com/defense-humanites/greek-conversion/actions/workflows/python.yml/badge.svg" alt="CI"></a>
48
+ <a href="https://github.com/defense-humanites/greek-conversion/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License: MIT"></a>
49
+ </p>
50
+
51
+ <p align="center">
52
+ <a href="https://greek-conversion.humanites.fr/python/"><b>Documentation</b></a> ·
53
+ <a href="https://greek-conversion.humanites.fr/playground/"><b>Playground</b></a>
54
+ </p>
55
+
56
+ <br>
57
+
58
+ `greek-conversion` is a Python library for everyone who moves Greek between
59
+ scripts:
60
+
61
+ - **Ancient Greek**: read polytonic Greek with every mark, digamma, koppa,
62
+ and sampi; transliterate an edition with its accents and length marks, or
63
+ after SBL, the BnF, ALA-LC, or ISO 843; read and write the Beta Code of
64
+ the TLG and Perseus.
65
+ - **Byzantine Greek**, under the same conventions: read the breathings
66
+ printed before capitals, the καί symbol, and alphabetic numerals; keep the
67
+ lunate sigma, the overline of the nomina sacra, and Byzantine punctuation;
68
+ romanize after ALA-LC, whose table runs to 1453.
69
+ - **Modern Greek**: transcribe names as passports and maps write them, after
70
+ ELOT 743, which the United Nations adopted and ISO 843 gives as its Type 2;
71
+ transliterate after ISO 843 Type 1, which converts back, or ALA-LC; turn
72
+ polytonic text into monotonic; build search keys and URL slugs.
73
+
74
+ Each convention is a preset: a set of the library's 52 atomic options, which
75
+ states its references and how far it follows them. The options also combine
76
+ beyond the presets, among 126 values: `transliteration={"chi": "kh",
77
+ "upsilon": "u"}` writes `ψυχή` as `psukhḗ`, and
78
+ `greek={"iota_subscript": "adscript"}` writes `τῷ` as `τῶι`. The ALA-LC,
79
+ BnF, and ISO 843 presets are tested against examples from their published
80
+ tables, and `iso-843-type-2` against every example of the BGN/PCGN table. When a conversion cannot be reversed, the
81
+ library says what was lost instead of quietly guessing. It converts whole
82
+ corpora in one call.
83
+
84
+ The package is the Python distribution of the TypeScript library of the same
85
+ name, and runs it: see [How the package works](#how-the-package-works).
86
+
87
+ **Not a developer?** The
88
+ [playground](https://greek-conversion.humanites.fr/playground/)
89
+ converts in the browser, with every preset and option, and shows what each
90
+ conversion loses.
91
+
92
+ ## Installation
93
+
94
+ ```sh
95
+ pip install greek-conversion
96
+ ```
97
+
98
+ The package requires Python 3.11 or later. It is typed: every option key
99
+ and value is known to editors and type checkers, which complete and check
100
+ them (`ConversionOptions`, `Preset`, `Format`).
101
+
102
+ ## Main functions
103
+
104
+ | You want to… | Use |
105
+ | ------------------------------------------------------------------------ | -------------------------------------------- |
106
+ | Convert a string | `convert(text, source, target, options)` |
107
+ | Convert many strings at once: the lines of a corpus, a column | `convert_many(texts, source, target, options)` |
108
+ | Normalize or restyle a string without changing its format | `reencode(text, format, options)` |
109
+ | …for many strings at once | `reencode_many(texts, format, options)` |
110
+ | Know whether the conversion loses information, and where each token went | `convert_detailed(text, source, target, options)` |
111
+ | …for many strings at once | `convert_detailed_many(texts, source, target, options)` |
112
+ | Convert only the Greek of a text in another language | `convert_greek_passages(text, target, options)` |
113
+ | Bind a preset, add characters, or restrict the repertoire | `create_converter(configuration)` |
114
+
115
+ Options are given as a mapping, as keyword arguments, or both.
116
+
117
+ ## Examples
118
+
119
+ ### `convert()`
120
+
121
+ `convert()` takes a string from one format to another, after a preset or
122
+ the options it is given:
123
+
124
+ ```python
125
+ >>> from greek_conversion import convert
126
+
127
+ >>> # The first words of the Odyssey, in the Beta Code of Perseus
128
+ >>> convert("ἄνδρα μοι ἔννεπε, μοῦσα", "greek", "beta-code")
129
+ 'a)/ndra moi e)/nnepe, mou=sa'
130
+
131
+ >>> # A Byzantine manuscript's ligature for ου
132
+ >>> convert("τȣ̃ θεȣ̃", "greek", "transliteration")
133
+ 'toũ theoũ'
134
+
135
+ >>> # A Modern Greek author, for a library record
136
+ >>> convert("Νίκος Καζαντζάκης", "greek", "transliteration", preset="ala-lc-modern")
137
+ 'Nikos Kazantzakēs'
138
+
139
+ >>> # A search key, without marks or capitals
140
+ >>> convert("Ἀριστοτέλης", "greek", "transliteration",
141
+ ... diacritics={"all": "remove"},
142
+ ... transliteration={"long_vowels": "omit"},
143
+ ... text={"letter_case": "lowercase"})
144
+ 'aristoteles'
145
+
146
+ ```
147
+
148
+ ### `convert_many()`
149
+
150
+ `convert_many()` converts a list of strings as `convert()` converts each,
151
+ in one call, which is much faster for a corpus; `reencode_many()` and
152
+ `convert_detailed_many()` do the same for `reencode()` and
153
+ `convert_detailed()`:
154
+
155
+ ```python
156
+ >>> from greek_conversion import convert_many
157
+
158
+ >>> convert_many(["μῆνιν ἄειδε", "Πηληϊάδεω Ἀχιλῆος"], "greek", "beta-code",
159
+ ... preset="tlg-core")
160
+ ['MH=NIN A)/EIDE', '*PHLHI+A/DEW *)AXILH=OS']
161
+
162
+ ```
163
+
164
+ ### `convert_detailed()`
165
+
166
+ `convert_detailed()` converts as `convert()` does, and says what the output
167
+ cannot carry back, and where:
168
+
169
+ ```python
170
+ >>> from greek_conversion import convert_detailed
171
+
172
+ >>> # ISO 843 Type 2, which Greek passports use, writes eta like iota
173
+ >>> city = convert_detailed("Θεσσαλονίκη", "greek", "transliteration",
174
+ ... preset="iso-843-type-2")
175
+ >>> city.output, city.lossy
176
+ ('Thessaloníki', True)
177
+ >>> city.losses[0].message, city.losses[0].offset
178
+ ('The target representation does not retain eta.', 10)
179
+
180
+ >>> # SBL's general style drops smooth breathings, accents, iota subscripts
181
+ >>> verse = convert_detailed("ἐν ἀρχῇ ἦν", "greek", "transliteration",
182
+ ... preset="sbl-general")
183
+ >>> verse.output, len(verse.losses)
184
+ ('en archē ēn', 6)
185
+
186
+ ```
187
+
188
+ ### `reencode()`
189
+
190
+ `reencode()` keeps the format and changes the spelling: it normalizes a
191
+ text, or writes it after other conventions:
192
+
193
+ ```python
194
+ >>> from greek_conversion import reencode
195
+
196
+ >>> # The lunate sigma of an edition, made standard
197
+ >>> reencode("ϲοφίαϲ", "greek", greek={"sigma": "standard"})
198
+ 'σοφίας'
199
+
200
+ >>> # Greek numerals, in figures
201
+ >>> reencode("ἔτει ͵αωκαʹ", "greek", text={"numerals": "decimal"})
202
+ 'ἔτει 1821'
203
+
204
+ >>> # The Beta Code of Perseus, in the capitals of the TLG
205
+ >>> reencode("a)/ndra moi e)/nnepe, mou=sa", "beta-code", preset="tlg-core")
206
+ 'A)/NDRA MOI E)/NNEPE, MOU=SA'
207
+
208
+ ```
209
+
210
+ ## How the package works
211
+
212
+ `greek-conversion` is first a TypeScript library, published on npm and JSR.
213
+ This package runs that library, the reference implementation, in a
214
+ JavaScript engine embedded in Python. It needs neither Node.js nor any other
215
+ installation:
216
+
217
+ - **The same results.** Outputs, losses, and positions are those of the
218
+ library of the same version. On every change, they are compared with the
219
+ library's own over more than a hundred thousand conversions.
220
+ - **The same versions.** The package's version is the library's (`1.0.0rc15`
221
+ for `1.0.0-rc.15`), followed by `.postN` for a fix of the Python package
222
+ alone, and the
223
+ [stability policy](https://greek-conversion.humanites.fr/python/reference/stability/#the-python-package)
224
+ applies to it as to the library.
225
+ - **The same documentation.** The
226
+ [Python documentation](https://greek-conversion.humanites.fr/python/) is
227
+ the library's, written in Python. In Python:
228
+ - functions and option keys are written in snake_case (`convert_detailed`,
229
+ `long_vowels`, `beta_code`, `out_of_scope_behavior`), as are the keys of
230
+ the options and metadata returned, and the option names in errors;
231
+ option values do not change (`"grave-circumflex"`, `"iso-843-type-2"`);
232
+ - positions (`offset`, `length`, `input_start`…) count characters as
233
+ Python does, so that `text[loss.offset : loss.offset + loss.length]` is
234
+ the token;
235
+ - results are frozen dataclasses; `OptionError` and `CharacterScopeError`
236
+ are `ValueError`s, with their details.
237
+ - **Prepared options and converters** (`prepare_options()`,
238
+ `create_converter()`) can be pickled and used in other processes, for
239
+ instance with `multiprocessing`.
240
+
241
+ ### Engines
242
+
243
+ The package runs the library in one of two engines:
244
+
245
+ | Engine | Installed with | Startup | Cost per call | Long text |
246
+ | --------- | ---------------------------------------- | ------- | ------------- | -------------- |
247
+ | QuickJS | the package: `quickjs-ng`, a 2 MB wheel | ~25 ms | ~40 µs | 10 to 20× Node |
248
+ | V8 | `pip install "greek-conversion[v8]"`: `mini-racer`, 22 MB | ~80 ms | 0.1 to 0.5 ms | ~1.7× Node |
249
+
250
+ [quickjs-ng](https://github.com/quickjs-ng/quickjs) is the maintained fork of
251
+ QuickJS: quick to start, and quick for many small calls. V8 is the engine of
252
+ Chrome and Node: quicker on long texts, slower to call. When `mini-racer` is
253
+ installed, the package uses V8; choose otherwise with
254
+ `set_engine("quickjs")` or the environment variable
255
+ `GREEK_CONVERSION_ENGINE`, for instance for many short strings converted
256
+ one by one. To convert a corpus, `convert_many()` pays the cost of a call
257
+ once for the whole list, as do `reencode_many()` and
258
+ `convert_detailed_many()`: with V8, they convert within twice the time of
259
+ Node, and 20 to 100 times faster than one call per string.
260
+
261
+ ## Documentation
262
+
263
+ - [Getting started](https://greek-conversion.humanites.fr/python/guide/getting-started/),
264
+ then the pages on
265
+ [Ancient](https://greek-conversion.humanites.fr/python/guide/ancient-greek/),
266
+ [Byzantine and Medieval](https://greek-conversion.humanites.fr/python/guide/byzantine-greek/),
267
+ and [Modern Greek](https://greek-conversion.humanites.fr/python/guide/modern-greek/).
268
+ - [Choosing a preset](https://greek-conversion.humanites.fr/python/guide/presets/):
269
+ what each convention writes, and what it loses.
270
+ - [Guarantees and limits](https://greek-conversion.humanites.fr/python/reference/guarantees/),
271
+ then the rest of the reference: the
272
+ [options](https://greek-conversion.humanites.fr/python/reference/options/),
273
+ [information loss](https://greek-conversion.humanites.fr/python/reference/information-loss/),
274
+ and the [API](https://greek-conversion.humanites.fr/python/reference/api/).
275
+ - [Contributing](https://github.com/defense-humanites/greek-conversion/blob/main/CONTRIBUTING.md):
276
+ the package lives in the `python/` folder of the repository, which
277
+ describes how to build and test it.
278
+
279
+ Every page of the site is also in Markdown, which
280
+ [`python/llms.txt`](https://greek-conversion.humanites.fr/python/llms.txt)
281
+ lists for the Python documentation.
282
+
283
+ ## Citing and license
284
+
285
+ If you use `greek-conversion` in research or in a published resource, please
286
+ cite it; GitHub's “Cite this repository” button uses the metadata in
287
+ [`CITATION.cff`](https://github.com/defense-humanites/greek-conversion/blob/main/CITATION.cff).
288
+
289
+ Copyright (C) 2021–2026 Antoine Boquet. Released under the
290
+ [MIT License](https://github.com/defense-humanites/greek-conversion/blob/main/LICENSE).
291
+ The greek-conversion logos are not covered by this license: all rights are
292
+ reserved, as recorded in
293
+ [`LicenseRef-greek-conversion-marks`](https://github.com/defense-humanites/greek-conversion/blob/main/LICENSES/LicenseRef-greek-conversion-marks.txt).
@@ -0,0 +1,262 @@
1
+ <br>
2
+
3
+ <p align="center">
4
+ <img src="https://raw.githubusercontent.com/defense-humanites/greek-conversion/main/docs/assets/greek-conversion-logo-clair.svg" alt="greek conversion" width="240">
5
+ </p>
6
+
7
+ <p align="center">
8
+ <b>A Python library that converts Ancient, Byzantine, and Modern Greek
9
+ between Greek script, Beta Code, and Latin script, with atomic options
10
+ composed into standards-based presets, and information-loss
11
+ diagnostics.</b>
12
+ </p>
13
+
14
+ <p align="center">
15
+ <a href="https://pypi.org/project/greek-conversion/"><img src="https://img.shields.io/pypi/v/greek-conversion" alt="PyPI"></a>
16
+ <a href="https://github.com/defense-humanites/greek-conversion/actions/workflows/python.yml"><img src="https://github.com/defense-humanites/greek-conversion/actions/workflows/python.yml/badge.svg" alt="CI"></a>
17
+ <a href="https://github.com/defense-humanites/greek-conversion/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License: MIT"></a>
18
+ </p>
19
+
20
+ <p align="center">
21
+ <a href="https://greek-conversion.humanites.fr/python/"><b>Documentation</b></a> ·
22
+ <a href="https://greek-conversion.humanites.fr/playground/"><b>Playground</b></a>
23
+ </p>
24
+
25
+ <br>
26
+
27
+ `greek-conversion` is a Python library for everyone who moves Greek between
28
+ scripts:
29
+
30
+ - **Ancient Greek**: read polytonic Greek with every mark, digamma, koppa,
31
+ and sampi; transliterate an edition with its accents and length marks, or
32
+ after SBL, the BnF, ALA-LC, or ISO 843; read and write the Beta Code of
33
+ the TLG and Perseus.
34
+ - **Byzantine Greek**, under the same conventions: read the breathings
35
+ printed before capitals, the καί symbol, and alphabetic numerals; keep the
36
+ lunate sigma, the overline of the nomina sacra, and Byzantine punctuation;
37
+ romanize after ALA-LC, whose table runs to 1453.
38
+ - **Modern Greek**: transcribe names as passports and maps write them, after
39
+ ELOT 743, which the United Nations adopted and ISO 843 gives as its Type 2;
40
+ transliterate after ISO 843 Type 1, which converts back, or ALA-LC; turn
41
+ polytonic text into monotonic; build search keys and URL slugs.
42
+
43
+ Each convention is a preset: a set of the library's 52 atomic options, which
44
+ states its references and how far it follows them. The options also combine
45
+ beyond the presets, among 126 values: `transliteration={"chi": "kh",
46
+ "upsilon": "u"}` writes `ψυχή` as `psukhḗ`, and
47
+ `greek={"iota_subscript": "adscript"}` writes `τῷ` as `τῶι`. The ALA-LC,
48
+ BnF, and ISO 843 presets are tested against examples from their published
49
+ tables, and `iso-843-type-2` against every example of the BGN/PCGN table. When a conversion cannot be reversed, the
50
+ library says what was lost instead of quietly guessing. It converts whole
51
+ corpora in one call.
52
+
53
+ The package is the Python distribution of the TypeScript library of the same
54
+ name, and runs it: see [How the package works](#how-the-package-works).
55
+
56
+ **Not a developer?** The
57
+ [playground](https://greek-conversion.humanites.fr/playground/)
58
+ converts in the browser, with every preset and option, and shows what each
59
+ conversion loses.
60
+
61
+ ## Installation
62
+
63
+ ```sh
64
+ pip install greek-conversion
65
+ ```
66
+
67
+ The package requires Python 3.11 or later. It is typed: every option key
68
+ and value is known to editors and type checkers, which complete and check
69
+ them (`ConversionOptions`, `Preset`, `Format`).
70
+
71
+ ## Main functions
72
+
73
+ | You want to… | Use |
74
+ | ------------------------------------------------------------------------ | -------------------------------------------- |
75
+ | Convert a string | `convert(text, source, target, options)` |
76
+ | Convert many strings at once: the lines of a corpus, a column | `convert_many(texts, source, target, options)` |
77
+ | Normalize or restyle a string without changing its format | `reencode(text, format, options)` |
78
+ | …for many strings at once | `reencode_many(texts, format, options)` |
79
+ | Know whether the conversion loses information, and where each token went | `convert_detailed(text, source, target, options)` |
80
+ | …for many strings at once | `convert_detailed_many(texts, source, target, options)` |
81
+ | Convert only the Greek of a text in another language | `convert_greek_passages(text, target, options)` |
82
+ | Bind a preset, add characters, or restrict the repertoire | `create_converter(configuration)` |
83
+
84
+ Options are given as a mapping, as keyword arguments, or both.
85
+
86
+ ## Examples
87
+
88
+ ### `convert()`
89
+
90
+ `convert()` takes a string from one format to another, after a preset or
91
+ the options it is given:
92
+
93
+ ```python
94
+ >>> from greek_conversion import convert
95
+
96
+ >>> # The first words of the Odyssey, in the Beta Code of Perseus
97
+ >>> convert("ἄνδρα μοι ἔννεπε, μοῦσα", "greek", "beta-code")
98
+ 'a)/ndra moi e)/nnepe, mou=sa'
99
+
100
+ >>> # A Byzantine manuscript's ligature for ου
101
+ >>> convert("τȣ̃ θεȣ̃", "greek", "transliteration")
102
+ 'toũ theoũ'
103
+
104
+ >>> # A Modern Greek author, for a library record
105
+ >>> convert("Νίκος Καζαντζάκης", "greek", "transliteration", preset="ala-lc-modern")
106
+ 'Nikos Kazantzakēs'
107
+
108
+ >>> # A search key, without marks or capitals
109
+ >>> convert("Ἀριστοτέλης", "greek", "transliteration",
110
+ ... diacritics={"all": "remove"},
111
+ ... transliteration={"long_vowels": "omit"},
112
+ ... text={"letter_case": "lowercase"})
113
+ 'aristoteles'
114
+
115
+ ```
116
+
117
+ ### `convert_many()`
118
+
119
+ `convert_many()` converts a list of strings as `convert()` converts each,
120
+ in one call, which is much faster for a corpus; `reencode_many()` and
121
+ `convert_detailed_many()` do the same for `reencode()` and
122
+ `convert_detailed()`:
123
+
124
+ ```python
125
+ >>> from greek_conversion import convert_many
126
+
127
+ >>> convert_many(["μῆνιν ἄειδε", "Πηληϊάδεω Ἀχιλῆος"], "greek", "beta-code",
128
+ ... preset="tlg-core")
129
+ ['MH=NIN A)/EIDE', '*PHLHI+A/DEW *)AXILH=OS']
130
+
131
+ ```
132
+
133
+ ### `convert_detailed()`
134
+
135
+ `convert_detailed()` converts as `convert()` does, and says what the output
136
+ cannot carry back, and where:
137
+
138
+ ```python
139
+ >>> from greek_conversion import convert_detailed
140
+
141
+ >>> # ISO 843 Type 2, which Greek passports use, writes eta like iota
142
+ >>> city = convert_detailed("Θεσσαλονίκη", "greek", "transliteration",
143
+ ... preset="iso-843-type-2")
144
+ >>> city.output, city.lossy
145
+ ('Thessaloníki', True)
146
+ >>> city.losses[0].message, city.losses[0].offset
147
+ ('The target representation does not retain eta.', 10)
148
+
149
+ >>> # SBL's general style drops smooth breathings, accents, iota subscripts
150
+ >>> verse = convert_detailed("ἐν ἀρχῇ ἦν", "greek", "transliteration",
151
+ ... preset="sbl-general")
152
+ >>> verse.output, len(verse.losses)
153
+ ('en archē ēn', 6)
154
+
155
+ ```
156
+
157
+ ### `reencode()`
158
+
159
+ `reencode()` keeps the format and changes the spelling: it normalizes a
160
+ text, or writes it after other conventions:
161
+
162
+ ```python
163
+ >>> from greek_conversion import reencode
164
+
165
+ >>> # The lunate sigma of an edition, made standard
166
+ >>> reencode("ϲοφίαϲ", "greek", greek={"sigma": "standard"})
167
+ 'σοφίας'
168
+
169
+ >>> # Greek numerals, in figures
170
+ >>> reencode("ἔτει ͵αωκαʹ", "greek", text={"numerals": "decimal"})
171
+ 'ἔτει 1821'
172
+
173
+ >>> # The Beta Code of Perseus, in the capitals of the TLG
174
+ >>> reencode("a)/ndra moi e)/nnepe, mou=sa", "beta-code", preset="tlg-core")
175
+ 'A)/NDRA MOI E)/NNEPE, MOU=SA'
176
+
177
+ ```
178
+
179
+ ## How the package works
180
+
181
+ `greek-conversion` is first a TypeScript library, published on npm and JSR.
182
+ This package runs that library, the reference implementation, in a
183
+ JavaScript engine embedded in Python. It needs neither Node.js nor any other
184
+ installation:
185
+
186
+ - **The same results.** Outputs, losses, and positions are those of the
187
+ library of the same version. On every change, they are compared with the
188
+ library's own over more than a hundred thousand conversions.
189
+ - **The same versions.** The package's version is the library's (`1.0.0rc15`
190
+ for `1.0.0-rc.15`), followed by `.postN` for a fix of the Python package
191
+ alone, and the
192
+ [stability policy](https://greek-conversion.humanites.fr/python/reference/stability/#the-python-package)
193
+ applies to it as to the library.
194
+ - **The same documentation.** The
195
+ [Python documentation](https://greek-conversion.humanites.fr/python/) is
196
+ the library's, written in Python. In Python:
197
+ - functions and option keys are written in snake_case (`convert_detailed`,
198
+ `long_vowels`, `beta_code`, `out_of_scope_behavior`), as are the keys of
199
+ the options and metadata returned, and the option names in errors;
200
+ option values do not change (`"grave-circumflex"`, `"iso-843-type-2"`);
201
+ - positions (`offset`, `length`, `input_start`…) count characters as
202
+ Python does, so that `text[loss.offset : loss.offset + loss.length]` is
203
+ the token;
204
+ - results are frozen dataclasses; `OptionError` and `CharacterScopeError`
205
+ are `ValueError`s, with their details.
206
+ - **Prepared options and converters** (`prepare_options()`,
207
+ `create_converter()`) can be pickled and used in other processes, for
208
+ instance with `multiprocessing`.
209
+
210
+ ### Engines
211
+
212
+ The package runs the library in one of two engines:
213
+
214
+ | Engine | Installed with | Startup | Cost per call | Long text |
215
+ | --------- | ---------------------------------------- | ------- | ------------- | -------------- |
216
+ | QuickJS | the package: `quickjs-ng`, a 2 MB wheel | ~25 ms | ~40 µs | 10 to 20× Node |
217
+ | V8 | `pip install "greek-conversion[v8]"`: `mini-racer`, 22 MB | ~80 ms | 0.1 to 0.5 ms | ~1.7× Node |
218
+
219
+ [quickjs-ng](https://github.com/quickjs-ng/quickjs) is the maintained fork of
220
+ QuickJS: quick to start, and quick for many small calls. V8 is the engine of
221
+ Chrome and Node: quicker on long texts, slower to call. When `mini-racer` is
222
+ installed, the package uses V8; choose otherwise with
223
+ `set_engine("quickjs")` or the environment variable
224
+ `GREEK_CONVERSION_ENGINE`, for instance for many short strings converted
225
+ one by one. To convert a corpus, `convert_many()` pays the cost of a call
226
+ once for the whole list, as do `reencode_many()` and
227
+ `convert_detailed_many()`: with V8, they convert within twice the time of
228
+ Node, and 20 to 100 times faster than one call per string.
229
+
230
+ ## Documentation
231
+
232
+ - [Getting started](https://greek-conversion.humanites.fr/python/guide/getting-started/),
233
+ then the pages on
234
+ [Ancient](https://greek-conversion.humanites.fr/python/guide/ancient-greek/),
235
+ [Byzantine and Medieval](https://greek-conversion.humanites.fr/python/guide/byzantine-greek/),
236
+ and [Modern Greek](https://greek-conversion.humanites.fr/python/guide/modern-greek/).
237
+ - [Choosing a preset](https://greek-conversion.humanites.fr/python/guide/presets/):
238
+ what each convention writes, and what it loses.
239
+ - [Guarantees and limits](https://greek-conversion.humanites.fr/python/reference/guarantees/),
240
+ then the rest of the reference: the
241
+ [options](https://greek-conversion.humanites.fr/python/reference/options/),
242
+ [information loss](https://greek-conversion.humanites.fr/python/reference/information-loss/),
243
+ and the [API](https://greek-conversion.humanites.fr/python/reference/api/).
244
+ - [Contributing](https://github.com/defense-humanites/greek-conversion/blob/main/CONTRIBUTING.md):
245
+ the package lives in the `python/` folder of the repository, which
246
+ describes how to build and test it.
247
+
248
+ Every page of the site is also in Markdown, which
249
+ [`python/llms.txt`](https://greek-conversion.humanites.fr/python/llms.txt)
250
+ lists for the Python documentation.
251
+
252
+ ## Citing and license
253
+
254
+ If you use `greek-conversion` in research or in a published resource, please
255
+ cite it; GitHub's “Cite this repository” button uses the metadata in
256
+ [`CITATION.cff`](https://github.com/defense-humanites/greek-conversion/blob/main/CITATION.cff).
257
+
258
+ Copyright (C) 2021–2026 Antoine Boquet. Released under the
259
+ [MIT License](https://github.com/defense-humanites/greek-conversion/blob/main/LICENSE).
260
+ The greek-conversion logos are not covered by this license: all rights are
261
+ reserved, as recorded in
262
+ [`LicenseRef-greek-conversion-marks`](https://github.com/defense-humanites/greek-conversion/blob/main/LICENSES/LicenseRef-greek-conversion-marks.txt).
@@ -0,0 +1,85 @@
1
+ [build-system]
2
+ # 77: `license` as an SPDX expression, and `license-files`.
3
+ requires = ["setuptools>=77"]
4
+ build-backend = "setuptools.build_meta"
5
+
6
+ [project]
7
+ name = "greek-conversion"
8
+ dynamic = ["version"]
9
+ description = "Convert Ancient, Byzantine, and Modern Greek between Greek script, Beta Code, and Latin script, with atomic options composed into standards-based presets, and information-loss diagnostics."
10
+ readme = "README.md"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [{ name = "Antoine Boquet" }]
14
+ requires-python = ">=3.11"
15
+ keywords = [
16
+ "greek",
17
+ "ancient greek",
18
+ "byzantine greek",
19
+ "medieval greek",
20
+ "modern greek",
21
+ "polytonic",
22
+ "monotonic",
23
+ "beta code",
24
+ "betacode",
25
+ "transliteration",
26
+ "romanization",
27
+ "unicode",
28
+ "digital humanities",
29
+ "classics",
30
+ "ala-lc",
31
+ "bnf",
32
+ "iso843",
33
+ "elot743",
34
+ "sbl",
35
+ "tlg",
36
+ ]
37
+ classifiers = [
38
+ "Intended Audience :: Science/Research",
39
+ "Intended Audience :: Developers",
40
+ "Natural Language :: Greek",
41
+ "Operating System :: OS Independent",
42
+ "Programming Language :: Python :: 3",
43
+ "Programming Language :: Python :: 3.11",
44
+ "Programming Language :: Python :: 3.12",
45
+ "Programming Language :: Python :: 3.13",
46
+ "Programming Language :: Python :: 3.14",
47
+ "Topic :: Text Processing :: Linguistic",
48
+ "Typing :: Typed",
49
+ ]
50
+ # QuickJS by default (quickjs-ng, the maintained fork of QuickJS): small
51
+ # abi3 wheels, a low cost per call. Its binding is a 0.x release: below 1, so
52
+ # that a breaking release does not reach users unchecked. V8 on request, for
53
+ # long texts and large batches; when installed, it is preferred.
54
+ dependencies = ["quickjs-ng>=0.18,<1"]
55
+
56
+ [project.optional-dependencies]
57
+ # 0.12.2: the first with `MiniRacer.close()`.
58
+ v8 = ["mini-racer>=0.12.2"]
59
+
60
+ [dependency-groups]
61
+ # ruff within a minor release: its default rules change between them.
62
+ test = ["pytest>=8", "ruff>=0.17,<0.18", "mypy>=1.13", "typing_extensions>=4.12"]
63
+
64
+ [project.urls]
65
+ Homepage = "https://greek-conversion.humanites.fr/python/"
66
+ Documentation = "https://greek-conversion.humanites.fr/python/"
67
+ Source = "https://github.com/defense-humanites/greek-conversion"
68
+ Issues = "https://github.com/defense-humanites/greek-conversion/issues"
69
+ Changelog = "https://github.com/defense-humanites/greek-conversion/blob/main/CHANGELOG.md"
70
+
71
+ [tool.setuptools.dynamic]
72
+ version = { attr = "greek_conversion._version.__version__" }
73
+
74
+ [tool.setuptools.packages.find]
75
+ where = ["src"]
76
+
77
+ [tool.setuptools.package-data]
78
+ greek_conversion = ["_bundle/*.js", "py.typed"]
79
+
80
+ [tool.pytest.ini_options]
81
+ testpaths = ["tests", "src"]
82
+ addopts = "--doctest-modules --import-mode=importlib"
83
+
84
+ [tool.ruff]
85
+ target-version = "py311"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+