/// <summary> Adds each lexeme form to the entry for the vernacular </summary> public void MergeInLexemeForm(LiftEntry entry, LiftMultiText contents) { foreach (var(key, value) in contents) { entry.LexicalForm.Add(key, value); } }
/// <summary> Adds each citation form to the entry for the vernacular </summary> public void MergeInCitationForm(LiftEntry entry, LiftMultiText contents) { foreach (var(key, value) in contents) { entry.CitationForm.Add(key, value.Text); } }
/// <summary> Creates an empty sense object and adds it to the entry </summary> public LiftSense GetOrMakeSense(LiftEntry entry, Extensible info, string rawXml) { var sense = new LiftSense(info, info.Guid, entry) { Gloss = new LiftMultiText() }; entry.Senses.Add(sense); return(sense); }
public LiftObject MergeInVariant(LiftEntry entry, LiftMultiText contents, string rawXml) { return(new LiftVariant()); }
public LiftObject MergeInEtymology(LiftEntry entry, string source, string type, LiftMultiText form, LiftMultiText gloss, string rawXml) { return(new LiftEtymology()); }
/// <summary> Needs to be called before MergeInMedia </summary> public LiftObject MergeInPronunciation(LiftEntry entry, LiftMultiText contents, string rawXml) { return(entry); }
/// <summary> /// A significant portion of lift import is done here. This reads in all necessary /// attributes to create a word from <paramref name="entry"/>, adding the result /// to <see cref="_importEntries"/> to be saved to the database. /// </summary> /// <remarks> /// This method cannot safely be marked async because Parent classes are not async aware and do not await /// it. /// </remarks> /// <param name="entry"></param> public void FinishEntry(LiftEntry entry) { var newWord = new Word { Guid = entry.Guid, Created = Time.ToUtcIso8601(entry.DateCreated), Modified = Time.ToUtcIso8601(entry.DateModified) }; // Add Note if one exists. // Note: Currently only support for a single note is included. if (entry.Notes.Count > 0) { var(language, liftString) = entry.Notes[0].Content.FirstValue; newWord.Note = new Note(language, liftString.Text); } // Add vernacular // TODO: currently we just add the first listed option, we may want to choose eventually if (!entry.CitationForm.IsEmpty) // Prefer citation form for vernacular { newWord.Vernacular = entry.CitationForm.FirstValue.Value.Text; } else if (!entry.LexicalForm.IsEmpty) // lexeme form for backup { newWord.Vernacular = entry.LexicalForm.FirstValue.Value.Text; } else // this is not a word if there is no vernacular { return; } // This is not a word if there are no senses if (entry.Senses.Count == 0) { return; } // Add senses newWord.Senses = new List <Sense>(); foreach (var sense in entry.Senses) { var newSense = new Sense { SemanticDomains = new List <SemanticDomain>(), Glosses = new List <Gloss>(), // FieldWorks uses LiftSense.Id for the GUID field, rather than LiftSense.Guid, // so follow this convention. Guid = new Guid(sense.Id) }; // Add glosses foreach (var(key, value) in sense.Gloss) { newSense.Glosses.Add(new Gloss { Language = key, Def = value.Text }); } // Find semantic domains var semanticDomainStrings = new List <string>(); foreach (var trait in sense.Traits) { if (trait.Name.StartsWith("semantic-domain")) { semanticDomainStrings.Add(trait.Value); } } // Add semantic domains foreach (var semanticDomainString in semanticDomainStrings) { // Splits on the space between the number and name of the semantic domain var splitSemDom = semanticDomainString.Split(" ", 2); newSense.SemanticDomains.Add( new SemanticDomain { Id = splitSemDom[0], Name = splitSemDom[1] }); } newWord.Senses.Add(newSense); } // Add plural foreach (var field in entry.Fields) { if (field.Type == "Plural") { foreach (var _ in field.Content) { var pluralForm = entry.Fields.First().Content.First().Value.Text; newWord.Plural = pluralForm; } } } // Get path to directory with audio files ~/{projectId}/Import/ExtractedLocation/Lift/audio var extractedAudioDir = FileStorage.GenerateAudioFileDirPath(_projectId); // Only add audio if the files exist if (Directory.Exists(extractedAudioDir)) { // Add audio foreach (var pro in entry.Pronunciations) { // get path to audio file in lift package at // ~/{projectId}/Import/ExtractedLocation/Lift/audio/{audioFile}.mp3 var audioFile = pro.Media.First().Url; newWord.Audio.Add(audioFile); } } newWord.ProjectId = _projectId; _importEntries.Add(newWord); }