예제 #1
0
        private Guid AddEntry(string lexemeForm,
                              string meaningWritingSystemId,
                              string meaning,
                              bool includeExample)
        {
            LexEntry entry = _lexEntryRepository.CreateItem();

            entry.LexicalForm.SetAlternative("th", 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("th", "hello");
            }
            _lexEntryRepository.SaveItem(entry);
            return(entry.Guid);
        }
예제 #2
0
        private static void AddExample(LexSense sense)
        {
            LexExampleSentence example = new LexExampleSentence();

            sense.ExampleSentences.Add(example);
            example.Sentence[WritingSystemsIdsForTests.VernacularIdForTest] = "sentence";
        }
예제 #3
0
        public void ExampleTranslations_FreeFollowedByUnmarked()
        {
            LexEntry e     = MakeSimpleEntry();
            LexSense sense = new LexSense();

            e.Senses.Add(sense);
            LexExampleSentence ex = new LexExampleSentence();

            sense.ExampleSentences.Add(ex);

            LiftMultiText t2 = new LiftMultiText();

            t2.Add("aa", "freestuff");
            _builder.MergeInTranslationForm(ex,
                                            "Free translation",
                                            t2,
                                            "<translation type='free'><bogus/></translation>");
            LiftMultiText translation = new LiftMultiText();

            translation.Add("aa", "unmarked translation");
            _builder.MergeInTranslationForm(ex,
                                            "",
                                            translation,
                                            "<translation><bogusUnmarked/></translation>");
            _builder.FinishEntry(e);

            _liftWriter.Add(e);
            _liftWriter.End();
            AssertHasAtLeastOneMatch("//entry/sense/example/translation[not(@type)]/bogusUnmarked");
            AssertHasAtLeastOneMatch(
                "//entry/sense/example/translation[@type='Free translation']/form/text[text()='freestuff']");
        }
예제 #4
0
        public void ExampleTranslations_MultipleTypes()
        {
            LexEntry e     = MakeSimpleEntry();
            LexSense sense = new LexSense();

            e.Senses.Add(sense);
            LexExampleSentence ex = new LexExampleSentence();

            sense.ExampleSentences.Add(ex);
            LiftMultiText translation = new LiftMultiText();

            translation.Add("aa", "unmarked translation");
            _builder.MergeInTranslationForm(ex, "", translation, "bogus raw xml");
            LiftMultiText t2 = new LiftMultiText();

            t2.Add("aa", "type2translation");
            _builder.MergeInTranslationForm(ex,
                                            "type2",
                                            t2,
                                            "<translation type='type2'><bogus/></translation>");
            _builder.FinishEntry(e);

            _liftWriter.Add(e);
            _liftWriter.End();
            AssertHasAtLeastOneMatch(
                "//entry/sense/example/translation[not(@type)]/form[@lang='aa']/text[text()='unmarked translation']");
            AssertHasAtLeastOneMatch("//entry/sense/example/translation[@type='type2']/bogus");
        }
예제 #5
0
        public void Init(Mediator mediator, XmlNode configurationNode, ICmObject sourceObject)
        {
            CheckDisposed();

            m_cache = sourceObject.Cache;

            // Find the sense owning our LexExampleSentence
            if (sourceObject is LexExampleSentence)
            {
                m_les         = sourceObject as LexExampleSentence;
                m_owningSense = LexSense.CreateFromDBObject(m_cache, m_les.OwnerHVO);
            }
            else if (sourceObject is LexSense)
            {
                m_owningSense = sourceObject as ILexSense;
            }
            else
            {
                throw new ArgumentException("Invalid object type for sourceObject.");
            }

            m_mediator          = mediator;
            m_configurationNode = configurationNode;
            AddConfigurableControls();

            m_virtFlidReference = BaseVirtualHandler.GetInstalledHandlerTag(m_cache, "CmBaseAnnotation", "Reference");
        }
예제 #6
0
        private static void AddTranslationToEntry(LexEntry entry, string translation)
        {
            LexSense           sense   = entry.Senses[0];
            LexExampleSentence example = sense.ExampleSentences[0];

            example.Translation[WritingSystemsIdsForTests.AnalysisIdForTest] = translation;
        }
예제 #7
0
        public ILexExampleSentence GetOrMakeExample(ILexSense sense, IdentifyingInfo idInfo)
        {
            //nb, has no guid or dates
            ILexExampleSentence x = new LexExampleSentence();

            sense.ExamplesOS.Append(x);
            return(x);
        }
        public void SenseExampleTranslationWritingSystemNoAnalysis()
        {
            LexEntry           entry   = CreateEmptyEntryWithOneExampleSentence();
            LexExampleSentence example = entry.Senses[0].ExampleSentences[0];

            example.Translation["vernacular"] = "filler";
            Assert.AreEqual(true, _missingExampleTranslationFilter.FilteringPredicate(entry));
        }
