示例#1
0
 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();
        }
 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;
            }
        }
        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);
 }
 public DFAMatrixBuilder(DFAMatrix dfaMatrix)
 {
     DFAMatrixes = new Stack <DFAMatrix>();
     Add(dfaMatrix);
 }
示例#14
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();
        }
示例#15
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;
            }
        }
示例#16
0
 public PatternDetector(PatternCollection patterns)
 {
     PatternCollection = patterns;
     DFAMatrixBuilder lDFAMatrixBuilder = new DFAMatrixBuilder(patterns);
     DFAMatrix = lDFAMatrixBuilder.GetMatrix();
 }
示例#17
0
 public void Add(DFAMatrix dfaMatrix)
 {
     if (dfaMatrix != null)
         DFAMatrixes.Push(dfaMatrix);
 }
示例#18
0
 public DFAMatrixBuilder(DFAMatrix dfaMatrix)
 {
     DFAMatrixes = new Stack<DFAMatrix>();
     Add(dfaMatrix);
 }
示例#19
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);
        }
示例#20
0
        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
 public DFAMatrix(DFAMatrix dfaMatrixA, DFAMatrix dfaMatrixB)
 {
     Merge(dfaMatrixA, dfaMatrixB);
 }
示例#22
0
 public DFAMatrix(DFAMatrix dfaMatrixA, DFAMatrix dfaMatrixB)
 {
     Merge(dfaMatrixA, dfaMatrixB);
 }
示例#23
0
 public DFAMatrix(DFAMatrix dfaMatrixA, DFAMatrix dfaMatrixB, DFAMatrix dfaMatrixC)
 {
     Merge(dfaMatrixA, dfaMatrixB, dfaMatrixC);
 }