public void Test3Frags()
 {
     FieldFragList ffl = this.ffl("a c", "a b b b b b b b b b b b a b a b b b b b c a a b b");
     SimpleFragmentsBuilder sfb = new SimpleFragmentsBuilder();
     String[] f = sfb.CreateFragments(reader, 0, F, ffl, 3);
     Assert.AreEqual(3, f.Length);
     Assert.AreEqual("<b>a</b> b b b b b b b b b ", f[0]);
     Assert.AreEqual("b b <b>a</b> b <b>a</b> b b b b b ", f[1]);
     Assert.AreEqual("<b>c</b> <b>a</b> <b>a</b> b b", f[2]);
 }
        public void Test1TermIndex()
        {
            FieldFragList ffl = this.ffl("a", "a");
            SimpleFragmentsBuilder sfb = new SimpleFragmentsBuilder();
            Assert.AreEqual("<b>a</b>", sfb.CreateFragment(reader, 0, F, ffl));

            // change tags
            sfb = new SimpleFragmentsBuilder(new String[] { "[" }, new String[] { "]" });
            Assert.AreEqual("[a]", sfb.CreateFragment(reader, 0, F, ffl));
        }
 public void Test2Frags()
 {
     FieldFragList ffl = this.ffl("a", "a b b b b b b b b b b b a b a b");
     SimpleFragmentsBuilder sfb = new SimpleFragmentsBuilder();
     String[] f = sfb.CreateFragments(reader, 0, F, ffl, 3);
     // 3 snippets requested, but should be 2
     Assert.AreEqual(2, f.Length);
     Assert.AreEqual("<b>a</b> b b b b b b b b b ", f[0]);
     Assert.AreEqual("b b <b>a</b> b <b>a</b> b", f[1]);
 }
Ejemplo n.º 4
0
        public void Test3Frags()
        {
            FieldFragList          ffl = this.ffl("a c", "a b b b b b b b b b b b a b a b b b b b c a a b b");
            SimpleFragmentsBuilder sfb = new SimpleFragmentsBuilder();

            String[] f = sfb.CreateFragments(reader, 0, F, ffl, 3);
            Assert.AreEqual(3, f.Length);
            Assert.AreEqual("<b>a</b> b b b b b b b b b ", f[0]);
            Assert.AreEqual("b b <b>a</b> b <b>a</b> b b b b b ", f[1]);
            Assert.AreEqual("<b>c</b> <b>a</b> <b>a</b> b b", f[2]);
        }
Ejemplo n.º 5
0
        public void Test2Frags()
        {
            FieldFragList          ffl = this.ffl("a", "a b b b b b b b b b b b a b a b");
            SimpleFragmentsBuilder sfb = new SimpleFragmentsBuilder();

            String[] f = sfb.CreateFragments(reader, 0, F, ffl, 3);
            // 3 snippets requested, but should be 2
            Assert.AreEqual(2, f.Length);
            Assert.AreEqual("<b>a</b> b b b b b b b b b ", f[0]);
            Assert.AreEqual("b b <b>a</b> b <b>a</b> b", f[1]);
        }
Ejemplo n.º 6
0
        public void Test1TermIndex()
        {
            FieldFragList          ffl = this.ffl("a", "a");
            SimpleFragmentsBuilder sfb = new SimpleFragmentsBuilder();

            Assert.AreEqual("<b>a</b>", sfb.CreateFragment(reader, 0, F, ffl));

            // change tags
            sfb = new SimpleFragmentsBuilder(new String[] { "[" }, new String[] { "]" });
            Assert.AreEqual("[a]", sfb.CreateFragment(reader, 0, F, ffl));
        }
Ejemplo n.º 7
0
        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));
        }
Ejemplo n.º 8
0
        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));
        }
Ejemplo n.º 9
0
        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));
        }
Ejemplo n.º 10
0
        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);
            SimpleFragListBuilder  sflb  = new SimpleFragListBuilder();
            FieldFragList          ffl   = sflb.CreateFieldFragList(fpl, 100);
            SimpleFragmentsBuilder sfb   = new SimpleFragmentsBuilder();

            Assert.AreEqual(" most <b>search engines</b> use only one of these methods. Even the <b>search engines</b> that says they can use t",
                            sfb.CreateFragment(reader, 0, F, ffl));
        }
Ejemplo n.º 11
0
        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);
            SimpleFragListBuilder sflb = new SimpleFragListBuilder();
            FieldFragList ffl = sflb.CreateFieldFragList(fpl, 100);
            SimpleFragmentsBuilder sfb = new SimpleFragmentsBuilder();
            Assert.AreEqual(" most <b>search engines</b> use only one of these methods. Even the <b>search engines</b> that says they can use t",
                sfb.CreateFragment(reader, 0, F, ffl));
        }
Ejemplo n.º 12
0
        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));
        }
Ejemplo n.º 13
0
        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));
        }
Ejemplo n.º 14
0
        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));
        }