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


C# ISilDataAccess.get_MultiStringAlt方法代码示例

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


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

示例1: GetBestGloss

			/// <summary>
			/// Get the most appropriate WfiGloss from among those belonging to the given WfiAnalysis.
			/// The goal is to match as closely as possible the strings found in sda.get_MultiStringAlt(hvoWord, ktagSbWordGloss, ws)
			/// for each ws in wsIds. Ideally we find an alternative where all writing systems match exactly.
			/// Failing that, one where as many as possible match, and the others are blank.
			/// </summary>
			/// <param name="wfiAnalysis"></param>
			/// <param name="wsIds"></param>
			/// <param name="sda"></param>
			/// <param name="hvoWord"></param>
			/// <returns></returns>
			internal static IWfiGloss GetBestGloss(IWfiAnalysis wfiAnalysis, List<int> wsIds, ISilDataAccess sda, int hvoWord)
			{
				IWfiGloss best = null;
				int cBestMatch = 0;
				int cBestBlanks = 0; // number of non-matching alternatives that are blank, in the best match so far
				foreach (IWfiGloss possibleGloss in wfiAnalysis.MeaningsOC)
				{
					int cMatch = 0;
					int cBlanks = 0; // number of non-matching alternatives that are blank, in the current item.
					foreach (int wsId in wsIds)
					{
						ITsString tssGloss = sda.get_MultiStringAlt(hvoWord, ktagSbWordGloss, wsId);
						ITsString tssMainGloss = possibleGloss.Form.get_String(wsId);
						string sdaGloss = tssGloss.Text;
						string smainGloss = tssMainGloss.Text;

						if (tssGloss.Equals(tssMainGloss))
							cMatch++;
						else if (tssMainGloss.Length == 0)
							cBlanks++;
						else
						{
							cMatch = int.MinValue; // non-matching alternative on the WfiGloss, this one is no good for sure
							cBlanks = int.MinValue;
						}
					}
					// This one is better if:
					// - it has more matches
					// - it has as many matches and more relevant empty alternatives
					// - it is as good otherwise and has fewer non-relevant alternatives.
					if (cMatch > cBestMatch
						|| (cMatch == cBestMatch && cBlanks > cBestBlanks)
						|| (cMatch == cBestMatch && cBlanks == cBestBlanks && best != null && AdditionalAlternatives(possibleGloss, wsIds) < AdditionalAlternatives(best, wsIds)))
					{
						cBestMatch = cMatch;
						cBestBlanks = cBlanks;
						best = possibleGloss;
					}
				}
				// we won't return something where nothing matched, just because it had a blank alternative
				return cBestMatch > 0 ? best : null;
			}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:53,代码来源:SandboxBase.GetRealyAnalysisMethod.cs

示例2: CacheStringAltForAllCurrentWs

		private static void CacheStringAltForAllCurrentWs(IEnumerable<int> currentWsList, IVwCacheDa cda, int hvoSec, int flidSec,
			ISilDataAccess sdaMain, int hvoMain, int flidMain)
		{
			CacheStringAltForAllCurrentWs(currentWsList, cda, hvoSec, flidSec,
				delegate(int ws1)
				{
					ITsString tssMain;
					if (hvoMain != 0)
						tssMain = sdaMain.get_MultiStringAlt(hvoMain, flidMain, ws1);
					else
						tssMain = TsStringUtils.MakeTss("", ws1);
					return tssMain;
				});
		}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:14,代码来源:SandboxBase.cs

示例3: GetTssWffCandidate

		/// <summary>
		/// the tss of the wordform form of the given hvoMatchingWordform in the ws we are querying for.
		/// </summary>
		/// <param name="sda"></param>
		/// <param name="tssTxtWord">the tss of the baseline at current word boundaries</param>
		/// <param name="tssWordAnn">the tss of the wordform form (in the baseline ws) of the annotation.</param>
		/// <param name="hvoMatchingWordform"></param>
		/// <param name="wsMatchQuery">the ws of the wordform we're looking for</param>
		/// <returns></returns>
		private ITsString GetTssWffCandidate(ISilDataAccess sda, ITsString tssTxtWord, ITsString tssWordAnn,
											 int hvoMatchingWordform, int wsMatchQuery)
		{
			ITsString tssWff = tssWordAnn;
			int wsTxtWord = TsStringUtils.GetWsAtOffset(tssTxtWord, 0);
			if (hvoMatchingWordform == 0)
			{
				// return a candidate if it matches the ws we're trying to query.
				return wsMatchQuery == wsTxtWord ? tssWordAnn : null;
			}
			// if the ws of the matcher doesn't match the ws of the baseline
			// find the wordform in an alternative ws.
			if (wsMatchQuery != wsTxtWord)
			{
				tssWff = sda.get_MultiStringAlt(hvoMatchingWordform, WfiWordformTags.kflidForm, wsMatchQuery);
			}
			return tssWff;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:27,代码来源:ITextUtils.cs

示例4: StringsFor

		/// <summary>
		/// Returns an array of string values (keys) for the objects under this layout node.
		/// </summary>
		/// <param name="fdoCache">The fdo cache.</param>
		/// <param name="sda">The sda.</param>
		/// <param name="layout">The layout.</param>
		/// <param name="hvo">The hvo.</param>
		/// <param name="layoutCache">The layout cache.</param>
		/// <param name="caller">where layout is a component of a 'part' element, caller
		/// is the 'part ref' that invoked it.</param>
		/// <param name="stringTbl">The string TBL.</param>
		/// <param name="wsForce">if non-zero, "string" elements are forced to use that writing system for multistrings.</param>
		/// <returns></returns>
		static public string[] StringsFor(FdoCache fdoCache, ISilDataAccess sda, XmlNode layout, int hvo,
			LayoutCache layoutCache, XmlNode caller, StringTable stringTbl, int wsForce)
		{
			// Some nodes are known to be uninteresting.
			if (XmlVc.CanSkipNode(layout))
				return new string[0]; // don't know how to sort, treat as empty key.

			switch (layout.Name)
			{
				case "string":
				{
					int hvoTarget = hvo;
					XmlVc.GetActualTarget(layout, ref hvoTarget, sda);	// modify the hvo if needed
					if (hvo != hvoTarget)
					{
						return AddStringFromOtherObj(layout, hvoTarget, fdoCache, sda);
					}
					int flid = GetFlid(sda, layout, hvo);
					if (wsForce != 0)
					{
						// If we are forcing a writing system, and it's a multistring, get the forced alternative.
						int itype = sda.MetaDataCache.GetFieldType(flid);
						itype = itype & (int)CellarPropertyTypeFilter.VirtualMask;
						switch (itype)
						{
							case (int) CellarPropertyType.MultiUnicode:
							case (int) CellarPropertyType.MultiString:
								if (wsForce < 0)
								{
									int wsActual;
									var tss = WritingSystemServices.GetMagicStringAlt(fdoCache, sda, wsForce, hvo, flid, true, out wsActual);
									return new[] {tss == null ? "" : tss.Text };
								}
								return new[]
										   {sda.get_MultiStringAlt(hvo, flid, wsForce).Text};
						}
					}
					bool fFoundType;
					var strValue = fdoCache.GetText(hvo, flid, layout, out fFoundType);
					if (fFoundType)
						return new[] {strValue};

					throw new Exception("Bad property type (" + strValue + " for hvo " + hvo +
												" found for string property "
							+ flid + " in " + layout.OuterXml);
				}
				case "configureMlString":
				{
					int flid = GetFlid(sda, layout, hvo);
					// The Ws info specified in the part ref node
					HashSet<int> wsIds = WritingSystemServices.GetAllWritingSystems(fdoCache, caller, null, hvo, flid);
					if (wsIds.Count == 1)
					{
						var strValue = sda.get_MultiStringAlt(hvo, flid, wsIds.First()).Text;
						return new[] {strValue};
					}
					return new[] {AddMultipleAlternatives(fdoCache, sda, wsIds, hvo, flid, caller)};
				}
				case "multiling":
					return ProcessMultiLingualChildren(fdoCache, sda, layout, hvo, layoutCache, caller, stringTbl, wsForce);
				case "layout":
					// "layout" can occur when GetNodeToUseForColumn returns a phony 'layout'
					// formed by unifying a layout with child nodes. Assemble its children.
					// (arguably, we should treat that like div if current flow is a pile.
					// but we can't tell that and it rarely makes a difference.)
				case "para":
				case "span":
				{
					return AssembleChildKeys(fdoCache, sda, layout, hvo, layoutCache, caller, stringTbl, wsForce);
				}
				case "column":
					// top-level node for whole column; concatenate children as for "para"
					// if multipara is false, otherwise as for "div"
					if (XmlUtils.GetOptionalBooleanAttributeValue(layout, "multipara", false))
						return ChildKeys(fdoCache, sda, layout, hvo, layoutCache, caller, stringTbl, wsForce);
					else
						return AssembleChildKeys(fdoCache, sda, layout, hvo, layoutCache, caller, stringTbl, wsForce);

				case "part":
				{
					string partref = XmlUtils.GetOptionalAttributeValue(layout, "ref");
					if (partref == null)
						return ChildKeys(fdoCache, sda, layout, hvo, layoutCache, caller, stringTbl, wsForce); // an actual part, made up of its pieces
					XmlNode part = XmlVc.GetNodeForPart(hvo, partref, false, sda, layoutCache);
					// This is the critical place where we introduce a caller. The 'layout' is really a 'part ref' which is the
					// 'caller' for all embedded nodes in the called part.
					return StringsFor(fdoCache, sda, part, hvo, layoutCache, layout, stringTbl, wsForce);
//.........这里部分代码省略.........
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:101,代码来源:XmlViewsUtils.cs

示例5: CopyStringsToSecondary

		private void CopyStringsToSecondary(IList<int> writingSystems, ISilDataAccess sdaMain, int hvoMain,
			int flidMain, IVwCacheDa cda, int hvoSec, int flidSec, ITsStrFactory tsf)
		{
			CheckDisposed();
			foreach (int ws in writingSystems)
			{
				int wsActual = 0;
				ITsString tss;
				if (ws > 0)
				{
					wsActual = ws;
				}
				else if (ws == WritingSystemServices.kwsFirstAnal)
				{
					IList<int> currentAnalysisWsList = m_caches.MainCache.ServiceLocator.WritingSystems.CurrentAnalysisWritingSystems.Select(wsObj => wsObj.Handle).ToArray();
					CacheStringAltForAllCurrentWs(currentAnalysisWsList, cda, hvoSec, flidSec, sdaMain, hvoMain, flidMain);
					continue;
				}
				else if (ws == WritingSystemServices.kwsFirstVern)
				{
					IList<int> currentVernWsList = m_caches.MainCache.ServiceLocator.WritingSystems.CurrentVernacularWritingSystems.Select(wsObj => wsObj.Handle).ToArray();
					CacheStringAltForAllCurrentWs(currentVernWsList, cda, hvoSec, flidSec, sdaMain, hvoMain, flidMain);
					continue;
				}
				else if (ws == WritingSystemServices.kwsVernInParagraph)
				{
					wsActual = RawWordformWs;
				}
				if (wsActual <= 0)
					throw new ArgumentException(String.Format("magic ws {0} not yet supported.", ws));

				if (hvoMain == 0)
				{
					tss = MakeTss("", wsActual, tsf);
				}
				else
				{
					tss = sdaMain.get_MultiStringAlt(hvoMain, flidMain, wsActual);
				}
				cda.CacheStringAlt(hvoSec, flidSec, wsActual, tss);
			}
		}
开发者ID:sillsdev,项目名称:FieldWorks,代码行数:42,代码来源:SandboxBase.cs

示例6: AddMultipleAlternatives

		static string AddMultipleAlternatives(FdoCache cache, ISilDataAccess sda, IEnumerable<int> wsIds, int hvo, int flid, XmlNode frag)
		{
			string sep = XmlUtils.GetOptionalAttributeValue(frag, "sep", null);
			bool fLabel = XmlUtils.GetOptionalBooleanAttributeValue(frag, "showLabels", false); // true to 'separate' using multistring labels.
			string result = "";
			bool fFirst = true;
			foreach (int ws in wsIds)
			{
				string val = sda.get_MultiStringAlt(hvo, flid, ws).Text;
				if (string.IsNullOrEmpty(val))
					continue; // doesn't even count as 'first'
				if (fLabel)
				{
					IWritingSystem wsObj = cache.ServiceLocator.WritingSystemManager.Get(ws);
					result += DisplayWsLabel(wsObj, cache);
				}
				if (fFirst)
				{
					fFirst = false;
				}
				else if (sep != null)
				{
					result = result + sep;
				}
				result += val;
			}
			return result;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:28,代码来源:XmlViewsUtils.cs

示例7: AddStringFromOtherObj

		internal static string[] AddStringFromOtherObj(XmlNode frag, int hvoTarget, FdoCache cache, ISilDataAccess sda)
		{
			int flid = XmlVc.GetFlid(frag, hvoTarget, sda);
			ITsStrFactory tsf = cache.TsStrFactory;
			CellarPropertyType itype = (CellarPropertyType)sda.MetaDataCache.GetFieldType(flid);
			if (itype == CellarPropertyType.Unicode)
			{
				return new[] { sda.get_UnicodeProp(hvoTarget, flid) };
			}
			else if (itype == CellarPropertyType.String)
			{
				return new[] { sda.get_StringProp(hvoTarget, flid).Text };
			}
			else // multistring of some type
			{
				int wsid = 0;
				string sep = "";
				if (s_cwsMulti > 1)
				{
					string sLabelWs = XmlUtils.GetOptionalAttributeValue(frag, "ws");
					if (sLabelWs != null && sLabelWs == "current")
					{
						sep = DisplayMultiSep(frag)
							+ DisplayWsLabel(s_qwsCurrent, cache);
						wsid = s_qwsCurrent.Handle;
					}
				}
				if (wsid == 0)
					wsid = WritingSystemServices.GetWritingSystem(cache,
						frag, null, WritingSystemServices.kwsAnal).Handle;
				if (itype == CellarPropertyType.MultiUnicode)
				{
					return new[] { sep, sda.get_MultiStringAlt(hvoTarget, flid, wsid).Text };
				}
				else
				{
					return new[] { sep, sda.get_MultiStringAlt(hvoTarget, flid, wsid).Text };
				}
			}
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:40,代码来源:XmlViewsUtils.cs

示例8: GetTssWffCandidate

		/// <summary>
		/// the tss of the wordform form of the given hvoMatchingWordform in the ws we are querying for.
		/// </summary>
		/// <param name="sda"></param>
		/// <param name="tssTxtWord">the tss of the baseline at current word boundaries</param>
		/// <param name="tssWordAnn">the tss of the wordform form (in the baseline ws) of the annotation.</param>
		/// <param name="hvoMatchingWordform"></param>
		/// <param name="wsMatchQuery">the ws of the wordform we're looking for</param>
		/// <returns></returns>
		private ITsString GetTssWffCandidate(ISilDataAccess sda, ITsString tssTxtWord, ITsString tssWordAnn,
			int hvoMatchingWordform, int wsMatchQuery)
		{
			ITsString tssWff = tssWordAnn;
			int wsTxtWord = StringUtils.GetWsAtOffset(tssTxtWord, 0);
			if (hvoMatchingWordform == 0)
			{
				// return a candidate if it matches the ws we're trying to query.
				return wsMatchQuery == wsTxtWord ? tssWordAnn : null;
			}
			// if the ws of the matcher doesn't match the ws of the baseline
			// find the wordform in an alternative ws.
			if (wsMatchQuery != wsTxtWord)
			{
				try
				{
					// bulk load wordform forms in the alternative ws if we get any misses.
					m_cache.EnableBulkLoadingIfPossible(true);
					tssWff = sda.get_MultiStringAlt(hvoMatchingWordform, (int)WfiWordform.WfiWordformTags.kflidForm, wsMatchQuery);
				}
				finally
				{
					m_cache.EnableBulkLoadingIfPossible(false);
				}
			}
			return tssWff;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:36,代码来源:ITextUtils.cs

示例9: Setup

		public void Setup()
		{
			// Create the following:
			// - part and layout inventories
			// - metadata cache
			// - DataAccess cache
			// - collection of columns to display.

			// We want a MetaDataCache that knows about
			// - LexEntry.Senses, Msas, CitationForm, Bibliography, Etymology
			// - LexSense.SemanticDomains, SenseType, Status, gloss
			// - CmPossibility Name, abbr
			// - MoMorphSynAnalysis
			// - MoStemMsa
			// - MoDerivationalMsa
			m_mdc = FwMetaDataCacheClass.Create();
			string m_sTestPath = Path.Combine(DirectoryFinder.FwSourceDirectory,
				@"Common\Controls\XmlViews\XmlViewsTests\SampleCm.xml");
			m_mdc.InitXml(m_sTestPath, true);

			// We want ISilDataAccess with:
			// - LexEntry (1) with no senses and one MSA (2)
			// - LexEntry (4) with one sense (5) and no MSA
			// - LexEntry (6) with three senses (7, 8, 9) and two MSAs (10, 11)
			// - sense(5) with no semantic domains
			// - senses with one SD (7->30, 8->31)
			// - sense with three SDs, one the same as the first (9->30, 31, 32)
			// - MoStemMsa (2, 11)
			// - MoDerivationalMsa (10)
			m_cda = VwCacheDaClass.Create();
			m_sda = m_cda as ISilDataAccess;
			m_wsf = LgWritingSystemFactoryClass.Create();
			m_sda.WritingSystemFactory = m_wsf;
			SimpleDataParser parser = new SimpleDataParser(m_mdc, m_cda);

			parser.Parse(Path.Combine(DirectoryFinder.FwSourceDirectory,
				@"Common\Controls\XmlViews\XmlViewsTests\SampleData.xml"));
			int wsEn = m_wsf.GetWsFromStr("en");
			// These are mainly to check out the parser.
			Assert.AreEqual(3, m_sda.get_ObjectProp(2, 23011), "part of speech of an MoStemMsa");
			Assert.AreEqual(2, m_sda.get_VecItem(1, 2009, 0), "owned msa");
			Assert.AreEqual("noun", m_sda.get_MultiStringAlt(3, 7003, wsEn).Text, "got ms property");
			Assert.AreEqual(9, m_sda.get_VecItem(6, 2010, 2), "3rd sense");
			Assert.AreEqual(31, m_sda.get_VecItem(9, 21016, 1), "2nd semantic domain");

			// Columns includes
			// - CitationForm (string inside span)
			// - Bibliography (string not in span)
			// - Sense glosses (string in para in seq, nested in column element)
			// - Semantic domains (pair of strings in para in seq in seq, using layout refs)
			// - MSAs (simplified, but polymorphic with one having <choice> and one <obj> to CmPossibility
			XmlDocument docColumns = new XmlDocument();
			docColumns.Load(Path.Combine(DirectoryFinder.FwSourceDirectory,
				@"Common\Controls\XmlViews\XmlViewsTests\TestColumns.xml"));
			m_columnList = docColumns.DocumentElement.ChildNodes;

			// Parts just has what those columns need.
			string partDirectory = Path.Combine(DirectoryFinder.FwSourceDirectory,
				@"Common\Controls\XmlViews\XmlViewsTests");
			Dictionary<string, string[]> keyAttrs = new Dictionary<string, string[]>();
			keyAttrs["layout"] = new string[] {"class", "type", "name" };
			keyAttrs["group"] = new string[] {"label"};
			keyAttrs["part"] = new string[] {"ref"};


			// Currently there are no specialized layout files that match.
			m_layoutInventory = new Inventory(new string[] {partDirectory},
				"*Layouts.xml", "/LayoutInventory/*", keyAttrs);

			keyAttrs = new Dictionary<string, string[]>();
			keyAttrs["part"] = new string[] {"id"};

			m_partInventory = new Inventory(new string[] {partDirectory},
				"TestParts.xml", "/PartInventory/bin/*", keyAttrs);
			if (m_layouts != null)
				m_layouts.Dispose();
			m_layouts = new LayoutCache(m_mdc, m_layoutInventory, m_partInventory);
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:78,代码来源:TestManyOneBrowse.cs

示例10: FirstAlternativeName

		private ITsString FirstAlternativeName(ISilDataAccess sda, int hvoText, int[] rgws)
		{
			ITsString tss;
			for (int i = 0; i < rgws.Length; ++i)
			{
				tss = sda.get_MultiStringAlt(hvoText,
					(int)CmMajorObject.CmMajorObjectTags.kflidName, rgws[i]);
				if (tss.Length > 0)
					return tss;
			}
			return null;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:12,代码来源:InterlinVc.cs

示例11: CacheStringAltForAllCurrentWs

		private void CacheStringAltForAllCurrentWs(int[] currentWsList, IVwCacheDa cda, int hvoSec, int flidSec,
			ISilDataAccess sdaMain, int hvoMain, int flidMain)
		{
			foreach (int ws1 in currentWsList)
				cda.CacheStringAlt(hvoSec, flidSec, ws1, sdaMain.get_MultiStringAlt(hvoMain, flidMain, ws1));
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:6,代码来源:SandboxBase.cs

示例12: CopyStringsToSecondary

		private void CopyStringsToSecondary(List<int> writingSystems, ISilDataAccess sdaMain, int hvoMain,
			int flidMain, IVwCacheDa cda, int hvoSec, int flidSec, ITsStrFactory tsf)
		{
			CheckDisposed();
			foreach (int ws in writingSystems)
			{
				int wsActual = 0;
				ITsString tss;
				if (ws > 0)
				{
					wsActual = ws;
				}
				else if (ws == LangProject.kwsFirstAnal)
				{
					int[] currentAnalysisWsList = m_caches.MainCache.LangProject.CurAnalysisWssRS.HvoArray;
					CacheStringAltForAllCurrentWs(currentAnalysisWsList, cda, hvoSec, flidSec, sdaMain, hvoMain, flidMain);
					continue;
				}
				else if (ws == LangProject.kwsFirstVern)
				{
					int[] currentVernWsList = m_caches.MainCache.LangProject.CurVernWssRS.HvoArray;
					CacheStringAltForAllCurrentWs(currentVernWsList, cda, hvoSec, flidSec, sdaMain, hvoMain, flidMain);
					continue;
				}
				else if (ws == LangProject.kwsVernInParagraph)
				{
					wsActual = this.RawWordformWs;
				}
				if (wsActual <= 0)
					throw new ArgumentException(String.Format("magic ws {0} not yet supported.", ws));

				if (hvoMain == 0)
				{
					tss = MakeTss("", wsActual, tsf);
				}
				else
				{
					tss = sdaMain.get_MultiStringAlt(hvoMain, flidMain, wsActual);
				}
				cda.CacheStringAlt(hvoSec, flidSec, wsActual, tss);
			}
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:42,代码来源:SandboxBase.cs


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