SIL.FieldWorks.IText.LinguaLinksImport.CreateWordAnalysisStack C# (CSharp) Method

CreateWordAnalysisStack() private static method

private static CreateWordAnalysisStack ( SIL.FieldWorks.FDO.FdoCache cache, Word word, ITsStrFactory strFactory ) : IAnalysis
cache SIL.FieldWorks.FDO.FdoCache
word Word
strFactory ITsStrFactory
return IAnalysis
		private static IAnalysis CreateWordAnalysisStack(FdoCache cache, Word word, ITsStrFactory strFactory)
		{
			if (word.Items == null || word.Items.Length <= 0) return null;
			IAnalysis analysis = null;
			var wsFact = cache.WritingSystemFactory;
			ILgWritingSystem wsMainVernWs = null;
			foreach (var wordItem in word.Items)
			{
				ITsString wordForm = null;
				switch (wordItem.type)
				{
					case "txt":
						wsMainVernWs = GetWsEngine(wsFact, wordItem.lang);
						wordForm = strFactory.MakeString(wordItem.Value, wsMainVernWs.Handle);
						analysis = WfiWordformServices.FindOrCreateWordform(cache, wordForm);
						break;
					case "punct":
						wordForm = strFactory.MakeString(wordItem.Value,
														 GetWsEngine(wsFact, wordItem.lang).Handle);
						analysis = WfiWordformServices.FindOrCreatePunctuationform(cache, wordForm);
						break;
				}
				if (wordForm != null)
					break;
			}

			// now add any alternative word forms. (overwrite any existing)
			if (analysis != null && analysis.HasWordform)
			{
				AddAlternativeWssToWordform(analysis, word, wsMainVernWs, strFactory);
			}

			if (analysis != null)
			{
				UpgradeToWordGloss(word, ref analysis);
			}
			else
			{
				Debug.Assert(analysis != null, "What else could this do?");
			}
			//Add any morphemes to the thing
			if (word.morphemes != null && word.morphemes.morphs.Length > 0)
			{
				//var bundle = newSegment.Cache.ServiceLocator.GetInstance<IWfiMorphBundleFactory>().Create();
				//analysis.Analysis.MorphBundlesOS.Add(bundle);
				//foreach (var morpheme in word.morphemes)
				//{
				//    //create a morpheme
				//    foreach(item item in morpheme.items)
				//    {
				//        //fill in morpheme's stuff
				//    }
				//}
			}
			return analysis;
		}