use of edu.stanford.nlp.sentiment.RNNOptions in project CoreNLP by stanfordnlp.
the class ConvertModels method readSentiment.
public static SentimentModel readSentiment(ObjectInputStream in) throws IOException, ClassNotFoundException {
Function<List<List<Double>>, SimpleMatrix> f = (List<List<Double>> x) -> toMatrix(x);
TwoDimensionalMap<String, String, List<List<Double>>> map2dSM = ErasureUtils.uncheckedCast(in.readObject());
TwoDimensionalMap<String, String, SimpleMatrix> binaryTransform = transform2DMap(map2dSM, f);
TwoDimensionalMap<String, String, List<List<List<Double>>>> map2dST = ErasureUtils.uncheckedCast(in.readObject());
TwoDimensionalMap<String, String, SimpleTensor> binaryTensor = transform2DMap(map2dST, (x) -> toTensor(x));
map2dSM = ErasureUtils.uncheckedCast(in.readObject());
TwoDimensionalMap<String, String, SimpleMatrix> binaryClassification = transform2DMap(map2dSM, f);
Map<String, List<List<Double>>> map = ErasureUtils.uncheckedCast(in.readObject());
Map<String, SimpleMatrix> unaryClassification = transformMap(map, f);
map = ErasureUtils.uncheckedCast(in.readObject());
Map<String, SimpleMatrix> wordVectors = transformMap(map, f);
RNNOptions op = ErasureUtils.uncheckedCast(in.readObject());
return new SentimentModel(binaryTransform, binaryTensor, binaryClassification, unaryClassification, wordVectors, op);
}
Aggregations