List of usage examples for org.apache.commons.codec.language Soundex US_ENGLISH
Soundex US_ENGLISH
To view the source code for org.apache.commons.codec.language Soundex US_ENGLISH.
Click Source Link
From source file:de.micromata.genome.util.matcher.norm.StringNormalizeUtils.java
/** * normalize a string./*from w w w . jav a 2 s . c o m*/ * * @param text the text * @param flags a collection of characters. See public static finals in this class. * @return the string */ public static String normalize(String text, String flags) { if (text == null) { return text; } if (flags.indexOf(REPLACEUMLAUTS) != -1) { text = deAccent(text); //replaceUmlauts(text); } if (flags.indexOf(UPPERCASE) != -1) { text = text.toUpperCase(); } if (flags.indexOf(NOWHITESPACE) != -1) { text = NON_WHITESPACE_PATTERN.get().matcher(text).replaceAll(""); } if (flags.indexOf(ASCIILETTERNUMBERSONLY) != -1) { text = NON_ALPHANUM_PATTERN.get().matcher(text).replaceAll(""); } if (flags.indexOf(SOUNDEX) != -1) { text = Soundex.US_ENGLISH.encode(text); } if (flags.indexOf(COLOGNE) != -1) { text = new ColognePhonetic().encode(text); } return text; }
From source file:com.inikah.slayer.service.impl.LocationLocalServiceImpl.java
public long insertCity(long regionId, String name, long userId) { long cityId = 0l; List<Location> cities = null; try {//from w w w.jav a2s .c om cities = locationPersistence.findByParentId_LocType(regionId, IConstants.LOC_TYPE_CITY); } catch (SystemException e) { e.printStackTrace(); } // check for soundex for (Location city : cities) { int diff = 0; try { diff = Soundex.US_ENGLISH.difference(city.getName(), name); } catch (EncoderException e) { e.printStackTrace(); } if (diff == 4) { cityId = city.getLocationId(); break; } } if (cityId == 0l) { try { cityId = counterLocalService.increment(Location.class.getName()); } catch (SystemException e) { e.printStackTrace(); } Location city = createLocation(cityId); city.setName(name); city.setUserId(userId); city.setLocType(IConstants.LOC_TYPE_CITY); city.setParentId(regionId); city.setActive_(false); try { addLocation(city); NotifyUtil.newCityCreated(city); } catch (SystemException e) { e.printStackTrace(); } } return cityId; }
From source file:com.slayer.service.impl.LocationLocalServiceImpl.java
public long insertCityUI(long regionId, String name, long userId) { long cityId = 0l; List<Location> cities = null; try {//from w w w . ja v a 2 s . c o m cities = locationPersistence.findByParentId_LocType(regionId, IConstants.LOC_TYPE_CITY); } catch (SystemException e) { e.printStackTrace(); } // check for soundex for (Location city : cities) { int diff = 0; try { diff = Soundex.US_ENGLISH.difference(city.getName(), name); } catch (EncoderException e) { e.printStackTrace(); } if (diff == 4) { cityId = city.getLocationId(); break; } } if (cityId == 0l) { try { cityId = counterLocalService.increment(Location.class.getName()); } catch (SystemException e) { e.printStackTrace(); } Location city = createLocation(cityId); city.setName(name); city.setUserId(userId); city.setLocType(IConstants.LOC_TYPE_CITY); city.setParentId(regionId); city.setActive_(false); try { addLocation(city); } catch (SystemException e) { e.printStackTrace(); } } return cityId; }
From source file:org.vivoweb.harvester.score.algorithm.NormalizedSoundExDifference.java
@Override public float calculate(CharSequence itemX, CharSequence itemY) { try {/* w w w . j ava 2 s . c o m*/ int diff = Soundex.US_ENGLISH.difference(itemX.toString(), itemY.toString()); return (diff / 4f); } catch (EncoderException e) { throw new IllegalArgumentException(e); } }