Skip to content

Commit

Permalink
Revert "Revert "improve run-on suggestions for camel case words""
Browse files Browse the repository at this point in the history
This reverts commit e44fac4.
  • Loading branch information
dweiss committed Apr 21, 2022
1 parent 2c07544 commit 2a6482f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,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());
Expand Down

0 comments on commit 2a6482f

Please sign in to comment.