Beispiel #1
0
        private List <scanPath> getCode(scanPath scn)
        {
            List <scanPath> mainList = new List <scanPath>();

            if (this.children.Count > 0)
            {
                codeLocation wordCode = new codeLocation();
                for (int k = 0; k < this.children.Count; k++)
                {
                    scanPath scpath = new scanPath();
                    for (int i = 0; i < scn.location.Count; i++)
                    {
                        scpath.location.Add(scn.location[i]);
                    }

                    scpath.location.Add(this.children[k].location);
                    List <scanPath> temp;
                    temp = new List <scanPath>();
                    temp = this.children[k].getCode(scpath);

                    for (int i = 0; i < temp.Count; i++)
                    {
                        mainList.Add(temp[i]);
                    }
                    // scn.location.Add(this.children[k].location);
                }
            }
            else  //tree leaf
            {
                mainList.Add(scn);
            }
            return(mainList);
        }
Beispiel #2
0
        public List <scanPath> isMatch()
        {
            scanPath        scn = new scanPath();
            List <scanPath> b   = new List <scanPath>();
            List <scanPath> a   = new List <scanPath>();

            a = traverseOriginalHindi(scn, 0);
            if (a.Count > 0)
            {
                for (int i = 0; i < a.Count; i++)
                {
                    b.Add(a[i]);
                }
            }

            scanPath        scn3 = new scanPath();
            List <scanPath> a3   = new List <scanPath>();

            a3 = traverseZamzama(scn3, 0);
            if (a3.Count > 0)
            {
                for (int i = 0; i < a3.Count; i++)
                {
                    b.Add(a3[i]);
                }
            }

            /*scanPath scn2 = new scanPath();
             * List<scanPath> a2 = new List<scanPath>();
             *
             * a2 = traverseHindi(scn2, 0);
             * if ((a2.Count > 0) && (a.Count == 0) && (a3.Count == 0))
             * {
             *  for (int i = 0; i < a2.Count; i++)
             *  {
             *      b.Add(a2[i]);
             *  }
             * }
             */

            return(b);
        }
Beispiel #3
0
        public List<scanPath> isMatch()
        {
            scanPath scn = new scanPath();
            List<scanPath> b = new List<scanPath>();
            List<scanPath> a = new List<scanPath>();
            a = traverseOriginalHindi(scn, 0);
            if (a.Count > 0)
            {
                for (int i = 0; i < a.Count; i++)
                {
                    b.Add(a[i]);
                }
            }

            scanPath scn3 = new scanPath();
            List<scanPath> a3 = new List<scanPath>();

            a3 = traverseZamzama(scn3, 0);
            if (a3.Count > 0)
            {
                for (int i = 0; i < a3.Count; i++)
                {
                    b.Add(a3[i]);
                }
            }
            
            /*scanPath scn2 = new scanPath();
            List<scanPath> a2 = new List<scanPath>();

            a2 = traverseHindi(scn2, 0);
            if ((a2.Count > 0) && (a.Count == 0) && (a3.Count == 0))
            {
                for (int i = 0; i < a2.Count; i++)
                {
                    b.Add(a2[i]);
                }
            }
            */

            return b;
        }
