classifieddatum.java

来自「Standord Classifier实现了一个基于Java的最大熵分类器。用于」· Java 代码 · 共 63 行

JAVA
63
字号
package edu.stanford.nlp.classify;import edu.stanford.nlp.dbm.Datum;import edu.stanford.nlp.process.Appliable;/** * Stores a classified Datum with predicted and correct labels. */public class ClassifiedDatum{        private final Datum datum;        private final Object predictedLabel;        private final Object correctLabel;       private final boolean correct;        /**     * Constructs a new classification result for the given Datum with the given     * predicted and correct labels.     * @param datum Datum that was classified     * @param predictedLabel label (class) predicted for this Datum by the Classifier     * @param correctLabel correct label (class) to compare prediction to     */    public ClassifiedDatum(Datum datum,Object predictedLabel,Object correctLabel)    {        this.datum=datum;        this.predictedLabel=predictedLabel;        this.correctLabel=correctLabel;        correct=predictedLabel.equals(correctLabel);    }        /**     * Constructs a new classificationr esult for the given Datum with the given     * predicted label, and using the datum's label as the correct label.     * @param datum Data that was classified (containing correct label)     * @param predictedLabel label (class) predicted for this Datum by the Classifier     */    public ClassifiedDatum(Datum datum,Object predictedLabel)    {        this(datum,predictedLabel,datum.label());    }        /** Returns the classified Datum. */    public Datum getDatum() { return(datum); }    /** Returns the label (class) predicted for the Datum by the Classifier. */    public Object getPredictedLabel() { return(predictedLabel); }    /** Returns the corect label (class) for the Datum. */    public Object getCorrectLabel() { return(correctLabel); }    /** Returns whether the predicted label matches the correct label. */    public boolean isCorrect() { return(correct); }            /** Appliable that returns the Datum inside a ClassifiedDatum. */    public static Appliable datumExtractor() { return(datumExtractor); }        /** Appliable that returns the Datum inside a ClassifiedDatum. */    private static class DatumExtractor implements Appliable    {        public Object apply(Object o) { return(((ClassifiedDatum)o).getDatum()); }    }        private static final Appliable datumExtractor=new DatumExtractor();}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?