final String remainder = input.substring(2); final String combined = "d" + remainder; return "(" + encode(remainder) + ")-(" + encode(combined) + ")"; return "(" + encode(remainder) + ")-(" + encode(combined) + ")"; input = join(words2, " "); } else if (words2.size() == 1) { result.append("-").append(encode(word)); phonemeBuilder = applyFinalRules(phonemeBuilder, finalRules1); phonemeBuilder = applyFinalRules(phonemeBuilder, finalRules2);
/** * Sets the rule type to apply. This will widen or narrow the range of phonetic encodings considered. * * @param ruleType * {@link RuleType#APPROX} or {@link RuleType#EXACT} for approximate or exact phonetic matches */ public void setRuleType(final RuleType ruleType) { this.engine = new PhoneticEngine(this.engine.getNameType(), ruleType, this.engine.isConcat(), this.engine.getMaxPhonemes()); }
/** * Sets the type of name. Use {@link NameType#GENERIC} unless you specifically want phonetic encodings * optimized for Ashkenazi or Sephardic Jewish family names. * * @param nameType * the NameType in use */ public void setNameType(final NameType nameType) { this.engine = new PhoneticEngine(nameType, this.engine.getRuleType(), this.engine.isConcat(), this.engine.getMaxPhonemes()); }
/** * Sets the number of maximum of phonemes that shall be considered by the engine. * * @param maxPhonemes * the maximum number of phonemes returned by the engine * @since 1.7 */ public void setMaxPhonemes(final int maxPhonemes) { this.engine = new PhoneticEngine(this.engine.getNameType(), this.engine.getRuleType(), this.engine.isConcat(), maxPhonemes); }
/** * Sets how multiple possible phonetic encodings are combined. * * @param concat * true if multiple encodings are to be combined with a '|', false if just the first one is * to be considered */ public void setConcat(final boolean concat) { this.engine = new PhoneticEngine(this.engine.getNameType(), this.engine.getRuleType(), concat, this.engine.getMaxPhonemes()); }
@Override public String encode(final String source) throws EncoderException { if (source == null) { return null; } return this.engine.encode(source); }
@Test public void test() { final PhoneticEngine engine = new PhoneticEngine(NameType.GENERIC, RuleType.APPROX, true); final String input = "Angelo"; final long startMillis = System.currentTimeMillis(); for (int i = 0; i < LOOP; i++) { engine.encode(input); } final long totalMillis = System.currentTimeMillis() - startMillis; System.out.println(String.format("Time for encoding %,d times the input '%s': %,d millis.", LOOP, input, totalMillis)); } }
/** * Gets the name type currently in operation. * * @return the NameType currently being used */ public NameType getNameType() { return this.engine.getNameType(); }
/** * Gets the rule type currently in operation. * * @return the RuleType currently being used */ public RuleType getRuleType() { return this.engine.getRuleType(); }
/** * Discovers if multiple possible encodings are concatenated. * * @return true if multiple encodings are concatenated, false if just the first one is returned */ public boolean isConcat() { return this.engine.isConcat(); }
/** * Sets the number of maximum of phonemes that shall be considered by the engine. * * @param maxPhonemes * the maximum number of phonemes returned by the engine * @since 1.7 */ public void setMaxPhonemes(final int maxPhonemes) { this.engine = new PhoneticEngine(this.engine.getNameType(), this.engine.getRuleType(), this.engine.isConcat(), maxPhonemes); }
/** * Sets how multiple possible phonetic encodings are combined. * * @param concat * true if multiple encodings are to be combined with a '|', false if just the first one is * to be considered */ public void setConcat(final boolean concat) { this.engine = new PhoneticEngine(this.engine.getNameType(), this.engine.getRuleType(), concat, this.engine.getMaxPhonemes()); }
/** * Encodes a string to its phonetic representation. * * @param input * the String to encode * @return the encoding of the input */ public String encode(final String input) { final Languages.LanguageSet languageSet = this.lang.guessLanguages(input); return encode(input, languageSet); }
final RuleType ruleType = (ruleTypeArg == null) ? RuleType.APPROX : RuleType.valueOf(ruleTypeArg); engine = new PhoneticEngine(nameType, ruleType, concat); return engine.encode(input); return engine.encode(input, languageSet);
/** * Gets the name type currently in operation. * * @return the NameType currently being used */ public NameType getNameType() { return this.engine.getNameType(); }
/** * Gets the rule type currently in operation. * * @return the RuleType currently being used */ public RuleType getRuleType() { return this.engine.getRuleType(); }
/** * Discovers if multiple possible encodings are concatenated. * * @return true if multiple encodings are concatenated, false if just the first one is returned */ public boolean isConcat() { return this.engine.isConcat(); }
/** * Sets the rule type to apply. This will widen or narrow the range of phonetic encodings considered. * * @param ruleType * {@link RuleType#APPROX} or {@link RuleType#EXACT} for approximate or exact phonetic matches */ public void setRuleType(final RuleType ruleType) { this.engine = new PhoneticEngine(this.engine.getNameType(), ruleType, this.engine.isConcat(), this.engine.getMaxPhonemes()); }
/** * Sets the type of name. Use {@link NameType#GENERIC} unless you specifically want phonetic encodings * optimized for Ashkenazi or Sephardic Jewish family names. * * @param nameType * the NameType in use */ public void setNameType(final NameType nameType) { this.engine = new PhoneticEngine(nameType, this.engine.getRuleType(), this.engine.isConcat(), this.engine.getMaxPhonemes()); }
/** * Sets the number of maximum of phonemes that shall be considered by the engine. * * @param maxPhonemes * the maximum number of phonemes returned by the engine * @since 1.7 */ public void setMaxPhonemes(final int maxPhonemes) { this.engine = new PhoneticEngine(this.engine.getNameType(), this.engine.getRuleType(), this.engine.isConcat(), maxPhonemes); }