Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenwrite.git

Fix spellchecking possessives

AuthorDaveJarvis <email>
Date2020-07-09 20:19:54 GMT-0700
Commit8a9eead13a976e8bbe7e3045644b8ebe23d8036d
Parent1532e92
Delta8 lines added, 4 lines removed, 4-line increase
src/main/java/com/scrivenvar/spelling/impl/SymSpellSpeller.java
while( boundaryIndex != BreakIterator.DONE ) {
- final String substring =
- text.substring( previousIndex, boundaryIndex ).toLowerCase();
+ final var lex = text.substring( previousIndex, boundaryIndex )
+ .toLowerCase();
- if( isWord( substring ) && !inLexicon( substring ) ) {
- consumer.accept( substring, previousIndex, boundaryIndex );
+ // Get the lexeme for the possessive.
+ final var pos = lex.endsWith( "'s" ) || lex.endsWith( "’s" );
+ final var lexeme = pos ? lex.substring( 0, lex.length() - 2 ) : lex;
+
+ if( isWord( lexeme ) && !inLexicon( lexeme ) ) {
+ consumer.accept( lex, previousIndex, boundaryIndex );
}