Ejemplo n.º 1
0
		public void SparseAnalyses_SimpleEdits_SimpleSegmentParagraph_DuplicateWordforms_AddWhitespace_LT5313()
		{
			// First set sparse analyses on wordforms that have multiple occurrences.
			ParagraphBuilder pb = new ParagraphBuilder(m_textsDefn, m_text1, (int)Text1ParaIndex.SimpleSegmentPara);
			pb.ParseParagraph();
			ParagraphAnnotatorForParagraphBuilder tapb = new ParagraphAnnotatorForParagraphBuilder(pb);
			string gloss;
			var gloss0_1 = tapb.SetDefaultWordGloss(0, 1, out gloss);   // xxxyalola 1
			var gloss1_1 = tapb.SetDefaultWordGloss(1, 1, out gloss);   // xxxpus 2
			var gloss2_1 = tapb.SetDefaultWordGloss(2, 1, out gloss);   // xxxnihimbilira 3

			tapb.ValidateAnnotations(); // precondition testing.
			// Append whitespace in the text, and see if the analyses still show up in the right place
			// (cf. LT-5313).
			pb.ReplaceTrailingWhitepace(0, 0, 1);
			pb.RebuildParagraphContentFromAnnotations();
			pb.ParseParagraph();
			Assert.AreEqual(gloss0_1, tapb.GetAnalysis(0, 1));
			Assert.AreEqual(gloss1_1, tapb.GetAnalysis(1, 1));
			Assert.AreEqual(gloss2_1, tapb.GetAnalysis(2, 1));
			tapb.ValidateAnnotations();
		}
Ejemplo n.º 2
0
		public void SparseAnalyses_SimpleEdits_SimpleSegmentParagraph_DuplicateWordforms()
		{
			// First set sparse analyses on wordforms that have multiple occurrences.
			ParagraphBuilder pb = new ParagraphBuilder(m_textsDefn, m_text1, (int)Text1ParaIndex.SimpleSegmentPara);
			ParagraphAnnotatorForParagraphBuilder tapb = new ParagraphAnnotatorForParagraphBuilder(pb);
			pb.ParseParagraph();
			IWfiGloss gloss_xxxyalola0_1 = tapb.SetDefaultWordGloss("xxxyalola", 0);		// gloss first occurrence.
			IWfiGloss gloss_xxxpus1_1 = tapb.SetDefaultWordGloss("xxxpus", 1);			// gloss second occurrence.
			IWfiGloss gloss_xxxnihimbilira2_1 = tapb.SetDefaultWordGloss("xxxnihimbilira", 2);	// gloss third occurrence.
			pb.ParseParagraph();
			var actualAnalysis_xxxyalola0_1 = tapb.GetAnalysis(0, 1);
			var actualAnalysis_xxxpus1_1 = tapb.GetAnalysis(1, 1);
			var actualAnalysis_xxxnihimbilira2_1 = tapb.GetAnalysis(2, 1);
			Assert.AreEqual(gloss_xxxyalola0_1, actualAnalysis_xxxyalola0_1);
			Assert.AreEqual(gloss_xxxpus1_1, actualAnalysis_xxxpus1_1);
			Assert.AreEqual(gloss_xxxnihimbilira2_1, actualAnalysis_xxxnihimbilira2_1);
			// verify the rest
			tapb.ValidateAnnotations();
			// Replace some occurrences of these wordforms from the text to validate the analysis does not show up on the wrong occurrence.
			// Remove the first occurrence of 'xxxnihimbilira'; the (newly) second occurrence should still have the gloss.
			pb.ReplaceSegmentForm("xxxnihimbilira", 0, "");
			pb.RebuildParagraphContentFromAnnotations();
			pb.ParseParagraph();
			actualAnalysis_xxxnihimbilira2_1 = tapb.GetAnalysis(2, 1);
			Assert.AreEqual(gloss_xxxnihimbilira2_1, actualAnalysis_xxxnihimbilira2_1);
			tapb.ValidateAnnotations();
			// Remove first occurrence of 'xxxpus'; the next one should still have the gloss.
			pb.ReplaceSegmentForm("xxxpus", 0, "");
			pb.RebuildParagraphContentFromAnnotations();
			pb.ParseParagraph();
			actualAnalysis_xxxpus1_1 = tapb.GetAnalysis(1, 1);
			Assert.AreEqual(gloss_xxxpus1_1, actualAnalysis_xxxpus1_1);
			tapb.ValidateAnnotations();
		}
Ejemplo n.º 3
0
		public void SparseAnalyses_SimpleEdits_SimpleSegmentParagraph_DuplicateWordforms_RemoveSegment_LT5376()
		{
			// First set sparse analyses on wordforms that have multiple occurrences.
			ParagraphBuilder pb = new ParagraphBuilder(m_textsDefn, m_text1, (int)Text1ParaIndex.SimpleSegmentPara);
			pb.ParseParagraph();
			ParagraphAnnotatorForParagraphBuilder tapb = new ParagraphAnnotatorForParagraphBuilder(pb);
			tapb.SetDefaultWordGloss("xxxyalola", 0);		// gloss first occurrence.
			tapb.ValidateAnnotations();
			// Remove first sentence containing 'xxxyalola'; its annotation should be removed.
			pb.RemoveSegment(0);
			pb.RebuildParagraphContentFromAnnotations();
			pb.ParseParagraph();
			tapb.ValidateAnnotations();
		}
