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(); }
public void Phrase_SimpleEdits_LT6244() { // 1. Make Phrases IList<int[]> secondaryPathsToJoinWords = new List<int[]>(); IList<int[]> secondaryPathsToBreakPhrases = new List<int[]>(); ParagraphBuilder pb = new ParagraphBuilder(m_textsDefn, m_text1, (int)Text1ParaIndex.PhraseWordforms); ParagraphAnnotatorForParagraphBuilder tapb = new ParagraphAnnotatorForParagraphBuilder(pb); pb.ParseParagraph(); // first do a basic phrase (without secondary phrases (guesses)) // xxxpus xxxyalola xxxnihimbilira. xxxpus xxxyalola [xxxhesyla xxxnihimbilira]. xxxpus xxxyalola xxxnihimbilira tapb.MergeAdjacentAnnotations(1, 2, secondaryPathsToJoinWords, secondaryPathsToBreakPhrases); tapb.ValidateAnnotations(true); // edit the second word in the phrase. pb.ReplaceSegmentForm("xxxhesyla xxxnihimbilira", 0, "xxxhesyla xxxra"); pb.BreakPhraseAnnotation(1, 2); // this edit should break the phrase back into words. tapb.ValidateAnnotations(); }
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() }
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); }
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); }