Beispiel #4
0
        private List<scanPath> traverseZamzama(scanPath scn, int state)
        {
            List<scanPath> mainList = new List<scanPath>();
            if (this.children.Count > 0)
            {
                for (int i = 0; i < this.children.Count; i++)
                {
                    int localstate = StateMachine.ZamzamaMeter(this.children[i].location.code, state);
                    if (localstate != -1)
                    {
                        scanPath scpath = new scanPath();
                        for (int j = 0; j < scn.location.Count; j++)
                            scpath.location.Add(scn.location[j]);

                        scpath.location.Add(this.children[i].location);
                        List<scanPath> temp;
                        temp = new List<scanPath>();
                        temp = children[i].traverseZamzama(scpath, localstate);
                        for (int j = 0; j < temp.Count; j++)
                            mainList.Add(temp[j]);
                    }
                }
            }
            else
            {
                int count = 0;
                for (int i = 0; i < scn.location.Count; i++)
                {
                    if (scn.location[i].code.Equals("="))
                    {
                        count += 2;
                    }
                    else if (scn.location[i].code.Equals("-"))
                    {
                        count += 1;
                    }
                }
                if (count == 32)
                {
                    if (scn.location[scn.location.Count - 1].code.Equals("="))
                    {
                        scn.meters.Add(Meters.numMeters + Meters.numVariedMeters + Meters.numRubaiMeters + 8);
                        mainList.Add(scn);
                    }
                }
                else if (count == 33)
                {
                    if (scn.location[scn.location.Count - 1].code.Equals("-") && scn.location[scn.location.Count - 2].code.Equals("="))
                    {
                        scn.meters.Add(Meters.numMeters + Meters.numVariedMeters + Meters.numRubaiMeters + 8);
                        mainList.Add(scn);
                    }
                }
                else if (count == 24)
                {
                    if (scn.location[scn.location.Count - 1].code.Equals("="))
                    {
                        scn.meters.Add(Meters.numMeters + Meters.numVariedMeters + Meters.numRubaiMeters + 9);
                        mainList.Add(scn);
                    }
                }
                else if (count == 25)
                {
                    if (scn.location[scn.location.Count - 1].code.Equals("-") && scn.location[scn.location.Count - 2].code.Equals("="))
                    {
                        scn.meters.Add(Meters.numMeters + Meters.numVariedMeters + Meters.numRubaiMeters + 9);
                        mainList.Add(scn);
                    }
                }
                else if (count == 16)
                {
                    if (scn.location[scn.location.Count - 1].code.Equals("="))
                    {
                        scn.meters.Add(Meters.numMeters + Meters.numVariedMeters + Meters.numRubaiMeters + 10);
                        mainList.Add(scn);
                    }
                }
                else if (count == 17)
                {
                    if (scn.location[scn.location.Count - 1].code.Equals("-") && scn.location[scn.location.Count - 2].code.Equals("="))
                    {
                        scn.meters.Add(Meters.numMeters + Meters.numVariedMeters + Meters.numRubaiMeters + 10);
                        mainList.Add(scn);
                    }
                }
            }
            return mainList;
        }
Beispiel #5
0
        private List<scanPath> traverseFuzzy(scanPath scn)
        {
            List<scanPath> mainList = new List<scanPath>();
            if (scn.meters.Count == 0)
            {
                return mainList;
            }
            else
            {
                if (this.children.Count > 0)
                {
                    string code = "";
                    int fuzz = 0;
                    for (int i = 0; i < scn.location.Count; i++)
                        code = code + scn.location[i].code;
                    for (int i = 0; i < scn.location.Count; i++)
                        fuzz = fuzz + scn.location[i].fuzzy;
                    List<int> ind = new List<int>();
                    for (int k = 0; k < this.children.Count; k++)
                    {
                        bool flag = false;
                        string tentativeCode = code;
                        string wordCode = this.children[k].location.code;
                        List<int> indices = new List<int>();
                        for (int i = 0; i < scn.meters.Count; i++)
                            indices.Add(scn.meters[i]);
                        int numIndices = scn.meters.Count;

                        scanPath scpath = new scanPath();
                        scpath.meters = indices;
                        for (int i = 0; i < scn.location.Count; i++)
                            scpath.location.Add(scn.location[i]);

                        scpath.location.Add(this.children[k].location);
                        List<scanPath> temp;
                        temp = new List<scanPath>();
                        temp = this.children[k].traverseFuzzy(scpath);

                        for (int i = 0; i < temp.Count; i++)
                            mainList.Add(temp[i]);

                        // return ind;
                    }
                    return mainList;
                }
                else   //Tree Leaf
                {
                    string code = "";
                    List<scanPath> sp = new List<scanPath>();
                    List<int> metList = new List<int>();
                    for (int i = 0; i < scn.location.Count; i++)
                        code = code + scn.location[i].code;
                    List<int> met = checkCodeLengthFuzzy(code, scn.meters);
                    if (met.Count != 0)
                    {
                        scn.meters = met;
                        sp.Add(scn);
                    }
                    return sp;
                }
            }
        }