Ejemplo n.º 4
0
		public void NoAnalyses_SimpleEdits_MultipleWritingSystemsParagraph()
		{
			ParagraphBuilder pb = new ParagraphBuilder(m_textsDefn, m_text1, (int)Text1ParaIndex.MultipleWritingSystems);
			// verify that our wfics point to wordforms in the expected wss.
			pb.ParseParagraph();
			ParagraphAnnotatorForParagraphBuilder tapb = new ParagraphAnnotatorForParagraphBuilder(pb);
			FdoValidator.ValidateCbaWordToBaselineWord(tapb, 0, 0);
			//FdoValidator.ValidateCbaWordToBaselineWord(tapb, 0, 1); // currently considered punctuation.
			//FdoValidator.ValidateCbaWordToBaselineWord(tapb, 1, 0); // french word considered punctuation.
			//FdoValidator.ValidateCbaWordToBaselineWord(tapb, 1, 1); // eng word considered punctuation
			// FdoValidator.ValidateCbaWordToBaselineWord(tapb, 1, 4); // german word considered punctuation.
			// validate the rest
			tapb.ValidateAnnotations();

			// xxxpus xxes xxxnihimbilira. xxfr xxen xxxnihimbilira xxxpus xxde. xxkal xxkal xxxxhesyla xxxxhesyla.
			//	xxkal: German (de)		-- occurrence 0
			//	xxkal: Kalaba (xkal)	-- occurrence 1
			Dictionary<string, int> expectedOccurrences = pb.ExpectedWordformsAndOccurrences;
			CheckExpectedWordformsAndOccurrences(pb.ActualParagraph, expectedOccurrences);
			// replace the german occurrence of "xxkal" with a xkal version.
			int wsDe;
			FdoValidator.GetTssStringValue(tapb, 2, 0, out wsDe);
			int wsVernDef = Cache.DefaultVernWs;
			Assert.AreNotEqual(wsVernDef, wsDe, "Precondition: did not expect to have a default vern ws.");
			pb.ReplaceSegmentForm(2, 0, "xxkal", wsVernDef);
			var segformNode = pb.SegmentFormNode(2, 0);
			// Now it should parse as a wfic.
			var linkNode = segformNode.SelectSingleNode("AnnotationType34/Link");
			linkNode.Attributes["guid"].Value = ParagraphBuilder.WficGuid;
			linkNode.Attributes["name"].Value = "Wordform In Context";

			expectedOccurrences.Remove("xxkal" + wsDe.ToString());
			expectedOccurrences["xxkal" + wsVernDef.ToString()] += 1;
			pb.RebuildParagraphContentFromAnnotations(true);
			pb.ParseParagraph();
			int wsAnalysis2_0;
			FdoValidator.GetTssStringValue(tapb, 2, 0, out wsAnalysis2_0);
			Assert.AreEqual(Cache.DefaultVernWs, wsAnalysis2_0, "Precondition: expected to have default vern ws.");
			FdoValidator.ValidateCbaWordToBaselineWord(tapb, 2, 0);
			// validate the rest.
			tapb.ValidateAnnotations();
			CheckExpectedWordformsAndOccurrences(pb.ActualParagraph, expectedOccurrences);
		}
Ejemplo n.º 5
0
		public void NoAnalyses_NoEdits_PhraseWordforms()
		{
			// 1. Setup Tests with a basic phrase
			ParagraphBuilder pb = new ParagraphBuilder(m_textsDefn, m_text1, (int) Text1ParaIndex.PhraseWordforms);

			// first do a basic phrase (without secondary phrases (guesses))
			// xxxpus xxxyalola xxxnihimbilira. [xxxpus xxxyalola] xxxhesyla xxxnihimbilira. xxxpus xxxyalola xxxnihimbilira
			pb.MergeAdjacentAnnotations(1, 0);
			// generate mock ids
			pb.RebuildParagraphContentFromAnnotations();
			// now produce a guess to establish the phrase annotation.
			var tapb = new ParagraphAnnotatorForParagraphBuilder(pb);
			pb.ParseParagraph();
			pb.ActualParagraph.SegmentsOS[1].AnalysesRS.RemoveAt(0); // delete "xxxpus"
			// now replace "xxxyalola" with the new phrase form "xxxpus xxxyalola"
			IAnalysis beforeParse_phrase1_0 = pb.ExportCbaNodeToReal(1, 0);
			//string gloss;
			//IWfiGloss wg_phrase1_0 = tapb.SetDefaultWordGloss(1, 0, out gloss);
			// NOTE: Precondition checks to make sure we set up the annotation properly

			// The real test: now parse and verify that we maintained the expected result for the phrase annotation.
			pb.ParseParagraph();
			var afterParse_actualWordform = tapb.GetAnalysis(1, 0);
			Assert.AreEqual(beforeParse_phrase1_0, afterParse_actualWordform, "word mismatch");
			// verify the rest.
			tapb.ValidateAnnotations();
		}
