protected void ValidateExportedParagraph(XmlDocument exportedXml, InterlinLineChoices choices, IStTxtPara para) { ExportedInterlinearReader exportReader = new ExportedInterlinearReader(exportedXml, choices); ExportedParagraphValidator validator = new ExportedParagraphValidator(exportReader, para); validator.ValidateParagraphs(para, exportReader.GetParaNode(para.IndexInOwner)); }
internal ExportedParagraphValidator(ExportedInterlinearReader reader, IStTxtPara para) { m_reader = reader; m_choices = reader.Choices; m_para = para; m_cache = m_para.Cache; }
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); }
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); }
internal ExportedParagraphValidatorForELAN(ExportedInterlinearReader reader, IStTxtPara para) : base(reader, para) { }