public class PhoneticEngine extends Object
This is a two-stage process. Firstly, the word is converted into a phonetic representation that takes into account the likely source language. Next, this phonetic representation is converted into a pan-European 'average' representation, allowing comparison between different versions of essentially the same word from different languages.
This class is intentionally immutable and thread-safe. If you wish to alter the settings for a PhoneticEngine, you must make a new one with the updated settings.
Ported from phoneticengine.php
Modifier and Type | Class and Description |
---|---|
(package private) static class |
PhoneticEngine.PhonemeBuilder
Utility for manipulating a set of phonemes as they are being built up.
|
private static class |
PhoneticEngine.RulesApplication
A function closure capturing the application of a list of rules to an input sequence at a particular offset.
|
Modifier and Type | Field and Description |
---|---|
private boolean |
concat |
private static int |
DEFAULT_MAX_PHONEMES |
private Lang |
lang |
private int |
maxPhonemes |
private static Map<NameType,Set<String>> |
NAME_PREFIXES |
private NameType |
nameType |
private RuleType |
ruleType |
Constructor and Description |
---|
PhoneticEngine(NameType nameType,
RuleType ruleType,
boolean concat)
Generates a new, fully-configured phonetic engine.
|
PhoneticEngine(NameType nameType,
RuleType ruleType,
boolean concat,
int maxPhonemes)
Generates a new, fully-configured phonetic engine.
|
Modifier and Type | Method and Description |
---|---|
private PhoneticEngine.PhonemeBuilder |
applyFinalRules(PhoneticEngine.PhonemeBuilder phonemeBuilder,
Map<String,List<Rule>> finalRules)
Applies the final rules to convert from a language-specific phonetic representation to a
language-independent representation.
|
String |
encode(String input)
Encodes a string to its phonetic representation.
|
String |
encode(String input,
Languages.LanguageSet languageSet)
Encodes an input string into an output phonetic representation, given a set of possible origin languages.
|
Lang |
getLang()
Gets the Lang language guessing rules being used.
|
int |
getMaxPhonemes()
Gets the maximum number of phonemes the engine will calculate for a given input.
|
NameType |
getNameType()
Gets the NameType being used.
|
RuleType |
getRuleType()
Gets the RuleType being used.
|
boolean |
isConcat()
Gets if multiple phonetic encodings are concatenated or if just the first one is kept.
|
private static String |
join(Iterable<String> strings,
String sep)
Joins some strings with an internal separator.
|
private static final Map<NameType,Set<String>> NAME_PREFIXES
private static final int DEFAULT_MAX_PHONEMES
private final boolean concat
private final int maxPhonemes
public PhoneticEngine(NameType nameType, RuleType ruleType, boolean concat)
nameType
- the type of names it will useruleType
- the type of rules it will applyconcat
- if it will concatenate multiple encodingspublic PhoneticEngine(NameType nameType, RuleType ruleType, boolean concat, int maxPhonemes)
nameType
- the type of names it will useruleType
- the type of rules it will applyconcat
- if it will concatenate multiple encodingsmaxPhonemes
- the maximum number of phonemes that will be handledprivate static String join(Iterable<String> strings, String sep)
strings
- Strings to joinsep
- String to separate them withstrings
interleaved by sep
private PhoneticEngine.PhonemeBuilder applyFinalRules(PhoneticEngine.PhonemeBuilder phonemeBuilder, Map<String,List<Rule>> finalRules)
phonemeBuilder
- the current phonemesfinalRules
- the final rules to applypublic String encode(String input)
input
- the String to encodepublic String encode(String input, Languages.LanguageSet languageSet)
input
- String to phoneticise; a String with dashes or spaces separating each wordlanguageSet
- public Lang getLang()
public NameType getNameType()
public RuleType getRuleType()
public boolean isConcat()
public int getMaxPhonemes()
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses