当前位置: 首页>>代码示例>>C#>>正文


C# Vectorhighlight.FieldPhraseList类代码示例

本文整理汇总了C#中Lucene.Net.Search.Vectorhighlight.FieldPhraseList的典型用法代码示例。如果您正苦于以下问题:C# FieldPhraseList类的具体用法?C# FieldPhraseList怎么用?C# FieldPhraseList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FieldPhraseList类属于Lucene.Net.Search.Vectorhighlight命名空间,在下文中一共展示了FieldPhraseList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateFieldFragList

        public FieldFragList CreateFieldFragList(FieldPhraseList fieldPhraseList, int fragCharSize)
        {
            if (fragCharSize < MIN_FRAG_CHAR_SIZE)
                throw new ArgumentException("fragCharSize(" + fragCharSize + ") is too small. It must be " +
                    MIN_FRAG_CHAR_SIZE + " or higher.");

            FieldFragList ffl = new FieldFragList(fragCharSize);

            List<WeightedPhraseInfo> wpil = new List<WeightedPhraseInfo>();
            LinkedList<WeightedPhraseInfo>.Enumerator ite = fieldPhraseList.phraseList.GetEnumerator();

            WeightedPhraseInfo phraseInfo = null;
            int startOffset = 0;
            bool taken = false;
            while (true)
            {
                if (!taken)
                {
                    if (!ite.MoveNext()) break;
                    phraseInfo = ite.Current;
                }
                taken = false;
                if (phraseInfo == null) break;

                // if the phrase violates the border of previous fragment, discard it and try next phrase
                if (phraseInfo.StartOffset < startOffset)
                {
                    if(phraseInfo.EndOffset < startOffset)
                        continue;
                    startOffset = phraseInfo.StartOffset;
                }

                wpil.Clear();
                wpil.Add(phraseInfo);
                int st = phraseInfo.StartOffset - MARGIN < startOffset ?
                    startOffset : phraseInfo.StartOffset - MARGIN;
                int en = st + fragCharSize;
                if (phraseInfo.EndOffset > en)
                    en = phraseInfo.EndOffset;
                startOffset = en;

                while (true)
                {
                    if (ite.MoveNext())
                    {
                        phraseInfo = ite.Current;
                        taken = true;
                        if (phraseInfo == null) break;
                    }
                    else
                        break;
                    if (phraseInfo.EndOffset <= en)
                        wpil.Add(phraseInfo);
                    else
                        break;
                }
                ffl.Add(st, en, wpil);
            }
            return ffl;
        }
开发者ID:j2jensen,项目名称:ravendb,代码行数:60,代码来源:SimpleFragListBuilder.cs

示例2: Ffl

 private FieldFragList Ffl(String queryValue, String indexValue)
 {
     Make1d1fIndex(indexValue);
     Query query = paW.Parse(queryValue);
     FieldQuery fq = new FieldQuery(query, true, true);
     FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
     FieldPhraseList fpl = new FieldPhraseList(stack, fq);
     return new SimpleFragListBuilder().CreateFieldFragList(fpl, 20);
 }
开发者ID:hanabi1224,项目名称:lucene.net,代码行数:9,代码来源:ScoreOrderFragmentsBuilderTest.cs

示例3: Test2TermsIndex

        public void Test2TermsIndex()
        {
            Make1d1fIndex("a a");

            FieldQuery fq = new FieldQuery(Tq("a"), true, true);
            FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
            FieldPhraseList fpl = new FieldPhraseList(stack, fq);
            Assert.AreEqual(2, fpl.phraseList.Count);
            Assert.AreEqual("a(1.0)((0,1))", fpl.phraseList.First.Value.ToString());
            Assert.AreEqual("a(1.0)((2,3))", fpl.phraseList.First.Next.Value.ToString());
        }
开发者ID:VirtueMe,项目名称:ravendb,代码行数:11,代码来源:FieldPhraseListTest.cs

示例4: Test1PhraseIndex

        public void Test1PhraseIndex()
        {
            Make1d1fIndex("a b");

            FieldQuery fq = new FieldQuery(PqF("a", "b"), true, true);
            FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
            FieldPhraseList fpl = new FieldPhraseList(stack, fq);
            Assert.AreEqual(1, fpl.phraseList.Count);
            Assert.AreEqual("ab(1.0)((0,3))", fpl.phraseList.First.Value.ToString());

            fq = new FieldQuery(Tq("b"), true, true);
            stack = new FieldTermStack(reader, 0, F, fq);
            fpl = new FieldPhraseList(stack, fq);
            Assert.AreEqual(1, fpl.phraseList.Count);
            Assert.AreEqual("b(1.0)((2,3))", fpl.phraseList.First.Value.ToString());
        }
开发者ID:VirtueMe,项目名称:ravendb,代码行数:16,代码来源:FieldPhraseListTest.cs

示例5: Test3TermsPhrase

        public void Test3TermsPhrase()
        {
            Make1d1fIndex("d a b a b c d");

            FieldQuery fq = new FieldQuery(PqF("a", "b", "c"), true, true);
            FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
            FieldPhraseList fpl = new FieldPhraseList(stack, fq);
            Assert.AreEqual(1, fpl.phraseList.Count);
            Assert.AreEqual("abc(1.0)((6,11))", fpl.phraseList.First.Value.ToString());
        }
开发者ID:VirtueMe,项目名称:ravendb,代码行数:10,代码来源:FieldPhraseListTest.cs

示例6: TestPhraseSlop

        public void TestPhraseSlop()
        {
            Make1d1fIndex("c a a b c");

            FieldQuery fq = new FieldQuery(pqF(2F, 1, "a", "c"), true, true);
            FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
            FieldPhraseList fpl = new FieldPhraseList(stack, fq);
            Assert.AreEqual(1, fpl.phraseList.Count);
            Assert.AreEqual("ac(2.0)((4,5)(8,9))", fpl.phraseList.First.Value.ToString());
            Assert.AreEqual(4, fpl.phraseList.First.Value.GetStartOffset());
            Assert.AreEqual(9, fpl.phraseList.First.Value.GetEndOffset());
        }
开发者ID:VirtueMe,项目名称:ravendb,代码行数:12,代码来源:FieldPhraseListTest.cs

示例7: Test2Terms1PhraseIndex

        public void Test2Terms1PhraseIndex()
        {
            Make1d1fIndex("c a a b");

            // phraseHighlight = true
            FieldQuery fq = new FieldQuery(PqF("a", "b"), true, true);
            FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
            FieldPhraseList fpl = new FieldPhraseList(stack, fq);
            Assert.AreEqual(1, fpl.phraseList.Count);
            Assert.AreEqual("ab(1.0)((4,7))", fpl.phraseList.First.Value.ToString());

            // phraseHighlight = false
            fq = new FieldQuery(PqF("a", "b"), false, true);
            stack = new FieldTermStack(reader, 0, F, fq);
            fpl = new FieldPhraseList(stack, fq);
            Assert.AreEqual(2, fpl.phraseList.Count);
            Assert.AreEqual("a(1.0)((2,3))", fpl.phraseList.First.Value.ToString());
            Assert.AreEqual("ab(1.0)((4,7))", fpl.phraseList.First.Next.Value.ToString());
        }
开发者ID:VirtueMe,项目名称:ravendb,代码行数:19,代码来源:FieldPhraseListTest.cs

示例8: Test2PhrasesOverlap

        public void Test2PhrasesOverlap()
        {
            Make1d1fIndex("d a b c d");

            BooleanQuery query = new BooleanQuery();
            query.Add(PqF("a", "b"), Occur.SHOULD);
            query.Add(PqF("b", "c"), Occur.SHOULD);
            FieldQuery fq = new FieldQuery(query, true, true);
            FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
            FieldPhraseList fpl = new FieldPhraseList(stack, fq);
            Assert.AreEqual(1, fpl.phraseList.Count);
            Assert.AreEqual("abc(1.0)((2,7))", fpl.phraseList.First.Value.ToString());
        }
开发者ID:synhershko,项目名称:lucene.net,代码行数:13,代码来源:FieldPhraseListTest.cs

示例9: TestFieldPhraseListIndex2w1wSearch1term1phrase

        public void TestFieldPhraseListIndex2w1wSearch1term1phrase()
        {
            MakeIndex2w1w();

            BooleanQuery bq = new BooleanQuery();
            bq.Add(Tq("pc"), Occur.SHOULD);
            bq.Add(PqF("personal", "computer"), Occur.SHOULD);
            FieldQuery fq = new FieldQuery(bq, true, true);
            FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
            FieldPhraseList fpl = new FieldPhraseList(stack, fq);
            Assert.AreEqual(1, fpl.phraseList.Count);
            Assert.IsTrue(fpl.phraseList.First.Value.ToString().IndexOf("(1.0)((3,20))") > 0);
            Assert.AreEqual(3, fpl.phraseList.First.Value.StartOffset);
            Assert.AreEqual(20, fpl.phraseList.First.Value.EndOffset);
        }
开发者ID:Nangal,项目名称:lucene.net,代码行数:15,代码来源:IndexTimeSynonymTest.cs

