Dear all,

I've previously added some features to CRF package, and I'm doing some tests now, but the program fails to satisfy some tests, here is the most strange one,

input: a sequence of consecutive tokens with their associated labels
labels: only 2 labels (lab1, lab2)
features: only 2 simple features:
  feature 1:
        public boolean startScanFeaturesAt(DataSequence data, int prevPos, int pos) {
        //In other words I take no account of the input observation, I know this is strange
                {
                        edgeNum = 0;
                        if (edgeIter == null) {
                            setEdgeIter();
                        }
                        if (edgeIter != null)
                            edgeIter.start();
                        return hasNext();
                }
        }

        public void next(FeatureImpl f) {
                edgeIsOuter = edgeIter.nextIsOuter();
                Edge e = edgeIter.next();
                Object name="";
                if (featureCollectMode()) {
                        if (labelNames == null) {
                                name = "E."+model.label(e.start);
                        } else {
                                name = labelNames[model.label(e.start)];
                        }
                }
                if (edgeIsOuter) {
                        setFeatureIdentifier(model.label(e.start)*model.numberOfLabels() +model.label(e.end) + model.numEdges(), model.label(e.end),name,f);
                } else {
                        setFeatureIdentifier(edgeNum,e.end,name,f);
                }
                f.ystart = e.start;
                f.yend = e.end;

        if (e.end==1)  //Label 1
            f.val = 1;
        else
            f.val=0;


                edgeNum++;
        }
        if (y_end==lab1) f.val=1; else f.val=0;

  feature 2:
       exactly the same as feature 1 except these lines

if (e.end==0)  //Label 2
            f.val = 1;
        else
            f.val=0;


These are the some lines of codes from my two feature classes. What I intend to do is that if label at position i is 0 feature 1 should fire otherwise feature 2 must fire. According to the training algorithm of CRF the expectation value of features in the training set should be equal to the expectation value feature with respect to the model. That means that if in my training file 50% of the times I observe label 1 and 50% label 2, then the test set should be labelized ! 50% of times with label 1 and 50% with label 2. Unfortunately after I run the program I get 100% label 1. 

What is wrong then? Am I making a mistake in the implementation ?

Regards