Exemplo n.º 1
0
		/// <summary>
		/// Constructor.
		/// </summary>
		public LiftField(string type, LiftMultiText contents)
		{
			Annotations = new List<LiftAnnotation>();
			Traits = new List<LiftTrait>();
			Type = type;
			Content = contents;
		}
Exemplo n.º 2
0
		private static LiftMultiText MakeBasicLiftMultiText()
		{
			LiftMultiText forms = new LiftMultiText();
			forms.Add("ws-one", "uno");
			forms.Add("ws-two", "dos");
			return forms;
		}
Exemplo n.º 3
0
		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"]);
		}
Exemplo n.º 4
0
        public PalasoDataObject MergeInEtymology(LexEntry entry,
                                                 string source,
                                                 string type,
                                                 LiftMultiText form,
                                                 LiftMultiText gloss,
                                                 string rawXml)
        {
            entry.GetOrCreateProperty <EmbeddedXmlCollection>("etymology").Values.Add(rawXml);

            return(null);
        }
Exemplo n.º 5
0
            /// <summary> Adds in media for audio pronunciation </summary>
            public void MergeInMedia(LiftObject pronunciation, string href, LiftMultiText caption)
            {
                var entry    = (LiftEntry)pronunciation;
                var phonetic = new LiftPhonetic();
                var url      = new LiftUrlRef {
                    Url = href
                };

                phonetic.Media.Add(url);
                entry.Pronunciations.Add(phonetic);
            }
Exemplo n.º 6
0
 /// <summary> Adds in note, if there is one to add </summary>
 public void MergeInNote(LiftObject extensible, string type, LiftMultiText contents, string rawXml)
 {
     if (extensible is LiftEntry entry)
     {
         var note = new LiftNote(
             // This application only uses "basic" notes, which have no type
             null,
             new LiftMultiText(contents.FirstValue.Key, contents.FirstValue.Value.Text));
         entry.Notes.Add(note);
     }
 }
        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);
            }
        }
Exemplo n.º 8
0
		public void GetFormWithSpans_WritingSystemLinkedToFormWithSpans_ReturnsFormWithSpans()
		{
			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"]);
		}
Exemplo n.º 9
0
        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"]);
        }
Exemplo n.º 10
0
        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"]);
        }
Exemplo n.º 11
0
        public void UnexpectedCustomFieldRetained()
        {
            LexEntry      e = MakeSimpleEntry();
            LiftMultiText t = new LiftMultiText();

            t["z"] = new LiftString("dub");
            _builder.MergeInField(e, "flub", default(DateTime), default(DateTime), t, null);
            Assert.AreEqual(1, e.Properties.Count);
            Assert.AreEqual("flub", e.Properties[0].Key);
            MultiText mt = e.GetProperty <MultiText>("flub");

            Assert.AreEqual("dub", mt["z"]);
        }
Exemplo n.º 12
0
        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));
        }
Exemplo n.º 13
0
 private static void AddAnnotationsToMultiText(LiftMultiText forms, MultiTextBase text)
 {
     foreach (Annotation annotation in forms.Annotations)
     {
         if (annotation.Name == "flag")
         {
             text.SetAnnotationOfAlternativeIsStarred(annotation.LanguageHint,
                                                      int.Parse(annotation.Value) > 0);
         }
         else
         {
             //log dropped
         }
     }
 }
Exemplo n.º 14
0
        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"]);
        }
Exemplo n.º 15
0
        public void NewEntry_OldLiteralMeaning_GetsMoved()
        {
            // _builder.AfterEntryRead += _builder.ApplyWeSayPolicyToParsedEntry;

            Extensible    extensibleInfo = new Extensible();
            LexEntry      e = _builder.GetOrMakeEntry(extensibleInfo, 0);
            LexSense      s = _builder.GetOrMakeSense(e, new Extensible(), string.Empty);
            LiftMultiText t = new LiftMultiText("en", "test");

            _builder.MergeInField(s, "LiteralMeaning", default(DateTime), default(DateTime), t, null);
            _builder.FinishEntry(e);
            Assert.IsNull(e.Senses[0].GetProperty <MultiText>("LiteralMeaning"));
            Assert.IsNotNull(e.GetProperty <MultiText>(LexEntry.WellKnownProperties.LiteralMeaning));
            Assert.AreEqual("test", e.GetProperty <MultiText>(LexEntry.WellKnownProperties.LiteralMeaning).GetExactAlternative("en"));
        }