示例10: Test1PhraseLongMV

        public void Test1PhraseLongMV()
        {
            MakeIndexLongMV();

            FieldQuery fq = new FieldQuery(PqF("search", "engines"), true, true);
            FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
            FieldPhraseList fpl = new FieldPhraseList(stack, fq);
            Assert.AreEqual(2, fpl.phraseList.Count);
            Assert.AreEqual("searchengines(1.0)((102,116))", fpl.phraseList.First.Value.ToString());
            Assert.AreEqual("searchengines(1.0)((157,171))", fpl.phraseList.First.Next.Value.ToString());
        }
开发者ID:VirtueMe,项目名称:ravendb,代码行数:11,代码来源:FieldPhraseListTest.cs

示例11: Test1PhraseShortMV

        public void Test1PhraseShortMV()
        {
            MakeIndexShortMV();

            FieldQuery fq = new FieldQuery(Tq("d"), true, true);
            FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
            FieldPhraseList fpl = new FieldPhraseList(stack, fq);
            SimpleFragListBuilder sflb = new SimpleFragListBuilder();
            FieldFragList ffl = sflb.CreateFieldFragList(fpl, 100);
            SimpleFragmentsBuilder sfb = new SimpleFragmentsBuilder();
            Assert.AreEqual("a b c <b>d</b> e", sfb.CreateFragment(reader, 0, F, ffl));
        }
开发者ID:Nangal,项目名称:lucene.net,代码行数:12,代码来源:SimpleFragmentsBuilderTest.cs

示例12: TestUnstoredField

        public void TestUnstoredField()
        {
            MakeUnstoredIndex();

            FieldQuery fq = new FieldQuery(Tq("aaa"), true, true);
            FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
            FieldPhraseList fpl = new FieldPhraseList(stack, fq);
            SimpleFragListBuilder sflb = new SimpleFragListBuilder();
            FieldFragList ffl = sflb.CreateFieldFragList(fpl, 100);
            SimpleFragmentsBuilder sfb = new SimpleFragmentsBuilder();
            Assert.IsNull(sfb.CreateFragment(reader, 0, F, ffl));
        }
开发者ID:Nangal,项目名称:lucene.net,代码行数:12,代码来源:SimpleFragmentsBuilderTest.cs

示例13: Test1PhraseLongMVB

        public void Test1PhraseLongMVB()
        {
            MakeIndexLongMVB();

            FieldQuery fq = new FieldQuery(PqF("sp", "pe", "ee", "ed"), true, true); // "speed" -(2gram)-> "sp","pe","ee","ed"
            FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
            FieldPhraseList fpl = new FieldPhraseList(stack, fq);
            SimpleFragListBuilder sflb = new SimpleFragListBuilder();
            FieldFragList ffl = sflb.CreateFieldFragList(fpl, 100);
            SimpleFragmentsBuilder sfb = new SimpleFragmentsBuilder();
            Assert.AreEqual("ssing <b>speed</b>, the", sfb.CreateFragment(reader, 0, F, ffl));
        }
开发者ID:Nangal,项目名称:lucene.net,代码行数:12,代码来源:SimpleFragmentsBuilderTest.cs

示例14: TestCompleteSearchInLongMV

        public void TestCompleteSearchInLongMV()
        {
            MakeIndexLongMV();

            FieldQuery fq = new FieldQuery(Preq("engin"), true, true);
            FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
            FieldPhraseList fpl = new FieldPhraseList(stack, fq);
            Assert.AreEqual(2, fpl.phraseList.Count);
            Assert.AreEqual("engines(1.0)((109,116))", fpl.phraseList.First.Value.ToString());
            Assert.AreEqual("engines(1.0)((164,171))", fpl.phraseList.First.Next.Value.ToString());
        }
开发者ID:raol,项目名称:lucene.net,代码行数:11,代码来源:FieldTermStackTest.cs

示例15: Test1PhraseLongMVB

        public void Test1PhraseLongMVB()
        {
            MakeIndexLongMVB();

            FieldQuery fq = new FieldQuery(PqF("sp", "pe", "ee", "ed"), true, true); // "speed" -(2gram)-> "sp","pe","ee","ed"
            FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
            FieldPhraseList fpl = new FieldPhraseList(stack, fq);
            SimpleFragListBuilder sflb = new SimpleFragListBuilder();
            FieldFragList ffl = sflb.CreateFieldFragList(fpl, 100);
            Assert.AreEqual(1, ffl.fragInfos.Count);
            Assert.AreEqual("subInfos=(sppeeeed((88,93)))/1.0(82,182)", ffl.fragInfos[0].ToString());
        }
开发者ID:Rationalle,项目名称:ravendb,代码行数:12,代码来源:SimpleFragListBuilderTest.cs


注:本文中的Lucene.Net.Search.Vectorhighlight.FieldPhraseList类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。