当前位置: 首页>>代码示例>>C#>>正文


C# Word.SetSRL方法代码示例

本文整理汇总了C#中Word.SetSRL方法的典型用法代码示例。如果您正苦于以下问题:C# Word.SetSRL方法的具体用法?C# Word.SetSRL怎么用?C# Word.SetSRL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Word的用法示例。


在下文中一共展示了Word.SetSRL方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddSentence


//.........这里部分代码省略.........
            {
                throw new Exception(LtpServiceError.AddSentenceNoteMissMatchError);
            }

            if (m_listParas.Count == 0)
            {
                Word w = wordList[0];
                // if the xmlDocument is empty, paragraphIdx should be zero
                m_xmlNote.SetAttribute(LTPTag.NOTE_SENT, "y");
                if (w.HasWS())
                {
                    m_xmlNote.SetAttribute(LTPTag.NOTE_WORD, "y");
                }
                if (w.HasPOS())
                {
                    m_xmlNote.SetAttribute(LTPTag.NOTE_POS, "y");
                }
                if (w.HasNE())
                {
                    m_xmlNote.SetAttribute(LTPTag.NOTE_NE, "y");
                }
                if (w.HasWSD())
                {
                    m_xmlNote.SetAttribute(LTPTag.NOTE_WSD, "y");
                }
                if (w.HasParser())
                {
                    m_xmlNote.SetAttribute(LTPTag.NOTE_PARSER, "y");
                }
            }
            String strSentence = String.Empty;
            foreach (Word w in wordList)
            {
                if (CheckWordMatch(w) == false)
                {
                    return;
                    //throw new Exception("AddSentence error: Some word's attribute mismatch !");
                }
                strSentence = strSentence + w.XmlElem.GetAttribute("cont");
            }

            SetParagraphNumber(paragraphIdx + 1);

            XmlElement xmlParaElement = m_listParas[paragraphIdx].XmlElem;

            XmlNode xmlSentNode = m_xmlDocument.CreateNode(XmlNodeType.Element, "sent", "");
            XmlAttribute xmlSentIdAttribute = m_xmlDocument.CreateAttribute("id");
            xmlSentIdAttribute.Value = m_listParas[paragraphIdx].SentenceList.Count.ToString();
            xmlSentNode.Attributes.Append(xmlSentIdAttribute);
            XmlAttribute xmlSentContAttribute = m_xmlDocument.CreateAttribute("cont");
            xmlSentContAttribute.Value = strSentence;
            xmlSentNode.Attributes.Append(xmlSentContAttribute);
            xmlParaElement.AppendChild(xmlSentNode);

            SentIndex sentIndexCur = new SentIndex();
            sentIndexCur.StrContent = strSentence;
            sentIndexCur.XmlElem = (XmlElement)xmlSentNode;
            int globalSentenceId = m_listParas[paragraphIdx].GlobalSentenceStartId + m_listParas[paragraphIdx].SentenceList.Count;
            m_listParas[paragraphIdx].SentenceList.Add(sentIndexCur);
            m_listSentences.Insert(globalSentenceId, sentIndexCur);
            for (int i = paragraphIdx + 1; i < m_listParas.Count; i++)
            {
                m_listParas[i].GlobalSentenceStartId++;
            }

            int length = wordList.Count;
            for (int i = 0; i < length; i++)
            {
                XmlNode wordNode = m_xmlDocument.CreateNode(XmlNodeType.Element, "word", "");
                xmlSentNode.AppendChild(wordNode);
                XmlElement wordElem = (XmlElement)wordNode;
                wordElem.SetAttribute("id", i.ToString());
                Word curWord = new Word(wordElem);
                if (HasWS())
                {
                    wordElem.SetAttribute(LTPTag.CONT, wordList[i].GetWS());
                }
                if (HasPOS())
                {
                    wordElem.SetAttribute(LTPTag.POS, wordList[i].GetPOS());
                }
                if (HasNE())
                {
                    wordElem.SetAttribute(LTPTag.NE, wordList[i].GetNE());
                }
                if (HasParser())
                {
                    wordElem.SetAttribute(LTPTag.PSR_PARENT, "" + wordList[i].GetParserParent());
                    wordElem.SetAttribute(LTPTag.PSR_RELATE, wordList[i].GetParserRelation());
                }
                if (HasWSD())
                {
                    wordElem.SetAttribute(LTPTag.WSD, wordList[i].GetWSD());
                    wordElem.SetAttribute(LTPTag.WSD_EXP, wordList[i].GetWSDExplanation());
                }
                curWord.SetSRL(wordList[i].GetSRLs());

                m_listSentences[globalSentenceId].WordList.Add(curWord);
            }
        }
开发者ID:kiapper,项目名称:ltp-cloud-sdk,代码行数:101,代码来源:LTML.cs


注:本文中的Word.SetSRL方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。