예제 #9
0
        public void ExampleSentencePropertiesInUse_HasPropertyProp1_ReturnsProp1()
        {
            var ex = new LexExampleSentence();

            ex.GetOrCreateProperty <MultiText>("Prop1");
            Assert.That(ex.PropertiesInUse, Contains.Item("Prop1"));
            Assert.That(ex.PropertiesInUse.Count(), Is.EqualTo(3));
        }
        public void SenseExampleSentenceWritingSystemNoVernacular()
        {
            LexEntry           entry   = CreateEmptyEntryWithOneExampleSentence();
            LexExampleSentence example = entry.Senses[0].ExampleSentences[0];

            example.Sentence["analysis"] = "filler";
            Assert.AreEqual(true, _missingExampleSentenceFilter.FilteringPredicate(entry));
        }
        public void SenseOneExampleTranslationWithOneWithoutWritingSystems()
        {
            LexEntry           entry   = CreateEmptyEntryWithOneExampleSentence();
            LexExampleSentence example = entry.Senses[0].ExampleSentences[0];

            example.Translation["analysis"] = "filler";
            entry.Senses[0].ExampleSentences.Add(new LexExampleSentence());
            Assert.AreEqual(true, _missingExampleTranslationFilter.FilteringPredicate(entry));
        }
        public void SenseExampleSentenceHasVernacularWritingSystem()
        {
            LexEntry           entry   = CreateEmptyEntryWithOneExampleSentence();
            LexExampleSentence example = entry.Senses[0].ExampleSentences[0];

            example.Sentence["vernacular"] = "filler";

            Assert.AreEqual(false, _missingExampleSentenceFilter.FilteringPredicate(entry));
        }
예제 #13
0
        public void MergeInTranslationForm_NoType_GetContents()
        {
            LexExampleSentence ex          = new LexExampleSentence();
            LiftMultiText      translation = new LiftMultiText();

            translation.Add("aa", "aaaa");
            _builder.MergeInTranslationForm(ex, "", translation, "bogus raw xml");
            Assert.AreEqual("aaaa", ex.Translation["aa"]);
            Assert.IsTrue(string.IsNullOrEmpty(ex.TranslationType));
        }
예제 #14
0
        public void MergeInTranslationForm_UnheardOfType_StillBecomesTranslation()
        {
            LexExampleSentence ex          = new LexExampleSentence();
            LiftMultiText      translation = new LiftMultiText();

            translation.Add("aa", "aaaa");
            _builder.MergeInTranslationForm(ex, "madeUpType", translation, "bogus raw xml");
            Assert.AreEqual("aaaa", ex.Translation["aa"]);
            Assert.AreEqual("madeUpType", ex.TranslationType);
        }
예제 #15
0
        public void MergeInTranslationForm_TypeFree_GetContentsAndSavesType()
        {
            LexExampleSentence ex          = new LexExampleSentence();
            LiftMultiText      translation = new LiftMultiText();

            translation.Add("aa", "aaaa");
            _builder.MergeInTranslationForm(ex, "Free translation", translation, "bogus raw xml");
            Assert.AreEqual("aaaa", ex.Translation["aa"]);
            Assert.AreEqual("Free translation", ex.TranslationType);
        }
예제 #16
0
        public void ExampleSourcePreserved()
        {
            LexExampleSentence ex = new LexExampleSentence();

            _builder.MergeInSource(ex, "fred");

            Assert.AreEqual("fred",
                            ex.GetProperty <OptionRef>(LexExampleSentence.WellKnownProperties.Source)
                            .Value);
        }
예제 #17
0
        public void SenseGetsExample()
        {
            LexSense           sense = new LexSense();
            Extensible         x     = new Extensible();
            LexExampleSentence ex    = _builder.GetOrMakeExample(sense, x);

            Assert.IsNotNull(ex);
            _builder.MergeInExampleForm(ex, MakeBasicLiftMultiText());
            Assert.AreEqual(2, ex.Sentence.Forms.Length);
            Assert.AreEqual("dos", ex.Sentence["ws-two"]);
        }
        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 SenseOneExampleSentenceWithOneWithoutWritingSystems()
        {
            LexEntry           entry   = CreateEmptyEntryWithOneExampleSentence();
            LexExampleSentence example = entry.Senses[0].ExampleSentences[0];

            example.Sentence["vernacular"] = "filler";

            example = new LexExampleSentence();
            entry.Senses[0].ExampleSentences.Add(example);
            Assert.AreEqual(true, _missingExampleSentenceFilter.FilteringPredicate(entry));
        }
예제 #20
0
        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);
            propertiesAlreadyOutput.Add(LexExampleSentence.WellKnownProperties.ExampleSentence);
            //  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");
                }

                AddMultitextForms(LexExampleSentence.WellKnownProperties.Translation, example.Translation);
                Writer.WriteEndElement();
                propertiesAlreadyOutput.Add(LexExampleSentence.WellKnownProperties.Translation);
            }

            if (ShouldOutputProperty(LexExampleSentence.WellKnownProperties.ExampleSentence))
            {
                WriteWellKnownCustomMultiText(example,
                                              PalasoDataObject.WellKnownProperties.Note,
                                              propertiesAlreadyOutput);
            }

            WriteCustomProperties(example, propertiesAlreadyOutput);
            Writer.WriteEndElement();
        }
예제 #21
0
        internal override int AddWidgets(PalasoDataObject wsdo, int insertAtRow)
        {
            LexExampleSentence example = (LexExampleSentence)wsdo;

            FirstRow = insertAtRow;

            DetailList.SuspendLayout();
            int rowCount = 0;

            try
            {
                Field field =
                    ActiveViewTemplate.GetField(Field.FieldNames.ExampleSentence.ToString());
                if (field != null && field.GetDoShow(example.Sentence, ShowNormallyHiddenFields))
                {
                    Control control = MakeBoundControl(example.Sentence, field);
                    DetailList.AddWidgetRow(
                        StringCatalog.Get("~Example",
                                          "This is the field containing an example sentence of a sense of a word."),
                        false,
                        control,
                        insertAtRow,
                        false);
                    ++rowCount;
                    insertAtRow = DetailList.GetRow(control);
                }

                field = ActiveViewTemplate.GetField(Field.FieldNames.ExampleTranslation.ToString());
                if (field != null && field.GetDoShow(example.Translation, ShowNormallyHiddenFields))
                {
                    Control entry = MakeBoundControl(example.Translation, field);
                    DetailList.AddWidgetRow(
                        StringCatalog.Get("~Translation",
                                          "This is the field for putting in a translation of an example sentence."),
                        false,
                        entry,
                        insertAtRow + rowCount,
                        false);
                    ++rowCount;
                }

                rowCount += AddCustomFields(example, insertAtRow + rowCount);
            }
            catch (ConfigurationException e)
            {
                ErrorReport.NotifyUserOfProblem(e.Message);
            }

            DetailList.ResumeLayout(false);
            LastRow = insertAtRow + rowCount - 1;               // want index of last row owned, not a limit value
            return(rowCount);
        }
예제 #22
0
        public void LexEntryPropertiesInUse_EntryandMultipleSensesAndExampleSentencesHaveMultipleProperties_ReturnsAllProperties()
        {
            var ex1 = new LexExampleSentence();

            ex1.GetOrCreateProperty <MultiText>("Ex1Prop1");
            ex1.GetOrCreateProperty <MultiText>("Ex1Prop2");

            var ex2 = new LexExampleSentence();

            ex2.GetOrCreateProperty <MultiText>("Ex2Prop1");
            ex2.GetOrCreateProperty <MultiText>("Ex2Prop2");

            var ex3 = new LexExampleSentence();

            ex3.GetOrCreateProperty <MultiText>("Ex3Prop1");
            ex3.GetOrCreateProperty <MultiText>("Ex3Prop2");

            var lexSense1 = new LexSense();

            lexSense1.GetOrCreateProperty <MultiText>("Se1Prop1");
            lexSense1.GetOrCreateProperty <MultiText>("Se1Prop2");

            var lexSense2 = new LexSense();

            lexSense2.GetOrCreateProperty <MultiText>("Se2Prop1");
            lexSense2.GetOrCreateProperty <MultiText>("Se2Prop2");

            var entry = new LexEntry();

            entry.GetOrCreateProperty <MultiText>("Prop1");
            entry.GetOrCreateProperty <MultiText>("Prop2");

            entry.Senses.Add(lexSense1);
            entry.Senses.Add(lexSense2);
            lexSense1.ExampleSentences.Add(ex1);
            lexSense1.ExampleSentences.Add(ex2);
            lexSense2.ExampleSentences.Add(ex3);

            Assert.That(entry.PropertiesInUse, Contains.Item("Ex1Prop1"));
            Assert.That(entry.PropertiesInUse, Contains.Item("Ex1Prop2"));
            Assert.That(entry.PropertiesInUse, Contains.Item("Ex2Prop1"));
            Assert.That(entry.PropertiesInUse, Contains.Item("Ex2Prop2"));
            Assert.That(entry.PropertiesInUse, Contains.Item("Ex3Prop1"));
            Assert.That(entry.PropertiesInUse, Contains.Item("Ex3Prop2"));
            Assert.That(entry.PropertiesInUse, Contains.Item("Se1Prop1"));
            Assert.That(entry.PropertiesInUse, Contains.Item("Se1Prop2"));
            Assert.That(entry.PropertiesInUse, Contains.Item("Se2Prop1"));
            Assert.That(entry.PropertiesInUse, Contains.Item("Se2Prop2"));
            Assert.That(entry.PropertiesInUse, Contains.Item("Prop1"));
            Assert.That(entry.PropertiesInUse, Contains.Item("Prop2"));
            Assert.That(entry.PropertiesInUse.Count(), Is.EqualTo(18));
        }
