⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 classifieddatum.java

📁 Standord Classifier实现了一个基于Java的最大熵分类器。用于模式识别
💻 JAVA
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -