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


C# ITsString.GetSubstring方法代码示例

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


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

示例1: CreateAnalyses

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Creates analyses for the words and punctuation forms of the specified segment. Words
		/// will have WfiWordforms created if they don't already exist.
		/// </summary>
		/// <param name="segment">The segment.</param>
		/// <param name="paraContents">The para contents.</param>
		/// <param name="ichBeginOffset">The beginning character offset.</param>
		/// <param name="ichLimOffset">The character offset limit.</param>
		/// <param name="fCreateGlosses">if set to <c>true</c> create glosses in addition to the
		/// WfiWordforms for each surface form.</param>
		/// ------------------------------------------------------------------------------------
		public static void CreateAnalyses(ISegment segment, ITsString paraContents,
			int ichBeginOffset, int ichLimOffset, bool fCreateGlosses)
		{
			FdoCache cache = segment.Cache;
			IFdoServiceLocator servloc = cache.ServiceLocator;
			if (SegmentBreaker.HasLabelText(paraContents, ichBeginOffset, ichLimOffset))
			{
				IPunctuationForm labelPunc = servloc.GetInstance<IPunctuationFormFactory>().Create();
				segment.AnalysesRS.Add(labelPunc);
				labelPunc.Form = paraContents.GetSubstring(ichBeginOffset, ichLimOffset);
			}
			else
			{
				ParseSegBaseline(segment, ichBeginOffset, ichLimOffset, (iForm, word, iAnalysis) =>
					{
						CreateAnalysisForWord(word, segment, cache.DefaultAnalWs, fCreateGlosses);
						return true;
					},
					(sPunc, iAnalysis) => CreatePuncForm(segment, cache.TsStrFactory.MakeString(sPunc, cache.DefaultVernWs)),
					(ichOrc, iAnalysis) => CreatePuncForm(segment, paraContents.Substring(segment.BeginOffset + ichOrc, 1)));
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:34,代码来源:FdoTestHelper.cs

示例2: CrawlRuns

		/// <summary>
		/// Crawls all runs in the specified string. The run modifier is called for each run in the
		/// specified string. If the run modifier returns <c>null</c>, the run is removed from
		/// the string. If all runs are removed, this method returns <c>null</c>.
		/// </summary>
		/// <param name="str">The string.</param>
		/// <param name="runModifier">The run modifier.</param>
		/// <returns></returns>
		public static ITsString CrawlRuns(ITsString str, Func<ITsString, ITsString> runModifier)
		{
			ITsIncStrBldr tisb = TsIncStrBldrClass.Create();
			bool modified = false;
			bool empty = true;
			for (int i = 0; i < str.RunCount; i++)
			{
				int ichMin, ichLim;
				str.GetBoundsOfRun(i, out ichMin, out ichLim);
				var oldRun = str.GetSubstring(ichMin, ichLim);
				var newRun = runModifier(oldRun);
				modified = modified || newRun != oldRun;
				if (newRun != null)
				{
					tisb.AppendTsString(newRun);
					empty = false;
				}
			}

			if (empty)
				return null;

			return modified ? tisb.GetString() : str;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:32,代码来源:StringServices.cs

示例3: CreateAllomorph

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create an allomorph.
		/// </summary>
		/// <param name="entry">The entry.</param>
		/// <param name="msa">The msa.</param>
		/// <param name="tssform">The tssform.</param>
		/// <param name="morphType">Type of the morph.</param>
		/// <param name="fLexemeForm">set to <c>true</c> to create a lexeme form.</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		public static IMoForm CreateAllomorph(ILexEntry entry, IMoMorphSynAnalysis msa,
			ITsString tssform, IMoMorphType morphType, bool fLexemeForm)
		{
			IMoForm allomorph = null;
			switch (morphType.Guid.ToString())
			{
				case Ling.MoMorphType.kguidMorphProclitic: // Fall through.
				case Ling.MoMorphType.kguidMorphClitic: // Fall through.
				case Ling.MoMorphType.kguidMorphEnclitic:
					Debug.Assert(msa is IMoStemMsa, "Wrong MSA for a clitic.");
					IMoStemMsa stemMsa = (IMoStemMsa) msa;
					goto case Ling.MoMorphType.kguidMorphBoundStem;
				case Ling.MoMorphType.kguidMorphRoot: // Fall through.
				case Ling.MoMorphType.kguidMorphBoundRoot: // Fall through.
				case Ling.MoMorphType.kguidMorphStem: // Fall through.
				case Ling.MoMorphType.kguidMorphParticle: // Fall through.
				case Ling.MoMorphType.kguidMorphPhrase: // Fall through.
				case Ling.MoMorphType.kguidMorphDiscontiguousPhrase: // Fall through.
					// AndyB_Yahoo: On particles, (and LT-485), these are always to be
					// roots that never take any affixes
					// AndyB_Yahoo: Therefore, they need to have StemMsas and Stem
					// allomorphs
				case Ling.MoMorphType.kguidMorphBoundStem:
					allomorph = new MoStemAllomorph();
					break;
				default:
					// All others, which should get an non-stem MSA and an affix allo.
					Debug.Assert(!(msa is IMoStemMsa), "Wrong MSA for a affix.");
					allomorph = new MoAffixAllomorph();
					break;
			}
			if (fLexemeForm)
				entry.LexemeFormOA = allomorph;
			else
				allomorph = (IMoForm) entry.AlternateFormsOS.Append(allomorph);
			allomorph.MorphTypeRA = morphType; // Has to be done before the next call.
			ITsString tssAllomorphForm = null;
			int maxLength = entry.Cache.MaxFieldLength((int) MoForm.MoFormTags.kflidForm);
			if (tssform.Length > maxLength)
			{
				string sMessage = String.Format(Strings.ksTruncatedXXXToYYYChars,
												fLexemeForm ? Strings.ksLexemeForm : Strings.ksAllomorph, maxLength);
				System.Windows.Forms.MessageBox.Show(sMessage, Strings.ksWarning,
													 System.Windows.Forms.MessageBoxButtons.OK,
													 System.Windows.Forms.MessageBoxIcon.Warning);
				tssAllomorphForm = tssform.GetSubstring(0, maxLength);
			}
			else
			{
				tssAllomorphForm = tssform;
			}
			allomorph.FormMinusReservedMarkers = tssAllomorphForm;
			if ((morphType.Guid.ToString() == Ling.MoMorphType.kguidMorphInfix) ||
				(morphType.Guid.ToString() == Ling.MoMorphType.kguidMorphInfixingInterfix))
			{
				HandleInfix(entry, allomorph);
			}
			return allomorph;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:70,代码来源:MoClasses.cs

示例4: VerifyString

		private void VerifyString(ITsString tss, string[] parts, string[] expectedStyles)
		{
			// The number of runs is not necessarily the same as the number of parts, because some runs may have merged.
			Assert.AreEqual(parts.Length, expectedStyles.Length);
			Assert.That(tss.Length, Is.EqualTo((from item in parts select item.Length).Sum()));
			int start = 0;
			for (int i = 0; i < parts.Length; i++)
			{
				int end = start + parts[i].Length;
				var sub = tss.GetSubstring(start, end);
				Assert.That(sub.RunCount, Is.EqualTo(1), " part " + i + " (" + parts[i] + ") has too many runs in string " + tss.Text );
				Assert.That(sub.Text, Is.EqualTo(parts[i]));
				Assert.That(sub.get_Properties(0).GetStrPropValue((int)FwTextPropType.ktptNamedStyle), Is.EqualTo(expectedStyles[i]),
					" part " + i + " (" + parts[i] + ") has the wrong style " + tss.Text);
				start = end;
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:17,代码来源:StringServicesTests.cs

示例5: CreatePuncFormsInSegmentForOrcs

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Creates punctuation form analyses for all of the ORCs in the specified baseLine string.
		/// </summary>
		/// <param name="segment">The segment to which we are going to add the analyses.</param>
		/// <param name="baseLine">The base line of the original segment from which we are moving
		/// the ORCs.</param>
		/// <param name="para">The paragraph that owns the given segment.</param>
		/// <param name="iInsertPos">Index (0-based) in the sequence of analyses where the ORC
		/// punctuation form(s) should be inserted.</param>
		/// ------------------------------------------------------------------------------------
		private static void CreatePuncFormsInSegmentForOrcs(ISegment segment, ITsString baseLine,
			IScrTxtPara para, int iInsertPos)
		{
			if (!para.SegmentsOS.Any(seg => seg.AnalysesRS.Count > 0))
				return;

			for (int i = 0; i < baseLine.RunCount; i++)
			{
				if (baseLine.get_IsRunOrc(i))
				{
					IPunctuationForm orcForm = para.Cache.ServiceLocator.GetInstance<IPunctuationFormFactory>().Create();
					orcForm.Form = baseLine.GetSubstring(baseLine.get_MinOfRun(i), baseLine.get_LimOfRun(i));
					segment.AnalysesRS.Insert(iInsertPos++, orcForm);
				}
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:27,代码来源:DataStoreInitializationServices.cs


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