private static LexEntry CreateEmptyEntryWithOneExampleSentence() { LexEntry entry = new LexEntry(); LexSense sense = new LexSense(); entry.Senses.Add(sense); LexExampleSentence example = new LexExampleSentence(); sense.ExampleSentences.Add(example); return entry; }
public void SenseExampleTranslationHasAnalysisWritingSystem() { LexEntry entry = new LexEntry(); LexSense sense = new LexSense(); entry.Senses.Add(sense); LexExampleSentence example = new LexExampleSentence(); sense.ExampleSentences.Add(example); example.Translation["analysis"] = "filler"; Assert.AreEqual(false, _missingExampleTranslationFilter.FilteringPredicate(entry)); }
private void CreateTestEntry(string lexicalForm, string Definition, string exampleSentence) { LexEntry entry = _lexEntryRepository.CreateItem(); entry.LexicalForm[_writingSystem.Id] = lexicalForm; LexSense sense = new LexSense(); entry.Senses.Add(sense); sense.Definition["analysis"] = Definition; LexExampleSentence example = new LexExampleSentence(); sense.ExampleSentences.Add(example); example.Sentence[_writingSystem.Id] = exampleSentence; _lexEntryRepository.SaveItem(entry); return; }
public string AddEntryCore(string lexemeFormWritingSystemId, string lexemeForm, string definitionWritingSystemId, string definition, string exampleWritingSystemId, string example) { if (string.IsNullOrEmpty(lexemeForm)) { Logger.WriteEvent("Dictionary Services AddEntry() called with Empty lexemeform"); return null; } if (!CheckWritingSystemAndContentsPair(lexemeFormWritingSystemId, lexemeForm)) { return null; } if (!CheckWritingSystemAndContentsPair(definitionWritingSystemId, definition)) { return null; } if (!CheckWritingSystemAndContentsPair(exampleWritingSystemId, example)) { return null; } Logger.WriteEvent("dictionary services.AddEntry()"); LexEntry e = _lexEntryRepository.CreateItem(); e.LexicalForm.SetAlternative(lexemeFormWritingSystemId, lexemeForm); LexSense sense = null; if (!string.IsNullOrEmpty(definition)) { sense = new LexSense(); e.Senses.Add(sense); sense.Definition.SetAlternative(definitionWritingSystemId, definition); } if (!string.IsNullOrEmpty(example)) { if (sense == null) { sense = new LexSense(); e.Senses.Add(sense); } LexExampleSentence ex = new LexExampleSentence(); sense.ExampleSentences.Add(ex); ex.Sentence.SetAlternative(exampleWritingSystemId, example); } _lexEntryRepository.SaveItem(e); return e.Id; }
private LexEntry CreateTestEntry(string lexicalForm, string meaning, string exampleSentence) { LexEntry entry = _lexEntryRepository.CreateItem(); entry.LexicalForm[GetSomeValidWsIdForField("EntryLexicalForm")] = lexicalForm; LexSense sense = new LexSense(); entry.Senses.Add(sense); #if GlossMeaning sense.Gloss[GetSomeValidWsIdForField("SenseGloss")] = meaning; #else sense.Definition[WeSayWordsProject.Project.WritingSystems.TestWritingSystemAnalId] = meaning; #endif LexExampleSentence example = new LexExampleSentence(); sense.ExampleSentences.Add(example); example.Sentence[GetSomeValidWsIdForField("ExampleSentence")] = exampleSentence; _lexEntryRepository.SaveItem(entry); return entry; }
public void OneSenseExampleSentenceWithOneWithoutWritingSystems() { LexEntry entry = CreateEmptyEntryWithOneExampleSentence(); LexExampleSentence example = entry.Senses[0].ExampleSentences[0]; example.Sentence["vernacular"] = "filler"; LexSense sense = new LexSense(); entry.Senses.Add(sense); example = new LexExampleSentence(); sense.ExampleSentences.Add(example); Assert.AreEqual(true, _missingExampleSentenceFilter.FilteringPredicate(entry)); }
private Guid AddEntry(string lexemeForm, string meaningWritingSystemId, string meaning, bool includeExample) { LexEntry entry = _lexEntryRepository.CreateItem(); entry.LexicalForm.SetAlternative(_vernacularWritingSystem.Id, lexemeForm); LexSense sense = new LexSense(); entry.Senses.Add(sense); #if GlossMeaning sense.Gloss[ WeSayWordsProject.Project.DefaultViewTemplate.GetField("SenseGloss").WritingSystemIds[0]] = meaning; #else sense.Definition.SetAlternative(meaningWritingSystemId, meaning); #endif if (includeExample) { LexExampleSentence ex = new LexExampleSentence(); sense.ExampleSentences.Add(ex); ex.Sentence.SetAlternative("x", "hello"); } _lexEntryRepository.SaveItem(entry); return entry.Guid; }
private static void AddExample(LexSense sense) { LexExampleSentence example = new LexExampleSentence(); sense.ExampleSentences.Add(example); example.Sentence[BasilProject.Project.WritingSystems.TestWritingSystemVernId] = "sentence"; }
public void SenseOneExampleTranslationWritingSystemWithOneWithoutAnalysis() { LexEntry entry = CreateEmptyEntryWithOneExampleSentence(); LexExampleSentence example = entry.Senses[0].ExampleSentences[0]; example.Translation["analysis"] = "filler"; example = new LexExampleSentence(); entry.Senses[0].ExampleSentences.Add(example); example.Translation["vernacular"] = "filler"; Assert.AreEqual(true, _missingExampleTranslationFilter.FilteringPredicate(entry)); }
public void RemovingAssociationWhereSenseHasExample_DoesNothing() { RecordToken<LexEntry> token = PrepareEntryWithOneGloss(); //now tweak the entry LexEntry entry = token.RealObject; LexSense sense = entry.Senses[0]; LexExampleSentence ex = new LexExampleSentence(); sense.ExampleSentences.Add(ex); ex.Sentence.SetAlternative(VernWs.Id, "blah blah"); //now simulate removing it, as when the user wants to correct spelling Task.TryToRemoveAssociationWithListWordFromEntry(token); Assert.AreEqual(1, _lexEntryRepository.GetEntriesWithMatchingLexicalForm("uno", VernWs). Count); Assert.AreEqual(1, entry.Senses.Count); Assert.AreEqual("one", sense.Gloss.GetExactAlternative(_glossingLanguageWSId), "should not remove the gloss"); }
public void Add(LexExampleSentence example) { if (!ShouldOutputProperty(LexExampleSentence.WellKnownProperties.ExampleSentence)) { return; } List<string> propertiesAlreadyOutput = new List<string>(); Writer.WriteStartElement("example"); OptionRef source = example.GetProperty<OptionRef>(LexExampleSentence.WellKnownProperties.Source); if (source != null && source.Value.Length > 0) { if (ShouldOutputProperty(LexExampleSentence.WellKnownProperties.Source)) { Writer.WriteAttributeString("source", source.Value); propertiesAlreadyOutput.Add("source"); } } WriteMultiTextNoWrapper(LexExampleSentence.WellKnownProperties.ExampleSentence, example.Sentence); // WriteMultiWithWrapperIfNonEmpty(LexExampleSentence.WellKnownProperties.Translation, "translation", example.Translation); if (!MultiTextBase.IsEmpty(example.Translation)) { Writer.WriteStartElement("translation"); if (!string.IsNullOrEmpty(example.TranslationType)) { Writer.WriteAttributeString("type", example.TranslationType); propertiesAlreadyOutput.Add("type"); } Add(LexExampleSentence.WellKnownProperties.Translation, example.Translation); Writer.WriteEndElement(); } if (ShouldOutputProperty(LexExampleSentence.WellKnownProperties.ExampleSentence)) { WriteWellKnownCustomMultiText(example, WeSayDataObject.WellKnownProperties.Note, propertiesAlreadyOutput); } WriteCustomProperties(example, propertiesAlreadyOutput); Writer.WriteEndElement(); }
public void OneSenseExampleCustomFieldWritingSystemWithOneWithoutAnalysis() { LexEntry entry = CreateEmptyLexEntryWithOneEmptySentence(); LexExampleSentence example = entry.Senses[0].ExampleSentences[0]; MultiText custom = example.GetOrCreateProperty<MultiText>("customField"); custom["vernacular"] = "filler"; LexSense sense = new LexSense(); entry.Senses.Add(sense); example = new LexExampleSentence(); sense.ExampleSentences.Add(example); custom = example.GetOrCreateProperty<MultiText>("customField"); custom["analysis"] = "filler"; Assert.AreEqual(true, _missingCustomFieldFilter.FilteringPredicate(entry)); }
public void RemoveWord_HasCustomFieldInExample_DisassociatesWordFromDomain() { LexEntry e = _lexEntryRepository.CreateItem(); e.LexicalForm.SetAlternative("br", "peixe"); LexSense s = AddNewSenseToEntry(e); OptionRefCollection o = s.GetOrCreateProperty<OptionRefCollection>( LexSense.WellKnownProperties.SemanticDomainsDdp4); o.Add(Task.DomainKeys[0]); LexExampleSentence example = new LexExampleSentence(); s.ExampleSentences.Add(example); OptionRef optionRef = example.GetOrCreateProperty<OptionRef>("custom"); optionRef.Value = "hello"; _lexEntryRepository.SaveItem(e); int originalCount = _lexEntryRepository.CountAllItems(); Task.CurrentDomainIndex = 0; Task.DetachFromMatchingEntries("peixe"); Assert.AreEqual(originalCount, _lexEntryRepository.CountAllItems()); }