Exemplo n.º 1
0
        public void WordCollected_LiftWithCustomField_CopiedOver()
        {
            LexSense firstSense = AddWordAndGetFirstSense();
            var      custom     = firstSense.GetProperty <MultiText>("custom1");

            Assert.IsNotNull(custom);
            Assert.AreEqual("EnglishCustomValue", custom.GetExactAlternative("en"));
        }
Exemplo n.º 2
0
        public void WordCollected_LiftWithPartOfSpeech_CopiedOver()
        {
            LexSense  firstSense = AddWordAndGetFirstSense();
            OptionRef pos        =
                firstSense.GetProperty <OptionRef>(
                    LexSense.WellKnownProperties.PartOfSpeech);

            Assert.AreEqual("noun", pos.Key);
        }
Exemplo n.º 3
0
        public void WordCollected_LiftWithSemanticDomain_CopiedOver()
        {
            LexSense            firstSense = AddWordAndGetFirstSense();
            OptionRefCollection domains    =
                firstSense.GetProperty <OptionRefCollection>(
                    LexSense.WellKnownProperties.SemanticDomainDdp4);

            Assert.AreEqual(1, domains.Count);
            Assert.AreEqual("fruit", domains.KeyAtIndex(0));
        }
Exemplo n.º 4
0
        public void SenseGetsRelation()
        {
            LexSense sense = new LexSense();

            _builder.MergeInRelation(sense, "synonym", "foo", null);
            LexRelationCollection synonyms = sense.GetProperty <LexRelationCollection>("synonym");
            LexRelation           relation = synonyms.Relations[0];

            Assert.AreEqual("synonym", relation.FieldId);
            Assert.AreEqual("foo", relation.Key);
        }
Exemplo n.º 5
0
        public void SenseGetsGrammi()
        {
            LexSense sense = new LexSense();

            _builder.MergeInGrammaticalInfo(sense, "red", null);
            OptionRef optionRef =
                sense.GetProperty <OptionRef>(LexSense.WellKnownProperties.PartOfSpeech);

            Assert.IsNotNull(optionRef);
            Assert.AreEqual("red", optionRef.Value);
        }
Exemplo n.º 6
0
        public void SenseGetsPictureNoCaption()
        {
            Extensible extensibleInfo = new Extensible();
            LexEntry   e = MakeSimpleEntry();
            LexSense   s = _builder.GetOrMakeSense(e, extensibleInfo, string.Empty);

            _builder.MergeInPicture(s, "testPicture.png", null);
            PictureRef pict = s.GetProperty <PictureRef>("Picture");

            Assert.AreEqual("testPicture.png", pict.Value);
            Assert.IsNull(pict.Caption);
        }
Exemplo n.º 7
0
        public void GrammiGetsFlagTrait()
        {
            LexSense sense = new LexSense();

            _builder.MergeInGrammaticalInfo(sense,
                                            "red",
                                            new List <Trait>(new Trait[] { new Trait("flag", "1") }));
            OptionRef optionRef =
                sense.GetProperty <OptionRef>(LexSense.WellKnownProperties.PartOfSpeech);

            Assert.IsTrue(optionRef.IsStarred);
        }
Exemplo n.º 8
0
        private void WriteGrammi(LexSense sense)
        {
            if (!ShouldOutputProperty(LexSense.WellKnownProperties.PartOfSpeech))
            {
                return;
            }

            OptionRef pos = sense.GetProperty <OptionRef>(LexSense.WellKnownProperties.PartOfSpeech);

            if (pos != null && !pos.IsEmpty)
            {
                WritePosCore(pos);
            }
        }
Exemplo n.º 9
0
        public void SenseGetsPictureWithCaption()
        {
            Extensible extensibleInfo = new Extensible();
            LexEntry   e = MakeSimpleEntry();
            LexSense   s = _builder.GetOrMakeSense(e, extensibleInfo, string.Empty);

            LiftMultiText caption = new LiftMultiText();

            caption["aa"] = new LiftString("acaption");
            _builder.MergeInPicture(s, "testPicture.png", caption);
            PictureRef pict = s.GetProperty <PictureRef>("Picture");

            Assert.AreEqual("testPicture.png", pict.Value);
            Assert.AreEqual("acaption", pict.Caption["aa"]);
        }
