Skip to content

Commit

Permalink
Merge pull request #114 from jaumeortola/run-on-camelcase
Browse files Browse the repository at this point in the history
improve run-on suggestions for camel case words
dweiss authored Apr 20, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 3364cf6 + dbc11c3 commit fcaa33e
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -335,7 +335,9 @@ public List<CandidateData> replaceRunOnWordCandidates(final String original) {
// chop from left to right
final String prefix = wordToCheck.substring(0, i);
final String suffix = wordToCheck.substring(i);
if (isInDictionary(suffix)) {
if (isInDictionary(suffix)
// camel case words: e.g. GreatElephant
|| (!isNotCapitalizedWord(suffix) && isInDictionary(suffix.toLowerCase(locale)))) {
if (isInDictionary(prefix)) {
addReplacement(candidates, prefix + " " + suffix);
} else if (Character.isUpperCase(prefix.charAt(0)) && isInDictionary(prefix.toLowerCase(locale))) {
Original file line number Diff line number Diff line change
@@ -51,6 +51,10 @@ public void testRunonWords() throws IOException {
final URL url2 = getClass().getResource("single-char-word.dict");
final Speller spell2 = new Speller(Dictionary.read(url2));
assertTrue(spell2.replaceRunOnWords("alot").contains("a lot"));
assertTrue(spell2.replaceRunOnWords("Alot").contains("A lot"));
assertTrue(spell2.replaceRunOnWords("ALot").contains("A Lot"));
assertTrue(spell2.replaceRunOnWords("LotAmusement").contains("Lot Amusement"));
//TODO? assertTrue(spell2.replaceRunOnWords("LOTAMUSEMENT").contains("LOT AMUSEMENT"));
assertTrue(spell2.replaceRunOnWords("aalot").contains("aa lot"));
assertTrue(spell2.replaceRunOnWords("aamusement").contains("a amusement"));
assertTrue(spell2.replaceRunOnWords("clot").isEmpty());

0 comments on commit fcaa33e

Please sign in to comment.