syllabify 0.1.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.
- syllabify-0.1.0/LICENSE +7 -0
- syllabify-0.1.0/PKG-INFO +101 -0
- syllabify-0.1.0/README.md +77 -0
- syllabify-0.1.0/pyproject.toml +73 -0
- syllabify-0.1.0/syllabify/CMU_dictionary/cmudict.0.7a +133388 -0
- syllabify-0.1.0/syllabify/CMU_dictionary/cmudict.0.7a.phones +39 -0
- syllabify-0.1.0/syllabify/CMU_dictionary/cmudict.0.7a.symbols +84 -0
- syllabify-0.1.0/syllabify/__init__.py +42 -0
- syllabify-0.1.0/syllabify/cli.py +24 -0
- syllabify-0.1.0/syllabify/cmu_parser.py +159 -0
- syllabify-0.1.0/syllabify/phoneme_types.py +46 -0
- syllabify-0.1.0/syllabify/syllable.py +381 -0
- syllabify-0.1.0/syllabify/syllable_types.py +315 -0
syllabify-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2025 Fong-Chun Tsai
|
|
2
|
+
|
|
3
|
+
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:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
syllabify-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: syllabify
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Automatically convert plain text into phonemes (US English pronunciation) and syllabify
|
|
5
|
+
License: MIT
|
|
6
|
+
Keywords: phonetics,syllabification,linguistics,cmu,pronunciation
|
|
7
|
+
Author: Fong-Chun Tsai
|
|
8
|
+
Author-email: eoleedimin@gmail.com
|
|
9
|
+
Requires-Python: >=3.9
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Science/Research
|
|
12
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
13
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Project-URL: Homepage, https://github.com/eoleedi/syllabify
|
|
21
|
+
Project-URL: Repository, https://github.com/eoleedi/syllabify
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# Syllabify
|
|
25
|
+
|
|
26
|
+
Automatically convert plain text into phonemes (US English pronunciation) and syllabify.
|
|
27
|
+
|
|
28
|
+
Modified from [the repository](https://github.com/cainesap/syllabify) set up by Andrew Caines with some key changes, itemised below:
|
|
29
|
+
|
|
30
|
+
- Environment management using Poetry
|
|
31
|
+
- Python 3.9+ compatibility
|
|
32
|
+
- Easy to access class and function interfaces
|
|
33
|
+
|
|
34
|
+
## Set up
|
|
35
|
+
|
|
36
|
+
Requires [Python 3](https://www.python.org/downloads) (Anthony Evans used Python 2: if that's what you prefer, see his repo).
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install syllabify
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Usage
|
|
43
|
+
|
|
44
|
+
### Package interface
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from syllabify import generate
|
|
48
|
+
|
|
49
|
+
syllable = generate("linguistics")
|
|
50
|
+
print(syllable)
|
|
51
|
+
|
|
52
|
+
# Output:
|
|
53
|
+
# [Syllable(onset=L , nucleus=IH [st:0 ln:short], coda=NG ),
|
|
54
|
+
# Syllable(onset=G W , nucleus=IH [st:1 ln:short], coda=empty),
|
|
55
|
+
# Syllable(onset=S T , nucleus=IH [st:0 ln:short], coda=K S )
|
|
56
|
+
# ]
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
You can get the onset, nucleus, and coda of each syllable:
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from syllabify import generate
|
|
63
|
+
|
|
64
|
+
syllable = generate("linguistics")
|
|
65
|
+
print(f"Onset: {syllable.get_onset()}")
|
|
66
|
+
print(f"Nucleus: {syllable.get_nucleus()}")
|
|
67
|
+
print(f"Coda: {syllable.get_coda()}")
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
### Command line interface
|
|
73
|
+
|
|
74
|
+
One word at a time:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
python3 syllable3.py linguistics
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Or several (space-separated):
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
python3 syllable3.py colourless green ideas
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Output
|
|
87
|
+
|
|
88
|
+
If the input word is found in the dictionary, a phonemic, syllabified transcript is returned. For example, for the word _linguistics_:
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
{onset: L , nucleus: IH [st:0 ln:short], coda: NG }
|
|
92
|
+
{onset: G W , nucleus: IH [st:1 ln:short], coda: empty}
|
|
93
|
+
{onset: S T , nucleus: IH [st:0 ln:short], coda: K S }
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
There's one syllable per line. Each syllable is made up of an 'onset', 'nucleus', and 'coda'. Phonemes are space-separated and capitalized in [ARPAbet](http://en.wikipedia.org/wiki/ARPABET) format. In line with phonological theory, the nucleus must have content, whereas the onset and coda may be empty. Within the vocalic content of the nucleus there's also an indication whether the syllable is stressed ('st':0 or 1), and whether the length ('ln') is short or long.
|
|
97
|
+
|
|
98
|
+
## CMU Pronouncing Dictionary
|
|
99
|
+
|
|
100
|
+
`Syllabify` depends on the [CMU Pronouncing Dictionary](http://www.speech.cs.cmu.edu/cgi-bin/cmudict) of North American English word pronunciations. Version 0.7b was the current one at time of writing, but it throws a UnicodeDecodeError, so we're still using version 0.7a (amended to remove erroneous 'G' from SUGGEST and related words). Please see the dictionary download website to obtain the current version, add the `cmudict-N.nx(.phones|.symbols)*` files to the `CMU_dictionary` directory, remove the '.txt' suffixes, and update the line `VERSION = 'cmudict-n.nx'` in `cmu_parser.py`
|
|
101
|
+
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Syllabify
|
|
2
|
+
|
|
3
|
+
Automatically convert plain text into phonemes (US English pronunciation) and syllabify.
|
|
4
|
+
|
|
5
|
+
Modified from [the repository](https://github.com/cainesap/syllabify) set up by Andrew Caines with some key changes, itemised below:
|
|
6
|
+
|
|
7
|
+
- Environment management using Poetry
|
|
8
|
+
- Python 3.9+ compatibility
|
|
9
|
+
- Easy to access class and function interfaces
|
|
10
|
+
|
|
11
|
+
## Set up
|
|
12
|
+
|
|
13
|
+
Requires [Python 3](https://www.python.org/downloads) (Anthony Evans used Python 2: if that's what you prefer, see his repo).
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install syllabify
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
### Package interface
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
from syllabify import generate
|
|
25
|
+
|
|
26
|
+
syllable = generate("linguistics")
|
|
27
|
+
print(syllable)
|
|
28
|
+
|
|
29
|
+
# Output:
|
|
30
|
+
# [Syllable(onset=L , nucleus=IH [st:0 ln:short], coda=NG ),
|
|
31
|
+
# Syllable(onset=G W , nucleus=IH [st:1 ln:short], coda=empty),
|
|
32
|
+
# Syllable(onset=S T , nucleus=IH [st:0 ln:short], coda=K S )
|
|
33
|
+
# ]
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
You can get the onset, nucleus, and coda of each syllable:
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from syllabify import generate
|
|
40
|
+
|
|
41
|
+
syllable = generate("linguistics")
|
|
42
|
+
print(f"Onset: {syllable.get_onset()}")
|
|
43
|
+
print(f"Nucleus: {syllable.get_nucleus()}")
|
|
44
|
+
print(f"Coda: {syllable.get_coda()}")
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
### Command line interface
|
|
50
|
+
|
|
51
|
+
One word at a time:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
python3 syllable3.py linguistics
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Or several (space-separated):
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
python3 syllable3.py colourless green ideas
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Output
|
|
64
|
+
|
|
65
|
+
If the input word is found in the dictionary, a phonemic, syllabified transcript is returned. For example, for the word _linguistics_:
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
{onset: L , nucleus: IH [st:0 ln:short], coda: NG }
|
|
69
|
+
{onset: G W , nucleus: IH [st:1 ln:short], coda: empty}
|
|
70
|
+
{onset: S T , nucleus: IH [st:0 ln:short], coda: K S }
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
There's one syllable per line. Each syllable is made up of an 'onset', 'nucleus', and 'coda'. Phonemes are space-separated and capitalized in [ARPAbet](http://en.wikipedia.org/wiki/ARPABET) format. In line with phonological theory, the nucleus must have content, whereas the onset and coda may be empty. Within the vocalic content of the nucleus there's also an indication whether the syllable is stressed ('st':0 or 1), and whether the length ('ln') is short or long.
|
|
74
|
+
|
|
75
|
+
## CMU Pronouncing Dictionary
|
|
76
|
+
|
|
77
|
+
`Syllabify` depends on the [CMU Pronouncing Dictionary](http://www.speech.cs.cmu.edu/cgi-bin/cmudict) of North American English word pronunciations. Version 0.7b was the current one at time of writing, but it throws a UnicodeDecodeError, so we're still using version 0.7a (amended to remove erroneous 'G' from SUGGEST and related words). Please see the dictionary download website to obtain the current version, add the `cmudict-N.nx(.phones|.symbols)*` files to the `CMU_dictionary` directory, remove the '.txt' suffixes, and update the line `VERSION = 'cmudict-n.nx'` in `cmu_parser.py`
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "syllabify"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Automatically convert plain text into phonemes (US English pronunciation) and syllabify"
|
|
5
|
+
authors = [
|
|
6
|
+
{ name = "Fong-Chun Tsai", email = "eoleedimin@gmail.com" },
|
|
7
|
+
{ name = "Andrew Caines", email = "cainesap@gmail.com" },
|
|
8
|
+
{ name = "Anthony Evans" }
|
|
9
|
+
]
|
|
10
|
+
license = "MIT"
|
|
11
|
+
readme = "README.md"
|
|
12
|
+
keywords = ["phonetics", "syllabification", "linguistics", "cmu", "pronunciation"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 3 - Alpha",
|
|
15
|
+
"Intended Audience :: Science/Research",
|
|
16
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
17
|
+
"Topic :: Text Processing :: Linguistic",
|
|
18
|
+
"License :: OSI Approved :: MIT License",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.9",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
]
|
|
25
|
+
requires-python = ">=3.9"
|
|
26
|
+
dynamic = ["dependencies"]
|
|
27
|
+
|
|
28
|
+
[project.urls]
|
|
29
|
+
Homepage = "https://github.com/eoleedi/syllabify"
|
|
30
|
+
Repository = "https://github.com/eoleedi/syllabify"
|
|
31
|
+
|
|
32
|
+
[tool.poetry.dependencies]
|
|
33
|
+
python = "^3.9"
|
|
34
|
+
|
|
35
|
+
[tool.poetry]
|
|
36
|
+
packages = [{ include = "syllabify" }]
|
|
37
|
+
include = ["syllabify/CMU_dictionary/*"]
|
|
38
|
+
|
|
39
|
+
[tool.poetry.group.dev.dependencies]
|
|
40
|
+
black = "^25.0"
|
|
41
|
+
flake8 = "^7.0"
|
|
42
|
+
mypy = "^1.0"
|
|
43
|
+
|
|
44
|
+
[tool.poetry.scripts]
|
|
45
|
+
syllabify = "syllabify.cli:main"
|
|
46
|
+
|
|
47
|
+
[build-system]
|
|
48
|
+
requires = ["poetry-core>=2.0.0,<3.0.0"]
|
|
49
|
+
build-backend = "poetry.core.masonry.api"
|
|
50
|
+
|
|
51
|
+
[tool.black]
|
|
52
|
+
line-length = 88
|
|
53
|
+
target-version = ['py39']
|
|
54
|
+
include = '\.pyi?$'
|
|
55
|
+
extend-exclude = '''
|
|
56
|
+
/(
|
|
57
|
+
# directories
|
|
58
|
+
\.eggs
|
|
59
|
+
| \.git
|
|
60
|
+
| \.hg
|
|
61
|
+
| \.mypy_cache
|
|
62
|
+
| \.tox
|
|
63
|
+
| \.venv
|
|
64
|
+
| build
|
|
65
|
+
| dist
|
|
66
|
+
)/
|
|
67
|
+
'''
|
|
68
|
+
|
|
69
|
+
[tool.mypy]
|
|
70
|
+
python_version = "3.9"
|
|
71
|
+
warn_return_any = true
|
|
72
|
+
warn_unused_configs = true
|
|
73
|
+
disallow_untyped_defs = true
|