Skip to main content

ipapy is a Python module to work with IPA strings

Project description

ipapy is a Python module to work with IPA strings.

Installation

$ pip install ipapy

or

$ git clone https://github.com/pettarin/ipapy.git
$ cd ipapy

Usage

from ipapy.ipastring import IPAString
from ipapy.ipachar import IPADiacritic

# Unicode string for "Italian style"
s = u"iˈtaljans ˈtail"

# check if s contains only IPA characters (yes)
if IPAString.is_valid_ipa(s):
    print("s is a valid IPA string")

# create IPA string from Unicode string
s_ipa = IPAString(unicode_string=s)

# print the IPAString
print(unicode(s_ipa))   # Python 2
print(s_ipa)            # Python 3

# print the IPAString (Python 3)
print(s_ipa)

# new IPAStrings containing only...
s_cv = s.cns_vwl                # vowels and consonants
s_cvs = s.cns_vwl_str           # + stress marks
s_cvsl = s.cns_vwl_str_len      # + lenght marks
s_cvslw = s.cns_vwl_str_len_wb  # + word breaks

# iterate over each IPA char, print it, and,
# if it is a diacritic, print its properties
for c_ipa in s_ipa:
    print(c_ipa)
    if isinstance(c_ipa, IPADiacritic):
        print(c_ipa.properties)

# print the name and properties of all the vowels in the string
for c_ipa in [c for c in s_ipa if c.is_vowel]:
    print(u"%s => %s" % (c_ipa, c_ipa.name))

# print the name and properties of all the consonants in the string
for c_ipa in [c for c in s_ipa if c.is_consonant]:
    print(u"%s => %s" % (c_ipa, c_ipa.name))

License

ipapy is released under the MIT License.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ipapy-0.0.1.0.tar.gz (32.4 kB view details)

Uploaded Source

File details

Details for the file ipapy-0.0.1.0.tar.gz.

File metadata

  • Download URL: ipapy-0.0.1.0.tar.gz
  • Upload date:
  • Size: 32.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for ipapy-0.0.1.0.tar.gz
Algorithm Hash digest
SHA256 fdb7f47be21f99a31767c7c02b5666442b492e2c145c29d642a5f822d864f6ca
MD5 3aaae9f4d55d1140496add8bf63e1d42
BLAKE2b-256 fc452851945ee8f9c86b16c5be1bc12375d6f3c8a4607baec00e75bf096c5615

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page