Beispiel #6
0
        private List<scanPath> traverse(scanPath scn)
        {
            List<scanPath> mainList = new List<scanPath>();
            if (scn.meters.Count == 0)
            {
                return mainList;
            }
            else
            {
                if (this.children.Count > 0)
                {
                    string code = "";
                    for (int i = 0; i < scn.location.Count; i++)
                        code = code + scn.location[i].code;
                    List<int> ind = new List<int>();
                    for (int k = 0; k < this.children.Count; k++)
                    {
                        bool flag = false;
                        string tentativeCode = code;
                        string wordCode = this.children[k].location.code;
                        List<int> indices = new List<int>();
                        for (int i = 0; i < scn.meters.Count; i++)
                            indices.Add(scn.meters[i]);
                        int numIndices = scn.meters.Count;
                        for (int i = 0; i < numIndices; i++)
                        {
                            if (scn.meters[i] < Meters.numMeters)
                            {

                                if (!isMatch(Meters.meters[scn.meters[i]], tentativeCode, wordCode))  //remove meter indices that don't match
                                {

                                    indices.Remove(scn.meters[i]);
                                }
                                else
                                {
                                    flag = true;
                                }

                            }
                            else if (scn.meters[i] < Meters.numMeters + Meters.numVariedMeters && scn.meters[i] >= Meters.numMeters)
                            {
                                if (!isMatch(Meters.metersVaried[scn.meters[i] - Meters.numMeters], tentativeCode, wordCode))  //remove meter indices that donot match
                                {
                                    indices.Remove(scn.meters[i]);
                                }
                                else
                                {
                                    flag = true;
                                }


                            }
                            else if (scn.meters[i] < Meters.numMeters + Meters.numVariedMeters + Meters.numRubaiMeters && scn.meters[i] >= Meters.numMeters + Meters.numVariedMeters)
                            {
                                if (!isMatch(Meters.rubaiMeters[scn.meters[i] - Meters.numMeters - Meters.numVariedMeters], tentativeCode, wordCode))  //remove meter indices that don't match
                                {
                                    indices.Remove(scn.meters[i]);
                                }
                                else
                                {
                                    flag = true;
                                }
                            }

                        }

                        if (flag)
                        {
                            scanPath scpath = new scanPath();
                            scpath.meters = indices;
                            for (int i = 0; i < scn.location.Count; i++)
                                scpath.location.Add(scn.location[i]);

                            scpath.location.Add(this.children[k].location);
                            List<scanPath> temp;
                            temp = new List<scanPath>();
                            temp = this.children[k].traverse(scpath);

                            for (int i = 0; i < temp.Count; i++)
                                mainList.Add(temp[i]);
                        }
                        // return ind;
                    }

                    return mainList;
                }
                else   //Tree Leaf
                {
                    string code = "";
                    List<scanPath> sp = new List<scanPath>();
                    for (int i = 0; i < scn.location.Count; i++)
                        code = code + scn.location[i].code;
                    List<int> met = checkCodeLength(code, scn.meters);
                    if (met.Count != 0)
                    {
                        scn.meters = met;
                        sp.Add(scn);
                    }
                    return sp;
                }
            }

        }
