Phonetics

You could use from sinophone.phonetics import * to import all the phonetics-related interfaces.

IPA

You could abbreviate sinophone.phonetics.ipa_utils.<something> to sinophone.phonetics.<something>.

Fixes problems in ipapy, and augment its classes for purposes of sinophone.

sinophone.phonetics.ipa_utils.DG_ALL_DESCRIPTORS = <IPADescriptorGroup [dento-nasal uvular retroflex-nasal long ejective-affricate lateral-ejective-affricate tie-bar-below advanced velar open laminal lateral-affricate diacritic advanced-tongue-root falling-contour lateral-click non-sibilant-affricate more-rounded approximant labialized near-open nasal nasalized word-break palatal secondary-stress unrounded palato-alveolar sibilant-affricate front unexploded linguolabial retroflex half-long palato-nasal extra-low-level voiced central near-back rounded tie-bar-above upstep lateral-ejective-fricative centralized dental ejective rising-contour velarized-or-pharyngealized alveolar open-mid falling-rising-contour voiceless close rhotacized labio-dental bilabial linking lateral-flap pharyngeal syllabic palatalized primary-stress consonant no-audible-release low-rising-contour syllable-break suprasegmental near-front labio-velar implosive nasal-release non-sibilant-fricative uvulo-pharyngeal lateral-fricative lowered less-rounded close-mid mid-centralized click global-rise raised minor-group alveolo-palatal pharyngealized lateral-release creaky-voiced labio-palatal tone ejective-fricative rising-falling-contour mid-level high-mid-falling-contour non-syllabic mid-low-falling-contour vowel lateral-approximant palato-alveolo-velar extra-high-level low-level extra-short downstep breathy-voiced near-close high-level plosive velarized retracted-tongue-root retracted aspirated trill sibilant-fricative major-group alveolo-nasal apical glottal mid back global-fall high-rising-contour labio-alveolar flap]>

吳:所有描述器

class sinophone.phonetics.ipa_utils.IPAChar(descriptors: str)

Bases: PrettyClass, IPAChar

吳:IPA 字元

Parameters

descriptors (str) –

__init__(descriptors: str) None
Parameters

descriptors (str) –

Return type

None

property canonical_representation

The canonical representation of the character.

Each descriptor of the character is represented with its canonical value.

Return type

str

dg_value(descriptor_group)

Return the canonical value of a descriptor of the character, provided it is present in the given descriptor group.

If not present, return None.

Parameters

descriptor_group (IPADescriptorGroup) – the descriptor group to be checked against

Return type

str

has_descriptor(descriptor)

Return True if the character has the given descriptor.

Parameters

descriptor (IPADescriptor) – the descriptor to be checked against

Return type

bool

has_feature(feature: IPAFeature) bool

Returns True if this IPAChar has the given feature.

Parameters

feature (IPAFeature) –

Return type

bool

has_features(features: IPAFeatureGroup) bool

Returns True if this IPAChar has all the given features.

Parameters

features (IPAFeatureGroup) –

Return type

bool

property ipa_order: int

Returns the order of this IPAChar in the IPA alphabet.

The order is as defined in https://github.com/pettarin/ipapy/blob/v0.0.9/ipapy/data/ipa.dat.

property is_consonant

Return True if the character is a consonant.

Return type

bool

property is_diacritic

Return True if the character is a diacritic mark.

Return type

bool

is_equivalent(other)

Return True if the IPA character is equivalent to the other object.

The other object can be:

  1. a Unicode string, containing the representation of the IPA character,

  2. a Unicode string, containing a space-separated list of descriptors,

  3. a list of Unicode strings, containing descriptors, and

  4. another IPAChar.

Return type

bool

property is_letter

Return True if the character is a letter.

Return type

bool

property is_suprasegmental

Return True if the character is a suprasegmental mark.

Return type

bool

property is_tone

Return True if the character is a tone mark.

Return type

bool

property is_vowel

Return True if the character is a vowel.

Return type

bool

property translated_name: str

The name of the component in a language according to the language code as specified in sinophone.options.repr_lang.

property unicode_repr: str

Returns the unicode string converted from descriptors.

property wuu_hant_name: str

Wu Chinese translation of a SyllableComponent in Sinographs is always preceded by 吳: in the docstring.

class sinophone.phonetics.ipa_utils.IPAConsonant(descriptors: str)

Bases: IPAChar, IPAConsonant

吳:IPA 輔音

