Class PhonexMatcher

java.lang.Object
ca.phon.phonex.PhonexMatcher

public class PhonexMatcher extends Object
  • Method Details

    • pattern

      public PhonexPattern pattern()
      Return this matcher's pattern.
      Returns:
      the pattern for this matcher
    • reset

      public void reset()
      Reset the matcher
    • getTape

      public IPAElement[] getTape()
    • region

      public void region(int regionStart, int regionEnd)
      Constrains the region of the input to which this matcher is applied
      Parameters:
      regionStart -
      regionEnd -
    • reset

      public void reset(List<IPAElement> input)
      Reset the matcher with a new input sequence
      Parameters:
      input -
    • matches

      public boolean matches()
      Reset matcher and perform a full input match test.
      Returns:
      true if the entire input matches the pattern, false otherwise
    • find

      public boolean find()
      Attempt to find an occurrence of the pattern in the given input. Use group(), start(), and end() for more information.
      Returns:
      true if a sub-sequence of phones is found that matches the pattern
    • find

      public boolean find(int index)
      Reset matcher and attempt to find the next occurrence of the pattern starting at the given index in the input.
      Parameters:
      index -
      Returns:
      true if an occurrence of the pattern was found, false otherwise
    • groupCount

      public int groupCount()
      Return the number of capturing groups (excluding group zero.)
      Returns:
      the number of capturing groups
    • start

      public int start()
      Return the start index of the last match.
      Returns:
      the start index of the last match (i.e., start index of group zero.)
    • start

      public int start(int gIdx)
      Return the start index of the specified group.
      Parameters:
      gIdx -
      Returns:
      the start index of the group gIdx, or -1 if group data was not found
    • end

      public int end()
      Return the end index plus one of group zero
      Returns:
      the end index plus one of group zero
    • end

      public int end(int gIdx)
      Return the end index plus one of the specified group.
      Parameters:
      gIdx -
      Returns:
      the end index of the specified group plus one
    • group

      public List<IPAElement> group()
      Return the group value for this match.
      Returns:
      group value for group zero
    • group

      public List<IPAElement> group(int gIdx)
      Return the group value for the specified group
      Parameters:
      gIdx -
      Returns:
      (possibly empty) group value for the specified group
      Throws:
      IllegalStateException - if no previous match
      IndexOutOfBoundsException - on gIdx
    • group

      public List<IPAElement> group(String groupName)
      Return the group value for the given group name
      Parameters:
      groupName -
      Returns:
      group value for group name
      Throws:
      IllegalStateException - if no previous match
      IllegalArgumentException - if group name is not valid for pattern
    • hasMatch

      public boolean hasMatch()
      Tells if the matcher has a current match.
      Returns:
      true if the last call to matches() or find() was successful
    • appendReplacement

      public void appendReplacement(IPATranscriptBuilder builder, IPATranscript replacement)

      This method performs the following actions:

      • It reads IPAElements from the input sequence, starting at the append position, and appends them to the given IPATranscriptBuilder. It stops after reading the last element preceding the previous match, that is, the element at index start() - 1.
      • It appends the given replacement sequence to the transcript buffer.
      • It sets the append position of this matcher to the index of the last element matched, plus one, that is, to end().

      The replacement sequence may contain references to subsequences captured during the previous match: Each occurrence of \{name} or \g will be replaced by the result of evaluating the corresponding group(name) or group(g) respectively. Only the numerals '0' through '9' are considered as potential components of the group reference. If the second group matched the string "foo", for example, then passing the replacement sequence "\2bar" would cause "foobar" to be appended to the transcript builder.

      Parameters:
      builder -
      replacement -
    • appendTail

      public void appendTail(IPATranscriptBuilder builder)

      Append IPAElements from the input sequence to the IPATranscriptBuilder from the last append position to the end of the input sequence.

      Parameters:
      builder -