예제 #23
0
        private static void CheckCompleteEntry(LexEntry entry)
        {
            Assert.AreEqual(1, entry.Senses.Count);
            LexSense sense = entry.Senses[0];

            Assert.AreEqual(1, sense.ExampleSentences.Count);
            LexExampleSentence example = sense.ExampleSentences[0];

            Assert.AreEqual("this is a sentence", example.Sentence["foo"]);
            Assert.AreEqual("aaaa", example.Translation["aa"]);
            Assert.AreEqual(entry, sense.Parent);
            Assert.AreEqual(entry, example.Parent.Parent);
        }
        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));
        }
예제 #25
0
        public void ModifiedDateAfterChangingExampleSentence()
        {
            var sense = new LexSense();

            _entry.Senses.Add(sense);
            long start = _entry.ModificationTime.Ticks;

            Thread.Sleep(1000);             //else modtime doesn't change
            var example = new LexExampleSentence();

            sense.ExampleSentences.Add(example);
            example.Sentence["foo"] = "hello";
            Assert.Greater((decimal)_entry.ModificationTime.Ticks, start);
            Assert.IsTrue(_didNotify);
        }
예제 #26
0
        public void SenseOneExampleCustomWritingSystemWithOneWithoutAnalysis()
        {
            var entry   = CreateEmptyLexEntryWithOneEmptySentence();
            var example = entry.Senses[0].ExampleSentences[0];

            var custom = example.GetOrCreateProperty <MultiText>("customField");

            custom["vernacular"] = "filler";

            example = new LexExampleSentence();
            entry.Senses[0].ExampleSentences.Add(example);
            custom             = example.GetOrCreateProperty <MultiText>("customField");
            custom["analysis"] = "filler";
            Assert.AreEqual(true, _missingCustomFieldFilter.FilteringPredicate(entry));
        }
        private static LexEntry MakeEntryWithExampleSentence(string[] writingSystemsToFillIn)
        {
            var entry = new LexEntry();
            var sense = new LexSense();

            entry.Senses.Add(sense);
            LexExampleSentence example = new LexExampleSentence();

            sense.ExampleSentences.Add(example);
            foreach (var id in writingSystemsToFillIn)
            {
                example.Sentence.SetAlternative(id, "foo");
            }
            return(entry);
        }
예제 #28
0
        private void CreateTestEntry(string lexicalForm, string Definition, string exampleSentence)
        {
            var entry = _lexEntryRepository.CreateItem();

            entry.LexicalForm[_writingSystem.Id] = lexicalForm;
            var sense = new LexSense();

            entry.Senses.Add(sense);
            sense.Definition[WritingSystemsIdsForTests.AnalysisIdForTest] = Definition;
            var example = new LexExampleSentence();

            sense.ExampleSentences.Add(example);
            example.Sentence[_writingSystem.Id] = exampleSentence;
            _lexEntryRepository.SaveItem(entry);
            return;
        }
        public void OneSenseExampleTranslationWritingSystemWithOneWithoutAnalysis()
        {
            LexEntry           entry   = CreateEmptyEntryWithOneExampleSentence();
            LexExampleSentence example = entry.Senses[0].ExampleSentences[0];

            example.Translation["analysis"] = "filler";

            LexSense sense = new LexSense();

            entry.Senses.Add(sense);
            example = new LexExampleSentence();
            sense.ExampleSentences.Add(example);
            example.Translation["vernacular"] = "filler";

            Assert.AreEqual(true, _missingExampleTranslationFilter.FilteringPredicate(entry));
        }