descriptors = ‘{voicing} {place} {manner}’

Parameters

descriptors (str) –

__init__(descriptors: str) None
Parameters

descriptors (str) –

Return type

None

property canonical_representation: str

Returns the canonical representation of this consonant.

dg_value(descriptor_group)

Return the canonical value of a descriptor of the character, provided it is present in the given descriptor group.

If not present, return None.

Parameters

descriptor_group (IPADescriptorGroup) – the descriptor group to be checked against

Return type

str

has_descriptor(descriptor)

Return True if the character has the given descriptor.

Parameters

descriptor (IPADescriptor) – the descriptor to be checked against

Return type

bool

has_feature(feature: IPAFeature) bool

Returns True if this IPAChar has the given feature.

Parameters

feature (IPAFeature) –

Return type

bool

has_features(features: IPAFeatureGroup) bool

Returns True if this IPAChar has all the given features.

Parameters

features (IPAFeatureGroup) –

Return type

bool

property ipa_order: int

Returns the order of this IPAChar in the IPA alphabet.

The order is as defined in https://github.com/pettarin/ipapy/blob/v0.0.9/ipapy/data/ipa.dat.

property is_consonant

Return True if the character is a consonant.

Return type

bool

property is_diacritic

Return True if the character is a diacritic mark.

Return type

bool

is_equivalent(other)

Return True if the IPA character is equivalent to the other object.

The other object can be:

  1. a Unicode string, containing the representation of the IPA character,

  2. a Unicode string, containing a space-separated list of descriptors,

  3. a list of Unicode strings, containing descriptors, and

  4. another IPAChar.

Return type

bool

property is_letter

Return True if the character is a letter.

Return type

bool

property is_suprasegmental

Return True if the character is a suprasegmental mark.

Return type

bool

property is_tone

Return True if the character is a tone mark.

Return type

bool

property is_vowel

Return True if the character is a vowel.

Return type

bool

property manner

The manner of articulation of the consonant.

Return type

str

property modifiers

The modifiers (e.g., “velarized” or “more-rounded”) of the letter.

Return type

list

property place

The place of articulation of the consonant.

Return type

str

property translated_name: str

The name of the component in a language according to the language code as specified in sinophone.options.repr_lang.

property unicode_repr: str

Returns the unicode string converted from descriptors.

property voicing

The voicing of the consonant.

Return type

str

property wuu_hant_name: str

Wu Chinese translation of a SyllableComponent in Sinographs is always preceded by 吳: in the docstring.

class sinophone.phonetics.ipa_utils.IPADescriptor(labels: Sequence[str])
class sinophone.phonetics.ipa_utils.IPADescriptor(labels: IPADescriptor)

Bases: PrettyClass, IPADescriptor

吳:IPA 描述器

Parameters

labels (Union[Sequence[str], IPADescriptor]) –

__init__(labels: Sequence[str]) None
__init__(labels: IPADescriptor) None
property canonical_label

Return the canonical label for this descriptor.

Return type

str

property labels

Return all the labels for this descriptor, the first being the canonical label.

Return type

list of str

property translated_name: str

The name of the component in a language according to the language code as specified in sinophone.options.repr_lang.

property wuu_hant_name: str

Wu Chinese translation of a SyllableComponent in Sinographs is always preceded by 吳: in the docstring.

class sinophone.phonetics.ipa_utils.IPADescriptorGroup(descriptors: Collection[IPADescriptor])

Bases: PrettyClass, IPADescriptorGroup, AbstractSet[IPADescriptor]

吳:IPA 描述器組

Parameters

descriptors (Collection[IPADescriptor]) –

__init__(descriptors: Collection[IPADescriptor]) None
Parameters

descriptors (Collection[IPADescriptor]) –

Return type

None

canonical_value(query)

Return the canonical value corresponding to the given query value.

Return None if the query value is not present in any descriptor of the group.

Parameters

query (str) – the descriptor value to be checked against

property descriptors: FrozenSet[IPADescriptor]

Return all the descriptors in this group.

Return type

list of IPADescriptor objects

isdisjoint(other)

Return True if two sets have a null intersection.

property translated_name: str

The name of the component in a language according to the language code as specified in sinophone.options.repr_lang.

property wuu_hant_name: str

Wu Chinese translation of a SyllableComponent in Sinographs is always preceded by 吳: in the docstring.

class sinophone.phonetics.ipa_utils.IPADiacritic(descriptors: str)

