Search for tiers in a sppasTranscription.
Module sppas.src.annotations
Class sppasFindTier
Description
Public functions
ipus
Return the tier with Inter-Pausal Units.
Parameters
- trs: (sppasTranscription)
Returns
- (sppasTier or None)
View Source
@staticmethod
def ipus(trs):
"""Return the tier with Inter-Pausal Units.
:param trs: (sppasTranscription)
:returns: (sppasTier or None)
"""
for tier in trs:
tier_name = tier.get_name().lower()
if 'ipu' in tier_name:
return tier
return None
transcription
Return the tier with orthographic transcription.
Parameters
- trs: (sppasTranscription)
Returns
- (sppasTier or None)
View Source
@staticmethod
def transcription(trs):
"""Return the tier with orthographic transcription.
:param trs: (sppasTranscription)
:returns: (sppasTier or None)
"""
tier = trs.find('transcription', case_sensitive=False)
if tier is not None:
return tier
for tier in trs:
tier_name = tier.get_name().lower()
if 'transcription' in tier_name:
return tier
for tier in trs:
tier_name = tier.get_name().lower()
if 'trans' in tier_name:
return tier
elif 'trs' in tier_name:
return tier
elif 'toe' in tier_name:
return tier
elif 'ortho' in tier_name:
return tier
return None
tokenization
Return the tier with tokenization.
In case of EOT, several tiers with tokens are available. Priority is given to faked (i.e. without pattern).
Parameters
- trs: (sppasTranscription)
- pattern: (str) Priority pattern
Returns
- (sppasTier or None)
View Source
@staticmethod
def tokenization(trs, pattern=''):
"""Return the tier with tokenization.
In case of EOT, several tiers with tokens are available.
Priority is given to faked (i.e. without pattern).
:param trs: (sppasTranscription)
:param pattern: (str) Priority pattern
:returns: (sppasTier or None)
"""
if len(pattern) > 0:
pattern = pattern.lower()
for tier in trs:
tier_name = tier.get_name().lower()
if pattern in tier_name and 'token' in tier_name:
return tier
if len(trs) == 1:
if 'token' in trs[0].get_name().lower():
return trs[0]
else:
tok_tier = None
std_tier = None
for tier in trs:
tier_name = tier.get_name().lower()
if 'align' in tier_name:
continue
if tier_name == 'tokens':
return tier
elif 'std' in tier_name and 'token' in tier_name:
std_tier = tier
elif 'token' in tier_name:
tok_tier = tier
if std_tier is not None:
return std_tier
if tok_tier is not None:
return tok_tier
return None
phonetization
Return the tier with phonetization.
Parameters
- trs: (sppasTranscription)
Returns
- (sppasTier or None)
View Source
@staticmethod
def phonetization(trs):
"""Return the tier with phonetization.
:param trs: (sppasTranscription)
:returns: (sppasTier or None)
"""
tier = trs.find('phones', case_sensitive=False)
if tier is not None:
return tier
for tier in trs:
tier_name = tier.get_name().lower()
if 'align' in tier_name:
continue
if tier_name.startswith('phon') is True:
return tier
for tier in trs:
tier_name = tier.get_name().lower()
if 'align' in tier_name:
continue
if 'phon' in tier_name:
return tier
return None
aligned_phones
Return the tier with time-aligned phonemes.
Parameters
- trs: (sppasTier or None)
View Source
@staticmethod
def aligned_phones(trs):
"""Return the tier with time-aligned phonemes.
:param trs: (sppasTier or None)
"""
for tier in trs:
if 'align' in tier.get_name().lower() and 'phon' in tier.get_name().lower():
return tier
return None
aligned_tokens
Return the tier with time-aligned tokens.
Parameters
- trs: (sppasTier or None)
View Source
@staticmethod
def aligned_tokens(trs):
"""Return the tier with time-aligned tokens.
:param trs: (sppasTier or None)
"""
for tier in trs:
if 'align' in tier.get_name().lower() and 'token' in tier.get_name().lower():
return tier
return None
aligned_syllables
Return the tier with time-aligned syllables.
Parameters
- trs: (sppasTier or None)
View Source
@staticmethod
def aligned_syllables(trs):
"""Return the tier with time-aligned syllables.
:param trs: (sppasTier or None)
"""
for tier in trs:
if 'align' in tier.get_name().lower() and 'syll' in tier.get_name().lower():
return tier
for tier in trs:
if tier.get_name() == 'Syllables':
return tier
for tier in trs:
if 'Syll' in tier.get_name():
return tier
return None
aligned_lemmas
Return the tier with time-aligned lemmas.
Parameters
- trs: (sppasTier or None)
View Source
@staticmethod
def aligned_lemmas(trs):
"""Return the tier with time-aligned lemmas.
:param trs: (sppasTier or None)
"""
for tier in trs:
if 'lemma' in tier.get_name().lower():
return tier
return None
pitch
Return the tier with pitch values.
Parameters
- trs: (sppasTranscription)
Returns
- (sppasTier or None)
View Source
@staticmethod
def pitch(trs):
"""Return the tier with pitch values.
:param trs: (sppasTranscription)
:returns: (sppasTier or None)
"""
for tier in trs:
if tier.get_name() == 'PitchHz':
return tier
for tier in trs:
if tier.get_name() == 'PitchTier':
return tier
for tier in trs:
if 'pitch' in tier.get_name().lower():
return tier
return None
pitch_anchors
Return the tier with pitch anchors, like momel result.
Parameters
- trs: (sppasTranscription)
Returns
- (sppasTier or None)
View Source
@staticmethod
def pitch_anchors(trs):
"""Return the tier with pitch anchors, like momel result.
:param trs: (sppasTranscription)
:returns: (sppasTier or None)
"""
for tier in trs:
if 'momel' in tier.get_name().lower():
return tier
for tier in trs:
if 'anchors' in tier.get_name().lower():
return tier
return None