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


C# Token.Term方法代码示例

本文整理汇总了C#中Lucene.Net.Analysis.Token.Term方法的典型用法代码示例。如果您正苦于以下问题:C# Token.Term方法的具体用法?C# Token.Term怎么用?C# Token.Term使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Lucene.Net.Analysis.Token的用法示例。


在下文中一共展示了Token.Term方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestCtor

		public virtual void  TestCtor()
		{
			Token t = new Token();
			char[] content = "hello".ToCharArray();
			t.SetTermBuffer(content, 0, content.Length);
			char[] buf = t.TermBuffer();
			Assert.AreNotEqual(t.TermBuffer(), content);
			Assert.AreEqual("hello", t.Term());
			Assert.AreEqual("word", t.Type());
			Assert.AreEqual(0, t.GetFlags());
			
			t = new Token(6, 22);
			t.SetTermBuffer(content, 0, content.Length);
			Assert.AreEqual("hello", t.Term());
			Assert.AreEqual("(hello,6,22)", t.ToString());
			Assert.AreEqual("word", t.Type());
			Assert.AreEqual(0, t.GetFlags());
			
			t = new Token(6, 22, 7);
			t.SetTermBuffer(content, 0, content.Length);
			Assert.AreEqual("hello", t.Term());
			Assert.AreEqual("(hello,6,22)", t.ToString());
			Assert.AreEqual(7, t.GetFlags());
			
			t = new Token(6, 22, "junk");
			t.SetTermBuffer(content, 0, content.Length);
			Assert.AreEqual("hello", t.Term());
			Assert.AreEqual("(hello,6,22,type=junk)", t.ToString());
			Assert.AreEqual(0, t.GetFlags());
		}
开发者ID:Rationalle,项目名称:ravendb,代码行数:30,代码来源:TestToken.cs

示例2: Add

			public override void  Add(Token t)
			{
				if (t != null && t.Term().ToUpper().Equals("The".ToUpper()))
				{
					base.Add(t);
				}
			}
开发者ID:Rationalle,项目名称:ravendb,代码行数:7,代码来源:TestTeeTokenFilter.cs

示例3: TestResize

		public virtual void  TestResize()
		{
			Token t = new Token();
			char[] content = "hello".ToCharArray();
			t.SetTermBuffer(content, 0, content.Length);
			for (int i = 0; i < 2000; i++)
			{
				t.ResizeTermBuffer(i);
				Assert.IsTrue(i <= t.TermBuffer().Length);
				Assert.AreEqual("hello", t.Term());
			}
		}
开发者ID:Rationalle,项目名称:ravendb,代码行数:12,代码来源:TestToken.cs

示例4: ConsumeStreamOldAPI

		private static void  ConsumeStreamOldAPI(TokenStream stream)
		{
			stream.Reset();
			Token reusableToken = new Token();
			
			int i = 0;
			while ((reusableToken = stream.Next(reusableToken)) != null)
			{
				System.String term = reusableToken.Term();
				Payload p = reusableToken.GetPayload();
				if (p != null && p.GetData().Length == 1 && p.GetData()[0] == PartOfSpeechAnnotatingFilter.PROPER_NOUN_ANNOTATION)
				{
					Assert.IsTrue("tokenstream".Equals(term), "only TokenStream is a proper noun");
				}
				else
				{
					Assert.IsFalse("tokenstream".Equals(term), "all other tokens (if this test fails, the special POSToken subclass is not correctly passed through the chain)");
				}
				Assert.AreEqual(results[i], term);
				i++;
			}
		}
开发者ID:Rationalle,项目名称:ravendb,代码行数:22,代码来源:TestTokenStreamBWComp.cs