Bases: IPAChar, IPADiacritic

吳:IPA 附標

descriptors = ‘{diacritic}’

Parameters

descriptors (str) –

__init__(descriptors: str) None
Parameters

descriptors (str) –

Return type

None

property canonical_representation: str

Returns the canonical representation of this diacritic.

dg_value(descriptor_group)

Return the canonical value of a descriptor of the character, provided it is present in the given descriptor group.

If not present, return None.

Parameters

descriptor_group (IPADescriptorGroup) – the descriptor group to be checked against

Return type

str

has_descriptor(descriptor)

Return True if the character has the given descriptor.

Parameters

descriptor (IPADescriptor) – the descriptor to be checked against

Return type

bool

has_feature(feature: IPAFeature) bool

Returns True if this IPAChar has the given feature.

Parameters

feature (IPAFeature) –

Return type

bool

has_features(features: IPAFeatureGroup) bool

Returns True if this IPAChar has all the given features.

Parameters

features (IPAFeatureGroup) –

Return type

bool

property ipa_order: int

Returns the order of this IPAChar in the IPA alphabet.

The order is as defined in https://github.com/pettarin/ipapy/blob/v0.0.9/ipapy/data/ipa.dat.

property is_consonant

Return True if the character is a consonant.

Return type

bool

property is_diacritic

Return True if the character is a diacritic mark.

Return type

bool

is_equivalent(other)

Return True if the IPA character is equivalent to the other object.

The other object can be:

  1. a Unicode string, containing the representation of the IPA character,

  2. a Unicode string, containing a space-separated list of descriptors,

  3. a list of Unicode strings, containing descriptors, and

  4. another IPAChar.

Return type

bool

property is_letter

Return True if the character is a letter.

Return type

bool

property is_suprasegmental

Return True if the character is a suprasegmental mark.

Return type

bool

property is_tone

Return True if the character is a tone mark.

Return type

bool

property is_vowel

Return True if the character is a vowel.

Return type

bool

property translated_name: str

The name of the component in a language according to the language code as specified in sinophone.options.repr_lang.

property unicode_repr: str

Returns the unicode string converted from descriptors.

property wuu_hant_name: str

Wu Chinese translation of a SyllableComponent in Sinographs is always preceded by 吳: in the docstring.

class sinophone.phonetics.ipa_utils.IPAString(ipa_str: str = '')
class sinophone.phonetics.ipa_utils.IPAString(ipa_str: Sequence[IPAChar])

Bases: PrettyClass, IPAString, MutableSequence[IPAChar]

吳:IPA 字符串

Parameters

ipa_str (Union[str, Sequence[IPAChar]]) –

__init__(ipa_str: str = '') None
__init__(ipa_str: Sequence[IPAChar]) None
append(value)

S.append(value) – append value to the end of the sequence

property canonical_representation: str

Returns the canonical representations of characters in this IPAString.

clear() None -- remove all items from S
property cns_vwl

Return a new IPAString, containing only:

  1. the consonants, and

  2. the vowels

in the current string.

Return type

IPAString

property cns_vwl_pstr

Return a new IPAString, containing only:

  1. the consonants,

  2. the vowels, and

  3. the primary stress diacritics

in the current string.

Return type

IPAString

property cns_vwl_pstr_long

Return a new IPAString, containing only:

  1. the consonants,

  2. the vowels, and

  3. the primary stress diacritics, and

  4. the long suprasegmental

in the current string.

Return type

IPAString

property cns_vwl_str

Return a new IPAString, containing only:

  1. the consonants,

  2. the vowels, and

  3. the stress diacritics

in the current string.

Return type

IPAString

property cns_vwl_str_len

Return a new IPAString, containing only:

  1. the consonants,

  2. the vowels, and

  3. the stress diacritics, and

  4. the length diacritics

in the current string.

Return type

IPAString

property cns_vwl_str_len_wb

Return a new IPAString, containing only:

  1. the consonants,

  2. the vowels, and

  3. the stress diacritics,

  4. the length diacritics, and

  5. the word breaks

in the current string.

Return type

IPAString

property cns_vwl_str_len_wb_sb

Return a new IPAString, containing only:

  1. the consonants,

  2. the vowels, and

  3. the stress diacritics,

  4. the length diacritics,

  5. the word breaks, and

  6. the syllable breaks

in the current string.

Return type

IPAString

property consonants

Return a new IPAString, containing only the consonants in the current string.

Return type

IPAString

