Пример #1
0
        /// <summary>
        /// Generates a logical block:
        /// var tsm = tran.TextSearch("MyTextSearchTable");
        /// tsm.Block("choose").And(new DBreeze.TextSearch.BlockAnd("pill")).Or(tsm.BlockOr("blue red"))
        /// .GetDocumentIDs
        /// </summary>
        /// <param name="containsWords">space separated words to be used by "contains" logic</param>
        /// <param name="fullMatchWords">space separated words to be used by "full-match" logic</param>
        /// <param name="ignoreOnEmptyParameters">Block will not be counted in intersection calculations if has empty FullMatch and Contains words</param>
        /// <returns></returns>
        public SBlock BlockAnd(string containsWords = "", string fullMatchWords = "", bool ignoreOnEmptyParameters = false)
        {
            fullMatchWords = String.IsNullOrEmpty(fullMatchWords) ? "" : fullMatchWords;
            containsWords  = String.IsNullOrEmpty(containsWords) ? "" : containsWords;

            SBlock sb = new BlockAnd()
            {
                _tsm = this,
                InternalBlockOperation = SBlock.eOperation.AND,
                BlockId        = this.cntBlockId++,
                IsLogicalBlock = false
            };

            //First we add always but with the ignored flag
            if (ignoreOnEmptyParameters && String.IsNullOrEmpty(fullMatchWords) && String.IsNullOrEmpty(containsWords))
            {
                sb.Ignored = true;
            }

            Blocks.Add(sb.BlockId, sb);

            this.WordsPrepare(fullMatchWords.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Where(r => r.Length > 2), true, ref sb.ParsedWords);
            this.WordsPrepare(containsWords.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Where(r => r.Length > 2), false, ref sb.ParsedWords);

            toComputeWordsOrigin = true;
            return(sb);
        }
Пример #2
0
        /// <summary>
        /// Generates a logical block:
        /// var tsm = tran.TextSearch("MyTextSearchTable");
        /// tsm.Block("choose").And(new DBreeze.TextSearch.BlockAnd("pill")).Or(tsm.BlockOr("blue red"))
        /// .GetDocumentIDs
        /// </summary>
        /// <param name="containsWords">space separated words to be used by "contains" logic</param>
        /// <param name="fullMatchWords">space separated words to be used by "full-match" logic</param>
        /// <returns></returns>
        public SBlock BlockAnd(IEnumerable <string> containsWords, IEnumerable <string> fullMatchWords)
        {
            //SBlock sb = new BlockAnd()
            //{
            //    _tsm = this,
            //    InternalBlockOperation = SBlock.eOperation.AND,
            //    BlockId = this.cntBlockId++,
            //    IsLogicalBlock = false
            //};

            SBlock sb = new BlockAnd()
            {
                _tsm = this,
                InternalBlockOperation = SBlock.eOperation.AND,
                BlockId        = this.cntBlockId++,
                IsLogicalBlock = false
            };

            Blocks.Add(sb.BlockId, sb);

            this.WordsPrepare(fullMatchWords, true, ref sb.ParsedWords);
            this.WordsPrepare(containsWords, false, ref sb.ParsedWords);

            toComputeWordsOrigin = true;
            return(sb);
        }
Пример #3
0
        /// <summary>
        /// Generates a logical block:
        /// var tsm = tran.TextSearch("MyTextSearchTable");
        /// tsm.Block("choose").And(new DBreeze.TextSearch.BlockAnd("pill")).Or(tsm.BlockOr("blue red"))
        /// .GetDocumentIDs
        /// </summary>
        /// <param name="containsWords">space separated words to be used by "contains" logic</param>
        /// <param name="fullMatchWords">space separated words to be used by "full-match" logic</param>
        /// <returns></returns>
        public SBlock BlockAnd(string containsWords, string fullMatchWords = "")
        {
            fullMatchWords = String.IsNullOrEmpty(fullMatchWords) ? "" : fullMatchWords;
            containsWords  = String.IsNullOrEmpty(containsWords) ? "" : containsWords;

            //SBlock sb = new BlockAnd()
            //{
            //    _tsm = this,
            //    InternalBlockOperation = SBlock.eOperation.AND,
            //    BlockId = this.cntBlockId++,
            //    IsLogicalBlock = false
            //};

            SBlock sb = new BlockAnd()
            {
                _tsm = this,
                InternalBlockOperation = SBlock.eOperation.AND,
                BlockId        = this.cntBlockId++,
                IsLogicalBlock = false
            };



            Blocks.Add(sb.BlockId, sb);

            this.WordsPrepare(fullMatchWords.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Where(r => r.Length >= 2), true, ref sb.ParsedWords);
            this.WordsPrepare(containsWords.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Where(r => r.Length >= 2), false, ref sb.ParsedWords);

            toComputeWordsOrigin = true;
            return(sb);
        }
