Package ca.phon.phonex
Class PhonexPattern
java.lang.Object
ca.phon.phonex.PhonexPattern
- All Implemented Interfaces:
Comparable<PhonexPattern>
A compiled representation of a phonex expression.
A phonex expression, specified as a string, must first be compiled
into this class using the compile(String)
method. The
resulting PhonexPattern
object can then be used to create
a PhonexMatcher
that can match arbitrary IPA sequences
against the phonex expression. A single pattern can be used to
create many matchers.
A typcial use case:
// an expression to find geminates final String phonex = "(\c)\S?\1"; final PhonexPattern pattern = PhonexPattern.compile(phonex); final IPATranscript ipa = IPATranscript.parseIPATranscript("ˈlæmp.poʊst"); final PhonexMatcher matcher = pattern.matcher(ipa); boolean b = matcher.find();
For more information about phonex expressions, please refer to the phonex manual.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
compareTo
(PhonexPattern arg0) Compares phonex pattern strings.static PhonexPattern
static PhonexPattern
Compile the given phonex into a patternstatic PhoneMatcher
compileSingleMatcher
(String phonex) Compile a phonex expression for a single matcher (including phone classes) and return the provided matcher.getFsa()
Access the internal fsa for package-level classes.int
groupIndex
(String groupName) Return the group index for the given group name.groupName
(int gIdx) Get the group name for the specified groupmatcher
(Iterable<IPAElement> input) Create a new phonex matcher which will match the given input against this pattern.int
Returns the number of groups in the compiled pattern.pattern()
Return the phonex for this pattern.
-
Field Details
-
USE_ANTLR4
-
-
Method Details
-
compileSingleMatcher
Compile a phonex expression for a single matcher (including phone classes) and return the provided matcher.- Parameters:
phonex
-- Returns:
- Throws:
PhonexPatternException
-
compile
- Throws:
PhonexPatternException
-
compile
Compile the given phonex into a pattern- Parameters:
phonex
- the expressionflags
-- Throws:
PhonexPatternException
- if the expression's syntax is invalid
-
matcher
Create a new phonex matcher which will match the given input against this pattern.- Parameters:
input
- The list of phones to be matched
-
pattern
Return the phonex for this pattern.- Returns:
- the phonex compiled into this pattern
-
getFsa
Access the internal fsa for package-level classes.- Returns:
- the complied fsa
-
numberOfGroups
public int numberOfGroups()Returns the number of groups in the compiled pattern.- Returns:
- the number of groups in the pattern
-
groupName
Get the group name for the specified group- Returns:
- the group name for the specified group
or
null
if the group is not named - Throws:
ArrayIndexOutOfBoundsException
- if the given group index is out of bounds
-
groupIndex
Return the group index for the given group name.- Returns:
- group index or invalid input: '<' 0 if not found
-
compareTo
Compares phonex pattern strings.- Specified by:
compareTo
in interfaceComparable<PhonexPattern>
-