count(value) integer -- return number of occurrences of value
extend(values)

S.extend(iterable) – extend sequence by appending elements from the iterable

filter_chars(chars='')

Return a new IPAString, containing only the IPA characters specified by the chars string.

Valid values for chars are:

  • consonants or cns

  • vowels or vwl

  • letters or cns_vwl

  • cns_vwl_pstr or cvp

  • cns_vwl_pstr_long or cvpl

  • cns_vwl_str or cvs

  • cns_vwl_str_len or cvsl

  • cns_vwl_str_len_wb or cvslw

  • cns_vwl_str_len_wb_sb or cvslws

Return type

IPAString

index(value[, start[, stop]]) integer -- return first index of value.

Raises ValueError if the value is not present.

Supporting start and stop arguments is optional, but recommended.

insert(i, value)

S.insert(index, value) – insert value before index

property ipa_chars

Return the list of IPAChar objects composing the IPA string

Return type

list of IPAChar

is_equivalent(other, ignore=False)

Return True if the IPA string is equivalent to the other object.

The other object can be:

  1. a Unicode string,

  2. a list of IPAChar objects, and

  3. another IPAString.

Parameters
  • other (variant) – the object to be compared against

  • ignore (bool) – if other is a Unicode string, ignore Unicode characters not IPA valid

Return type

bool

property letters

Return a new IPAString, containing only the consonants and the vowels in the current string.

This property is an alias for cns_vwl.

Return type

IPAString

pop([index]) item -- remove and return item at index (default last).

Raise IndexError if list is empty or index is out of range.

remove(value)

S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.

reverse()

S.reverse() – reverse IN PLACE

property translated_name: str

The name of the component in a language according to the language code as specified in sinophone.options.repr_lang.

property vowels

Return a new IPAString, containing only the vowels in the current string.

Return type

IPAString

property wuu_hant_name: str

Wu Chinese translation of a SyllableComponent in Sinographs is always preceded by 吳: in the docstring.

class sinophone.phonetics.ipa_utils.IPATone(descriptors: str)

Bases: IPAChar, IPATone

吳:IPA 聲調

descriptors = ‘{tone_level}’

Parameters

descriptors (str) –

__init__(descriptors: str) None
Parameters

descriptors (str) –

Return type

None

property canonical_representation: str

Returns the canonical representation of this tone.

dg_value(descriptor_group)

Return the canonical value of a descriptor of the character, provided it is present in the given descriptor group.

If not present, return None.

Parameters

descriptor_group (IPADescriptorGroup) – the descriptor group to be checked against

Return type

str

has_descriptor(descriptor)

Return True if the character has the given descriptor.

Parameters

descriptor (IPADescriptor) – the descriptor to be checked against

Return type

bool

has_feature(feature: IPAFeature) bool

Returns True if this IPAChar has the given feature.

Parameters

feature (IPAFeature) –

Return type

bool

has_features(features: IPAFeatureGroup) bool

Returns True if this IPAChar has all the given features.

Parameters

features (IPAFeatureGroup) –

Return type

bool

property ipa_order: int

Returns the order of this IPAChar in the IPA alphabet.

The order is as defined in https://github.com/pettarin/ipapy/blob/v0.0.9/ipapy/data/ipa.dat.

property is_consonant

Return True if the character is a consonant.

Return type

bool

property is_diacritic

Return True if the character is a diacritic mark.

Return type

bool

is_equivalent(other)

Return True if the IPA character is equivalent to the other object.

The other object can be:

  1. a Unicode string, containing the representation of the IPA character,

  2. a Unicode string, containing a space-separated list of descriptors,

  3. a list of Unicode strings, containing descriptors, and

  4. another IPAChar.

Return type

bool

property is_global

Return True if the tone mark is a global tone mark.

Return type

bool

property is_letter

Return True if the character is a letter.

Return type

bool

property is_level_or_contour

Return True if the tone mark is a tone level or a tone contour mark.

Return type

bool

property is_suprasegmental

Return True if the character is a suprasegmental mark.

Return type

bool

property is_tone

Return True if the character is a tone mark.

Return type

bool

property is_vowel

Return True if the character is a vowel.

Return type

bool

property tone_contour

Return the tone contour value of the tone mark, or None if not a tone contour mark.

Return type

str

property tone_level

Return the tone level value of the tone mark, or None if not a tone level mark.

Return type

str

property translated_name: str

The name of the component in a language according to the language code as specified in sinophone.options.repr_lang.

