Dave Jarvis' Repositories

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

Resolve unambiguous possessives

AuthorDave Jarvis <email>
Date2022-06-08 22:20:31 GMT-0700
Commit32765e7a3a205440f1e8f061a5db04f5a67083a2
Parent45de341
src/main/java/com/whitemagicsoftware/keenquotes/Parser.java
}
else if( lex2.isType( NUMBER ) && lex1.isType( QUOTE_SINGLE ) ) {
- // Sentences must re-written to avoid starting with numerals.
+ // Authors must re-write their sentences to avoid starting with numerals.
if( lex3.isType( SPACE, PUNCT ) || lex3.isType( WORD ) &&
lex3.toString( mText ).equalsIgnoreCase( "s" ) ) {
- // Examples: '20s, '02
+ // E.g.: '20s, '02
consumer.accept( new Token( QUOTE_APOSTROPHE, lex1 ) );
}
(lex1.isSot() || lex1.isType( LEADING_QUOTE_OPENING_DOUBLE )) &&
lex3.isType( LAGGING_QUOTE_OPENING_DOUBLE ) ) {
- // Examples: "", "..., "word, ---"word
+ // E.g.: "", "..., "word, ---"word
consumer.accept( new Token( QUOTE_OPENING_DOUBLE, lex2 ) );
mOpeningDoubleQuotes.add( lex2 );
}
else if( lex2.isType( QUOTE_DOUBLE ) &&
lex1.isType( LEADING_QUOTE_CLOSING_DOUBLE ) &&
(lex3.isEot() || lex3.isType( LAGGING_QUOTE_CLOSING_DOUBLE )) ) {
- // Examples: ..."', word"', ?"', word"?
+ // E.g.: ..."', word"', ?"', word"?
consumer.accept( new Token( QUOTE_CLOSING_DOUBLE, lex2 ) );
mClosingDoubleQuotes.add( lex2 );
lex2.isType( QUOTE_SINGLE ) &&
lex3.isType( QUOTE_DOUBLE ) ) {
- // Example: ---'"
+ // E.g., ---'"
consumer.accept( new Token( QUOTE_CLOSING_SINGLE, lex2 ) );
mClosingSingleQuotes.add( lex2 );
// The quote mark forms a word that does not stand alone from its
// contraction. For example, twas is not a word: it's 'twas.
+ consumer.accept( new Token( QUOTE_APOSTROPHE, lex2 ) );
+ i.remove();
+ }
+ else if( lex1.isType( WORD ) &&
+ (lex3.isType( PUNCT, PERIOD, ELLIPSIS, DASH, SPACE, EOP ) ||
+ lex3.isEot()) && unresolved.indexOf( quotes ) == 0 &&
+ resolvedLeadingQuotes == 0 ) {
+ // E.g., Tyfós'
consumer.accept( new Token( QUOTE_APOSTROPHE, lex2 ) );
i.remove();
src/test/java/com/whitemagicsoftware/keenquotes/LexerTest.java
testType( "abc abc", WORD, SPACE, WORD );
testType( "abc...", WORD, ELLIPSIS );
- testType( "abc123", WORD, NUMBER );
+ testType( "abc123", WORD );
testType( "-123abc", NUMBER, WORD );
testType( "abc-o'-abc", WORD, HYPHEN, WORD, QUOTE_SINGLE, HYPHEN, WORD );
src/test/java/com/whitemagicsoftware/keenquotes/XmlLexerTest.java
void test_Lexing_XmlAttribute_EmitTags() {
final var actual = "<a href=\"http://x.org\">X11</a>";
- testType( createXmlLexer( actual ), actual, WORD, NUMBER );
+ testType( createXmlLexer( actual ), actual, WORD );
}
Delta15 lines added, 7 lines removed, 8-line increase