Exemplo n.º 10
0
        private static void RenderPartOfSpeech(LexSense sense, CurrentItemEventArgs currentItem, StringBuilder rtf)
        {
            OptionRef posRef = sense.GetProperty <OptionRef>(
                LexSense.WellKnownProperties.PartOfSpeech
                );

            if (posRef == null)
            {
                return;
            }

            OptionsList list = WeSayWordsProject.Project.GetOptionsList(
                LexSense.WellKnownProperties.PartOfSpeech
                );

            if (list == null)
            {
                return;
            }

            Option posOption = list.GetOptionFromKey(posRef.Value);

            if (posOption == null)
            {
                return;
            }

            Field posField = WeSayWordsProject.Project.GetFieldFromDefaultViewTemplate(
                LexSense.WellKnownProperties.PartOfSpeech
                );

            if (posField == null)
            {
                return;
            }
            rtf.Append(@" \i ");
            rtf.Append(RenderField(posOption.Name, currentItem, 0, posField));
            rtf.Append(@"\i0 ");
        }
		public void SenseGetsRelation()
		{
			LexSense sense = new LexSense();
			_builder.MergeInRelation(sense, "synonym", "foo", null);
			LexRelationCollection synonyms = sense.GetProperty<LexRelationCollection>("synonym");
			LexRelation relation = synonyms.Relations[0];
			Assert.AreEqual("synonym", relation.FieldId);
			Assert.AreEqual("foo", relation.Key);
		}
		public void GrammiGetsFlagTrait()
		{
			LexSense sense = new LexSense();
			_builder.MergeInGrammaticalInfo(sense,
										   "red",
										   new List<Trait>(new Trait[] {new Trait("flag", "1")}));
			OptionRef optionRef =
					sense.GetProperty<OptionRef>(LexSense.WellKnownProperties.PartOfSpeech);
			Assert.IsTrue(optionRef.IsStarred);
		}
		public void SenseGetsGrammi()
		{
			LexSense sense = new LexSense();
			_builder.MergeInGrammaticalInfo(sense, "red", null);
			OptionRef optionRef =
					sense.GetProperty<OptionRef>(LexSense.WellKnownProperties.PartOfSpeech);
			Assert.IsNotNull(optionRef);
			Assert.AreEqual("red", optionRef.Value);
		}
Exemplo n.º 14
0
		public void MultipleNotesCombined()
		{
			LexSense sense = new LexSense();
			_builder.MergeInNote(sense, null, MakeBasicLiftMultiText());
			LiftMultiText secondNote = new LiftMultiText();
			secondNote.Add("ws-one", "UNO");
			secondNote.Add("ws-three", "tres");
			_builder.MergeInNote(sense, null, secondNote);

			MultiText mt = sense.GetProperty<MultiText>(WeSayDataObject.WellKnownProperties.Note);
			Assert.AreEqual(3, mt.Forms.Length);
			Assert.AreEqual("uno || UNO", mt["ws-one"]);
		}
Exemplo n.º 15
0
        public void PrepareToMoveWordToEditArea(WordDisplay wordDisplay)
        {
            VerifyTaskActivated();
            _savedSensesDuringMoveToEditArea = null;

            if (wordDisplay == null)
            {
                throw new ArgumentNullException();
            }
            // this task was coded to have a list of word-forms, not actual entries.
            //so we have to go searching for possible matches at this point.
            ResultSet <LexEntry> matchingEntries =
                LexEntryRepository.GetEntriesWithMatchingLexicalForm(wordDisplay.Vernacular.Form, FormWritingSystem);

            foreach (RecordToken <LexEntry> recordToken in matchingEntries)
            {
                if (_savedSensesDuringMoveToEditArea == null)
                {
                    _savedSensesDuringMoveToEditArea = new List <LexSense>();
                }
                // have to iterate through these in reverse order since they might get modified
                LexEntry entry = recordToken.RealObject;
                //If we aren't showing the meaning field then we are going let any edits effect all matching Senses
                if (!ShowMeaningField)
                {
                    for (int i = entry.Senses.Count - 1; i >= 0; i--)
                    {
                        LexSense sense           = entry.Senses[i];
                        var      semanticDomains = sense.GetProperty <OptionRefCollection>(_semanticDomainField.FieldName);
                        if (semanticDomains != null)
                        {
                            if (semanticDomains.Contains(CurrentDomainKey))
                            {
                                RememberMeaningOfDissociatedWord(sense);
                                entry.Senses.Remove(sense);
                                //if we don't do this and it has a meaning, we'll fail to delete the word when the user is trying to correct the spelling. (WS-34245)
                            }
                        }
                    }
                }
                //If we are showing the meaning field then we only let edits effect the sense that matches the shown meaning (definition)
                else
                {
                    var firstSenseMatchingSemDomAndMeaning =
                        entry.Senses.
                        Where(s => s.GetProperty <OptionRefCollection>(LexSense.WellKnownProperties.SemanticDomainDdp4) != null).
                        FirstOrDefault(s => s.GetProperty <OptionRefCollection>(LexSense.WellKnownProperties.SemanticDomainDdp4).Contains(CurrentDomainKey) &&
                                       s.Definition.GetBestAlternative(new[] { DefinitionWritingSystem.Id }) == wordDisplay.Meaning);
                    if (firstSenseMatchingSemDomAndMeaning != null)
                    {
                        RememberMeaningOfDissociatedWord(firstSenseMatchingSemDomAndMeaning);
                        entry.Senses.Remove(firstSenseMatchingSemDomAndMeaning);
                    }
                }
                entry.CleanUpAfterEditting();
                if (entry.IsEmptyExceptForLexemeFormForPurposesOfDeletion)
                {
                    LexEntryRepository.DeleteItem(entry);                     // if there are no senses left, get rid of it
                }
                else
                {
                    LexEntryRepository.SaveItem(entry);
                }
            }

            UpdateCurrentWords();
        }