Example usage for edu.stanford.nlp.ling RVFDatum RVFDatum

List of usage examples for edu.stanford.nlp.ling RVFDatum RVFDatum

Introduction

In this page you can find the example usage for edu.stanford.nlp.ling RVFDatum RVFDatum.

Prototype

public RVFDatum(Counter<F> features, L label) 

Source Link

Document

Constructs a new RVFDatum with the given features and label.

Usage

From source file:gr.aueb.cs.nlp.wordtagger.classifier.SVMWindows64Factory.java

License:Open Source License

/**
 * Builds a sigmoid model to turn the classifier outputs into probabilities.
 *//* w  w w  . java 2  s . co  m*/
private LinearClassifier<L, L> fitSigmoid(SVMLightClassifier<L, F> classifier, GeneralDataset<L, F> dataset) {
    RVFDataset<L, L> plattDataset = new RVFDataset<L, L>();
    for (int i = 0; i < dataset.size(); i++) {
        RVFDatum<L, F> d = dataset.getRVFDatum(i);
        Counter<L> scores = classifier.scoresOf((Datum<L, F>) d);
        scores.incrementCount(null);
        plattDataset.add(new RVFDatum<L, L>(scores, d.label()));
    }
    LinearClassifierFactory<L, L> factory = new LinearClassifierFactory<L, L>();
    factory.setPrior(new LogPrior(LogPrior.LogPriorType.NULL));
    return factory.trainClassifier(plattDataset);
}

From source file:gr.aueb.cs.nlp.wordtagger.data.structure.WordSet.java

License:Open Source License

/**
 * Converts any List with words to a Stanford set;
 * @param words//from w  w  w.  j a  v  a  2  s  .c om
 * @return, a list of real valued datums
 */
public static List<RVFDatum<String, String>> toStanfordSet(List<Word> words) {
    List<RVFDatum<String, String>> trainignData = new ArrayList<>();
    for (Word w : words) {
        List<Double> feats = Arrays.asList(ArrayUtils.toObject(w.getFeatureVec().getValues()));
        ClassicCounter<String> cc = new ClassicCounter<>();
        for (int i = 0; i < feats.size(); i++) {
            cc.incrementCount("feature" + i, feats.get(i));
        }
        if (w.getCategory() != null) {
            RVFDatum<String, String> dtm = new RVFDatum<>(cc, w.getCategory());
            trainignData.add(dtm);
        }
    }
    System.out.println("Converted List to classifier trainset");
    return trainignData;
}

From source file:gr.aueb.cs.nlp.wordtagger.data.structure.WordSet.java

License:Open Source License

/**
 * convers a word to a stanforf real valued atum
 * @param w/*from w w w  . j  a v  a 2  s  . co m*/
 * @return
 */
public static RVFDatum<String, String> word2Datum(Word w) {
    List<Double> feats = Arrays.asList(ArrayUtils.toObject(w.getFeatureVec().getValues()));
    ClassicCounter<String> cc = new ClassicCounter<>();
    for (int i = 0; i < feats.size(); i++) {
        cc.incrementCount("feature" + i, feats.get(i));
    }
    return new RVFDatum<>(cc, w.getCategory());
}