/// <summary> /// Add all the data from items in the FLExText file into their proper spots in the segment. /// </summary> /// <param name="cache"></param> /// <param name="wsFactory"></param> /// <param name="phrase"></param> /// <param name="newSegment"></param> /// <param name="tsStrFactory"></param> /// <param name="textInFile">This reference boolean indicates if there was a text item in the phrase</param> /// <param name="phraseText">This reference string will be filled with the contents of the "txt" item in the phrase if it is there</param> private static void AddSegmentItemData(FdoCache cache, ILgWritingSystemFactory wsFactory, Phrase phrase, ISegment newSegment, ITsStrFactory tsStrFactory, ref bool textInFile, ref ITsString phraseText) { if (phrase.Items != null) { foreach (var item in phrase.Items) { switch (item.type) { case "reference-label": newSegment.Reference = tsStrFactory.MakeString(item.Value, GetWsEngine(wsFactory, item.lang).Handle); break; case "gls": newSegment.FreeTranslation.set_String(GetWsEngine(wsFactory, item.lang).Handle, item.Value); break; case "lit": newSegment.LiteralTranslation.set_String(GetWsEngine(wsFactory, item.lang).Handle, item.Value); break; case "note": INote note = cache.ServiceLocator.GetInstance<INoteFactory>().Create(); newSegment.NotesOS.Add(note); note.Content.set_String(GetWsEngine(wsFactory, item.lang).Handle, item.Value); break; case "txt": phraseText = tsStrFactory.MakeString(item.Value, GetWsEngine(wsFactory, item.lang).Handle); textInFile = true; break; } } } }
private static void AddELANInfoToSegment(FdoCache cache, Phrase phrase, ISegment newSegment) { if (!String.IsNullOrEmpty(phrase.mediaFile)) { if(!String.IsNullOrEmpty(phrase.speaker)) { newSegment.SpeakerRA = FindOrCreateSpeaker(phrase.speaker, cache); } newSegment.BeginTimeOffset = phrase.beginTimeOffset; newSegment.EndTimeOffset = phrase.endTimeOffset; newSegment.MediaURIRA = cache.ServiceLocator.ObjectRepository.GetObject(new Guid(phrase.mediaFile)) as ICmMediaURI; } }
/// <summary> /// Return true if the phrase has exactly one word which has exactly one item of type txt, /// and that item is not a known wordform. /// </summary> /// <param name="fdoCache"></param> /// <param name="phrase"></param> /// <returns></returns> private static bool PhraseHasExactlyOneTxtItemNotAKnownWordform(FdoCache fdoCache, Phrase phrase) { if (phrase.WordsContent.Words.Length != 1 || phrase.WordsContent.Words[0].Items.Length != 1 || phrase.WordsContent.Words[0].Items[0].type != "txt") return false; var wsFact = fdoCache.WritingSystemFactory; var wordItem = phrase.WordsContent.Words[0].Items[0]; int ws = GetWsEngine(wsFact, wordItem.lang).Handle; if (string.IsNullOrEmpty(wordItem.Value)) return true; // if it has no text, it can't be a known wordform... var wf = fdoCache.ServiceLocator.GetInstance<IWfiWordformRepository>().GetMatchingWordform(ws, wordItem.Value); return wf == null; }