Inheritance: SBlock
Beispiel #1
0
        SBlock CreateBlock(SBlock block, eOperation operation)
        {
            if (_tsm == null)
                throw new Exception("DBreeze.Exception: first search block must be added via TextSearchTable");

            if (block._tsm == null)
            {
                //Creating real block
                block._tsm = this._tsm;
                block.BlockId = this._tsm.cntBlockId++;
                this._tsm.WordsPrepare(block._fullMatchWords.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Where(r => r.Length >= 2), true, ref block.ParsedWords);
                this._tsm.WordsPrepare(block._containsWords.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Where(r => r.Length >= 2), false, ref block.ParsedWords);

                this._tsm.toComputeWordsOrigin = true;
                this._tsm.Blocks[block.BlockId] = block;
            }

            //Creating logical block

            SBlock b = null;
            switch (operation)
            {
                case eOperation.AND:
                    b = new BlockAnd();
                    break;
                case eOperation.OR:
                    b = new BlockOr();
                    break;
                case eOperation.XOR:
                    b = new BlockXOR();
                    break;
                case eOperation.EXCLUDE:
                    b = new BlockEXCLUDE();
                    break;
            }

            b._tsm = this._tsm;
            b.BlockId = this._tsm.cntBlockId++;
            b.LeftBlockId = BlockId;
            b.RightBlockId = block.BlockId;
            b.TransBlockOperation = operation;

            //SBlock b = new SBlock()
            //{
            //    _tsm = this._tsm,
            //    BlockId = this._tsm.cntBlockId++,
            //    LeftBlockId = this.BlockId,
            //    RightBlockId = block.BlockId,
            //    TransBlockOperation = operation
            //};

            this._tsm.Blocks[b.BlockId] = b;

            return b;
        }
Beispiel #2
0
        SBlock CreateBlock(SBlock block, eOperation operation, bool ignoreOnEmptyParameters = false)
        {
            if (_tsm == null)
            {
                throw new Exception("DBreeze.Exception: first search block must be added via TextSearchTable");
            }

            //Returning parent block in case if this block must be ignored
            if (ignoreOnEmptyParameters && String.IsNullOrEmpty(block._fullMatchWords) && String.IsNullOrEmpty(block._containsWords))
            {
                return(this);
            }

            if (block._tsm == null)
            {
                //Creating real block
                block._tsm    = this._tsm;
                block.BlockId = this._tsm.cntBlockId++;
                this._tsm.WordsPrepare(block._fullMatchWords.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Where(r => r.Length > 2), true, ref block.ParsedWords);
                this._tsm.WordsPrepare(block._containsWords.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Where(r => r.Length > 2), false, ref block.ParsedWords);
                this._tsm.toComputeWordsOrigin  = true;
                this._tsm.Blocks[block.BlockId] = block;
            }

            //Creating logical block
            SBlock b = null;

            switch (operation)
            {
            case eOperation.AND:
                b = new BlockAnd();
                break;

            case eOperation.OR:
                b = new BlockOr();
                break;

            case eOperation.XOR:
                b = new BlockXOR();
                break;

            case eOperation.EXCLUDE:
                b = new BlockEXCLUDE();
                break;
            }

            b._tsm                = this._tsm;
            b.BlockId             = this._tsm.cntBlockId++;
            b.LeftBlockId         = BlockId;
            b.RightBlockId        = block.BlockId;
            b.TransBlockOperation = operation;

            //SBlock b = new SBlock()
            //{
            //    _tsm = this._tsm,
            //    BlockId = this._tsm.cntBlockId++,
            //    LeftBlockId = this.BlockId,
            //    RightBlockId = block.BlockId,
            //    TransBlockOperation = operation
            //};

            this._tsm.Blocks[b.BlockId] = b;

            return(b);
        }