Beispiel #7
0
        private List<scanPath> getCode(scanPath scn)
        {
            List<scanPath> mainList = new List<scanPath>();
            if (this.children.Count > 0)
            {
                codeLocation wordCode = new codeLocation();
                for (int k = 0; k < this.children.Count; k++)
                {
                    scanPath scpath = new scanPath();
                    for (int i = 0; i < scn.location.Count; i++)
                        scpath.location.Add(scn.location[i]);

                    scpath.location.Add(this.children[k].location);
                    List<scanPath> temp;
                    temp = new List<scanPath>();
                    temp = this.children[k].getCode(scpath);

                    for (int i = 0; i < temp.Count; i++)
                        mainList.Add(temp[i]);
                    // scn.location.Add(this.children[k].location);
                }
            }
            else  //tree leaf
            {
                mainList.Add(scn);
            }
            return mainList;
        }
Beispiel #8
0
        public List<scanPath> findMeter(List<int> meters)
        {
            bool flag = false;
            List<int> indices = new List<int>();
            if (meters.Count == 0)
            {
                for (int i = 0; i < Meters.numMeters; i++)
                {
                    if (Meters.usage[i] == 1)
                    {
                        indices.Add(i);
                    }
                }
                for (int i = 0; i < Meters.numMeters; i++)
                {
                    if (Meters.usage[i] == 0)
                    {
                        indices.Add(i);
                    }
                }
                for (int i = Meters.numMeters; i < Meters.numMeters + Meters.numRubaiMeters; i++)
                {
                    indices.Add(i);
                }
            }
            else
            {
                if (meters[0] == -2)
                {
                    for (int i = Meters.numMeters; i < Meters.numMeters + Meters.numRubaiMeters; i++)
                    {
                        indices.Add(i);
                    }
                }
                else
                {
                    for (int i = 0; i < meters.Count; i++)
                    {
                        if (meters[i] != -1)
                        {
                            indices.Add(meters[i]);
                        }
                        else
                        {
                            flag = true;
                        }

                    }
                }
            }
           
            //indices.Add(27);
            //indices.Add(18);
            List<scanPath> mainList = new List<scanPath>();
            List<scanPath> a = new List<scanPath>();
            List<scanPath> b = new List<scanPath>();
            scanPath scn = new scanPath();
            scn.meters = indices;
            scn.location.Add(new codeLocation());


            if (fuzzy)
            {
                mainList = traverseFuzzy(scn);
                //mainList = traverseFreeVerse(scn);
            }
            else if(freeVerse)
            {
                mainList = traverseFreeVerse(scn);
            }
            else
            {
                mainList = traverse(scn);
                //mainList = traverseFreeVerse(scn);

                if (flag || (meters.Count == 0))
                {
                    List<string> codeList = new List<string>();
                    a = getCode(scn);
                    codeLocation locs = new codeLocation();
                    locs.code = "root";
                    locs.word = "";
                    locs.wordRef = -1;
                    locs.codeRef = -1;
                    for (int i = 0; i < a.Count; i++)
                    {
                        patternTree pTree = new patternTree(locs);
                        for (int j = 0; j < a[i].location.Count; j++)
                        {
                            for (int k = 0; k < a[i].location[j].code.Length; k++)
                            {
                                codeLocation locn = new codeLocation();
                                locn.codeRef = a[i].location[j].codeRef;
                                locn.word = a[i].location[j].word;
                                locn.wordRef = a[i].location[j].wordRef;
                                locn.code = a[i].location[j].code[k].ToString();
                                if (j == a[i].location.Count - 1)
                                {
                                    if (k == a[i].location[j].code.Length - 1)
                                        if (locn.code.Equals("x"))
                                        {
                                            locn.code = "=";
                                        }
                                }
                                pTree.AddChild(locn);
                            }
                        }
                        b = pTree.isMatch();
                        if (b.Count > 0)
                        {
                            b = compressList(b);
                            for (int n = 0; n < b.Count; n++)
                                mainList.Add(b[n]);
                        }
                    }
                }
            }
            return mainList;
        }
