Dave Jarvis' Repositories

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

Add Unicode dash, add contractions, make an' unambiguous

AuthorDave Jarvis <email>
Date2021-06-16 22:41:31 GMT-0700
Commita2fe59913e6982c414bac89e462d9c42c278363f
Parent4d67ed8
lib/src/main/java/com/keenwrite/quotes/Contractions.java
// for/before
"fo",
+ // lord
+ "lor",
+ // myself
+ "masel",
// old
"ol",
lib/src/main/java/com/keenwrite/quotes/Lexer.java
lexeme = createLexeme( QUOTE_DOUBLE, began, i.getIndex() );
}
- else if( curr == '-' && peek( i ) == '-' ) {
- slurp( i, ( next, ci ) -> next == '-' );
+ else if( curr == '-' && peek( i ) == '-' || curr == '—' ) {
+ slurp( i, ( next, ci ) -> next == '-' || next == '—' );
lexeme = createLexeme( DASH, began, i.getIndex() );
lib/src/test/java/com/keenwrite/quotes/KeenQuotesTest.java
public void test_parse_SingleLine_Parsed() {
out.println( KeenQuotes.convert(
- "shouldn't drop letters, nor say \"ain't\" or \"hain't.\"",
+ "\"’Kearney lives on the banks of Killarney—’",
out::println
) );
@ParameterizedTest
- @ValueSource( strings = {"chapman", "habberton", "foote"} )
+ @ValueSource( strings = {"westrup"} )
void test_Parse_Story_Converted( final String filename ) throws IOException {
final var sb = new StringBuilder( 2 ^ 20 );
+ System.out.println( "---------------------" );
+ System.out.println( filename );
try( final var reader = open( filename + ".txt" ) ) {
String line;
while( (line = reader.readLine()) != null ) {
sb.append( line ).append( '\n' );
}
}
- KeenQuotes.convert( sb.toString(), out::println );
+ System.out.println( KeenQuotes.convert( sb.toString(), out::println ) );
}
lib/src/test/resources/com/keenwrite/quotes/smartypants.txt
shouldn&apos;t drop letters, nor say &ldquo;ain&apos;t&rdquo; or &ldquo;hain&apos;t.&rdquo;
+#"’Kearney lives on the banks of Killarney—’
+#&ldquo;’Kearney lives on the banks of Killarney—’
+
# ########################################################################
# Mixed
Delta14 lines added, 5 lines removed, 9-line increase