Package ca.phon.ipa
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
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCreate 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 TypeMethodDescriptionvoid
accept
(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.int
int
compareTo
(IPATranscript ipa, Comparator<IPAElement> comparator) boolean
boolean
Returnstrue
if this transcript contains the given phonex pattern.boolean
containsCVPattern
(String pattern) boolean
containsStressPattern
(String pattern) Does this transcript contain the givenStressPattern
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 ofIPAElement
s in the transcript using the given symbol map.elementAt
(int index) Get the element at specified indexboolean
findCVPattern
(String pattern) findStressPattern
(String pattern) Find all occurrences of the givenStressPattern
<T> T
getExtension
(Class<T> cap) Get the requested extension if available.Return all extension types supportedint
hashCode()
int
indexOf
(IPAElement ele) Return the index of the given elementint
indexOf
(IPATranscript transcript) Return the index of the first element in the given transcript.int
Returns the index of the first phone of the given phonex pattern in this transcript.int
Returns the index of the first phone of the given phonex pattern in this transcript starting at the given phone index.int
ipaIndexOf
(int charIdx) Return the ipa element index of the given string index.iterator()
int
length()
Length of transcription (in elements)boolean
boolean
Returnstrue
if this transcript matches the given phonex.boolean
matchesCVPattern
(String pattern) boolean
matchesStressPattern
(String pattern) Does this transcript's stress pattern match the givenStressPattern
static IPATranscript
parseIPATranscript
(String transcript) Convert a string into anIPATranscript
<T> T
putExtension
(Class<T> cap, T impl) Add a new extension.<T> T
removeExtension
(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.void
Reset syllabification for the transcript.Split transcript using the given phonex pattern as a delimiter.int
stringIndexOf
(IPATranscript transcript) Find the index of the given ipa transcript in the string representation of this transcript.int
stringIndexOfElement
(int index) Finds the index of the specified ipa element in the string representation of the transcript.int
Finds 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 String
stripDiacriticsFromText
(String text, boolean onlyOrExcept, Collection<Diacritic> selectedDiacritics) subsection
(int start, int end) Return a subsection of this transcription.Break 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, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
USE_ANTLR4
-
-
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
Returnstrue
if this transcript matches the given phonex.- Parameters:
phonex
-flags
-- Returns:
true
if the transcript matches the given phonex,false
otherwise- Throws:
PhonexPatternException
- if the given phonex is not valid
-
contains
-
contains
Returnstrue
if this transcript contains the given phonex pattern.- Parameters:
phonex
-flags
-- Returns:
true
if the transcript contains the given phonex pattern,false
otherwise- Throws:
PhonexPatternException
- if the given phonex is not valid
-
elementAt
Get the element at specified index- Parameters:
index
-- Returns:
- element
- Throws:
ArrayIndexOutOfBoundsException
-
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 eitherstart
orend
are 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
Break the transcript into syllables.- Returns:
- syllables
-
syllablesAndPauses
Return syllables, including intra-word pauses.- Returns:
- syllables and pauses
-
resetSyllabification
public void resetSyllabification()Reset syllabification for the transcript. -
words
Break the transcript into words- Returns:
- words
-
accept
Description copied from interface:Visitable
Accept the given visitor.- Specified by:
accept
in 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
-
getStressPattern
-
matchesStressPattern
Does this transcript's stress pattern match the givenStressPattern
- Parameters:
pattern
-- Returns:
true
if pattern matches,false
otherwise
-
containsStressPattern
Does this transcript contain the givenStressPattern
- Parameters:
pattern
-- Returns:
true
if this transcript contains the stress pattern,false
otherwise
-
findStressPattern
Find all occurrences of the givenStressPattern
- Parameters:
pattern
-- Returns:
-
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 ofIPAElement
s in the transcript using the given symbol map. The result will be a newIPATranscript
whose 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
-
getExtensions
Description copied from interface:IExtendable
Return all extension types supported- Specified by:
getExtensions
in interfaceIExtendable
-
getExtension
Description copied from interface:IExtendable
Get the requested extension if available.- Specified by:
getExtension
in interfaceIExtendable
- Returns:
- the capability object or
null
if the cability is not available
-
putExtension
Description copied from interface:IExtendable
Add a new extension.- Specified by:
putExtension
in interfaceIExtendable
- Parameters:
cap
- the extension to add- Returns:
- the added extension implementation
-
removeExtension
Description copied from interface:IExtendable
Remove a capability.- Specified by:
removeExtension
in interfaceIExtendable
- Parameters:
cap
- the capability to remove
-
toString
-
toString
-
hashCode
public int hashCode() -
equals
-
toList
Get an immutable list representation of this IPATranscript.- Returns:
- list
-
iterator
- Specified by:
iterator
in interfaceIterable<IPAElement>
-
compareTo
- Specified by:
compareTo
in interfaceComparable<IPATranscript>
-
compareTo
-