List of usage examples for org.apache.commons.codec.language Metaphone Metaphone
public Metaphone()
From source file:com.vangent.hieos.empi.transform.MetaphoneTransformFunction.java
/** * /*from w w w . j av a 2 s .com*/ * @param obj * @return */ public Object transform(Object obj) { Metaphone encoder = new Metaphone(); return encoder.encode((String) obj); }
From source file:dkpro.similarity.algorithms.sound.MetaphoneComparator.java
public MetaphoneComparator() { encoder = new Metaphone(); }
From source file:aos.lucene.analysis.codec.CodecTest.java
public void testMetaphone() throws Exception { Metaphone metaphoner = new Metaphone(); assertEquals(metaphoner.encode("cute"), metaphoner.encode("cat")); }
From source file:de.tudarmstadt.ukp.dkpro.core.commonscodec.MetaphonePhoneticTranscriptor.java
public MetaphonePhoneticTranscriptor() { this.encoder = new Metaphone(); }
From source file:com.kodemore.text.KmTextUtilities.java
/** * The metaphone alghorithm.//from ww w . j a v a 2 s. c om * This is an improvement over soundex and is generally applicable for * all words, not just names. * * http://en.wikipedia.org/wiki/Metaphone */ public static String metaphone(String s) { return new Metaphone().encode(s); }
From source file:ca.sqlpower.matchmaker.munge.MetaphoneMungeStep.java
public Boolean doCall() throws Exception { MungeStepOutput<String> out = getOut(); MungeStepOutput<String> in = getMSOInputs().get(0); String data = in.getData();/*from w ww. j a va2 s .com*/ if (data != null) { out.setData(new Metaphone().metaphone(data)); } else { out.setData(null); } return true; }
From source file:com.example.PhoneticTokenFilterFactory.java
@Inject public PhoneticTokenFilterFactory(Index index, IndexSettingsService indexSettingsService, @Assisted String name, @Assisted Settings settings) {//from w w w . j av a2 s. c o m super(index, indexSettingsService.getSettings(), name, settings); this.languageset = null; this.nametype = null; this.ruletype = null; this.maxcodelength = 0; this.replace = settings.getAsBoolean("replace", true); // weird, encoder is null at last step in SimplePhoneticAnalysisTests, so we set it to metaphone as default String encodername = settings.get("encoder", "metaphone"); if ("metaphone".equalsIgnoreCase(encodername)) { this.encoder = new Metaphone(); } else if ("soundex".equalsIgnoreCase(encodername)) { this.encoder = new Soundex(); } else if ("caverphone1".equalsIgnoreCase(encodername)) { this.encoder = new Caverphone1(); } else if ("caverphone2".equalsIgnoreCase(encodername)) { this.encoder = new Caverphone2(); } else if ("caverphone".equalsIgnoreCase(encodername)) { this.encoder = new Caverphone2(); } else if ("refined_soundex".equalsIgnoreCase(encodername) || "refinedSoundex".equalsIgnoreCase(encodername)) { this.encoder = new RefinedSoundex(); } else if ("cologne".equalsIgnoreCase(encodername)) { this.encoder = new ColognePhonetic(); } else if ("double_metaphone".equalsIgnoreCase(encodername) || "doubleMetaphone".equalsIgnoreCase(encodername)) { this.encoder = null; this.maxcodelength = settings.getAsInt("max_code_len", 4); } else if ("bm".equalsIgnoreCase(encodername) || "beider_morse".equalsIgnoreCase(encodername) || "beidermorse".equalsIgnoreCase(encodername)) { this.encoder = null; this.languageset = settings.getAsArray("languageset"); String ruleType = settings.get("rule_type", "approx"); if ("approx".equalsIgnoreCase(ruleType)) { ruletype = RuleType.APPROX; } else if ("exact".equalsIgnoreCase(ruleType)) { ruletype = RuleType.EXACT; } else { throw new IllegalArgumentException( "No matching rule type [" + ruleType + "] for beider morse encoder"); } String nameType = settings.get("name_type", "generic"); if ("GENERIC".equalsIgnoreCase(nameType)) { nametype = NameType.GENERIC; } else if ("ASHKENAZI".equalsIgnoreCase(nameType)) { nametype = NameType.ASHKENAZI; } else if ("SEPHARDIC".equalsIgnoreCase(nameType)) { nametype = NameType.SEPHARDIC; } } else if ("koelnerphonetik".equalsIgnoreCase(encodername)) { this.encoder = new KoelnerPhonetik(); } else if ("haasephonetik".equalsIgnoreCase(encodername)) { this.encoder = new HaasePhonetik(); } else if ("nysiis".equalsIgnoreCase(encodername)) { this.encoder = new Nysiis(); } else if ("daitch_mokotoff".equalsIgnoreCase(encodername)) { this.encoder = new DaitchMokotoffSoundex(); } else { throw new IllegalArgumentException("unknown encoder [" + encodername + "] for phonetic token filter"); } }
From source file:com.panet.imeta.core.row.ValueDataUtil.java
public static String get_Metaphone(ValueMetaInterface metaA, Object dataA) { if (dataA == null) return null; return (new Metaphone()).metaphone(dataA.toString()); }
From source file:com.jaeksoft.searchlib.analysis.filter.PhoneticFilter.java
@Override public TokenStream create(TokenStream tokenStream) { if (BEIDER_MORSE.equals(codec)) return new BeiderMorseTokenFilter(tokenStream, new EncoderKey(ruleType, maxPhonemes)); if (COLOGNE_PHONETIC.equals(codec)) return new EncoderTokenFilter(tokenStream, new ColognePhonetic()); if (SOUNDEX.equals(codec)) return new EncoderTokenFilter(tokenStream, new Soundex()); if (REFINED_SOUNDEX.equals(codec)) return new EncoderTokenFilter(tokenStream, new RefinedSoundex()); if (METAPHONE.equals(codec)) return new EncoderTokenFilter(tokenStream, new Metaphone()); if (CAVERPHONE1.equals(codec)) return new EncoderTokenFilter(tokenStream, new Caverphone1()); if (CAVERPHONE2.equals(codec)) return new EncoderTokenFilter(tokenStream, new Caverphone2()); return null;// w w w. j a v a2s.c o m }
From source file:at.jps.sanction.core.util.TokenTool.java
public static float compareCheckMetaphone(final String text1, final String text2, final boolean fuzzy, final int minlen, final double fuzzyValue) { final Metaphone encoder = new Metaphone(); // TODO: in reallife make this go // away/*from w w w .j a va2 s . c o m*/ // !! return (compareCheck(encoder.metaphone(text1), encoder.metaphone(text2), fuzzy, minlen, fuzzyValue)); }