예제 #30
0
 private bool IsMissingLexExampleSentenceField(LexExampleSentence example)
 {
     if (!Field.IsBuiltInViaCode)
     {
         return(IsMissingCustomField(example));
     }
     if (Field.FieldName == Field.FieldNames.ExampleSentence.ToString())
     {
         return(HasAllRequiredButMissingAtLeastOneWeWantToFillIn(example.Sentence));
     }
     if (Field.FieldName == Field.FieldNames.ExampleTranslation.ToString())
     {
         return(HasAllRequiredButMissingAtLeastOneWeWantToFillIn(example.Translation));
     }
     Debug.Fail("unknown FieldName");
     return(false);
 }
예제 #31
0
		public void Setup()
		{
			_entry = new LexEntry();
			_sense = new LexSense();
			_entry.Senses.Add(_sense);
#if GlossMeaning
			this._sense.Gloss["th"] = "sense";
#else
			_sense.Definition["th"] = "sense";
#endif
			MultiText customFieldInSense =
					_sense.GetOrCreateProperty<MultiText>("customFieldInSense");
			customFieldInSense["th"] = "custom";
			_examples = new LexExampleSentence();
			_sense.ExampleSentences.Add(_examples);
			_examples.Sentence["th"] = "example";
			_examples.Translation["en"] = "translation";
			MultiText customFieldInExample =
					_examples.GetOrCreateProperty<MultiText>("customFieldInExample");
			customFieldInExample["th"] = "custom";
			_entry.EmptyObjectsRemoved += _entry_EmptyObjectsRemoved;
			_entry.PropertyChanged += _entry_PropertyChanged;
			_removed = false;
		}
예제 #32
0
		public void ExampleSourceAsAttribute()
		{
			LexExampleSentence ex = new LexExampleSentence();
			OptionRef z =
					ex.GetOrCreateProperty<OptionRef>(LexExampleSentence.WellKnownProperties.Source);
			z.Value = "hearsay";

			_exporter.Add(ex);
			_exporter.End();
			AssertXPathNotNull("example[@source='hearsay']");
		}
예제 #33
0
		public void ExampleSentenceWithTranslation()
		{
			LexExampleSentence example = new LexExampleSentence();
			example.Sentence["blue"] = "ocean's eleven";
			example.Sentence["red"] = "red sunset tonight";
			example.Translation["green"] = "blah blah";
			_exporter.Add(example);
			CheckAnswer(
					"<example><form lang=\"blue\"><text>ocean's eleven</text></form><form lang=\"red\"><text>red sunset tonight</text></form><translation><form lang=\"green\"><text>blah blah</text></form></translation></example>");
		}
예제 #34
0
		public void ExampleSentence()
		{
			LexExampleSentence example = new LexExampleSentence();
			example.Sentence["blue"] = "ocean's eleven";
			example.Sentence["red"] = "red sunset tonight";
			_exporter.Add(example);
			CheckAnswer(
					"<example><form lang=\"blue\"><text>ocean's eleven</text></form><form lang=\"red\"><text>red sunset tonight</text></form></example>");
		}
예제 #35
0
		public void EmptyExampleSource_NoAttribute()
		{
			LexExampleSentence ex = new LexExampleSentence();
			ex.GetOrCreateProperty<OptionRef>(LexExampleSentence.WellKnownProperties.Source);
			_exporter.Add(ex);
			_exporter.End();
			AssertXPathNotNull("example[not(@source)]");
		}
예제 #36
0
		public void CustomMultiTextOnExample()
		{
			using (var session = new LiftExportAsFragmentTestSession())
			{
				var example = new LexExampleSentence();
				var m = example.GetOrCreateProperty<MultiText>("flubadub");
				m["zz"] = "orange";
				session.LiftWriter.Add(example);
				session.LiftWriter.End();
				AssertHasAtLeastOneMatch("example/field[@type='flubadub']/form[@lang='zz' and text='orange']", session);
			}
		}
예제 #37
0
		public void DeepChange()
		{
			LexEntry entry = _db4oRepository.CreateItem();
			entry.LexicalForm["en"] = "12";
			LexSense sense = new LexSense();
			entry.Senses.Add(sense);
			LexExampleSentence example = new LexExampleSentence();
			sense.ExampleSentences.Add(example);
			example.Sentence["th"] = "sawa";
			_db4oRepository.SaveItem(entry);

			CycleDatabase();
			entry = GetFirstEntry();
			entry.Senses[0].ExampleSentences[0].Sentence["th"] = "sawadee";
			_db4oRepository.SaveItem(entry);
			CycleDatabase();
			entry = GetFirstEntry();
			Assert.AreEqual("sawadee", entry.Senses[0].ExampleSentences[0].Sentence["th"]);
		}
