コード例 #1
0
ファイル: PatternDetector.cs プロジェクト: tgiphil/GoTraxx
 public PatternDetector(PatternDetector patternDetector)
 {
     lock (patternDetector)
     {
         DFAMatrix = patternDetector.DFAMatrix;
     }
 }
コード例 #2
0
 public PatternDetector(PatternDetector patternDetector)
 {
     lock (patternDetector)
     {
         DFAMatrix = patternDetector.DFAMatrix;
     }
 }
コード例 #3
0
        public PatternDetector(PatternCollection patterns)
        {
            PatternCollection = patterns;
            DFAMatrixBuilder lDFAMatrixBuilder = new DFAMatrixBuilder(patterns);

            DFAMatrix = lDFAMatrixBuilder.GetMatrix();
        }
コード例 #4
0
 public void Add(DFAMatrix dfaMatrix)
 {
     if (dfaMatrix != null)
     {
         DFAMatrixes.Push(dfaMatrix);
     }
 }
コード例 #5
0
        protected void Merge(DFAMatrix dfaMatrixA, DFAMatrix dfaMatrixB, DFAMatrix dfaMatrixC)
        {
            DFANodes = new List <DFANode>(Compare.Max <int>(dfaMatrixA.DFANodes.Count, dfaMatrixB.DFANodes.Count, dfaMatrixC.DFANodes.Count) + 128);

            DFANodes.Add(new DFANode());
            DFANodes.Add(new DFANode());

            DFAMatrixCache3 cache = new DFAMatrixCache3(DFANodes.Capacity);

            Product(dfaMatrixA, 1, dfaMatrixB, 1, dfaMatrixC, 1, cache);
        }
コード例 #6
0
        public int GetPatterns(int state, char value, List <PatternKey> patternList)
        {
            if (DFANodes[state].Attributes != null)
            {
                foreach (PatternKey lPattern in DFANodes[state].Attributes)
                {
                    patternList.Add(lPattern);
                }
            }

            return(DFANodes[state][DFAMatrix.GetDestination(value)]);
        }
コード例 #7
0
        public int GetPatterns(int state, char value, IPatternAddInterface patternList, Coordinate origin, int location)
        {
            if (DFANodes[state].Attributes != null)
            {
                foreach (PatternKey lPattern in DFANodes[state].Attributes)
                {
                    patternList.Add(lPattern.Pattern, lPattern.Transformation, origin, location);
                }
            }

            return(DFANodes[state][DFAMatrix.GetDestination(value)]);
        }
コード例 #8
0
        // temp. for testing
        static void LoadCompiledMatrix()
        {
            Console.WriteLine(DateTime.Now.ToString());
            SimpleTimer lTimer = new SimpleTimer();

            DFAMatrix lDFAMatrix = new DFAMatrix(@"Patterns/fuseki9.cdb");

            Console.WriteLine(lDFAMatrix.DFANodes.Count);

            Console.WriteLine(lTimer.SecondsElapsed.ToString());

            GC.Collect();
        }
コード例 #9
0
        public void Add(PatternCollection patterns)
        {
            DFAMatrixBuilder lDFAMatrixBuilder = new DFAMatrixBuilder(DFAMatrix);

            lDFAMatrixBuilder.Add(patterns);
            PatternCollection.Add(patterns);

            DFAMatrix lDFAMatrix = lDFAMatrixBuilder.GetMatrix();

            lock (this)
            {
                DFAMatrix = lDFAMatrix;
            }
        }
コード例 #10
0
        public DFAMatrix GetMatrix()
        {
            if (DFAMatrixes.Count == 0)
            {
                return(null);
            }

            if (DFAMatrixes.Count > 1)
            {
                BuildThreaded();
            }

            DFAMatrix lDFAMatrix = DFAMatrixes.Pop();

            DFAMatrixes.Push(lDFAMatrix);

            return(lDFAMatrix);
        }
コード例 #11
0
        protected void Product(DFAMatrix dfaLeft, int left, DFAMatrix dfaRight, int right, DFAMatrixCache cache)
        {
            int lState = DFANodes.Count - 1;

            AttributeUnion(DFANodes[lState], dfaLeft.DFANodes[left], dfaRight.DFANodes[right]);

            for (int c = 0; c != 4; c++)
            {
                int lNextL = dfaLeft.DFANodes[left][c];
                int lNextR = dfaRight.DFANodes[right][c];

                if ((lNextL != 0) || (lNextR != 0))
                {
                    int lNewValue = cache.Search(lNextL, lNextR);

                    if (lNewValue == 0)
                    {
                        // create it
                        int lLastState = DFANodes.Count;
                        //DFANodes.Add(new DFANode(DFANodes[lState].Level + 1));
                        DFANodes.Add(new DFANode());

                        cache.Add(lNextL, lNextR, lLastState);

                        DFANodes[lState][c] = lLastState;

                        Product(dfaLeft, lNextL, dfaRight, lNextR, cache);
                    }
                    else
                    {
                        // link to it
                        DFANodes[lState][c] = lNewValue;
                    }
                }
                else
                {
                    DFANodes[lState][c] = 0;
                }
            }
        }
コード例 #12
0
 public DFAMatrix(DFAMatrix dfaMatrixA, DFAMatrix dfaMatrixB, DFAMatrix dfaMatrixC)
 {
     Merge(dfaMatrixA, dfaMatrixB, dfaMatrixC);
 }
