예제 #1
0
        public void ExportGuesses()
        {
            //NOTE: The new test paragraphs need to have all new words w/o duplicates so we can predict the guesses
            //xxxcrayzee xxxyouneek xxxsintents.

            // copy a text of first paragraph into a new paragraph to generate guesses.
            StTxtPara paraGlossed = m_text1.ContentsOA.ParagraphsOS.Append(new StTxtPara()) as StTxtPara;
            StTxtPara paraGuessed = m_text1.ContentsOA.ParagraphsOS.Append(new StTxtPara()) as StTxtPara;

            paraGlossed.Contents.UnderlyingTsString = StringUtils.MakeTss("xxxcrayzee xxxyouneek xxxsintents.", Cache.DefaultVernWs);
            paraGuessed.Contents.UnderlyingTsString = paraGlossed.Contents.UnderlyingTsString;

            // collect expected guesses from the glosses in the first paragraph.
            ParagraphAnnotator paGlossed       = new ParagraphAnnotator(paraGlossed);
            List <int>         expectedGuesses = paGlossed.SetupDefaultWordGlosses();

            // then verify we've created guesses for the new text.
            ParagraphAnnotator paGuessed = new ParagraphAnnotator(paraGuessed);
            bool fDidParse;

            ParagraphParser.ParseText(m_text1.ContentsOA, new NullProgressState(), out fDidParse);
            paGuessed.LoadParaDefaultAnalyses();

            // export the paragraph and test the Display results
            m_choices.Add(InterlinLineChoices.kflidWord);
            m_choices.Add(InterlinLineChoices.kflidWordGloss);
            XmlDocument exportedDoc = ExportToXml();

            ValidateExportedParagraph(exportedDoc, m_choices, paraGuessed);
        }
예제 #2
0
        public void ExportPhraseWordGuids()
        {
            // create two paragraphs with two identical sentences.
            // copy a text of first paragraph into a new paragraph to generate guesses.
            StTxtPara paraGlossed = m_text1.ContentsOA.ParagraphsOS.Append(new StTxtPara()) as StTxtPara;
            StTxtPara paraGuessed = m_text1.ContentsOA.ParagraphsOS.Append(new StTxtPara()) as StTxtPara;

            paraGlossed.Contents.UnderlyingTsString = StringUtils.MakeTss(
                "xxxwordone xxxwordtwo xxxwordthree. xxxwordone xxxwordtwo xxxwordthree.",
                Cache.DefaultVernWs);
            paraGuessed.Contents.UnderlyingTsString = paraGlossed.Contents.UnderlyingTsString;

            // collect expected guesses from the glosses in the first paragraph.
            ParagraphAnnotator paGlossed       = new ParagraphAnnotator(paraGlossed);
            List <int>         expectedGuesses = paGlossed.SetupDefaultWordGlosses();

            // then verify we've created guesses for the new text.
            ParagraphAnnotator paGuessed = new ParagraphAnnotator(paraGuessed);
            bool fDidParse;

            ParagraphParser.ParseText(m_text1.ContentsOA, new NullProgressState(), out fDidParse);
            paGuessed.LoadParaDefaultAnalyses();

            // export the paragraph and test the Display results
            m_choices.Add(InterlinLineChoices.kflidWord);
            m_choices.Add(InterlinLineChoices.kflidWordGloss);
            m_choices.Add(InterlinLineChoices.kflidMorphemes);
            m_choices.Add(InterlinLineChoices.kflidLexEntries);
            m_choices.Add(InterlinLineChoices.kflidLexGloss);
            m_choices.Add(InterlinLineChoices.kflidLexPos);

            XmlDocument exportedDoc = ExportToXml("elan");
            // validate that we included the expected metadata
            string exportName = XmlUtils.GetOptionalAttributeValue(exportedDoc.DocumentElement, "exportTarget");

            Assert.AreEqual("elan", exportName);
            string version = XmlUtils.GetOptionalAttributeValue(exportedDoc.DocumentElement, "version");

            Assert.AreEqual("1", version);
            ExportedInterlinearReader         exportReader = new ExportedInterlinearReader(exportedDoc, m_choices);
            ExportedParagraphValidatorForELAN validator    = new ExportedParagraphValidatorForELAN(exportReader, paraGlossed);

            validator.ValidateParagraphs(paraGlossed, exportReader.GetParaNode(paraGlossed.IndexInOwner));
            validator.ValidateParagraphs(paraGuessed, exportReader.GetParaNode(paraGuessed.IndexInOwner));
            // only expecting to collect a total of 2 paragraph guids,
            // each paragraph with 2 phrase guids (2*2)
            // and each phrase with 3 word guids (2*2*3).
            validator.ValidateNonrepeatingGuidCount(2 + 2 * 2 + 2 * 2 * 3);
        }
