/** * Encode a value with Double Metaphone. * * @param value String to encode * @return an encoded string */ public String doubleMetaphone(final String value) { return doubleMetaphone(value, false); }
/** * Encode the value using DoubleMetaphone. * * @param value String to encode * @return An encoded String */ @Override public String encode(final String value) { return doubleMetaphone(value); }
/** * Encode the value using DoubleMetaphone. * * @param value String to encode * @return An encoded String */ public String encode(String value) { return doubleMetaphone(value); }
/** * Encode a value with Double Metaphone * * @param value String to encode * @return an encoded string */ public String doubleMetaphone(String value) { return doubleMetaphone(value, false); }
/** * Check if the Double Metaphone values of two <code>String</code> values * are equal, optionally using the alternate value. * * @param value1 The left-hand side of the encoded {@link String#equals(Object)}. * @param value2 The right-hand side of the encoded {@link String#equals(Object)}. * @param alternate use the alternate value if <code>true</code>. * @return <code>true</code> if the encoded <code>String</code>s are equal; * <code>false</code> otherwise. */ public boolean isDoubleMetaphoneEqual(final String value1, final String value2, final boolean alternate) { return StringUtils.equals(doubleMetaphone(value1, alternate), doubleMetaphone(value2, alternate)); }
/** * Check if the Double Metaphone values of two <code>String</code> values * are equal, optionally using the alternate value. * * @param value1 The left-hand side of the encoded {@link String#equals(Object)}. * @param value2 The right-hand side of the encoded {@link String#equals(Object)}. * @param alternate use the alternate value if <code>true</code>. * @return <code>true</code> if the encoded <code>String</code>s are equal; * <code>false</code> otherwise. */ public boolean isDoubleMetaphoneEqual(String value1, String value2, boolean alternate) { return doubleMetaphone(value1, alternate).equals(doubleMetaphone (value2, alternate)); }
/** * Encode the value using DoubleMetaphone. It will only work if * <code>obj</code> is a <code>String</code> (like <code>Metaphone</code>). * * @param obj Object to encode (should be of type String) * @return An encoded Object (will be of type String) * @throws EncoderException encode parameter is not of type String */ @Override public Object encode(final Object obj) throws EncoderException { if (!(obj instanceof String)) { throw new EncoderException("DoubleMetaphone encode parameter is not of type String"); } return doubleMetaphone((String) obj); }
public static String get_Double_Metaphone( ValueMetaInterface metaA, Object dataA ) { if ( dataA == null ) { return null; } return ( new DoubleMetaphone() ).doubleMetaphone( dataA.toString() ); }
/** * Encode the value using DoubleMetaphone. It will only work if * <code>obj</code> is a <code>String</code> (like <code>Metaphone</code>). * * @param obj Object to encode (should be of type String) * @return An encoded Object (will be of type String) * @throws EncoderException encode parameter is not of type String */ public Object encode(Object obj) throws EncoderException { if (!(obj instanceof String)) { throw new EncoderException("DoubleMetaphone encode parameter is not of type String"); } return doubleMetaphone((String) obj); }
@Override public void eval() { String input = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(rawInput.start, rawInput.end, rawInput.buffer); String outputString = new org.apache.commons.codec.language.DoubleMetaphone().doubleMetaphone(input); outputString = outputString == null ? "" : outputString; out.buffer = buffer; out.start = 0; out.end = outputString.getBytes().length; buffer.setBytes(0, outputString.getBytes()); } }
/** * Tests encoding APIs in one place. */ public void assertDoubleMetaphoneAlt(final String expected, final String source) { assertEquals(expected, this.getStringEncoder().doubleMetaphone(source, true)); }
private void checkDoubleMetaphone(final int typeIndex, final boolean alternate) { for (int i = 0; i < TEST_DATA.length; i++) { final String value = TEST_DATA[i][0]; assertEquals("Test [" + i + "]=" + value, TEST_DATA[i][typeIndex], this.getStringEncoder().doubleMetaphone(value, alternate)); } }
@Test public void testEmpty() { assertEquals(null, this.getStringEncoder().doubleMetaphone(null)); assertEquals(null, this.getStringEncoder().doubleMetaphone("")); assertEquals(null, this.getStringEncoder().doubleMetaphone(" ")); assertEquals(null, this.getStringEncoder().doubleMetaphone("\t\n\r ")); }
/** * Test setting maximum length */ @Test public void testSetMaxCodeLength() { final String value = "jumped"; final DoubleMetaphone doubleMetaphone = new DoubleMetaphone(); // Sanity check of default settings assertEquals("Default Max Code Length", 4, doubleMetaphone.getMaxCodeLen()); assertEquals("Default Primary", "JMPT", doubleMetaphone.doubleMetaphone(value, false)); assertEquals("Default Alternate", "AMPT", doubleMetaphone.doubleMetaphone(value, true)); // Check setting Max Code Length doubleMetaphone.setMaxCodeLen(3); assertEquals("Set Max Code Length", 3, doubleMetaphone.getMaxCodeLen()); assertEquals("Max=3 Primary", "JMP", doubleMetaphone.doubleMetaphone(value, false)); assertEquals("Max=3 Alternate", "AMP", doubleMetaphone.doubleMetaphone(value, true)); }
private String getEncodedMF( String value, Integer algorithmType ) { String encodedValueMF = ""; switch ( algorithmType ) { case FuzzyMatchMeta.OPERATION_TYPE_METAPHONE: encodedValueMF = ( new Metaphone() ).metaphone( value ); break; case FuzzyMatchMeta.OPERATION_TYPE_DOUBLE_METAPHONE: encodedValueMF = ( ( new DoubleMetaphone() ).doubleMetaphone( value ) ); break; case FuzzyMatchMeta.OPERATION_TYPE_SOUNDEX: encodedValueMF = ( new Soundex() ).encode( value ); break; case FuzzyMatchMeta.OPERATION_TYPE_REFINED_SOUNDEX: encodedValueMF = ( new RefinedSoundex() ).encode( value ); break; default: break; } return encodedValueMF; }
/** * Tests encoding APIs in one place. */ private void assertDoubleMetaphone(final String expected, final String source) { assertEquals(expected, this.getStringEncoder().encode(source)); try { assertEquals(expected, this.getStringEncoder().encode((Object) source)); } catch (final EncoderException e) { fail("Unexpected expection: " + e); } assertEquals(expected, this.getStringEncoder().doubleMetaphone(source)); assertEquals(expected, this.getStringEncoder().doubleMetaphone(source, false)); }
/** * Encode a value with Double Metaphone * * @param value String to encode * @return an encoded string */ public String doubleMetaphone(String value) { return doubleMetaphone(value, false); }
/** * Encode a value with Double Metaphone. * * @param value String to encode * @return an encoded string */ public String doubleMetaphone(final String value) { return doubleMetaphone(value, false); }
/** * Encode the value using DoubleMetaphone. * * @param value String to encode * @return An encoded String */ @Override public String encode(final String value) { return doubleMetaphone(value); }
/** * Encode the value using DoubleMetaphone. * * @param value String to encode * @return An encoded String */ public String encode(String value) { return doubleMetaphone(value); }