public static void normalizeDoubleQuotes ( final List < Token > sentence , final String lang ) { boolean isLeft = true ; for ( int i = 0 ; i < sentence . size ( ) ; i ++ ) { if ( lang . equalsIgnoreCase ( "en" ) ) { final Matcher doubleAsciiQuoteMatcher = doubleAsciiQuote . matcher ( sentence . get ( i ) . getTokenValue ( ) ) ; final Matcher singleAsciiQuoteMatcher = singleAsciiQuote . matcher ( sentence . get ( i ) . getTokenValue ( ) ) ; // if current token is " if ( doubleAsciiQuoteMatcher . find ( ) ) { if ( isLeft && i < sentence . size ( ) - 1 && doubleAsciiQuoteAlphaNumeric . matcher ( sentence . get ( i + 1 ) . getTokenValue ( ) ) . find ( ) ) { sentence . get ( i ) . setTokenValue ( "``" ) ; isLeft = false ; } else if ( ! isLeft ) { sentence . get ( i ) . setTokenValue ( "''" ) ; isLeft = true ; } } else if ( singleAsciiQuoteMatcher . find ( ) ) { if ( i < sentence . size ( ) - 2 && sentence . get ( i + 1 ) . getTokenValue ( ) . matches ( "[A-Za-z]" ) && sentence . get ( i + 2 ) . getTokenValue ( ) . matches ( "[^ \t\n\r\u00A0\u00B6]" ) ) { sentence . get ( i ) . setTokenValue ( "`" ) ; } } } } }
Normalizes double and ambiguous quotes according to language and corpus .