示例5: TestGrow

		public virtual void  TestGrow()
		{
			Token t = new Token();
			System.Text.StringBuilder buf = new System.Text.StringBuilder("ab");
			for (int i = 0; i < 20; i++)
			{
				char[] content = buf.ToString().ToCharArray();
				t.SetTermBuffer(content, 0, content.Length);
				Assert.AreEqual(buf.Length, t.TermLength());
				Assert.AreEqual(buf.ToString(), t.Term());
				buf.Append(buf.ToString());
			}
			Assert.AreEqual(1048576, t.TermLength());
			Assert.AreEqual(1179654, t.TermBuffer().Length);
			
			// now as a string, first variant
			t = new Token();
			buf = new System.Text.StringBuilder("ab");
			for (int i = 0; i < 20; i++)
			{
				System.String content = buf.ToString();
				t.SetTermBuffer(content, 0, content.Length);
				Assert.AreEqual(content.Length, t.TermLength());
				Assert.AreEqual(content, t.Term());
				buf.Append(content);
			}
			Assert.AreEqual(1048576, t.TermLength());
			Assert.AreEqual(1179654, t.TermBuffer().Length);
			
			// now as a string, second variant
			t = new Token();
			buf = new System.Text.StringBuilder("ab");
			for (int i = 0; i < 20; i++)
			{
				System.String content = buf.ToString();
				t.SetTermBuffer(content);
				Assert.AreEqual(content.Length, t.TermLength());
				Assert.AreEqual(content, t.Term());
				buf.Append(content);
			}
			Assert.AreEqual(1048576, t.TermLength());
			Assert.AreEqual(1179654, t.TermBuffer().Length);
			
			// Test for slow growth to a long term
			t = new Token();
			buf = new System.Text.StringBuilder("a");
			for (int i = 0; i < 20000; i++)
			{
				System.String content = buf.ToString();
				t.SetTermBuffer(content);
				Assert.AreEqual(content.Length, t.TermLength());
				Assert.AreEqual(content, t.Term());
				buf.Append("a");
			}
			Assert.AreEqual(20000, t.TermLength());
			Assert.AreEqual(20167, t.TermBuffer().Length);
			
			// Test for slow growth to a long term
			t = new Token();
			buf = new System.Text.StringBuilder("a");
			for (int i = 0; i < 20000; i++)
			{
				System.String content = buf.ToString();
				t.SetTermBuffer(content);
				Assert.AreEqual(content.Length, t.TermLength());
				Assert.AreEqual(content, t.Term());
				buf.Append("a");
			}
			Assert.AreEqual(20000, t.TermLength());
			Assert.AreEqual(20167, t.TermBuffer().Length);
		}
开发者ID:Rationalle,项目名称:ravendb,代码行数:71,代码来源:TestToken.cs

示例6: TestCopyTo

		public virtual void  TestCopyTo()
		{
			Token t = new Token();
			Token copy = (Token) TestSimpleAttributeImpls.AssertCopyIsEqual(t);
			Assert.AreEqual("", t.Term());
			Assert.AreEqual("", copy.Term());
			
			t = new Token(0, 5);
			char[] content = "hello".ToCharArray();
			t.SetTermBuffer(content, 0, 5);
			char[] buf = t.TermBuffer();
			copy = (Token) TestSimpleAttributeImpls.AssertCopyIsEqual(t);
			Assert.AreEqual(t.Term(), copy.Term());
			Assert.AreNotSame(buf, copy.TermBuffer());
			
			Payload pl = new Payload(new byte[]{1, 2, 3, 4});
			t.SetPayload(pl);
			copy = (Token) TestSimpleAttributeImpls.AssertCopyIsEqual(t);
			Assert.AreEqual(pl, copy.GetPayload());
            Assert.AreNotSame(pl, copy.GetPayload());
		}
开发者ID:Rationalle,项目名称:ravendb,代码行数:21,代码来源:TestToken.cs

示例7: TestMixedStringArray

		public virtual void  TestMixedStringArray()
		{
			Token t = new Token("hello", 0, 5);
			Assert.AreEqual(t.TermText(), "hello");
			Assert.AreEqual(t.TermLength(), 5);
			Assert.AreEqual(t.Term(), "hello");
			t.SetTermText("hello2");
			Assert.AreEqual(t.TermLength(), 6);
			Assert.AreEqual(t.Term(), "hello2");
			t.SetTermBuffer("hello3".ToCharArray(), 0, 6);
			Assert.AreEqual(t.TermText(), "hello3");
			
			// Make sure if we get the buffer and change a character
			// that termText() reflects the change
			char[] buffer = t.TermBuffer();
			buffer[1] = 'o';
			Assert.AreEqual(t.TermText(), "hollo3");
		}
开发者ID:Rationalle,项目名称:ravendb,代码行数:18,代码来源:TestToken.cs


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