Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve run-on suggestions for camel case words #114

Merged
merged 1 commit into from
Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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());
Expand Down