예제 #38
0
		public void SenseWithExample()
		{
			LexSense sense = new LexSense();
			LexExampleSentence example = new LexExampleSentence();
			example.Sentence["red"] = "red sunset tonight";
			sense.ExampleSentences.Add(example);
			_exporter.Add(sense);
			CheckAnswer(GetSenseElement(sense) +
						"<example><form lang=\"red\"><text>red sunset tonight</text></form></example></sense>");
		}
예제 #39
0
		public void ExampleSourceAsAttribute()
		{
			using (var session = new LiftExportAsFragmentTestSession())
			{
				LexExampleSentence ex = new LexExampleSentence();
				OptionRef z = ex.GetOrCreateProperty<OptionRef>(
					LexExampleSentence.WellKnownProperties.Source
				);
				z.Value = "hearsay";

				session.LiftWriter.Add(ex);
				session.LiftWriter.End();
				AssertHasAtLeastOneMatch("example[@source='hearsay']", session);
			}
		}
예제 #40
0
		public void ModifiedDateAfterChangingExampleSentence()
		{
			LexSense sense = new LexSense();
			_entry.Senses.Add(sense);
			long start = _entry.ModificationTime.Ticks;
			Thread.Sleep(1000); //else modtime doesn't change
			LexExampleSentence example = new LexExampleSentence();
			sense.ExampleSentences.Add(example);
			example.Sentence["foo"] = "hello";
			Assert.Greater((decimal) _entry.ModificationTime.Ticks, start);
			Assert.IsTrue(_didNotify);
		}
예제 #41
0
		public void ExampleSentenceWithTranslation()
		{
			using (var session = new LiftExportAsFragmentTestSession())
			{
				var example = new LexExampleSentence();
				example.Sentence["blue"] = "ocean's eleven";
				example.Sentence["red"] = "red sunset tonight";
				example.Translation["green"] = "blah blah";
				session.LiftWriter.Add(example);
				var outPut = session.OutputString();
				AssertEqualsCanonicalString(
					"<example><form lang=\"blue\"><text>ocean's eleven</text></form><form lang=\"red\"><text>red sunset tonight</text></form><translation><form lang=\"green\"><text>blah blah</text></form></translation></example>", outPut);
			}
		}
예제 #42
0
		public void EmptyExampleSource_NoAttribute()
		{
			using (var session = new LiftExportAsFragmentTestSession())
			{
				var ex = new LexExampleSentence();
				ex.GetOrCreateProperty<OptionRef>(
					LexExampleSentence.WellKnownProperties.Source
				);
				session.LiftWriter.Add(ex);
				session.LiftWriter.End();
				AssertHasAtLeastOneMatch("example[not(@source)]", session);
			}
		}
예제 #43
0
		public void CustomOptionRefOnExample()
		{
			using (var session = new LiftExportAsFragmentTestSession())
			{
				//_fieldToOptionListName.Add("flub", "kindsOfFlubs");
				var example = new LexExampleSentence();
				var o = example.GetOrCreateProperty<OptionRef>("flub");
				o.Value = "orange";
				session.LiftWriter.Add(example);
				session.LiftWriter.End();
				string expected = CanonicalXml.ToCanonicalStringFragment(
					"<example><trait name=\"flub\" value=\"orange\" /></example>"
				);
				Assert.AreEqual(
					expected,
					session.StringBuilder.ToString()
				);
			}
		}
예제 #44
0
		public void NoteOnExample_OutputAsNote()
		{
			LexExampleSentence example = new LexExampleSentence();
			MultiText m =
					example.GetOrCreateProperty<MultiText>(WeSayDataObject.WellKnownProperties.Note);
			m["zz"] = "orange";
			_exporter.Add(example);
			_exporter.End();
			AssertXPathNotNull("example/note/form[@lang='zz' and text='orange']");
			AssertXPathNotNull("example[not(field)]");
		}
예제 #45
0
		public void CustomMultiTextOnExample()
		{
			LexExampleSentence example = new LexExampleSentence();
			MultiText m = example.GetOrCreateProperty<MultiText>("flubadub");
			m["zz"] = "orange";
			_exporter.Add(example);
			_exporter.End();
			AssertXPathNotNull("example/field[@type='flubadub']/form[@lang='zz' and text='orange']");
		}
