Search in sources :

Example 1 with RNNOptions

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);
}
Also used : SentimentModel(edu.stanford.nlp.sentiment.SentimentModel) SimpleMatrix(org.ejml.simple.SimpleMatrix) RNNOptions(edu.stanford.nlp.sentiment.RNNOptions) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

RNNOptions (edu.stanford.nlp.sentiment.RNNOptions)1 SentimentModel (edu.stanford.nlp.sentiment.SentimentModel)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 SimpleMatrix (org.ejml.simple.SimpleMatrix)1