org.apache.commons.codec.language.bm
Class PhoneticEngine.PhonemeBuilder

java.lang.Object
  extended by org.apache.commons.codec.language.bm.PhoneticEngine.PhonemeBuilder
Enclosing class:
PhoneticEngine

static final class PhoneticEngine.PhonemeBuilder
extends Object

Utility for manipulating a set of phonemes as they are being built up. Not intended for use outside this package, and probably not outside the PhoneticEngine class.

Since:
1.6

Field Summary
private  Set<Rule.Phoneme> phonemes
           
 
Constructor Summary
private PhoneticEngine.PhonemeBuilder(Set<Rule.Phoneme> phonemes)
           
 
Method Summary
 PhoneticEngine.PhonemeBuilder append(CharSequence str)
          Creates a new phoneme builder containing all phonemes in this one extended by str.
 PhoneticEngine.PhonemeBuilder apply(Rule.PhonemeExpr phonemeExpr, int maxPhonemes)
          Creates a new phoneme builder containing the application of the expression to all phonemes in this builder.
static PhoneticEngine.PhonemeBuilder empty(Languages.LanguageSet languages)
          An empty builder where all phonemes must come from some set of languages.
 Set<Rule.Phoneme> getPhonemes()
          Gets underlying phoneme set.
 String makeString()
          Stringifies the phoneme set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

phonemes

private final Set<Rule.Phoneme> phonemes
Constructor Detail

PhoneticEngine.PhonemeBuilder

private PhoneticEngine.PhonemeBuilder(Set<Rule.Phoneme> phonemes)
Method Detail

empty

public static PhoneticEngine.PhonemeBuilder empty(Languages.LanguageSet languages)
An empty builder where all phonemes must come from some set of languages. This will contain a single phoneme of zero characters. This can then be appended to. This should be the only way to create a new phoneme from scratch.

Parameters:
languages - the set of languages
Returns:
a new, empty phoneme builder

append

public PhoneticEngine.PhonemeBuilder append(CharSequence str)
Creates a new phoneme builder containing all phonemes in this one extended by str.

Parameters:
str - the characters to append to the phonemes
Returns:
a new phoneme builder lenghtened by str

apply

public PhoneticEngine.PhonemeBuilder apply(Rule.PhonemeExpr phonemeExpr,
                                           int maxPhonemes)
Creates a new phoneme builder containing the application of the expression to all phonemes in this builder.

This will lengthen phonemes that have compatible language sets to the expression, and drop those that are incompatible.

Parameters:
phonemeExpr - the expression to apply
maxPhonemes - the maximum number of phonemes to build up
Returns:
a new phoneme builder containing the results of phonemeExpr applied to each phoneme in turn

getPhonemes

public Set<Rule.Phoneme> getPhonemes()
Gets underlying phoneme set. Please don't mutate.

Returns:
the phoneme set

makeString

public String makeString()
Stringifies the phoneme set. This produces a single string of the strings of each phoneme, joined with a pipe. This is explicitly provided in place of toString as it is a potentially expensive operation, which should be avoided when debugging.

Returns:
the stringified phoneme set


commons-codec version 1.7-SNAPSHOT - Copyright © 2002-2013 - Apache Software Foundation