Exemplo n.º 1
0
        private void ParseTextIntoSentences(string sText)
        {
            int iIndex = 0;
            int iBegin = 0;

            while (iBegin >= 0)
            {
                XmlNode sentenceNode = GetNextSentence(sText, ref iBegin);
                if (sentenceNode != null)
                {
                    PcPatrSentence sentence = new PcPatrSentence(sentenceNode);
                    m_aSentences.SetValue(sentence, iIndex++);
                }
            }
        }
Exemplo n.º 2
0
 private void CheckLoadAnaFile(string sFile, int iExpectedCount, int iExpectedCountOfParsesInFirstSentence, out PcPatrDocument doc, out PcPatrSentence sentence, out string sGrammarFile)
 {
     doc = new PcPatrDocument(sFile, out sGrammarFile);
     Assert.IsNotNull(doc.Sentences, "no sentences found in " + sFile);
     Assert.AreEqual(iExpectedCount, doc.Sentences.Length, sFile + " has " + iExpectedCount.ToString() + " Sentences");
     sentence = doc.FirstSentence;
     Assert.IsNotNull(sentence, "could not get first sentence in " + sFile);
     Assert.IsNotNull(sentence.Parses, "no parses found in 1st sentence of " + sFile);
     Assert.AreEqual(iExpectedCountOfParsesInFirstSentence, sentence.Parses.Length, sFile + " has " + iExpectedCountOfParsesInFirstSentence.ToString() + " parses in first sentence");
 }
Exemplo n.º 3
0
 private void CheckLoadAnaFile(string sFile, int iExpectedCount, int iExpectedCountOfParsesInFirstSentence, out PcPatrDocument doc, out PcPatrSentence sentence, out string sGrammarFile)
 {
     doc = new PcPatrDocument(sFile, out sGrammarFile);
     Assert.IsNotNull(doc.Sentences, "no sentences found in " + sFile);
     Assert.AreEqual(iExpectedCount, doc.Sentences.Length, sFile + " has " + iExpectedCount.ToString() + " Sentences");
     sentence = doc.FirstSentence;
     Assert.IsNotNull(sentence, "could not get first sentence in " + sFile);
     Assert.IsNotNull(sentence.Parses, "no parses found in 1st sentence of " + sFile);
     Assert.AreEqual(iExpectedCountOfParsesInFirstSentence, sentence.Parses.Length, sFile + " has " + iExpectedCountOfParsesInFirstSentence.ToString() + " parses in first sentence");
 }
Exemplo n.º 4
0
 private void UpdateStatusBar(PcPatrSentence sentence)
 {
     if (m_doc != null)
     {
         sbpnlSentence.Text = "Sentence " + m_doc.CurrentSentenceNumber.ToString() + " of " + m_doc.NumberOfSentences.ToString();
         if (sentence != null)
         {
             if (sentence.CurrentParse == null)
                 sbpnlParse.Text = m_ksNoParses;
             else
                 sbpnlParse.Text = "Parse " + sentence.CurrentParseNumber.ToString() + " of " + sentence.NumberOfParses.ToString();
         }
     }
 }
Exemplo n.º 5
0
        private void ShowTree(XmlDocument treeDoc, XmlNode xmlTree, PcPatrSentence sentence)
        {
            m_tree.Visible = true;
            m_tree.Enabled = true;
            m_tree.UseRightToLeft = miViewRightToLeft.Checked;
            m_tree.SetTreeParameters(treeDoc);
            m_tree.ParseXmlTreeDescription(xmlTree);
            m_tree.MessageText = "Parse " + sentence.CurrentParseNumber.ToString() + " of " + sentence.NumberOfParses.ToString();
            Graphics grfx = CreateGraphics();
            m_tree.CalculateCoordinates(grfx);
            m_tree.Draw(grfx, Color.Black);

            m_tree.Invalidate();
            pnlTree.Invalidate();
        }
Exemplo n.º 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);
        }
Exemplo n.º 7
0
        private void ShowInterlinear(PcPatrSentence sentence)
        {
            if (sentence == null)
            {
                ReportNoInterlinear();
                return;
            }
            XmlNode node = sentence.Node;
            XmlNode interlinear = node.SelectSingleNode("//Input");
            if (interlinear == null)
            {
                ReportNoInterlinear();
                return;
            }

            XmlDocument doc1 = new XmlDocument();
            doc1.LoadXml(interlinear.OuterXml);
            XmlNode format = doc1.SelectSingleNode("//Format");
            if (format != null)
            {
                string sBefore = format.InnerText;
                if (sBefore != null)
                {
                    string sAfter = sBefore.Replace("\\n", "\n");
                    format.InnerText = sAfter;
                }
            }
            XPathNavigator nav = doc1.CreateNavigator();

            XmlTextWriter writer = new XmlTextWriter(m_sInterFile, null);
            XsltArgumentList argList = new XsltArgumentList();
            argList.AddParam("sTextMessage", "", "Sentence " + m_doc.CurrentSentenceNumber.ToString() + " of " + m_doc.NumberOfSentences.ToString());
            argList.AddParam("bRightToLeft", "", miViewRightToLeft.Checked ? "Y" : "N");
            argList.AddParam("sDecompSeparationCharacter", "", m_language.DecompChar);
            argList.AddParam("sCategoryFont", "", m_language.NTFontFace);
            argList.AddParam("sDecompFont", "", m_language.LexFontFace);
            argList.AddParam("sFeatDescFont", "", m_language.NTFontFace);
            argList.AddParam("sFormatFont", "", m_language.NTFontFace);
            argList.AddParam("sGlossFont", "", m_language.GlossFontFace);
            argList.AddParam("sOrigWordFont", "", m_language.LexFontFace);
            argList.AddParam("sUnderFormFont", "", m_language.LexFontFace);
            m_interlinearTransform.Transform(nav, argList, writer, null);
            writer.Close();

            this.wbInterlinear.Navigate(m_sInterFile);
        }
Exemplo n.º 8
0
 private void ParseTextIntoSentences(string sText)
 {
     int iIndex = 0;
     int iBegin = 0;
     while (iBegin >= 0)
     {
         XmlNode sentenceNode = GetNextSentence(sText, ref iBegin);
         if (sentenceNode != null)
         {
             PcPatrSentence sentence = new PcPatrSentence(sentenceNode);
             m_aSentences.SetValue(sentence, iIndex++);
         }
     }
 }