/// <summary> /// Returns last added block. Can be added existing block or new block in format /// new DBreeze.TextSearch.BlockAnd(... or new DBreeze.TextSearch.BlockOr( /// </summary> /// <param name="block"></param> /// <param name="ignoreOnEmptyParameters">Block will not be counted in intersection calculations if has empty FullMatch and Contains words</param> /// <returns></returns> public SBlock And(SBlock block, bool ignoreOnEmptyParameters = false) { if (this.Ignored) { return(this.CreateBlock(block, eOperation.OR, ignoreOnEmptyParameters)); } return(this.CreateBlock(block, eOperation.AND, ignoreOnEmptyParameters)); }
/// <summary> /// Returns last added block. Can be added existing block or new block in format /// new DBreeze.TextSearch.BlockAnd(... or new DBreeze.TextSearch.BlockOr( /// </summary> /// <param name="block"></param> /// <param name="ignoreOnEmptyParameters">Block will not be counted in intersection calculations if has empty FullMatch and Contains words</param> /// <returns></returns> public SBlock Exclude(SBlock block, bool ignoreOnEmptyParameters = false) { if (this.Ignored) { return(this.CreateBlock(block, eOperation.OR, ignoreOnEmptyParameters)); } return(this.CreateBlock(block, eOperation.EXCLUDE, ignoreOnEmptyParameters)); }
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; }
/// <summary> /// Returns last added block. Can be added existing block or new block in format /// new DBreeze.TextSearch.BlockAnd(... or new DBreeze.TextSearch.BlockOr( /// </summary> /// <param name="block"></param> /// <returns></returns> public SBlock Xor(SBlock block) { return this.CreateBlock(block, eOperation.XOR); }
/// <summary> /// Returns last added block. Can be added existing block or new block in format /// new DBreeze.TextSearch.BlockAnd(... or new DBreeze.TextSearch.BlockOr( /// </summary> /// <param name="block"></param> /// <returns></returns> public SBlock Exclude(SBlock block) { return this.CreateBlock(block, eOperation.EXCLUDE); }
/// <summary> /// Returns last added block. Can be added existing block or new block in format /// new DBreeze.TextSearch.BlockAnd(... or new DBreeze.TextSearch.BlockOr( /// </summary> /// <param name="block"></param> /// <returns></returns> public SBlock And(SBlock block) { return this.CreateBlock(block, eOperation.AND); }
/// <summary> /// Returns last added block. Can be added existing block or new block in format /// new DBreeze.TextSearch.BlockAnd(... or new DBreeze.TextSearch.BlockOr( /// </summary> /// <param name="block"></param> /// <param name="ignoreOnEmptyParameters">Block will not be counted in intersection calculations if has empty FullMatch and Contains words</param> /// <returns></returns> public SBlock Or(SBlock block, bool ignoreOnEmptyParameters = false) { return(this.CreateBlock(block, eOperation.OR, ignoreOnEmptyParameters)); }
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); }
/// <summary> /// Returns last added block. Can be added existing block or new block in format /// new DBreeze.TextSearch.BlockAnd(... or new DBreeze.TextSearch.BlockOr( /// </summary> /// <param name="block"></param> /// <returns></returns> public SBlock Exclude(SBlock block) { return(this.CreateBlock(block, eOperation.EXCLUDE)); }
/// <summary> /// Returns last added block. Can be added existing block or new block in format /// new DBreeze.TextSearch.BlockAnd(... or new DBreeze.TextSearch.BlockOr( /// </summary> /// <param name="block"></param> /// <returns></returns> public SBlock Xor(SBlock block) { return(this.CreateBlock(block, eOperation.XOR)); }
/// <summary> /// Returns last added block. Can be added existing block or new block in format /// new DBreeze.TextSearch.BlockAnd(... or new DBreeze.TextSearch.BlockOr( /// </summary> /// <param name="block"></param> /// <returns></returns> public SBlock And(SBlock block) { return(this.CreateBlock(block, eOperation.AND)); }