Beispiel #9
0
        private List<scanPath> compressList(List<scanPath> lst)
        {
            List<scanPath> list = new List<scanPath>();
            for (int i = 0; i < lst.Count; i++)
            {
                scanPath sc = new scanPath();
                sc.meters = lst[i].meters;
                int j;
                string code = "";
                for (j = 0; j < lst[i].location.Count - 1; j++)
                {
                    if (j == 0) //first redundant element
                    {
                        codeLocation L = new codeLocation();
                        L.codeRef = -1;
                        L.word = "root";
                        L.wordRef = -1;
                        code += "";
                        L.code = code;
                        code = "";
                        sc.location.Add(L);
                    }
                    int wordRef = lst[i].location[j].wordRef;
                    if (wordRef == lst[i].location[j + 1].wordRef)
                    {
                        code += lst[i].location[j].code;
                    }
                    else
                    {
                        codeLocation cL = new codeLocation();
                        cL.codeRef = lst[i].location[j].codeRef;
                        cL.word = lst[i].location[j].word;
                        cL.wordRef = lst[i].location[j].wordRef;
                        code += lst[i].location[j].code;
                        cL.code = code;
                        code = "";
                        sc.location.Add(cL);
                    }
                }

                int wordRef2 = lst[i].location[j - 1].wordRef;
                if (wordRef2 == lst[i].location[lst[i].location.Count - 1].wordRef)
                {
                    code += lst[i].location[j].code;
                }
                else
                {
                    code = lst[i].location[j].code;
                }

                codeLocation cL2 = new codeLocation();
                cL2.codeRef = lst[i].location[j].codeRef;
                cL2.word = lst[i].location[j].word;
                cL2.wordRef = lst[i].location[j].wordRef;
                cL2.code = code;

                sc.location.Add(cL2);
                list.Add(sc);
            }
            return list;

        }
Beispiel #10
0
        private List <scanPath> traverseFuzzy(scanPath scn)
        {
            List <scanPath> mainList = new List <scanPath>();

            if (scn.meters.Count == 0)
            {
                return(mainList);
            }
            else
            {
                if (this.children.Count > 0)
                {
                    string code = "";
                    int    fuzz = 0;
                    for (int i = 0; i < scn.location.Count; i++)
                    {
                        code = code + scn.location[i].code;
                    }
                    for (int i = 0; i < scn.location.Count; i++)
                    {
                        fuzz = fuzz + scn.location[i].fuzzy;
                    }
                    List <int> ind = new List <int>();
                    for (int k = 0; k < this.children.Count; k++)
                    {
                        bool       flag          = false;
                        string     tentativeCode = code;
                        string     wordCode      = this.children[k].location.code;
                        List <int> indices       = new List <int>();
                        for (int i = 0; i < scn.meters.Count; i++)
                        {
                            indices.Add(scn.meters[i]);
                        }
                        int numIndices = scn.meters.Count;

                        scanPath scpath = new scanPath();
                        scpath.meters = indices;
                        for (int i = 0; i < scn.location.Count; i++)
                        {
                            scpath.location.Add(scn.location[i]);
                        }

                        scpath.location.Add(this.children[k].location);
                        List <scanPath> temp;
                        temp = new List <scanPath>();
                        temp = this.children[k].traverseFuzzy(scpath);

                        for (int i = 0; i < temp.Count; i++)
                        {
                            mainList.Add(temp[i]);
                        }

                        // return ind;
                    }
                    return(mainList);
                }
                else   //Tree Leaf
                {
                    string          code    = "";
                    List <scanPath> sp      = new List <scanPath>();
                    List <int>      metList = new List <int>();
                    for (int i = 0; i < scn.location.Count; i++)
                    {
                        code = code + scn.location[i].code;
                    }
                    List <int> met = checkCodeLengthFuzzy(code, scn.meters);
                    if (met.Count != 0)
                    {
                        scn.meters = met;
                        sp.Add(scn);
                    }
                    return(sp);
                }
            }
        }
