Class PhoneticEngine.PhonemeBuilder
- java.lang.Object
-
- org.apache.commons.codec.language.bm.PhoneticEngine.PhonemeBuilder
-
- Enclosing class:
- PhoneticEngine
static final class PhoneticEngine.PhonemeBuilder extends java.lang.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 thePhoneticEngine
class.- Since:
- 1.6
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Set<Rule.Phoneme>
phonemes
-
Constructor Summary
Constructors Modifier Constructor Description private
PhonemeBuilder(java.util.Set<Rule.Phoneme> phonemes)
private
PhonemeBuilder(Rule.Phoneme phoneme)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
append(java.lang.CharSequence str)
Creates a new phoneme builder containing all phonemes in this one extended bystr
.void
apply(Rule.PhonemeExpr phonemeExpr, int maxPhonemes)
Applies the given phoneme expression to all phonemes in this phoneme builder.static PhoneticEngine.PhonemeBuilder
empty(Languages.LanguageSet languages)
An empty builder where all phonemes must come from some set of languages.java.util.Set<Rule.Phoneme>
getPhonemes()
Gets underlying phoneme set.java.lang.String
makeString()
Stringifies the phoneme set.
-
-
-
Field Detail
-
phonemes
private final java.util.Set<Rule.Phoneme> phonemes
-
-
Constructor Detail
-
PhonemeBuilder
private PhonemeBuilder(Rule.Phoneme phoneme)
-
PhonemeBuilder
private PhonemeBuilder(java.util.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 void append(java.lang.CharSequence str)
Creates a new phoneme builder containing all phonemes in this one extended bystr
.- Parameters:
str
- the characters to append to the phonemes
-
apply
public void apply(Rule.PhonemeExpr phonemeExpr, int maxPhonemes)
Applies the given phoneme expression to all phonemes in this phoneme builder.This will lengthen phonemes that have compatible language sets to the expression, and drop those that are incompatible.
- Parameters:
phonemeExpr
- the expression to applymaxPhonemes
- the maximum number of phonemes to build up
-
getPhonemes
public java.util.Set<Rule.Phoneme> getPhonemes()
Gets underlying phoneme set. Please don't mutate.- Returns:
- the phoneme set
-
makeString
public java.lang.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
-
-