Exemplo n.º 1
0
        public override ProbingState HandleData(byte[] buf, int offset, int len)
        {
            int codingState = SMModel.START;
            int max         = offset + len;

            for (int i = offset; i < max; i++)
            {
                codingState = codingSM.NextState(buf[i]);
                if (codingState == SMModel.ERROR)
                {
                    state = ProbingState.NotMe;
                    break;
                }
                if (codingState == SMModel.ITSME)
                {
                    state = ProbingState.FoundIt;
                    break;
                }
                if (codingState == SMModel.START)
                {
                    int charLen = codingSM.CurrentCharLen;
                    if (i == offset)
                    {
                        lastChar[1] = buf[offset];
                        analyser.HandleOneChar(lastChar, 0, charLen);
                    }
                    else
                    {
                        analyser.HandleOneChar(buf, i - 1, charLen);
                    }
                }
            }

            lastChar[0] = buf[max - 1];

            if (state == ProbingState.Detecting)
            {
                if (analyser.GotEnoughData() && GetConfidence() > SHORTCUT_THRESHOLD)
                {
                    state = ProbingState.FoundIt;
                }
            }

            return(state);
        }
Exemplo n.º 2
0
        public override ProbingState HandleData(byte[] buf, int offset, int len)
        {
            int codingState = SMModel.START;
            int max         = offset + len;

            for (int i = offset; i < max; i++)
            {
                codingState = codingSM.NextState(buf[i]);

                if (codingState == SMModel.ERROR)
                {
                    state = ProbingState.NotMe;
                    break;
                }

                if (codingState == SMModel.ITSME)
                {
                    state = ProbingState.FoundIt;
                    break;
                }

                if (codingState == SMModel.START)
                {
                    if (codingSM.CurrentCharLen >= 2)
                    {
                        numOfMBChar++;
                    }
                }
            }

            if (state == ProbingState.Detecting)
            {
                if (GetConfidence() > SHORTCUT_THRESHOLD)
                {
                    state = ProbingState.FoundIt;
                }
            }
            return(state);
        }