@Override public String encode(final String source) throws EncoderException { if (source == null) { return null; } return this.engine.encode(source); }
/** * 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); }
@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)); } }
@Test(timeout = 10000L) public void testEncode() { final PhoneticEngine engine = new PhoneticEngine(this.nameType, this.ruleType, this.concat, this.maxPhonemes); final String phoneticActual = engine.encode(this.name); //System.err.println("expecting: " + this.phoneticExpected); //System.err.println("actual: " + phoneticActual); assertEquals("phoneme incorrect", this.phoneticExpected, phoneticActual); if (this.concat) { final String[] split = phoneticActual.split("\\|"); assertTrue(split.length <= this.maxPhonemes); } else { final String[] words = phoneticActual.split("-"); for (final String word : words) { final String[] split = word.split("\\|"); assertTrue(split.length <= this.maxPhonemes); } } } }
@Override public String encode(final String source) throws EncoderException { if (source == null) { return null; } return this.engine.encode(source); }
@Override public String encode(final String source) throws EncoderException { if (source == null) { return null; } return this.engine.encode(source); }
@Override public String encode(final String source) throws EncoderException { if (source == null) { return null; } return this.engine.encode(source); }
@Override public String encode(final String source) throws EncoderException { if (source == null) { return null; } return this.engine.encode(source); }
@Override public String encode(final String source) throws EncoderException { if (source == null) { return null; } return this.engine.encode(source); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
/** * 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); }
@Override public boolean incrementToken() throws IOException { if (matcher.find()) { clearAttributes(); termAtt.setEmpty().append(encoded, matcher.start(1), matcher.end(1)); posIncAtt.setPositionIncrement(0); offsetAtt.setOffset(startOffset, endOffset); return true; } if (input.incrementToken()) { encoded = (languages == null) ? engine.encode(termAtt.toString()) : engine.encode(termAtt.toString(), languages); startOffset = offsetAtt.startOffset(); endOffset = offsetAtt.endOffset(); matcher.reset(encoded); if (matcher.find()) { termAtt.setEmpty().append(encoded, matcher.start(1), matcher.end(1)); } return true; } else { return false; } }