Skip to content

Instantly share code, notes, and snippets.

@xrrocha
Created March 5, 2018 00:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xrrocha/3cf1b84a81394eadb131c34a9146a9ae to your computer and use it in GitHub Desktop.
Save xrrocha/3cf1b84a81394eadb131c34a9146a9ae to your computer and use it in GitHub Desktop.
private List<String> edits1(String typo) {
// Generate all splits for the word so as to account for typos originating
// in the insertion of a space in the middle of the word
List<WordSplit> wordSplits = splits(typo);
// Generate and apply all 4 edits (in parallel) to each split. Packing removes
// duplicates, ensures result presence in dictionary and orders by rank
return pack(edits.parallelStream()
.flatMap(edit -> edit.apply(wordSplits)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment