public static PSetupGuess guessSetup ( byte [ ] bytes ) { // find the last eof int i = bytes . length - 1 ; while ( i > 0 && bytes [ i ] != ' ' ) -- i ; assert i >= 0 ; InputStream is = new ByteArrayInputStream ( Arrays . copyOf ( bytes , i ) ) ; SVMLightParser p = new SVMLightParser ( new ParserSetup ( ParserType . SVMLight , CsvParser . AUTO_SEP , false ) ) ; InspectDataOut dout = new InspectDataOut ( ) ; try { p . streamParse ( is , dout ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } return new PSetupGuess ( new ParserSetup ( ParserType . SVMLight , CsvParser . AUTO_SEP , dout . _ncols , false , null , false ) , dout . _nlines , dout . _invalidLines , dout . data ( ) , dout . _ncols > 0 && dout . _nlines > 0 && dout . _nlines > dout . _invalidLines , dout . errors ( ) ) ; }
Try to parse the bytes as svm light format return SVMParser instance if the input is in svm light format null otherwise .