property unicode_repr: str

Returns the unicode string converted from descriptors.

property wuu_hant_name: str

Wu Chinese translation of a SyllableComponent in Sinographs is always preceded by 吳: in the docstring.

class sinophone.phonetics.ipa_utils.IPAVowel(descriptors: str)

Bases: IPAChar, IPAVowel

吳:IPA 元音

descriptors = ‘{height} {backness} {roundness}’

Parameters

descriptors (str) –

__init__(descriptors: str) None
Parameters

descriptors (str) –

Return type

None

property backness

The backness of the vowel.

Return type

str

property canonical_representation: str

Returns the canonical representation of this vowel.

dg_value(descriptor_group)

Return the canonical value of a descriptor of the character, provided it is present in the given descriptor group.

If not present, return None.

Parameters

descriptor_group (IPADescriptorGroup) – the descriptor group to be checked against

Return type

str

has_descriptor(descriptor)

Return True if the character has the given descriptor.

Parameters

descriptor (IPADescriptor) – the descriptor to be checked against

Return type

bool

has_feature(feature: IPAFeature) bool

Returns True if this IPAChar has the given feature.

Parameters

feature (IPAFeature) –

Return type

bool

has_features(features: IPAFeatureGroup) bool

Returns True if this IPAChar has all the given features.

Parameters

features (IPAFeatureGroup) –

Return type

bool

property height

The height of the vowel.

Return type

str

property ipa_order: int

Returns the order of this IPAChar in the IPA alphabet.

The order is as defined in https://github.com/pettarin/ipapy/blob/v0.0.9/ipapy/data/ipa.dat.

property is_consonant

Return True if the character is a consonant.

Return type

bool

property is_diacritic

Return True if the character is a diacritic mark.

Return type

bool

is_equivalent(other)

Return True if the IPA character is equivalent to the other object.

The other object can be:

  1. a Unicode string, containing the representation of the IPA character,

  2. a Unicode string, containing a space-separated list of descriptors,

  3. a list of Unicode strings, containing descriptors, and

  4. another IPAChar.

Return type

bool

property is_letter

Return True if the character is a letter.

Return type

bool

property is_suprasegmental

Return True if the character is a suprasegmental mark.

Return type

bool

property is_tone

Return True if the character is a tone mark.

Return type

bool

property is_vowel

Return True if the character is a vowel.

Return type

bool

property modifiers

The modifiers (e.g., “velarized” or “more-rounded”) of the letter.

Return type

list

property roundness

The roundness of the vowel.

Return type

str

property translated_name: str

The name of the component in a language according to the language code as specified in sinophone.options.repr_lang.

property unicode_repr: str

Returns the unicode string converted from descriptors.

property wuu_hant_name: str

Wu Chinese translation of a SyllableComponent in Sinographs is always preceded by 吳: in the docstring.

Phonetics

You could abbreviate sinophone.phonetics.phonetics.<something> to sinophone.phonetics.<something>.

class sinophone.phonetics.phonetics.IPAFeature(descriptor: str, presence: bool = True)

Bases: PrettyClass

吳:IPA 區別特徵

Parameters
  • descriptor (str) –

  • presence (bool) –

property translated_name: str

The name of the component in a language according to the language code as specified in sinophone.options.repr_lang.

property wuu_hant_name: str

Wu Chinese translation of a SyllableComponent in Sinographs is always preceded by 吳: in the docstring.

class sinophone.phonetics.phonetics.IPAFeatureGroup(features: str)
class sinophone.phonetics.phonetics.IPAFeatureGroup(features: Collection[IPAFeature] = None)

Bases: MutableSet[IPAFeature], PrettyClass

吳:IPA 區別特徵組

A set of (meaningful) IPA features.

Parameters

features (Union[str, Collection[IPAFeature]]) –

add(value) None

Add an element.

Return type

None

clear()

This is slow (creates N new iterators!) but effective.

discard(value) None

Remove an element. Do not raise an exception if absent.

Return type

None

isdisjoint(other)

Return True if two sets have a null intersection.

pop()

Return the popped value. Raise KeyError if empty.

remove(value)

Remove an element. If not a member, raise a KeyError.

property translated_name: str

The name of the component in a language according to the language code as specified in sinophone.options.repr_lang.

property wuu_hant_name: str

Wu Chinese translation of a SyllableComponent in Sinographs is always preceded by 吳: in the docstring.

Indices