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


C# Builder.add方法代码示例

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


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

示例1: testReplacements

        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: public void testReplacements() throws Exception
        public virtual void testReplacements()
        {
            Outputs<CharsRef> outputs = CharSequenceOutputs.Singleton;
            Builder<CharsRef> builder = new Builder<CharsRef>(FST.INPUT_TYPE.BYTE2, outputs);
            IntsRef scratchInts = new IntsRef();

            // a -> b
            Util.toUTF16("a", scratchInts);
            builder.add(scratchInts, new CharsRef("b"));

            // ab -> c
            Util.toUTF16("ab", scratchInts);
            builder.add(scratchInts, new CharsRef("c"));

            // c -> de
            Util.toUTF16("c", scratchInts);
            builder.add(scratchInts, new CharsRef("de"));

            // def -> gh
            Util.toUTF16("def", scratchInts);
            builder.add(scratchInts, new CharsRef("gh"));

            FST<CharsRef> fst = builder.finish();

            StringBuilder sb = new StringBuilder("atestanother");
            Dictionary.applyMappings(fst, sb);
            assertEquals("btestbnother", sb.ToString());

            sb = new StringBuilder("abtestanother");
            Dictionary.applyMappings(fst, sb);
            assertEquals("ctestbnother", sb.ToString());

            sb = new StringBuilder("atestabnother");
            Dictionary.applyMappings(fst, sb);
            assertEquals("btestcnother", sb.ToString());

            sb = new StringBuilder("abtestabnother");
            Dictionary.applyMappings(fst, sb);
            assertEquals("ctestcnother", sb.ToString());

            sb = new StringBuilder("abtestabcnother");
            Dictionary.applyMappings(fst, sb);
            assertEquals("ctestcdenother", sb.ToString());

            sb = new StringBuilder("defdefdefc");
            Dictionary.applyMappings(fst, sb);
            assertEquals("ghghghde", sb.ToString());
        }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:50,代码来源:TestDictionary.cs

示例2: build

		/// <summary>
		/// Builds the NormalizeCharMap; call this once you
		///  are done calling <seealso cref="#add"/>. 
		/// </summary>
		public virtual NormalizeCharMap build()
		{

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.apache.lucene.util.fst.FST<org.apache.lucene.util.CharsRef> map;
		  FST<CharsRef> map;
		  try
		  {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.apache.lucene.util.fst.Outputs<org.apache.lucene.util.CharsRef> outputs = org.apache.lucene.util.fst.CharSequenceOutputs.getSingleton();
			Outputs<CharsRef> outputs = CharSequenceOutputs.Singleton;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.apache.lucene.util.fst.Builder<org.apache.lucene.util.CharsRef> builder = new org.apache.lucene.util.fst.Builder<>(org.apache.lucene.util.fst.FST.INPUT_TYPE.BYTE2, outputs);
			Builder<CharsRef> builder = new Builder<CharsRef>(FST.INPUT_TYPE.BYTE2, outputs);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.apache.lucene.util.IntsRef scratch = new org.apache.lucene.util.IntsRef();
			IntsRef scratch = new IntsRef();
			foreach (KeyValuePair<string, string> ent in pendingPairs.SetOfKeyValuePairs())
			{
			  builder.add(Util.toUTF16(ent.Key, scratch), new CharsRef(ent.Value));
			}
			map = builder.finish();
			pendingPairs.Clear();
		  }
		  catch (IOException ioe)
		  {
			// Bogus FST IOExceptions!!  (will never happen)
			throw new Exception(ioe);
		  }

		  return new NormalizeCharMap(map);
		}
开发者ID:paulirwin,项目名称:lucene.net,代码行数:36,代码来源:NormalizeCharMap.cs


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