Beispiel #11
0
        private List <scanPath> traverse(scanPath scn)
        {
            List <scanPath> mainList = new List <scanPath>();

            if (scn.meters.Count == 0)
            {
                return(mainList);
            }
            else
            {
                if (this.children.Count > 0)
                {
                    string code = "";
                    for (int i = 0; i < scn.location.Count; i++)
                    {
                        code = code + scn.location[i].code;
                    }
                    List <int> ind = new List <int>();
                    for (int k = 0; k < this.children.Count; k++)
                    {
                        bool       flag          = false;
                        string     tentativeCode = code;
                        string     wordCode      = this.children[k].location.code;
                        List <int> indices       = new List <int>();
                        for (int i = 0; i < scn.meters.Count; i++)
                        {
                            indices.Add(scn.meters[i]);
                        }
                        int numIndices = scn.meters.Count;
                        for (int i = 0; i < numIndices; i++)
                        {
                            if (scn.meters[i] < Meters.numMeters)
                            {
                                if (!isMatch(Meters.meters[scn.meters[i]], tentativeCode, wordCode))  //remove meter indices that don't match
                                {
                                    indices.Remove(scn.meters[i]);
                                }
                                else
                                {
                                    flag = true;
                                }
                            }
                            else if (scn.meters[i] < Meters.numMeters + Meters.numVariedMeters && scn.meters[i] >= Meters.numMeters)
                            {
                                if (!isMatch(Meters.metersVaried[scn.meters[i] - Meters.numMeters], tentativeCode, wordCode))  //remove meter indices that donot match
                                {
                                    indices.Remove(scn.meters[i]);
                                }
                                else
                                {
                                    flag = true;
                                }
                            }
                            else if (scn.meters[i] < Meters.numMeters + Meters.numVariedMeters + Meters.numRubaiMeters && scn.meters[i] >= Meters.numMeters + Meters.numVariedMeters)
                            {
                                if (!isMatch(Meters.rubaiMeters[scn.meters[i] - Meters.numMeters - Meters.numVariedMeters], tentativeCode, wordCode))  //remove meter indices that don't match
                                {
                                    indices.Remove(scn.meters[i]);
                                }
                                else
                                {
                                    flag = true;
                                }
                            }
                        }

                        if (flag)
                        {
                            scanPath scpath = new scanPath();
                            scpath.meters = indices;
                            for (int i = 0; i < scn.location.Count; i++)
                            {
                                scpath.location.Add(scn.location[i]);
                            }

                            scpath.location.Add(this.children[k].location);
                            List <scanPath> temp;
                            temp = new List <scanPath>();
                            temp = this.children[k].traverse(scpath);

                            for (int i = 0; i < temp.Count; i++)
                            {
                                mainList.Add(temp[i]);
                            }
                        }
                        // return ind;
                    }

                    return(mainList);
                }
                else   //Tree Leaf
                {
                    string          code = "";
                    List <scanPath> sp   = new List <scanPath>();
                    for (int i = 0; i < scn.location.Count; i++)
                    {
                        code = code + scn.location[i].code;
                    }
                    List <int> met = checkCodeLength(code, scn.meters);
                    if (met.Count != 0)
                    {
                        scn.meters = met;
                        sp.Add(scn);
                    }
                    return(sp);
                }
            }
        }
