    001    package calhoun.analysis.crf.scoring;
    002
    003    import calhoun.analysis.crf.LocalPathSimilarityScore;
    004    import calhoun.analysis.crf.io.TrainingSequence;
    005
    006    public class SimScoreMinCodingMiscallsSV13 implements LocalPathSimilarityScore {
    007
    008            public double evaluate(int yprev, int y, TrainingSequence<?> seq, int pos) {
    009                    if (pos == 0) { return 0.0; }
    010                    int realy = seq.getY(pos);
    011                    if (isCodingPlus(y) && (!isCodingPlus(realy))) { return -1.0; }
    012                    if ((!isCodingPlus(y)) && isCodingPlus(realy)) { return -1.0; }
    013                    if (isCodingMinus(y) && (!isCodingMinus(realy))) { return -1.0; }
    014                    if ((!isCodingMinus(y)) && isCodingPlus(realy)) { return -1.0; }
    015                    return 0.0;
    016            }
    017
    018            private boolean isCodingMinus(int y) {
    019                    if (y==7) { return true; }
    020                    if (y==8) { return true; }
    021                    if (y==9) { return true; }
    022                    return false;
    023            }
    024
    025            private boolean isCodingPlus(int y) {
    026                    if (y==1) { return true; }
    027                    if (y==2) { return true; }
    028                    if (y==3) { return true; }
    029                    return false;
    030            }
    031
    032    }
    033