Exemplo n.º 16
0
        public void GlossGetsFlag()
        {
            LexSense      sense = new LexSense();
            LiftMultiText text  = MakeBasicLiftMultiText();

            AddAnnotationToLiftMultiText(text, "ws-one", "flag", "1");
            _builder.MergeInGloss(sense, text);
            Assert.IsTrue(sense.Gloss.GetAnnotationOfAlternativeIsStarred("ws-one"));
            Assert.IsFalse(sense.Gloss.GetAnnotationOfAlternativeIsStarred("ws-two"));

            text = MakeBasicLiftMultiText();
            AddAnnotationToLiftMultiText(text, "ws-one", "flag", "0");
            _builder.MergeInGloss(sense, text);
            Assert.IsFalse(sense.Gloss.GetAnnotationOfAlternativeIsStarred("ws-one"));
        }
Exemplo n.º 17
0
        public void MultipleGlossesCombined()
        {
            LexSense sense = new LexSense();

            _builder.MergeInGloss(sense, MakeBasicLiftMultiText());
            LiftMultiText secondGloss = new LiftMultiText();

            secondGloss.Add("ws-one", "UNO");
            secondGloss.Add("ws-three", "tres");
            _builder.MergeInGloss(sense, secondGloss);

            //MultiText mt = sense.GetProperty<MultiText>(LexSense.WellKnownProperties.Note);
            Assert.AreEqual(3, sense.Gloss.Forms.Length);
            Assert.AreEqual("uno; UNO", sense.Gloss["ws-one"]);
        }
Exemplo n.º 18
0
        public void EntryWithCitation()
        {
            LexEntry      entry = MakeSimpleEntry();
            LiftMultiText forms = new LiftMultiText();

            forms.Add("x", "hello");
            forms.Add("y", "bye");
            _builder.MergeInCitationForm(entry, forms);

            MultiText citation = entry.GetProperty <MultiText>(LexEntry.WellKnownProperties.Citation);

            Assert.AreEqual(2, citation.Forms.Length);
            Assert.AreEqual("hello", citation["x"]);
            Assert.AreEqual("bye", citation["y"]);
        }
Exemplo n.º 19
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.º 20
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);
            _liftWriter.Add(e);
            _liftWriter.End();
            AssertHasAtLeastOneMatch("//entry/sense/example/translation[not(@type)]/form[@lang='aa']");
        }
Exemplo n.º 21
0
        public static MultiText Create(LiftMultiText liftMultiText)
        {
            if (liftMultiText == null)
            {
                throw new ArgumentNullException("liftMultiText");
            }
            MultiText m = new MultiText();
            Dictionary <string, string> forms = new Dictionary <string, string>();

            foreach (KeyValuePair <string, LiftString> pair in liftMultiText)
            {
                if (pair.Value != null)
                {
                    forms.Add(pair.Key, ConvertLiftStringToSimpleStringWithMarkers(pair.Value));
                }
            }
            CopyForms(forms, m);
            return(m);
        }
Exemplo n.º 22
0
        /// <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);
                }
            }
        }
Exemplo n.º 23
0
        public override bool Matches(object o)
        {
            LiftMultiText m = (LiftMultiText)o;

            if (m.Annotations.Count != _expectedCount)
            {
                return(false);
            }
            Annotation t = m.Annotations[0];

            if (!string.IsNullOrEmpty(_expectedLanguageOfFirstAnnotation))
            {
//                    if (t.LanguageHint != _expectedLanguageOfFirstAnnotation)
//                    {
//                        return false;
//                    }
            }
            return(t.Name == _expectedNameOfFirstAnnotation &&
                   t.Value == _expectedValueOfFirstAnnotation &&
                   t.Who == _expectedWhoOfFirstAnnotation &&
                   t.When == _expectedWhenOfFirstAnnotation);
        }