Beispiel #12
0
        public List <scanPath> findMeter(List <int> meters)
        {
            bool       flag    = false;
            List <int> indices = new List <int>();

            if (meters.Count == 0)
            {
                for (int i = 0; i < Meters.numMeters; i++)
                {
                    if (Meters.usage[i] == 1)
                    {
                        indices.Add(i);
                    }
                }
                for (int i = 0; i < Meters.numMeters; i++)
                {
                    if (Meters.usage[i] == 0)
                    {
                        indices.Add(i);
                    }
                }
                for (int i = Meters.numMeters; i < Meters.numMeters + Meters.numRubaiMeters; i++)
                {
                    indices.Add(i);
                }
            }
            else
            {
                if (meters[0] == -2)
                {
                    for (int i = Meters.numMeters; i < Meters.numMeters + Meters.numRubaiMeters; i++)
                    {
                        indices.Add(i);
                    }
                }
                else
                {
                    for (int i = 0; i < meters.Count; i++)
                    {
                        if (meters[i] != -1)
                        {
                            indices.Add(meters[i]);
                        }
                        else
                        {
                            flag = true;
                        }
                    }
                }
            }

            //indices.Add(27);
            //indices.Add(18);
            List <scanPath> mainList = new List <scanPath>();
            List <scanPath> a        = new List <scanPath>();
            List <scanPath> b        = new List <scanPath>();
            scanPath        scn      = new scanPath();

            scn.meters = indices;
            scn.location.Add(new codeLocation());


            if (fuzzy)
            {
                mainList = traverseFuzzy(scn);
                //mainList = traverseFreeVerse(scn);
            }
            else if (freeVerse)
            {
                mainList = traverseFreeVerse(scn);
            }
            else
            {
                mainList = traverse(scn);
                //mainList = traverseFreeVerse(scn);

                if (flag || (meters.Count == 0))
                {
                    List <string> codeList = new List <string>();
                    a = getCode(scn);
                    codeLocation locs = new codeLocation();
                    locs.code    = "root";
                    locs.word    = "";
                    locs.wordRef = -1;
                    locs.codeRef = -1;
                    for (int i = 0; i < a.Count; i++)
                    {
                        patternTree pTree = new patternTree(locs);
                        for (int j = 0; j < a[i].location.Count; j++)
                        {
                            for (int k = 0; k < a[i].location[j].code.Length; k++)
                            {
                                codeLocation locn = new codeLocation();
                                locn.codeRef = a[i].location[j].codeRef;
                                locn.word    = a[i].location[j].word;
                                locn.wordRef = a[i].location[j].wordRef;
                                locn.code    = a[i].location[j].code[k].ToString();
                                if (j == a[i].location.Count - 1)
                                {
                                    if (k == a[i].location[j].code.Length - 1)
                                    {
                                        if (locn.code.Equals("x"))
                                        {
                                            locn.code = "=";
                                        }
                                    }
                                }
                                pTree.AddChild(locn);
                            }
                        }
                        b = pTree.isMatch();
                        if (b.Count > 0)
                        {
                            b = compressList(b);
                            for (int n = 0; n < b.Count; n++)
                            {
                                mainList.Add(b[n]);
                            }
                        }
                    }
                }
            }
            return(mainList);
        }
Beispiel #13
0
        private List <scanPath> compressList(List <scanPath> lst)
        {
            List <scanPath> list = new List <scanPath>();

            for (int i = 0; i < lst.Count; i++)
            {
                scanPath sc = new scanPath();
                sc.meters = lst[i].meters;
                int    j;
                string code = "";
                for (j = 0; j < lst[i].location.Count - 1; j++)
                {
                    if (j == 0) //first redundant element
                    {
                        codeLocation L = new codeLocation();
                        L.codeRef = -1;
                        L.word    = "root";
                        L.wordRef = -1;
                        code     += "";
                        L.code    = code;
                        code      = "";
                        sc.location.Add(L);
                    }
                    int wordRef = lst[i].location[j].wordRef;
                    if (wordRef == lst[i].location[j + 1].wordRef)
                    {
                        code += lst[i].location[j].code;
                    }
                    else
                    {
                        codeLocation cL = new codeLocation();
                        cL.codeRef = lst[i].location[j].codeRef;
                        cL.word    = lst[i].location[j].word;
                        cL.wordRef = lst[i].location[j].wordRef;
                        code      += lst[i].location[j].code;
                        cL.code    = code;
                        code       = "";
                        sc.location.Add(cL);
                    }
                }

                int wordRef2 = lst[i].location[j - 1].wordRef;
                if (wordRef2 == lst[i].location[lst[i].location.Count - 1].wordRef)
                {
                    code += lst[i].location[j].code;
                }
                else
                {
                    code = lst[i].location[j].code;
                }

                codeLocation cL2 = new codeLocation();
                cL2.codeRef = lst[i].location[j].codeRef;
                cL2.word    = lst[i].location[j].word;
                cL2.wordRef = lst[i].location[j].wordRef;
                cL2.code    = code;

                sc.location.Add(cL2);
                list.Add(sc);
            }
            return(list);
        }
