Beispiel #1
0
        public override void SetSegmentationAndGt(Intarray segmentation, Intarray cseg, ref string text)
        {
            // first, set the segmentation as usual
            SetSegmentation(segmentation);

            // Maybe fix up the transcript (remove spaces).
            gttranscript = text;
            string s = text;

            fixup_transcript(ref s, false);
            int  max_cseg  = NarrayUtil.Max(cseg);
            bool old_csegs = (s.Length != max_cseg);

            fixup_transcript(ref gttranscript, old_csegs);

            // Complain if it doesn't match.
            if (gttranscript.Length != max_cseg)
            {
                Logger.Default.Format("transcript = '{0}'\n", gttranscript);
                throw new Exception(String.Format("transcript doesn't agree with cseg (transcript {0}, cseg {1})",
                                                  gttranscript.Length, max_cseg));
            }

            // Now compute the correspondences between the character segmentation
            // and the raw segmentation.
            GrouperRoutine.segmentation_correspondences(gtsegments, segmentation, cseg);
        }
Beispiel #2
0
 /// <summary>
 /// Set a character segmentation.
 /// </summary>
 public override void SetCSegmentation(Intarray segmentation)
 {
     maxrange = 1;
     maxdist  = 2;
     labels.Copy(segmentation);
     SegmRoutine.make_line_segmentation_black(labels);
     GrouperRoutine.check_approximately_sorted(labels);
     boxes.Dealloc();
     segments.Dealloc();
     class_outputs.Dealloc();
     class_costs.Dealloc();
     spaces.Dealloc();
     computeGroups();
 }
Beispiel #3
0
        public override int GetGtIndex(int index)
        {
            Intarray segs = new Intarray();

            GetSegments(segs, index);

            // see whether this is a ground truth segment
            int match = -1;

            for (int j = 0; j < gtsegments.Length(); j++)
            {
                if (GrouperRoutine.Equals(gtsegments[j], segs))
                {
                    match = j;
                    break;
                }
            }
            return(match);       // this returns the color in the cseg
        }