Exemplo n.º 24
0
        /*
         * 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));
                }
            }
        }
Exemplo n.º 25
0
        public void MergeInTranslationForm(LexExampleSentence example,
                                           string type,
                                           LiftMultiText forms,
                                           string rawXml)
        {
            bool alreadyHaveAPrimaryTranslation = example.Translation != null &&
                                                  !string.IsNullOrEmpty(
                example.Translation.GetFirstAlternative());

            /*    bool typeIsCompatibleWithWeSayPrimaryTranslation = string.IsNullOrEmpty(type) ||
             *                                                                                                         type.ToLower() == "free translation"; //this is the default style in FLEx
             * */

            //WeSay's model only allows for one translation just grab the first translation
            if (!alreadyHaveAPrimaryTranslation /*&& typeIsCompatibleWithWeSayPrimaryTranslation*/)
            {
                MergeIn(example.Translation, forms);
                example.TranslationType = type;
            }
            else
            {
                example.GetOrCreateProperty <EmbeddedXmlCollection>(PalasoDataObject.GetEmbeddedXmlNameForProperty(LexExampleSentence.WellKnownProperties.Translation)).Values.Add(rawXml);
            }
        }
Exemplo n.º 26
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']");
		}
Exemplo n.º 27
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");
		}
Exemplo n.º 28
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']");
		}
Exemplo n.º 29
0
		///<summary>
		/// Constructor.
		///</summary>
		public LiftNote(string type, LiftMultiText contents)
		{
			Type = type;
			Content = contents;
		}
		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));
		}
		private static LiftMultiText MakeBasicLiftMultiText(string text)
		{
			LiftMultiText forms = new LiftMultiText();
			forms.Add("ws-one", text);
			forms.Add("ws-two", text+"-in-two");
			return forms;
		}
		private static void AddAnnotationToLiftMultiText(LiftMultiText text,
														 string languageHint,
														 string name,
														 string value)
		{
			Annotation annotation = new Annotation(name, value, default(DateTime), null);
			annotation.LanguageHint = languageHint;
			text.Annotations.Add(annotation);
		}
Exemplo n.º 33
0
 public void MergeInTranslationForm(LiftExample example, string type, LiftMultiText multiText, string rawXml)
 {
 }
Exemplo n.º 34
0
 public void MergeInPicture(LiftSense sense, string href, LiftMultiText caption)
 {
 }
Exemplo n.º 35
0
 public void MergeInNote(LiftObject extensible, string type, LiftMultiText contents, string rawXml)
 {
 }
Exemplo n.º 36
0
 public void MergeInExampleForm(LiftExample example, LiftMultiText multiText)
 {
 }
Exemplo n.º 37
0
 public void MergeInDefinition(LiftSense sense, LiftMultiText liftMultiText)
 {
 }
Exemplo n.º 38
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"]);
		}
		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.º 40
0
		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 NewEntry_OldLiteralMeaning_GetsMoved()
		{
		   // _builder.AfterEntryRead += _builder.ApplyWeSayPolicyToParsedEntry;

			Extensible extensibleInfo = new Extensible();
			LexEntry e = _builder.GetOrMakeEntry(extensibleInfo, 0);
			LexSense s = _builder.GetOrMakeSense(e, new Extensible(), string.Empty);
			LiftMultiText t = new LiftMultiText("en", "test");
			_builder.MergeInField(s, "LiteralMeaning", default(DateTime), default(DateTime), t, null);
			_builder.FinishEntry(e);
			Assert.IsNull(e.Senses[0].GetProperty<MultiText>("LiteralMeaning"));
			Assert.IsNotNull(e.GetProperty<MultiText>(LexEntry.WellKnownProperties.LiteralMeaning));
			Assert.AreEqual("test", e.GetProperty<MultiText>(LexEntry.WellKnownProperties.LiteralMeaning).GetExactAlternative("en"));
		}