예제 #3
0
		public void ExportPhraseWordGuids()
		{
			// create two paragraphs with two identical sentences.
			// copy a text of first paragraph into a new paragraph to generate guesses.
			StTxtPara paraGlossed = m_text1.ContentsOA.ParagraphsOS.Append(new StTxtPara()) as StTxtPara;
			StTxtPara paraGuessed = m_text1.ContentsOA.ParagraphsOS.Append(new StTxtPara()) as StTxtPara;
			paraGlossed.Contents.UnderlyingTsString = StringUtils.MakeTss(
				"xxxwordone xxxwordtwo xxxwordthree. xxxwordone xxxwordtwo xxxwordthree.",
				Cache.DefaultVernWs);
			paraGuessed.Contents.UnderlyingTsString = paraGlossed.Contents.UnderlyingTsString;

			// collect expected guesses from the glosses in the first paragraph.
			ParagraphAnnotator paGlossed = new ParagraphAnnotator(paraGlossed);
			List<int> expectedGuesses = paGlossed.SetupDefaultWordGlosses();

			// then verify we've created guesses for the new text.
			ParagraphAnnotator paGuessed = new ParagraphAnnotator(paraGuessed);
			bool fDidParse;
			ParagraphParser.ParseText(m_text1.ContentsOA, new NullProgressState(), out fDidParse);
			paGuessed.LoadParaDefaultAnalyses();

			// export the paragraph and test the Display results
			m_choices.Add(InterlinLineChoices.kflidWord);
			m_choices.Add(InterlinLineChoices.kflidWordGloss);
			m_choices.Add(InterlinLineChoices.kflidMorphemes);
			m_choices.Add(InterlinLineChoices.kflidLexEntries);
			m_choices.Add(InterlinLineChoices.kflidLexGloss);
			m_choices.Add(InterlinLineChoices.kflidLexPos);

			XmlDocument exportedDoc = ExportToXml("elan");
			// validate that we included the expected metadata
			string exportName = XmlUtils.GetOptionalAttributeValue(exportedDoc.DocumentElement, "exportTarget");
			Assert.AreEqual("elan", exportName);
			string version = XmlUtils.GetOptionalAttributeValue(exportedDoc.DocumentElement, "version");
			Assert.AreEqual("1", version);
			ExportedInterlinearReader exportReader = new ExportedInterlinearReader(exportedDoc, m_choices);
			ExportedParagraphValidatorForELAN validator = new ExportedParagraphValidatorForELAN(exportReader, paraGlossed);
			validator.ValidateParagraphs(paraGlossed, exportReader.GetParaNode(paraGlossed.IndexInOwner));
			validator.ValidateParagraphs(paraGuessed, exportReader.GetParaNode(paraGuessed.IndexInOwner));
			// only expecting to collect a total of 2 paragraph guids,
			// each paragraph with 2 phrase guids (2*2)
			// and each phrase with 3 word guids (2*2*3).
			validator.ValidateNonrepeatingGuidCount(2 + 2*2 + 2*2*3);
		}
예제 #4
0
		public void ExportGuesses()
		{
			//NOTE: The new test paragraphs need to have all new words w/o duplicates so we can predict the guesses
			//xxxcrayzee xxxyouneek xxxsintents.

			// copy a text of first paragraph into a new paragraph to generate guesses.
			StTxtPara paraGlossed = m_text1.ContentsOA.ParagraphsOS.Append(new StTxtPara()) as StTxtPara;
			StTxtPara paraGuessed = m_text1.ContentsOA.ParagraphsOS.Append(new StTxtPara()) as StTxtPara;
			paraGlossed.Contents.UnderlyingTsString = StringUtils.MakeTss("xxxcrayzee xxxyouneek xxxsintents.", Cache.DefaultVernWs);
			paraGuessed.Contents.UnderlyingTsString = paraGlossed.Contents.UnderlyingTsString;

			// collect expected guesses from the glosses in the first paragraph.
			ParagraphAnnotator paGlossed = new ParagraphAnnotator(paraGlossed);
			List<int> expectedGuesses = paGlossed.SetupDefaultWordGlosses();

			// then verify we've created guesses for the new text.
			ParagraphAnnotator paGuessed = new ParagraphAnnotator(paraGuessed);
			bool fDidParse;
			ParagraphParser.ParseText(m_text1.ContentsOA, new NullProgressState(), out fDidParse);
			paGuessed.LoadParaDefaultAnalyses();

			// export the paragraph and test the Display results
			m_choices.Add(InterlinLineChoices.kflidWord);
			m_choices.Add(InterlinLineChoices.kflidWordGloss);
			XmlDocument exportedDoc = ExportToXml();
			ValidateExportedParagraph(exportedDoc, m_choices, paraGuessed);
		}
