private static List < ContextWords > loadContextWords ( String path ) { List < ContextWords > set = new ArrayList <> ( ) ; InputStream stream = JLanguageTool . getDataBroker ( ) . getFromRulesDirAsStream ( path ) ; try ( Scanner scanner = new Scanner ( stream , "utf-8" ) ) { while ( scanner . hasNextLine ( ) ) { String line = scanner . nextLine ( ) ; if ( line . trim ( ) . isEmpty ( ) || line . charAt ( 0 ) == ' ' ) { continue ; } String [ ] column = line . split ( "\t" ) ; if ( column . length >= 6 ) { ContextWords contextWords = new ContextWords ( ) ; contextWords . setWord ( 0 , column [ 0 ] ) ; contextWords . setWord ( 1 , column [ 1 ] ) ; contextWords . matches [ 0 ] = column [ 2 ] ; contextWords . matches [ 1 ] = column [ 3 ] ; contextWords . setContext ( 0 , column [ 4 ] ) ; contextWords . setContext ( 1 , column [ 5 ] ) ; if ( column . length > 6 ) { contextWords . explanations [ 0 ] = column [ 6 ] ; if ( column . length > 7 ) { contextWords . explanations [ 1 ] = column [ 7 ] ; } } set . add ( contextWords ) ; } // if (column.length >= 6) } } return Collections . unmodifiableList ( set ) ; }
Load words contexts and explanations .