PString is a str class that recognizes IPA symbols.
Project description
PString
PString is a Python package for working with IPA (International Phonetic Alphabet) symbols in strings. It addresses issues where standard Python string operations may not work as expected with IPA symbols, such as iterating over a string and accessing a symbol by its index. This happens because Python interprets some phonemes as multiple individual chars when dealing with standard strings.
Installation
You can install PString using pip:
pip install pstring
Make sure you have the required Python version and any dependencies installed.
Usage
Example:
from PString import PString
text = "bõ d͡ʒiɐ"
phones = PString(text)
print(f"{text}")
print(f"{phones}")
Output:
bõ d͡ʒiɐ
bõ d͡ʒiɐ
You can iterate over a PString and also create a list of phonemes:
for phone in phones:
print(phone)
print(f"str list: {list(text)}")
print(f"PString list: {list(phones)}")
Output:
b
õ
d͡ʒ
i
ɐ
str list: ['b', 'õ', ' ', 'd', '͡', 'ʒ', 'i', 'ɐ']
PString list: ['b', 'õ', ' ', 'd͡ʒ', 'i', 'ɐ']
You can also access a specific position or slice of the PString:
print(phones[3])
print(phones[3:6])
Output:
d͡ʒ
d͡ʒiɐ
If you wish to convert a PString back to a str:
phones_string = phones.to_string()
print(phones_string)
print(phones_string == text)
Output:
bõ d͡ʒiɐ
True
Disclaimer
This package should represent IPA symbols listed on IPA symbols with Unicode decimal and hex codes. Any incompatibilities of encoding are not of the author's responsibility.
License
This package is distributed under the MIT license. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pstring-1.0.2.tar.gz.
File metadata
- Download URL: pstring-1.0.2.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8843c499997877697a34e10c1c2f7081788db470e44655ce60a2bf239942820
|
|
| MD5 |
210cc86027d90fd7e90047b88714d031
|
|
| BLAKE2b-256 |
a18b62c65cc15ef95a2c65e38ce555102ee9add86c702002a858ee511fda5f4b
|
File details
Details for the file pstring-1.0.2-py3-none-any.whl.
File metadata
- Download URL: pstring-1.0.2-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd5ba718ee3dab4f8d63d47e0463d5c726bdf249f36ddd6c0269e28197320d8f
|
|
| MD5 |
0f025f3dc2ad4eafbe0fa3c37427d00c
|
|
| BLAKE2b-256 |
57267050814e42c0d6e70ab9d2441e4e268a71705a96cf609636a1c6b75d9e6c
|