/// <summary> Adds vernacular of a word to be written out to lift </summary> private static void AddVern(LexEntry entry, Word wordEntry, string vernacularBcp47) { entry.LexicalForm.MergeIn(MultiText.Create( new LiftMultiText { { vernacularBcp47, wordEntry.Vernacular } })); }
/// <summary> Adds pronunciation audio of a word to be written out to lift </summary> private void AddAudio(LexEntry entry, Word wordEntry, string path) { foreach (var audioFile in wordEntry.Audio) { var lexPhonetic = new LexPhonetic(); var util = new Utilities(); var projectPath = Path.Combine(util.GenerateFilePath( Utilities.FileType.Dir, true, "", ""), _projectId); projectPath = Path.Combine(projectPath, "Import", "ExtractedLocation"); var extractedDir = Directory.GetDirectories(projectPath); projectPath = Path.Combine(projectPath, extractedDir.Single()); var src = Path.Combine(util.GenerateFilePath( Utilities.FileType.Audio, true), Path.Combine(projectPath, "audio", audioFile)); var dest = Path.Combine(path, audioFile); if (File.Exists(src)) { File.Copy(src, dest, true); var proMultiText = new LiftMultiText { { "href", dest } }; lexPhonetic.MergeIn(MultiText.Create(proMultiText)); entry.Pronunciations.Add(lexPhonetic); } } }
/// <summary> Adds vernacular of a word to be written out to lift </summary> private void AddVern(LexEntry entry, Word wordEntry, string projectId) { var lang = _projService.GetProject(projectId).Result.VernacularWritingSystem; entry.LexicalForm.MergeIn(MultiText.Create(new LiftMultiText { { lang, wordEntry.Vernacular } })); }
public void GetFormWithSpans_WritingSystemLinkedToFormWithOutSpans_ReturnsFormWithOutSpans() { LiftString liftStringToConvert = new LiftString("No spans here!"); LiftMultiText liftMultiTextWithSpansInForms = new LiftMultiText(); liftMultiTextWithSpansInForms.Add("de", liftStringToConvert); MultiText multiText = MultiText.Create(liftMultiTextWithSpansInForms); Assert.AreEqual("No spans here!", multiText["de"]); }
public void Create_LiftMultiTextWithOutSpansInForms_ReturnsMultiTextWithOutSpansInForms() { LiftString liftStringToConvert = new LiftString("No spans here!"); LiftMultiText liftMultiTextWithSpansInForms = new LiftMultiText(); liftMultiTextWithSpansInForms.Add("de", liftStringToConvert); MultiText multiText = MultiText.Create(liftMultiTextWithSpansInForms); Assert.AreEqual("No spans here!", multiText["de"]); }
public void MergeInPicture(LexSense sense, string href, LiftMultiText caption) { //nb 1: we're limiting ourselves to one picture per sense, here: //nb 2: the name and case must match the fieldName PictureRef pict = sense.GetOrCreateProperty <PictureRef>("Picture"); pict.Value = href; if (caption != null) { pict.Caption = MultiText.Create(caption.AsSimpleStrings); } }
public void Create_LiftMultiTextWithSpansInForms_ReturnsMultiTextWithSpansInForms() { LiftString liftStringToConvert = new LiftString("Text to Mark Up!"); LiftSpan span1 = new LiftSpan(0, 4, "", "", ""); liftStringToConvert.Spans.Add(span1); LiftMultiText liftMultiTextWithSpansInForms = new LiftMultiText(); liftMultiTextWithSpansInForms.Add("de", liftStringToConvert); MultiText multiText = MultiText.Create(liftMultiTextWithSpansInForms); Assert.AreEqual("<span>Text</span> to Mark Up!", multiText["de"]); }
private static void AddOrAppendMultiTextProperty(PalasoDataObject dataObject, LiftMultiText contents, string propertyName, string noticeToPrependIfNotEmpty) { MultiText mt = dataObject.GetOrCreateProperty <MultiText>(propertyName); mt.MergeInWithAppend(MultiText.Create(contents), string.IsNullOrEmpty(noticeToPrependIfNotEmpty) ? "; " : noticeToPrependIfNotEmpty); AddAnnotationsToMultiText(contents, mt); //dataObject.GetOrCreateProperty<string>(propertyName) mt)); }
/// <summary> Adds pronunciation audio of a word to be written out to lift </summary> private static void AddAudio(LexEntry entry, Word wordEntry, string path, string projectId) { foreach (var audioFile in wordEntry.Audio) { var lexPhonetic = new LexPhonetic(); var src = FileStorage.GenerateAudioFilePath(projectId, audioFile); var dest = Path.Combine(path, audioFile); if (File.Exists(src)) { File.Copy(src, dest, true); var proMultiText = new LiftMultiText { { "href", dest } }; lexPhonetic.MergeIn(MultiText.Create(proMultiText)); entry.Pronunciations.Add(lexPhonetic); } } }
/* * private static void AddMultiTextProperty(PalasoDataObject dataObject, LiftMultiText contents, string propertyName) * { * dataObject.Properties.Add( * new KeyValuePair<string, object>(propertyName, * MultiText.Create(contents))); * } */ /// <summary> /// Handle LIFT's "field" entity which can be found on any subclass of "extensible" /// </summary> public void MergeInField(PalasoDataObject extensible, string typeAttribute, DateTime dateCreated, DateTime dateModified, LiftMultiText contents, List <Trait> traits) { MultiText t = MultiText.Create(contents.AsSimpleStrings); //enchance: instead of KeyValuePair, make a LiftField class, so we can either keep the // other field stuff as xml (in order to round-trip it) or model it. extensible.Properties.Add(new KeyValuePair <string, IPalasoDataObjectProperty>(typeAttribute, t)); if (traits != null) { foreach (var trait in traits) { t.EmbeddedXmlElements.Add(string.Format(@"<trait name='{0}' value='{1}'/>", trait.Name, trait.Value)); } } }
public void Create_Null_Throws() { Assert.Throws <ArgumentNullException>(() => MultiText.Create((LiftMultiText)null)); }
// public ProgressState ProgressState // { // set // { // _progressState = value; // } // } private static void MergeIn(MultiTextBase multiText, LiftMultiText forms) { multiText.MergeIn(MultiText.Create(forms.AsSimpleStrings, forms.AllSpans)); AddAnnotationsToMultiText(forms, multiText); }
public void MergeInGloss(LexSense sense, LiftMultiText forms) { sense.Gloss.MergeInWithAppend(MultiText.Create(forms.AsSimpleStrings), "; "); AddAnnotationsToMultiText(forms, sense.Gloss); }