Beispiel #14
0
        private List <scanPath> traverseZamzama(scanPath scn, int state)
        {
            List <scanPath> mainList = new List <scanPath>();

            if (this.children.Count > 0)
            {
                for (int i = 0; i < this.children.Count; i++)
                {
                    int localstate = StateMachine.ZamzamaMeter(this.children[i].location.code, state);
                    if (localstate != -1)
                    {
                        scanPath scpath = new scanPath();
                        for (int j = 0; j < scn.location.Count; j++)
                        {
                            scpath.location.Add(scn.location[j]);
                        }

                        scpath.location.Add(this.children[i].location);
                        List <scanPath> temp;
                        temp = new List <scanPath>();
                        temp = children[i].traverseZamzama(scpath, localstate);
                        for (int j = 0; j < temp.Count; j++)
                        {
                            mainList.Add(temp[j]);
                        }
                    }
                }
            }
            else
            {
                int count = 0;
                for (int i = 0; i < scn.location.Count; i++)
                {
                    if (scn.location[i].code.Equals("="))
                    {
                        count += 2;
                    }
                    else if (scn.location[i].code.Equals("-"))
                    {
                        count += 1;
                    }
                }
                if (count == 32)
                {
                    if (scn.location[scn.location.Count - 1].code.Equals("="))
                    {
                        scn.meters.Add(Meters.numMeters + Meters.numVariedMeters + Meters.numRubaiMeters + 8);
                        mainList.Add(scn);
                    }
                }
                else if (count == 33)
                {
                    if (scn.location[scn.location.Count - 1].code.Equals("-") && scn.location[scn.location.Count - 2].code.Equals("="))
                    {
                        scn.meters.Add(Meters.numMeters + Meters.numVariedMeters + Meters.numRubaiMeters + 8);
                        mainList.Add(scn);
                    }
                }
                else if (count == 24)
                {
                    if (scn.location[scn.location.Count - 1].code.Equals("="))
                    {
                        scn.meters.Add(Meters.numMeters + Meters.numVariedMeters + Meters.numRubaiMeters + 9);
                        mainList.Add(scn);
                    }
                }
                else if (count == 25)
                {
                    if (scn.location[scn.location.Count - 1].code.Equals("-") && scn.location[scn.location.Count - 2].code.Equals("="))
                    {
                        scn.meters.Add(Meters.numMeters + Meters.numVariedMeters + Meters.numRubaiMeters + 9);
                        mainList.Add(scn);
                    }
                }
                else if (count == 16)
                {
                    if (scn.location[scn.location.Count - 1].code.Equals("="))
                    {
                        scn.meters.Add(Meters.numMeters + Meters.numVariedMeters + Meters.numRubaiMeters + 10);
                        mainList.Add(scn);
                    }
                }
                else if (count == 17)
                {
                    if (scn.location[scn.location.Count - 1].code.Equals("-") && scn.location[scn.location.Count - 2].code.Equals("="))
                    {
                        scn.meters.Add(Meters.numMeters + Meters.numVariedMeters + Meters.numRubaiMeters + 10);
                        mainList.Add(scn);
                    }
                }
            }
            return(mainList);
        }