Пример #4
0
        /// <summary>
        /// Generates a logical block:
        /// var tsm = tran.TextSearch("MyTextSearchTable");
        /// tsm.Block("choose").And(new DBreeze.TextSearch.BlockAnd("pill")).Or(tsm.BlockOr("blue red"))
        /// .GetDocumentIDs
        /// </summary>
        /// <param name="containsWords">space separated words to be used by "contains" logic or startswith if words were stored by full-match logic</param>
        /// <param name="fullMatchWords">space separated words to be used by "full-match" logic</param>
        /// <param name="ignoreOnEmptyParameters">Block will not be counted in intersection calculations if has empty FullMatch and Contains words</param>
        /// <returns></returns>
        public SBlock BlockAnd(IEnumerable <string> containsWords, IEnumerable <string> fullMatchWords, bool ignoreOnEmptyParameters = false)
        {
            //SBlock sb = new BlockAnd()
            //{
            //    _tsm = this,
            //    InternalBlockOperation = SBlock.eOperation.AND,
            //    BlockId = this.cntBlockId++,
            //    IsLogicalBlock = false
            //};

            SBlock sb = new BlockAnd()
            {
                _tsm = this,
                InternalBlockOperation = SBlock.eOperation.AND,
                BlockId        = this.cntBlockId++,
                IsLogicalBlock = false
            };

            //First we add always but with the ignored flag
            if (ignoreOnEmptyParameters)
            {
                if ((containsWords == null || containsWords.Count() == 0 || containsWords.Where(r => r.Trim().Length > 0).Count() < 1)
                    &&
                    (fullMatchWords == null || fullMatchWords.Count() == 0 || fullMatchWords.Where(r => r.Trim().Length > 0).Count() < 1))
                {
                    sb.Ignored = true;
                }
            }

            Blocks.Add(sb.BlockId, sb);

            this.WordsPrepare(fullMatchWords, true, ref sb.ParsedWords);
            this.WordsPrepare(containsWords, false, ref sb.ParsedWords);

            toComputeWordsOrigin = true;
            return(sb);
        }
Пример #5
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;
        }
Пример #6
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);
        }
Пример #7
0
        /// <summary>
        /// Generates a logical block: 
        /// var tsm = tran.TextSearch("MyTextSearchTable");
        /// tsm.Block("choose").And(new DBreeze.TextSearch.BlockAnd("pill")).Or(tsm.BlockOr("blue red"))
        /// .GetDocumentIDs
        /// </summary>
        /// <param name="containsWords">space separated words to be used by "contains" logic</param>
        /// <param name="fullMatchWords">space separated words to be used by "full-match" logic</param>
        /// <returns></returns>
        public SBlock BlockAnd(IEnumerable<string> containsWords, IEnumerable<string> fullMatchWords)
        {
            //SBlock sb = new BlockAnd()
            //{
            //    _tsm = this,
            //    InternalBlockOperation = SBlock.eOperation.AND,
            //    BlockId = this.cntBlockId++,
            //    IsLogicalBlock = false
            //};

            SBlock sb = new BlockAnd()
            {
                _tsm = this,
                InternalBlockOperation = SBlock.eOperation.AND,
                BlockId = this.cntBlockId++,
                IsLogicalBlock = false
            };

            Blocks.Add(sb.BlockId, sb);

            this.WordsPrepare(fullMatchWords, true, ref sb.ParsedWords);
            this.WordsPrepare(containsWords, false, ref sb.ParsedWords);

            toComputeWordsOrigin = true;
            return sb;
        }
Пример #8
0
        /// <summary>
        /// Generates a logical block: 
        /// var tsm = tran.TextSearch("MyTextSearchTable");
        /// tsm.Block("choose").And(new DBreeze.TextSearch.BlockAnd("pill")).Or(tsm.BlockOr("blue red"))
        /// .GetDocumentIDs
        /// </summary>
        /// <param name="containsWords">space separated words to be used by "contains" logic</param>
        /// <param name="fullMatchWords">space separated words to be used by "full-match" logic</param>
        /// <returns></returns>
        public SBlock BlockAnd(string containsWords, string fullMatchWords="")
        {
            fullMatchWords = String.IsNullOrEmpty(fullMatchWords) ? "" : fullMatchWords;
            containsWords = String.IsNullOrEmpty(containsWords) ? "" : containsWords;

            //SBlock sb = new BlockAnd()
            //{
            //    _tsm = this,
            //    InternalBlockOperation = SBlock.eOperation.AND,
            //    BlockId = this.cntBlockId++,
            //    IsLogicalBlock = false
            //};

            SBlock sb = new BlockAnd()
            {
                _tsm = this,
                InternalBlockOperation = SBlock.eOperation.AND,
                BlockId = this.cntBlockId++,
                IsLogicalBlock = false
            };

            Blocks.Add(sb.BlockId, sb);

            this.WordsPrepare(fullMatchWords.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Where(r => r.Length >= 2), true, ref sb.ParsedWords);
            this.WordsPrepare(containsWords.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Where(r => r.Length >= 2), false, ref sb.ParsedWords);

            toComputeWordsOrigin = true;
            return sb;
        }