예제 #46
0
		public ILexExampleSentence Create(Guid guid, ILexSense owner)
		{
			if (owner == null) throw new ArgumentNullException("owner");

			ILexExampleSentence les;
			if (guid == Guid.Empty)
			{
				les = new LexExampleSentence();
			}
			else
			{
				int hvo = ((IDataReader)m_cache.ServiceLocator.GetInstance<IDataSetup>()).GetNextRealHvo();
				les = new LexExampleSentence(m_cache, hvo, guid);
			}
			owner.ExamplesOS.Add(les);
			return les;
		}
예제 #47
0
		public void ExampleTranslations_FreeFollowedByUnmarked()
		{
			LexEntry e = MakeSimpleEntry();
			LexSense sense = new LexSense();
			e.Senses.Add(sense);
			LexExampleSentence ex = new LexExampleSentence();
			sense.ExampleSentences.Add(ex);

			LiftMultiText t2 = new LiftMultiText();
			t2.Add("aa", "freestuff");
			_builder.MergeInTranslationForm(ex,
											"Free translation",
											t2,
											"<translation type='free'><bogus/></translation>");
			LiftMultiText translation = new LiftMultiText();
			translation.Add("aa", "unmarked translation");
			_builder.MergeInTranslationForm(ex,
											"",
											translation,
											"<translation><bogusUnmarked/></translation>");
			_builder.FinishEntry(e);

			_liftWriter.Add(e);
			_liftWriter.End();
			AssertHasAtLeastOneMatch("//entry/sense/example/translation[not(@type)]/bogusUnmarked");
			AssertHasAtLeastOneMatch(
				"//entry/sense/example/translation[@type='Free translation']/form/text[text()='freestuff']");
		}
예제 #48
0
		public void DeepNotifyAfterDepersist()
		{
			LexEntry entry = _db4oRepository.CreateItem();
			LexSense sense = new LexSense();
			entry.Senses.Add(sense);
			LexExampleSentence example = new LexExampleSentence();
			sense.ExampleSentences.Add(example);
			example.Sentence["th"] = "sawa";
			_db4oRepository.SaveItem(entry);

			CycleDatabase();
			entry = GetFirstEntry();
			entry.PropertyChanged += _entry_PropertyChanged;
			_didNotify = false;
			entry.Senses[0].ExampleSentences[0].Sentence["th"] = "sawadeekap";
			Assert.IsTrue(_didNotify);
		}
		public void ExampleSourcePreserved()
		{
			LexExampleSentence ex = new LexExampleSentence();
			_builder.MergeInSource(ex, "fred");

			Assert.AreEqual("fred",
							ex.GetProperty<OptionRef>(LexExampleSentence.WellKnownProperties.Source)
									.Value);
		}
예제 #50
0
		public void ExampleTranslation_OneWithNoType()
		{
			LexEntry e = MakeSimpleEntry();
			LexSense sense = new LexSense();
			e.Senses.Add(sense);
			LexExampleSentence ex = new LexExampleSentence();
			sense.ExampleSentences.Add(ex);
			LiftMultiText translation = new LiftMultiText();
			translation.Add("aa", "aaaa");
			_builder.MergeInTranslationForm(ex, "", translation, "bogus raw xml");
			_builder.FinishEntry(e);
			_exporter.Add(e);
			_exporter.End();
			AssertXPathNotNull("//entry/sense/example/translation[not(@type)]/form[@lang='aa']");
		}
예제 #51
0
		public void SenseWithExample()
		{
			using (var session = new LiftExportAsFragmentTestSession())
			{
				var sense = new LexSense();
				var example = new LexExampleSentence();
				example.Sentence["red"] = "red sunset tonight";
				sense.ExampleSentences.Add(example);
				session.LiftWriter.Add(sense);
				string result = session.OutputString();
				AssertThatXmlIn.String(result).HasAtLeastOneMatchForXpath(
					"/sense/example/form[@lang='red']/text[text()='red sunset tonight']"
				);
			}
		}
예제 #52
0
		public void CustomOptionRefCollectionOnExample()
		{
			_fieldToOptionListName.Add("flubs", "colors");
			LexExampleSentence example = new LexExampleSentence();
			OptionRefCollection o = example.GetOrCreateProperty<OptionRefCollection>("flubs");
			o.AddRange(new string[] {"orange", "blue"});
			_exporter.Add(example);
			_exporter.End();
			Assert.AreEqual(
					"<example><trait name=\"flubs\" value=\"orange\" /><trait name=\"flubs\" value=\"blue\" /></example>",
					_stringBuilder.ToString());
		}
		public void MergeInTranslationForm_UnheardOfType_StillBecomesTranslation()
		{
			LexExampleSentence ex = new LexExampleSentence();
			LiftMultiText translation = new LiftMultiText();
			translation.Add("aa", "aaaa");
			_builder.MergeInTranslationForm(ex, "madeUpType", translation, "bogus raw xml");
			Assert.AreEqual("aaaa", ex.Translation["aa"]);
			Assert.AreEqual("madeUpType",ex.TranslationType);
		}
