@Override protected void unpackageClassifier(JarInputStream modelStream) throws IOException { super.unpackageClassifier(modelStream); JarStreams.getNextJarEntry(modelStream, MODEL_NAME); ObjectInputStream objectStream = new ObjectInputStream(modelStream); try { this.transducer = (Transducer) objectStream.readObject(); } catch (ClassNotFoundException e) { throw new IOException(e); } }
@Override protected void unpackageClassifier(JarInputStream modelStream) throws IOException { super.unpackageClassifier(modelStream); JarStreams.getNextJarEntry(modelStream, MODEL_NAME); ObjectInputStream objectStream = new ObjectInputStream(modelStream); try { this.transducer = (Transducer) objectStream.readObject(); } catch (ClassNotFoundException e) { throw new IOException(e); } }
@Override protected void unpackageClassifier(JarInputStream modelStream) throws IOException { super.unpackageClassifier(modelStream); try { JarStreams.getNextJarEntry(modelStream, JAR_ENTRY_MODEL); this.acrf = (ACRF) new ObjectInputStream(new GZIPInputStream(modelStream)).readObject(); JarStreams.getNextJarEntry(modelStream, JAR_ENTRY_OUTCOME_EXAMPLE); this.outcomeExample = (String) new ObjectInputStream(modelStream).readObject(); } catch (ClassNotFoundException e) { throw new IOException(e); } }
@Override protected void unpackageClassifier(JarInputStream modelStream) throws IOException { super.unpackageClassifier(modelStream); try { JarStreams.getNextJarEntry(modelStream, JAR_ENTRY_MODEL); this.acrf = (ACRF) new ObjectInputStream(new GZIPInputStream(modelStream)).readObject(); JarStreams.getNextJarEntry(modelStream, JAR_ENTRY_OUTCOME_EXAMPLE); this.outcomeExample = (String) new ObjectInputStream(modelStream).readObject(); } catch (ClassNotFoundException e) { throw new IOException(e); } }
/** * As the filename of the model is not known the only solution is to write the model back to a * temporary file */ @Override protected void unpackageClassifier(JarInputStream modelStream) throws IOException { super.unpackageClassifier(modelStream); JarStreams.getNextJarEntry(modelStream, MODEL_NAME); this.modelFile = File.createTempFile("model", ".crfsuite"); this.modelFile.deleteOnExit(); logger.log(Level.FINE, "Start writing model to " + modelFile.getAbsolutePath()); InputStream inputStream = new DataInputStream(modelStream); OutputStream out = new FileOutputStream(modelFile); byte buf[] = new byte[1024]; int len; while ((len = inputStream.read(buf)) > 0) { out.write(buf, 0, len); } out.close(); inputStream.close(); logger.log(Level.FINE, "Model is written to " + modelFile.getAbsolutePath()); }
/** * As the filename of the model is not known the only solution is to write the model back to a * temporary file */ @Override protected void unpackageClassifier(JarInputStream modelStream) throws IOException { super.unpackageClassifier(modelStream); JarStreams.getNextJarEntry(modelStream, MODEL_NAME); this.modelFile = File.createTempFile("model", ".crfsuite"); this.modelFile.deleteOnExit(); logger.log(Level.FINE, "Start writing model to " + modelFile.getAbsolutePath()); InputStream inputStream = new DataInputStream(modelStream); OutputStream out = new FileOutputStream(modelFile); byte buf[] = new byte[1024]; int len; while ((len = inputStream.read(buf)) > 0) { out.write(buf, 0, len); } out.close(); inputStream.close(); logger.log(Level.FINE, "Model is written to " + modelFile.getAbsolutePath()); }