Example #1
0
        public FinalResult SegmentAB(SegmentInput A, SegmentInput B, double devW, double devSpace)
        {
            FinalResult result = new FinalResult();

            ResultA resA = SegmentA(A, devW);
            ResultB resB = SegmentB(B, devW, devSpace);

            result.Date           = resA.Date;
            result.DotA           = resA.Dot;
            result.IndexDateEnd   = resA.IndexDateEnd;
            result.IndexDateStart = resA.IndexDateStart;
            result.DotB           = resB.Dot;
            result.IndexDotBStart = resB.IndexDotStart;
            result.IndexDotBEnd   = resB.IndexDotEnd;

            return(result);
        }
Example #2
0
        // METHOD ALAIN:  KORTER, EVENTUEEL UITZOEKEN... WERKT NOG NIET ivm indexes

        /*
         * // Splitted string at index position
         *
         * string temp = str;
         * for (int i = 0; i < indexList.Count; i++)
         * {
         *  temp = temp.Insert(i + indexList[i], " ");
         *  Debug.WriteLine(temp);
         * }
         * string[] splitted = temp.Trim(new char[] { ' ' }).Split(' ');
         *
         * // Found date . First 4 lenght string on the end and add '*' before and at the end
         * int p = splitted.Length - 1;
         * bool DateFound = false;
         * while (p >= 0 && !DateFound)
         * {
         *  Debug.WriteLine(splitted[p]);
         *  if (splitted[p].Length == 4)
         *  {
         *      result.IndexDateStart = indexList[p - 1];
         *      result.IndexDateEnd = indexList[p] - 1;
         *      splitted[p] = $"*{splitted[p]}*";
         *  }
         *  p--;
         * }
         *
         * // Concate all to one string
         * string temp2 = String.Concat(splitted);
         *
         * // DOT*DATE*CLUTTER => DOT,DATE,CLUTTER
         * string[] Splitted2 = temp2.Split('*');
         * result.Dot = Splitted2[0];
         * result.Date = Splitted2[1];
         * string Clutter = Splitted2[2];
         *
         * return result;
         * }
         */


        public ResultB SegmentB(SegmentInput B, double devW, double devSpace)
        {
            //Remove clutter from end of string of B, we presume only one segment of clutter and with a bigger space
            ResultB result = new ResultB();              //final result for B

            SegmentResult segmentRes = Segment(B, devW); //Segment B --> list of indexes and spaces

            int    nSpace      = segmentRes.SpaceList.Count;
            int    nSegm       = segmentRes.SegmentIndexList.Count;
            string str         = segmentRes.FilteredString;
            int    nStr        = segmentRes.FilteredString.Length;
            int    indexDotEnd = 0;

            if (nStr > 0)                                                       //At least 1 char in string
            {
                indexDotEnd = nStr - 1;                                         //We assume last segment is not clutter or have no previous space to compare to

                if (nSpace > 1)                                                 //At least 2 spaces present--> compare last space to 1st space
                {
                    double spaceRef = segmentRes.SpaceList[0];                  //take first space as reference

                    if (segmentRes.SpaceList[nSpace - 1] > devSpace * spaceRef) //last space larger than allowed deviation (= devSpace * spaceRef)
                    {
                        //last segment is clutter
                        indexDotEnd = segmentRes.SegmentIndexList[nSegm - 1] - 1;//index of last segment - 1 = end of previous segm
                    }
                }
                result.Dot = str.Substring(0, indexDotEnd + 1);
            }
            else //if nStr=0
            {
                indexDotEnd = 0;
                result.Dot  = "";
            }


            result.IndexDotStart = 0;//We presume dot always starts at 0 (no clutter in beginning)
            result.IndexDotEnd   = indexDotEnd;


            return(result);
        }