Skip to content

Instantly share code, notes, and snippets.

@tlberglund
Created November 29, 2012 16:19
Show Gist options
  • Save tlberglund/4170099 to your computer and use it in GitHub Desktop.
Save tlberglund/4170099 to your computer and use it in GitHub Desktop.
Poetry Emitter encode() method
import org.apache.commons.codec.language.DoubleMetaphone;
public String encode(String line) {
DoubleMetaphone codec = new DoubleMetaphone();
List<String> words = new ArrayList<String>();
StringTokenizer st = new StringTokenizer(line);
while(st.hasMoreTokens()) {
String word = st.nextToken();
words.add(codec.encode(word));
}
StringBuilder sb = new StringBuilder();
for(String word : words) {
sb.append(word);
sb.append(" ");
}
return sb.toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment