Example #1
0
        private void SplitIntoParses()
        {
            int     iIndex    = 0;
            XmlNode parseNode = GetNextParseInSentence(m_node, iIndex);

            while (parseNode != null)
            {
                PcPatrParse parse = new PcPatrParse(parseNode);
                m_aParses.SetValue(parse, iIndex);
                iIndex++;
                parseNode = GetNextParseInSentence(m_node, iIndex);
            }
        }
Example #2
0
        public void LoadSimpleAnaFile()
        {
            PcPatrDocument doc;
            PcPatrSentence sentence;
            string         sFile = Path.Combine(m_ksTestData, "Simple.ana");
            string         sGrammarFile;

            CheckLoadAnaFile(sFile, 1, 1, out doc, out sentence, out sGrammarFile);
            Assert.IsNull(sGrammarFile, "Expect grammar file of Simple.ana to be null");
            CheckSentenceInAna(m_sSimpleSentenceXml, sentence.Node, "Simple");
            PcPatrParse parse = sentence.FirstParse;

            CheckParseInSentence(m_sSimpleSentenceParseXml, parse.Node, 1, 1, "Simple");
        }
Example #3
0
        public void LoadComplexAnaFile()
        {
            PcPatrDocument doc;
            PcPatrSentence sentence;
            string         sFile = Path.Combine(m_ksTestData, "Complex.ana");
            string         sGrammarFile;

            CheckLoadAnaFile(sFile, 1, 4, out doc, out sentence, out sGrammarFile);
            Assert.IsNull(sGrammarFile, "Expect grammar file of Complex.ana to be null");
            CheckSentenceInAna(m_sComplexSentenceXml, sentence.Node, "Complex");
            PcPatrParse parse = sentence.FirstParse;

            CheckParseInSentence(m_sComplexSentenceParseOneXml, parse.Node, 1, 1, "Complex");
            parse = sentence.NextParse;
            CheckParseInSentence(m_sComplexSentenceParseTwoXml, parse.Node, 1, 2, "Complex");
            parse = sentence.GoToParse(2);
            CheckParseInSentence(m_sComplexSentenceParseTwoXml, parse.Node, 1, 2, "Complex");
        }
Example #4
0
        public void GetFeatureStructuresBasedOnId()
        {
            PcPatrDocument doc;
            PcPatrSentence sentence;
            string         sFile = Path.Combine(m_ksTestData, "Simple.ana");
            string         sGrammarFile;

            CheckLoadAnaFile(sFile, 1, 1, out doc, out sentence, out sGrammarFile);
            Assert.IsNull(sGrammarFile, "Expect grammar file of Simple.ana to be null");
            CheckSentenceInAna(m_sSimpleSentenceXml, sentence.Node, "Simple");
            PcPatrParse parse = sentence.FirstParse;

            m_app.Parse = parse;

            CheckFeatureStructureAtId("_1._1", "SimpleSentenceParseId_1._1.xml");
            CheckFeatureStructureAtId("_1._14", "SimpleSentenceParseId_1._14.xml");
            CheckFeatureStructureAtId("_1._25", "SimpleSentenceParseId_1._25.xml");
            CheckFeatureStructureAtId("_1._25lex", "SimpleSentenceParseId_1._25Lexfs.xml");
            CheckFeatureStructureAtId("_1._25gloss", "SimpleSentenceParseId_1._25Lexfs.xml");
        }
Example #5
0
        public void LoadMultiAnaFile()
        {
            PcPatrDocument doc;
            PcPatrSentence sentence;
            string         sFile = Path.Combine(m_ksTestData, "MultiSentences.ana");
            string         sGrammarFile;

            CheckLoadAnaFile(sFile, 34, 4, out doc, out sentence, out sGrammarFile);
            Assert.AreEqual(@"..\..\testdata\calpatr2.grm", sGrammarFile, "Grammar file from Multi");
            CheckSentenceInAna(m_sMultiSentencesSentenceOneXml, sentence.Node, "Multi");
            PcPatrParse parse = sentence.FirstParse;

            CheckParseInSentence(m_sMultiSentencesSentenceOneParseOneXml, parse.Node, 1, 1, "Multi");
            parse = sentence.NextParse;
            CheckParseInSentence(m_sMultiSentencesSentenceOneParseTwoXml, parse.Node, 1, 2, "Multi");

            // Test next sentence
            // get 9th sentence
            for (int i = 1; i < 9; i++)
            {
                Assert.AreEqual(i, doc.CurrentSentenceNumber, "Current Sentence Number");
                sentence = doc.NextSentence;
            }
            parse = sentence.FirstParse;
            CheckParseInSentence(m_sMultiSentencesSentenceNineParseOneXml, parse.Node, 9, 1, "Multi");
            Assert.AreEqual(1, sentence.CurrentParseNumber, "Current Parse Number");
            parse = sentence.NextParse;
            CheckParseInSentence(m_sMultiSentencesSentenceNineParseTwoXml, parse.Node, 9, 2, "Multi");
            Assert.AreEqual(2, sentence.CurrentParseNumber, "Current Parse Number");

            // Test previous sentence
            // get first sentence
            for (int i = 1; i < 9; i++)
            {
                sentence = doc.PreviousSentence;
            }
            CheckSentenceInAna(m_sMultiSentencesSentenceOneXml, sentence.Node, "Multi sent 1");
            parse = sentence.FirstParse;
            CheckParseInSentence(m_sMultiSentencesSentenceOneParseOneXml, parse.Node, 1, 1, "Multi sent 1 parse 1");
            parse = sentence.NextParse;
            CheckParseInSentence(m_sMultiSentencesSentenceOneParseTwoXml, parse.Node, 1, 2, "Multi setn 1 parse 2");

            // Test last sentence
            sentence = doc.LastSentence;
            CheckSentenceInAna(m_sMultiSentencesSentenceLastXml, sentence.Node, "Multi");

            // Test go to sentence
            // go to 9th sentence
            sentence = doc.GoToSentence(9);
            parse    = sentence.FirstParse;
            CheckParseInSentence(m_sMultiSentencesSentenceNineParseOneXml, parse.Node, 9, 1, "Multi");

            sentence = doc.GoToSentence(1);             // get first
            CheckSentenceInAna(m_sMultiSentencesSentenceOneXml, sentence.Node, "Multi");
            sentence = doc.GoToSentence(-1);            // too small; get first
            CheckSentenceInAna(m_sMultiSentencesSentenceOneXml, sentence.Node, "Multi");

            sentence = doc.GoToSentence(38);             // get last
            CheckSentenceInAna(m_sMultiSentencesSentenceLastXml, sentence.Node, "Multi");
            sentence = doc.GoToSentence(100);            // too large; return last
            CheckSentenceInAna(m_sMultiSentencesSentenceLastXml, sentence.Node, "Multi");
        }
Example #6
0
        private void ShowParseTree(PcPatrSentence sentence, PcPatrParse parse)
        {
            m_parse = parse;
            if (sentence.Parses.Length > 0 && parse != null)
            {
                XmlNode node = parse.Node;

                if (node != null)
                {
                    XmlDocument treeDoc = MakeTreeDocFromNode(node);
                    XmlNode xmlTree = treeDoc.SelectSingleNode("//TreeDescription/node");
                    ShowTree(treeDoc, xmlTree, sentence);
                }
            }
            else
            {
                m_tree.Root = null;
                m_tree.Invalidate();
            }
            EnableDisableItems();
            UpdateStatusBar(sentence);
            wbFeatureStructure.Navigate(m_sInitFeatureMessagePath);
        }
Example #7
0
 private void SplitIntoParses()
 {
     int iIndex = 0;
     XmlNode parseNode = GetNextParseInSentence(m_node, iIndex);
     while (parseNode != null)
     {
         PcPatrParse parse = new PcPatrParse(parseNode);
         m_aParses.SetValue(parse, iIndex);
         iIndex++;
         parseNode = GetNextParseInSentence(m_node, iIndex);
     }
 }