コード例 #13
0
 public DFAMatrixBuilder(DFAMatrix dfaMatrix)
 {
     DFAMatrixes = new Stack <DFAMatrix>();
     Add(dfaMatrix);
 }
コード例 #14
0
ファイル: Program.cs プロジェクト: tgiphil/GoTraxx
        // temp. for testing
        static void LoadCompiledMatrix()
        {
            Console.WriteLine(DateTime.Now.ToString());
            SimpleTimer lTimer = new SimpleTimer();

            DFAMatrix lDFAMatrix = new DFAMatrix(@"Patterns/fuseki9.cdb");

            Console.WriteLine(lDFAMatrix.DFANodes.Count);

            Console.WriteLine(lTimer.SecondsElapsed.ToString());

            GC.Collect();
        }
コード例 #15
0
ファイル: PatternDetector.cs プロジェクト: tgiphil/GoTraxx
        public void Add(PatternCollection patterns)
        {
            DFAMatrixBuilder lDFAMatrixBuilder = new DFAMatrixBuilder(DFAMatrix);
            lDFAMatrixBuilder.Add(patterns);
            PatternCollection.Add(patterns);

            DFAMatrix lDFAMatrix = lDFAMatrixBuilder.GetMatrix();

            lock (this)
            {
                DFAMatrix = lDFAMatrix;
            }
        }
コード例 #16
0
ファイル: PatternDetector.cs プロジェクト: tgiphil/GoTraxx
 public PatternDetector(PatternCollection patterns)
 {
     PatternCollection = patterns;
     DFAMatrixBuilder lDFAMatrixBuilder = new DFAMatrixBuilder(patterns);
     DFAMatrix = lDFAMatrixBuilder.GetMatrix();
 }
コード例 #17
0
ファイル: DFAMatrixBuilder.cs プロジェクト: tgiphil/GoTraxx
 public void Add(DFAMatrix dfaMatrix)
 {
     if (dfaMatrix != null)
         DFAMatrixes.Push(dfaMatrix);
 }
コード例 #18
0
ファイル: DFAMatrixBuilder.cs プロジェクト: tgiphil/GoTraxx
 public DFAMatrixBuilder(DFAMatrix dfaMatrix)
 {
     DFAMatrixes = new Stack<DFAMatrix>();
     Add(dfaMatrix);
 }
コード例 #19
0
ファイル: DFAMatrix.cs プロジェクト: tgiphil/GoTraxx
        protected void Merge(DFAMatrix dfaMatrixA, DFAMatrix dfaMatrixB, DFAMatrix dfaMatrixC)
        {
            DFANodes = new List<DFANode>(Compare.Max<int>(dfaMatrixA.DFANodes.Count, dfaMatrixB.DFANodes.Count, dfaMatrixC.DFANodes.Count) + 128);

            DFANodes.Add(new DFANode());
            DFANodes.Add(new DFANode());

            DFAMatrixCache3 cache = new DFAMatrixCache3(DFANodes.Capacity);

            Product(dfaMatrixA, 1, dfaMatrixB, 1, dfaMatrixC, 1, cache);
        }
コード例 #20
0
ファイル: DFAMatrix.cs プロジェクト: tgiphil/GoTraxx
        protected void Product(DFAMatrix dfaLeft, int left, DFAMatrix dfaMiddle, int middle, DFAMatrix dfaRight, int right, DFAMatrixCache3 cache)
        {
            int lState = DFANodes.Count - 1;

            AttributeUnion(DFANodes[lState], dfaLeft.DFANodes[left], dfaMiddle.DFANodes[middle], dfaRight.DFANodes[right]);

            for (int c = 0; c != 4; c++)
            {
                int lNextL = dfaLeft.DFANodes[left][c];
                int lNextM = dfaMiddle.DFANodes[middle][c];
                int lNextR = dfaRight.DFANodes[right][c];

                if ((lNextL != 0) || (lNextM != 0) || (lNextR != 0))
                {
                    int lNewValue = cache.Search(lNextL, lNextM, lNextR);

                    if (lNewValue == 0)
                    {
                        // create it
                        int lLastState = DFANodes.Count;
                        DFANodes.Add(new DFANode());

                        cache.Add(lNextL, lNextM, lNextR, lLastState);

                        DFANodes[lState][c] = lLastState;
                        Product(dfaLeft, lNextL, dfaMiddle, lNextM, dfaRight, lNextR, cache);
                    }
                    else
                    {
                        // link to it
                        DFANodes[lState][c] = lNewValue;
                    }
                }
                else
                {
                    DFANodes[lState][c] = 0;
                }
            }
        }
コード例 #21
0
ファイル: DFAMatrix.cs プロジェクト: tgiphil/GoTraxx
 public DFAMatrix(DFAMatrix dfaMatrixA, DFAMatrix dfaMatrixB)
 {
     Merge(dfaMatrixA, dfaMatrixB);
 }
コード例 #22
0
 public DFAMatrix(DFAMatrix dfaMatrixA, DFAMatrix dfaMatrixB)
 {
     Merge(dfaMatrixA, dfaMatrixB);
 }
コード例 #23
0
ファイル: DFAMatrix.cs プロジェクト: tgiphil/GoTraxx
 public DFAMatrix(DFAMatrix dfaMatrixA, DFAMatrix dfaMatrixB, DFAMatrix dfaMatrixC)
 {
     Merge(dfaMatrixA, dfaMatrixB, dfaMatrixC);
 }