예제 #54
0
		public void ExampleTranslations_MultipleTypes()
		{
			LexEntry e = MakeSimpleEntry();
			LexSense sense = new LexSense();
			e.Senses.Add(sense);
			LexExampleSentence ex = new LexExampleSentence();
			sense.ExampleSentences.Add(ex);
			LiftMultiText translation = new LiftMultiText();
			translation.Add("aa", "unmarked translation");
			_builder.MergeInTranslationForm(ex, "", translation, "bogus raw xml");
			LiftMultiText t2 = new LiftMultiText();
			t2.Add("aa", "type2translation");
			_builder.MergeInTranslationForm(ex,
										   "type2",
										   t2,
										   "<translation type='type2'><bogus/></translation>");
			_builder.FinishEntry(e);

			_exporter.Add(e);
			_exporter.End();
			AssertXPathNotNull(
					"//entry/sense/example/translation[not(@type)]/form[@lang='aa']/text[text()='unmarked translation']");
			AssertXPathNotNull("//entry/sense/example/translation[@type='type2']/bogus");
		}
예제 #55
0
		public void CustomOptionRefOnExample()
		{
			_fieldToOptionListName.Add("flub", "kindsOfFlubs");
			LexExampleSentence example = new LexExampleSentence();
			OptionRef o = example.GetOrCreateProperty<OptionRef>("flub");
			o.Value = "orange";
			_exporter.Add(example);
			_exporter.End();
			Assert.AreEqual("<example><trait name=\"flub\" value=\"orange\" /></example>",
							_stringBuilder.ToString());
		}
		public void MergeInTranslationForm_TypeFree_GetContentsAndSavesType()
		{
			LexExampleSentence ex = new LexExampleSentence();
			LiftMultiText translation = new LiftMultiText();
			translation.Add("aa", "aaaa");
			_builder.MergeInTranslationForm(ex, "Free translation", translation, "bogus raw xml");
			Assert.AreEqual("aaaa", ex.Translation["aa"]);
			Assert.AreEqual("Free translation", ex.TranslationType);
		}
예제 #57
0
		public void ExampleTranslations_FreeThenUnmarked()
		{
			LexEntry e = MakeSimpleEntry();
			LexSense sense = new LexSense();
			e.Senses.Add(sense);
			LexExampleSentence ex = new LexExampleSentence();
			sense.ExampleSentences.Add(ex);

			LiftMultiText t2 = new LiftMultiText();
			t2.Add("aa", "freestuff");
			_builder.MergeInTranslationForm(ex,
										   "free",
										   t2,
										   "<translation type='free'><bogus/></translation>");
			LiftMultiText translation = new LiftMultiText();
			translation.Add("aa", "unmarked translation");
			_builder.MergeInTranslationForm(ex,
										   "",
										   translation,
										   "<translation><bogusUnmarked/></translation>");
			_builder.FinishEntry(e);

			_exporter.Add(e);
			_exporter.End();
			AssertXPathNotNull("//entry/sense/example/translation[not(@type)]/bogusUnmarked");
			AssertXPathNotNull(
					"//entry/sense/example/translation[@type='free']/form/text[text()='freestuff']");
		}
		public void MergeInTranslationForm_NoType_GetContents()
		{
			LexExampleSentence ex = new LexExampleSentence();
			LiftMultiText translation = new LiftMultiText();
			translation.Add("aa", "aaaa");
			_builder.MergeInTranslationForm(ex, "", translation, "bogus raw xml");
			Assert.AreEqual("aaaa", ex.Translation["aa"]);
			Assert.IsTrue(string.IsNullOrEmpty(ex.TranslationType));
		}
예제 #59
0
		public void NoteOnExample_OutputAsNote()
		{
			using (var session = new LiftExportAsFragmentTestSession())
			{
				LexExampleSentence example = new LexExampleSentence();
				MultiText m =
					example.GetOrCreateProperty<MultiText>(PalasoDataObject.WellKnownProperties.Note);
				m["zz"] = "orange";
				session.LiftWriter.Add(example);
				session.LiftWriter.End();
				AssertHasAtLeastOneMatch("example/note/form[@lang='zz' and text='orange']", session);
				AssertHasAtLeastOneMatch("example[not(field)]", session);
			}
		}