List of usage examples for edu.stanford.nlp.io IOUtils readStreamFromString
public static ObjectInputStream readStreamFromString(String filenameOrUrl) throws IOException
From source file:edu.iastate.airl.semtus.plugins.PluginHandler.java
License:Open Source License
public static List<Tree> generateTrees(final ArrayList<Sentence<Word>> sentenceList) throws IOException { /************************************************************************** * Generate dependencies here// w w w. j av a 2 s .com **************************************************************************/ ObjectInputStream thisInputStream = IOUtils .readStreamFromString(Utils.OUTPUT_DIRECTORY + "grammar/englishPCFG.ser.gz"); Parser thisParser = new Parser(thisInputStream); List<Tree> theseTrees = thisParser.parse(sentenceList); return theseTrees; }
From source file:knu.univ.lingvo.coref.SieveCoreferenceSystem.java
License:Open Source License
public static LogisticClassifier<String, String> getSingletonPredictorFromSerializedFile( String serializedFile) {//ww w. j av a 2 s. co m try { ObjectInputStream ois = IOUtils.readStreamFromString(serializedFile); Object o = ois.readObject(); if (o instanceof LogisticClassifier<?, ?>) { return (LogisticClassifier<String, String>) o; } throw new ClassCastException("Wanted SingletonPredictor, got " + o.getClass()); } catch (IOException e) { throw new RuntimeIOException(e); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } }