Class IPATranscript
java.lang.Object
ca.phon.ipa.IPATranscript
- All Implemented Interfaces:
IExtendable,Visitable<IPAElement>,Comparable<IPATranscript>,Iterable<IPAElement>
public final class IPATranscript
extends Object
implements Iterable<IPAElement>, Visitable<IPAElement>, IExtendable, Comparable<IPATranscript>
A (somewhat) immutable representation of an IPA transcription. While the number of elements
in the transcription cannot be changed, runtime extensions provided by the IExtendable
interface may be swapped.
Objects of this type should be created using either the parseIPATranscript(String)
static method or IPATranscriptBuilder.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionCreate an empty transcriptIPATranscript(IPAElement... phones) Create a new transcript from an array of phones.Createa new transcript with the phones from the given transcript.IPATranscript(Object... elements) IPATranscript(List<IPAElement> phones) Create a new transcript for a list of phones. -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(Visitor<IPAElement> visitor) Accept the given visitor.append(IPATranscript ipa) Return a new IPATranscript that include the contents of this transcript along with the contents of the given transcript appended at the end.Create a list of IPAElements which produce a sound.intintcompareTo(IPATranscript ipa, Comparator<IPAElement> comparator) booleanbooleanReturnstrueif this transcript contains the given phonex pattern.booleancontainsCVPattern(String pattern) booleancontainsStressPattern(String pattern) Does this transcript contain the given stress pattern.convertCVExpr(String expr) Convert a given 'CV' pattern to a PhonexPattern.convertStressExpr(String expr) Convert a stress pattern expr into a phonex pattern.cover()Get default CGV pattern coverCover IPATranscript using provided cover characters.Cover using string encoding symbol map.cover(List<PhoneMatcher> matchers, Map<PhoneMatcher, Character> symbolMap, boolean includeStress, boolean includeSyllableBoundaries, boolean includeDiacritics) Cover the image ofIPAElements in the transcript using the given symbol map.elementAt(int index) Get the element at specified indexbooleanfindCVPattern(String pattern) findStressPattern(String pattern) Find all occurrences of the given stress pattern.Get the first audible phone in the transcription, this will skip any stress or syllable boundary markers at the beginning of the transcription.<T> TgetExtension(Class<T> cap) Get the requested extension if available.Return all extension types supportedGet the stress pattern for this transcript.inthashCode()booleanHas this transcription been syllabified?intindexOf(IPAElement ele) Return the index of the given elementintindexOf(IPATranscript transcript) Return the index of the first element in the given transcript.intReturns the index of the first phone of the given phonex pattern in this transcript.intReturns the index of the first phone of the given phonex pattern in this transcript starting at the given phone index.Get the stress of the first syllable in this transcript.intipaIndexOf(int charIdx) Return the ipa element index of the given string index.iterator()intlength()Length of transcription (in elements)booleanbooleanReturnstrueif this transcript matches the given phonex.booleanmatchesCVPattern(String pattern) booleanmatchesStressPattern(String pattern) Does this transcript's stress pattern match the given stress pattern.static IPATranscriptparseIPATranscript(String transcript) Convert a string into anIPATranscript<T> TputExtension(Class<T> cap, T impl) Add a new extension.<T> TremoveExtension(Class<T> cap) Remove a capability.Create a new transcript with all punctuation removed (except word boundaries).removePunctuation(boolean ignoreWordBoundaries) Create a new transcript with all punctuation remove.replaceAll(PhonexPattern pattern, IPATranscript replacement) Replace all occurrences of the a phonex expression with the given replacement.replaceAll(String pattern, String replacement) Replace all occurrences of the a phonex expression with the given replacement.replaceFirst(PhonexPattern pattern, IPATranscript replacement) Replace the first occurrence of the a phonex expression with the given replacement.replaceFirst(String pattern, String replacement) Replace the first occurrence of the a phonex expression with the given replacement.Return a new transcript with syllabification information reset to UNKNOWN.setConstituentType(int index, SyllableConstituentType constituentType) Set constituent type for the given element index.setSyllableInfo(int index, SyllableInfo syllableInfo) Return a new IPATranscript with syllabification information set for the given element index.Split transcript using the given phonex pattern as a delimiter.intstringIndexOf(IPATranscript transcript) Find the index of the given ipa transcript in the string representation of this transcript.intstringIndexOfElement(int index) Finds the index of the specified ipa element in the string representation of the transcript.intFinds the index of the given ipa element in the string representation of the transcript.Remove all diacritics from phones and compound phones.stripDiacritics(Collection<Diacritic> selectedDiacritics) Strip only diacritics found in given diacriticsstripDiacritics(Predicate<Diacritic> diacriticFilter) Strip diacritics from transcript using custom filter.stripDiacriticsExcept(Collection<Diacritic> selectedDiacritics) Strip diacritics except those found in the given diacriticsstatic StringstripDiacriticsFromText(String text, boolean onlyOrExcept, Collection<Diacritic> selectedDiacritics) subsection(int start, int end) Return a subsection of this transcription.intsyllableIndexOf(IPAElement phone) Get syllable index of given phoneBreak the transcript into syllables.Return syllables, including intra-word pauses.toList()Get an immutable list representation of this IPATranscript.toString()toString(boolean includeScType) words()Break the transcript into wordsMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
IPATranscript
public IPATranscript()Create an empty transcript -
IPATranscript
Create a new transcript for a list of phones. -
IPATranscript
Createa new transcript with the phones from the given transcript.- Parameters:
ipa-
-
IPATranscript
Create a new transcript from an array of phones. -
IPATranscript
-
-
Method Details
-
parseIPATranscript
Convert a string into anIPATranscript- Parameters:
transcript- the text of the IPA transcription- Throws:
ParseException
-
length
public int length()Length of transcription (in elements)- Returns:
- length
-
matches
-
matches
Returnstrueif this transcript matches the given phonex.- Parameters:
phonex-flags-- Returns:
trueif the transcript matches the given phonex,falseotherwise- Throws:
PhonexPatternException- if the given phonex is not valid
-
contains
-
contains
Returnstrueif this transcript contains the given phonex pattern.- Parameters:
phonex-flags-- Returns:
trueif the transcript contains the given phonex pattern,falseotherwise- Throws:
PhonexPatternException- if the given phonex is not valid
-
elementAt
Get the element at specified index- Parameters:
index-- Returns:
- element
- Throws:
ArrayIndexOutOfBoundsException
-
firstPhone
Get the first audible phone in the transcription, this will skip any stress or syllable boundary markers at the beginning of the transcription.- Returns:
- the first audible phone or
nullif no audible phones
-
ipaIndexOf
public int ipaIndexOf(int charIdx) Return the ipa element index of the given string index.- Parameters:
charIdx-- Returns:
- ipaIndex
-
indexOf
Return the index of the given element- Parameters:
ele-- Returns:
- index of element or invalid input: '<' 0 if not found
-
indexOf
Returns the index of the first phone of the given phonex pattern in this transcript.- Parameters:
phonex-- Returns:
- the index of the first phone in the given pattern or -1 if not found
- Throws:
PhonexPatternException- if the given phonex is not valid
-
indexOf
Returns the index of the first phone of the given phonex pattern in this transcript starting at the given phone index.- Parameters:
phonex-index- of the phone to start searching from- Returns:
- the index of the first phone in the given pattern or -1 if not found
- Throws:
PhonexPatternException- if the given phonex is not valid
-
indexOf
Return the index of the first element in the given transcript.- Parameters:
transcript-- Returns:
- the index or -1 if not found
-
split
-
split
Split transcript using the given phonex pattern as a delimiter.- Parameters:
phonex-flags-
-
subsection
Return a subsection of this transcription.- Parameters:
start-end-- Returns:
- a new IPATranscript which is a sub-section of this transcription
- Throws:
ArrayIndexOutOfBoundsException- if eitherstartorendare out of bounds
-
replaceFirst
Replace the first occurrence of the a phonex expression with the given replacement.- Parameters:
pattern-replacement-- Returns:
- a new IPA transcript
- Throws:
ParseException
-
replaceFirst
Replace the first occurrence of the a phonex expression with the given replacement.- Parameters:
pattern-replacement-- Returns:
- a new IPA transcript
-
replaceAll
Replace all occurrences of the a phonex expression with the given replacement.- Parameters:
pattern-replacement-- Returns:
- a new IPA transcript
- Throws:
ParseException
-
replaceAll
Replace all occurrences of the a phonex expression with the given replacement.- Parameters:
pattern-replacement-- Returns:
- a new IPA transcript
-
append
Return a new IPATranscript that include the contents of this transcript along with the contents of the given transcript appended at the end.- Parameters:
ipa-
-
removePunctuation
Create a new transcript with all punctuation removed (except word boundaries). Same asremovePunctuation(false)- Returns:
- the filtered transcript
-
removePunctuation
Create a new transcript with all punctuation remove. Option to ignore word boundaries can be provided.- Parameters:
ignoreWordBoundaries-- Returns:
- the filtered transcript
-
stripDiacritics
Remove all diacritics from phones and compound phones.- Returns:
- transcript with filtered diacritics
-
stripDiacritics
Strip only diacritics found in given diacritics- Parameters:
selectedDiacritics-
-
stripDiacriticsExcept
Strip diacritics except those found in the given diacritics- Parameters:
selectedDiacritics-
-
stripDiacritics
Strip diacritics from transcript using custom filter.- Parameters:
diacriticFilter-- Returns:
-
stripDiacriticsFromText
public static String stripDiacriticsFromText(String text, boolean onlyOrExcept, Collection<Diacritic> selectedDiacritics) -
audiblePhones
Create a list of IPAElements which produce a sound.- Returns:
- audible phones
-
syllables
-
syllablesAndPauses
Return syllables, including intra-word pauses.- Returns:
- syllables and pauses
-
resetSyllabification
Return a new transcript with syllabification information reset to UNKNOWN. -
setSyllableInfo
Return a new IPATranscript with syllabification information set for the given element index.- Parameters:
index-syllableInfo-- Returns:
- IPATranscript with updated syllable info
- Throws:
ArrayIndexOutOfBoundsException- if index is out of bounds
-
setConstituentType
Set constituent type for the given element index.- Parameters:
index-constituentType-- Returns:
- IPATranscript a new IPATranscript with updated syllable info
- Throws:
ArrayIndexOutOfBoundsException- if index is out of bounds
-
hasSyllableInformation
public boolean hasSyllableInformation()Has this transcription been syllabified?- Returns:
- true if any phones have syllabification info set to something other than UNKNOWN
-
words
-
accept
Description copied from interface:VisitableAccept the given visitor.- Specified by:
acceptin interfaceVisitable<IPAElement>
-
stringIndexOfElement
Finds the index of the given ipa element in the string representation of the transcript.- Parameters:
ele-- Returns:
- the string index of the specified element or invalid input: '<' 0 if not found
-
stringIndexOf
Find the index of the given ipa transcript in the string representation of this transcript.- Parameters:
transcript-- Returns:
- the string index of the given transcript or invalid input: '<' 0 if not found
-
stringIndexOfElement
public int stringIndexOfElement(int index) Finds the index of the specified ipa element in the string representation of the transcript.- Parameters:
index-- Returns:
- the string index of the specified element or invalid input: '<' 0 if not found
-
initialStress
Get the stress of the first syllable in this transcript.- Returns:
- the stress of the first syllable or NoStress if no syllables
-
getStressPattern
Get the stress pattern for this transcript. The stress pattern is a string of characters where '1' indicates primary stress, '2' indicates secondary stress, 'U' indicates unstressed.- Returns:
- the stress pattern
-
convertStressExpr
Convert a stress pattern expr into a phonex pattern. This will convert all '1' into 'σ!1', '2' into 'σ!2', and, 'U' into 'σ!U', and 'A' into 'σ'. The remainder of the pattern is unchanged.- Parameters:
expr- the stress pattern expression- Returns:
- the phonex pattern expr
-
matchesStressPattern
Does this transcript's stress pattern match the given stress pattern.- Parameters:
pattern-- Returns:
trueif pattern matches,falseotherwise
-
containsStressPattern
Does this transcript contain the given stress pattern.- Parameters:
pattern-- Returns:
trueif this transcript contains the stress pattern,falseotherwise
-
findStressPattern
Find all occurrences of the given stress pattern.- Parameters:
pattern-- Returns:
-
convertCVExpr
-
getCvPattern
-
matchesCVPattern
-
containsCVPattern
-
findCVPattern
-
cover
Get default CGV pattern cover- Returns:
- transcript covered using G=\g; C=\c; V=\v
-
cover
Cover using string encoding symbol map.- Parameters:
symbolMap-
-
cover
public IPATranscript cover(List<PhoneMatcher> matchers, Map<PhoneMatcher, Character> symbolMap, boolean includeStress, boolean includeSyllableBoundaries, boolean includeDiacritics) Cover the image ofIPAElements in the transcript using the given symbol map. The result will be a newIPATranscriptwhose elements have the same feature set and syllablifiation information as the original transcript. Elements which are not matched using the symbol table are copied as-is.- Parameters:
matchers-symbolMap-includeStress- include stress marker elementsincludeSyllableBoundaries- keep syllable boundaries (i.e., '.') elementsincludeDiacritics- keep diacritics on elements
-
cover
Cover IPATranscript using provided cover characters.- Parameters:
consonantCover-vowelCover-- Returns:
-
cover
-
syllableIndexOf
Get syllable index of given phone- Parameters:
phone-- Returns:
- syllable index of phone or -1 if not found
-
getExtensions
Description copied from interface:IExtendableReturn all extension types supported- Specified by:
getExtensionsin interfaceIExtendable
-
getExtension
Description copied from interface:IExtendableGet the requested extension if available.- Specified by:
getExtensionin interfaceIExtendable- Returns:
- the capability object or
nullif the cability is not available
-
putExtension
Description copied from interface:IExtendableAdd a new extension.- Specified by:
putExtensionin interfaceIExtendable- Parameters:
cap- the extension to add- Returns:
- the added extension implementation
-
removeExtension
Description copied from interface:IExtendableRemove a capability.- Specified by:
removeExtensionin interfaceIExtendable- Parameters:
cap- the capability to remove
-
toString
-
toString
-
hashCode
-
equals
-
toList
Get an immutable list representation of this IPATranscript.- Returns:
- list
-
iterator
- Specified by:
iteratorin interfaceIterable<IPAElement>
-
compareTo
- Specified by:
compareToin interfaceComparable<IPATranscript>
-
compareTo
-