예제 #5
0
		public void CheckValidGuessesAfterInsertNewWord_LT8467()
		{
			//NOTE: The new test paragraphs need to have all new words w/o duplicates so we can predict the guesses
			//xxxcrayzee xxxyouneek xxxsintents.

			// copy a text of first paragraph into a new paragraph to generate guesses.
			IStTxtPara paraGlossed = m_text1.ContentsOA.AddNewTextPara("Normal");
			IStTxtPara paraGuessed = m_text1.ContentsOA.AddNewTextPara("Normal");

			paraGlossed.Contents = TsStringUtils.MakeTss("xxxcrayzee xxxyouneek xxxsintents.", Cache.DefaultVernWs);
			paraGuessed.Contents = paraGlossed.Contents;

			// collect expected guesses from the glosses in the first paragraph.
			ParagraphAnnotator paGlossed = new ParagraphAnnotator(paraGlossed);
			ParagraphParser.ParseText(m_text1.ContentsOA);
			IList<IWfiGloss> expectedGuesses = paGlossed.SetupDefaultWordGlosses();

			// then verify we've created guesses for the new text.
			ParagraphAnnotator paGuessed = new ParagraphAnnotator(paraGuessed);

			IList<IWfiGloss> expectedGuessesBeforeEdit = expectedGuesses;
			ValidateGuesses(expectedGuessesBeforeEdit, paraGuessed);

			// now edit the paraGuessed and expected Guesses.
			paraGuessed.Contents = TsStringUtils.MakeTss("xxxcrayzee xxxguessless xxxyouneek xxxsintents.", Cache.DefaultVernWs);
			IList<IWfiGloss> expectedGuessesAfterEdit = new List<IWfiGloss>(expectedGuesses);
			// we don't expect a guess for the inserted word, so insert 0 after first twfic.
			expectedGuessesAfterEdit.Insert(1, null);

			// Note: we need to use ParseText rather than ReparseParagraph, because it uses
			// code to Reuse dummy annotations.
			ParagraphParser.ParseText(m_text1.ContentsOA);
			ValidateGuesses(expectedGuessesAfterEdit, paraGuessed);
		}
예제 #6
0
		public void CheckValidGuessesAfterInsertNewWord_LT8467()
		{
			//NOTE: The new test paragraphs need to have all new words w/o duplicates so we can predict the guesses
			//xxxcrayzee xxxyouneek xxxsintents.

			// copy a text of first paragraph into a new paragraph to generate guesses.
			StTxtPara paraGlossed = m_text1.ContentsOA.ParagraphsOS.Append(new StTxtPara()) as StTxtPara;
			StTxtPara paraGuessed = m_text1.ContentsOA.ParagraphsOS.Append(new StTxtPara()) as StTxtPara;
			paraGlossed.Contents.UnderlyingTsString = StringUtils.MakeTss("xxxcrayzee xxxyouneek xxxsintents.", Cache.DefaultVernWs);
			paraGuessed.Contents.UnderlyingTsString = paraGlossed.Contents.UnderlyingTsString;

			// collect expected guesses from the glosses in the first paragraph.
			ParagraphAnnotator paGlossed = new ParagraphAnnotator(paraGlossed);
			List<int> expectedGuesses = paGlossed.SetupDefaultWordGlosses();

			// then verify we've created guesses for the new text.
			ParagraphAnnotator paGuessed = new ParagraphAnnotator(paraGuessed);
			bool fDidParse;
			ParagraphParser.ParseText(m_text1.ContentsOA, new NullProgressState(), out fDidParse);

			paGuessed.LoadParaDefaultAnalyses();
			List<int> expectedGuessesBeforeEdit = new List<int>(expectedGuesses);
			ValidateGuesses(expectedGuessesBeforeEdit, paraGuessed);

			// now edit the paraGuessed and expected Guesses.
			paraGuessed.Contents.UnderlyingTsString = StringUtils.MakeTss("xxxcrayzee xxxguessless xxxyouneek xxxsintents.", Cache.DefaultVernWs);
			List<int> expectedGuessesAfterEdit = new List<int>(expectedGuesses);
			// we don't expect a guess for the inserted word, so insert 0 after first twfic.
			expectedGuessesAfterEdit.Insert(1, 0);

			// Note: we need to use ParseText rather than ReparseParagraph, because it uses
			// code to Reuse dummy annotations.
			ParagraphParser.ParseText(m_text1.ContentsOA, new NullProgressState(), out fDidParse);
			paGuessed.LoadParaDefaultAnalyses();
			ValidateGuesses(expectedGuessesAfterEdit, paraGuessed);
		}