Ejemplo n.º 6
0
		public void SparseTwficAnalyses_SimpleEdits_SimpleSegmentParagraph_DuplicateWordforms_AddWhitespace_LT5313()
		{
			CheckDisposed();

			// First set sparse analyses on wordforms that have multiple occurrences.
			ParagraphBuilder pb = new ParagraphBuilder(m_textsDefn, m_text1, (int)Text1ParaIndex.SimpleSegmentPara);
			ParagraphAnnotatorForParagraphBuilder tapb = new ParagraphAnnotatorForParagraphBuilder(pb);
			tapb.SetDefaultWordGloss("xxxyalola", 0);		// gloss first occurrence.
			tapb.SetDefaultWordGloss("xxxpus", 1);			// gloss second occurrence.
			tapb.SetDefaultWordGloss("xxxnihimbilira", 2);	// gloss third occurrence.
			tapb.ValidateAnnotations();
			// Append whitespace in the text, and see if the analyses still show up in the right place
			// (cf. LT-5313).
			pb.ReplaceTrailingWhitepace(0, 0, 1);
			pb.RebuildParagraphContentFromAnnotations();
			tapb.ValidateAnnotations();
		}
Ejemplo n.º 7
0
		public void SparseTwficAnalyses_SimpleEdits_SimpleSegmentParagraph_DuplicateWordforms()
		{
			CheckDisposed();

			// First set sparse analyses on wordforms that have multiple occurrences.
			ParagraphBuilder pb = new ParagraphBuilder(m_textsDefn, m_text1, (int)Text1ParaIndex.SimpleSegmentPara);
			ParagraphAnnotatorForParagraphBuilder tapb = new ParagraphAnnotatorForParagraphBuilder(pb);
			tapb.SetDefaultWordGloss("xxxyalola", 0);		// gloss first occurrence.
			tapb.SetDefaultWordGloss("xxxpus", 1);			// gloss second occurrence.
			tapb.SetDefaultWordGloss("xxxnihimbilira", 2);	// gloss third occurrence.
			tapb.ValidateAnnotations();
			// Replace some occurrences of these wordforms from the text to validate the analysis does not show up on the wrong occurrence.
			// Remove the first occurrence of 'xxxnihimbilira'; the second occurrence should have the gloss.
			pb.ReplaceSegmentForm("xxxnihimbilira", 0, "");
			pb.RebuildParagraphContentFromAnnotations();
			tapb.ValidateAnnotations();
			// Remove first occurrence of 'xxxpus'; the next one should still have the gloss.
			pb.ReplaceSegmentForm("xxxpus", 0, "");
			pb.RebuildParagraphContentFromAnnotations();
			tapb.ValidateAnnotations();
			//SparseTwficAnalyses_SimpleEdits_SimpleSegmentParagraph_DuplicateWordforms_RemoveSegment_LT5376()
			//SparseTwficAnalyses_SimpleEdits_SimpleSegmentParagraph_DuplicateWordforms_AddWhitespace_LT5313()
		}
Ejemplo n.º 8
0
		public void NoAnalyses_SimpleEdits_MultipleWritingSystemsParagraph()
		{
			CheckDisposed();
			ParagraphBuilder pb = new ParagraphBuilder(m_textsDefn, m_text1, (int)Text1ParaIndex.MultipleWritingSystems);
			pb.ParseParagraph(true, true);
			// xxxpus xxes xxxnihimbilira. xxfr xxen xxxnihimbilira xxxpus xxde. xxkal xxkal xxxxhesyla xxxxhesyla.
			//	xxkal: German (de)		-- occurrence 0
			//	xxkal: Kalaba (xkal)	-- occurrence 1
			Dictionary<string, int> expectedOccurrences = pb.ExpectedWordformsAndOccurrences;
			WordformInventory wfi = Cache.LangProject.WordformInventoryOA as WordformInventory;
			CheckExpectedWordformsAndOccurrences(wfi, expectedOccurrences);
			// replace the german occurrence of "xxkal" with a xkal version.
			int hvoSeg2 = pb.ActualParagraph.Segments[2];
			int hvoSegForm2_0 = pb.ActualParagraph.SegmentForms(hvoSeg2)[0];
			StTxtPara.TwficInfo ti2_0 = new StTxtPara.TwficInfo(Cache, hvoSegForm2_0);
			int wsDe = StringUtils.GetWsAtOffset(pb.ActualParagraph.Contents.UnderlyingTsString, ti2_0.Object.BeginOffset);
			int wsVernDef = Cache.DefaultVernWs;
			Assert.AreNotEqual(wsVernDef, wsDe, "did not expect to have a default vern ws.");
			pb.ReplaceSegmentForm(2, 0, "xxkal", wsVernDef);
			expectedOccurrences.Remove("xxkal" + wsDe.ToString());
			expectedOccurrences["xxkal" + wsVernDef.ToString()] += 1;
			pb.RebuildParagraphContentFromAnnotations(true, true);
			CheckExpectedWordformsAndOccurrences(wfi, expectedOccurrences);
		}