Exemplo n.º 42
0
 public void ProcessFieldDefinition(string tag, LiftMultiText description)
 {
 }
		public void MultipleGlossesCombined()
		{
			LexSense sense = new LexSense();
			_builder.MergeInGloss(sense, MakeBasicLiftMultiText());
			LiftMultiText secondGloss = new LiftMultiText();
			secondGloss.Add("ws-one", "UNO");
			secondGloss.Add("ws-three", "tres");
			_builder.MergeInGloss(sense, secondGloss);

			//MultiText mt = sense.GetProperty<MultiText>(LexSense.WellKnownProperties.Note);
			Assert.AreEqual(3, sense.Gloss.Forms.Length);
			Assert.AreEqual("uno; UNO", sense.Gloss["ws-one"]);
		}
		public void NewEntryGetsLexemeForm()
		{
			LexEntry e = MakeSimpleEntry();
			LiftMultiText forms = new LiftMultiText();
			forms.Add("x", "hello");
			forms.Add("y", "bye");
			_builder.MergeInLexemeForm(e, forms);
			Assert.AreEqual(2, e.LexicalForm.Count);
		}
		public void EntryGetsLexemeFormWithUnheardOfLanguage()
		{
			LexEntry e = MakeSimpleEntry();
			LiftMultiText forms = new LiftMultiText();
			forms.Add("x99", "hello");
			_builder.MergeInLexemeForm(e, forms);
			Assert.AreEqual("hello", e.LexicalForm["x99"]);
		}
		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);
		}
		public void EntryWithCitation()
		{
			LexEntry entry = MakeSimpleEntry();
			LiftMultiText forms = new LiftMultiText();
			forms.Add("x", "hello");
			forms.Add("y", "bye");
			_builder.MergeInCitationForm(entry, forms);

			MultiText citation = entry.GetProperty<MultiText>(LexEntry.WellKnownProperties.Citation);
			Assert.AreEqual(2, citation.Forms.Length);
			Assert.AreEqual("hello", citation["x"]);
			Assert.AreEqual("bye", citation["y"]);
		}
Exemplo n.º 48
0
 public LiftObject MergeInEtymology(LiftEntry entry, string source, string type, LiftMultiText form,
                                    LiftMultiText gloss, string rawXml)
 {
     return(new LiftEtymology());
 }
		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);
		}
Exemplo n.º 50
0
 public LiftObject MergeInReversal(LiftSense sense, LiftObject parent, LiftMultiText contents, string type,
                                   string rawXml)
 {
     return(new LiftReversal());
 }
		public void UnexpectedCustomFieldRetained()
		{
			LexEntry e = MakeSimpleEntry();
			LiftMultiText t = new LiftMultiText();
			t["z"] = new LiftString("dub");
			_builder.MergeInField(e, "flub", default(DateTime), default(DateTime), t, null);
			Assert.AreEqual(1, e.Properties.Count);
			Assert.AreEqual("flub", e.Properties[0].Key);
			MultiText mt = e.GetProperty<MultiText>("flub");
			Assert.AreEqual("dub", mt["z"]);
		}
Exemplo n.º 52
0
 public LiftObject MergeInVariant(LiftEntry entry, LiftMultiText contents, string rawXml)
 {
     return(new LiftVariant());
 }
Exemplo n.º 53
0
		public void FirstValueOfSimpleMultiText()
		{
			LiftMultiText t = new LiftMultiText();
			LiftString s1 = new LiftString();
			s1.Text = "1";
			t.Add("x", s1);
			LiftString s2 = new LiftString();
			s2.Text = "2";
			t.Add("y", s2);
			Assert.AreEqual("x", t.FirstValue.Key);
			Assert.AreEqual("1", t.FirstValue.Value.Text);
		}
Exemplo n.º 54
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']");
		}