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


C# Parse.Add方法代码示例

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


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

示例1: BranchesAreAdded

 public void BranchesAreAdded()
 {
     var parse = new Parse("tr", string.Empty, null, null);
     parse.Add(new Parse("td", "first", null, null));
     Assert.AreEqual("first", parse.Parts.Body);
     parse.Add(new Parse("td", "second", null, null));
     Assert.AreEqual("second", parse.Parts.More.Body);
     parse.Add(new Parse("td", "third", null, null));
     Assert.AreEqual("third", parse.Parts.Last.Body);
 }
开发者ID:kpartusch,项目名称:fitsharp,代码行数:10,代码来源:ParseTest.cs

示例2: MakeCell

 public override Tree<Cell> MakeCell(string text, string tag, IEnumerable<Tree<Cell>> branches) {
     var result = new Parse(tag, text, null, null);
     foreach (var branch in branches) {
         result.Add(branch);
     }
     return result;
 }
开发者ID:GibSral,项目名称:fitsharp,代码行数:7,代码来源:Service.cs

示例3: MakeCell

 public override Tree<Cell> MakeCell(string text, string tag, IEnumerable<Tree<Cell>> branches)
 {
     var result = new Parse(new CellBase(text));
     if (!string.IsNullOrEmpty(tag)) result.Value.SetTag(tag);
     if (!string.IsNullOrEmpty(text)) result.Value.SetAttribute(CellAttribute.Body, text);
     foreach (var branch in branches) {
         result.Add(branch);
     }
     return result;
 }
开发者ID:jediwhale,项目名称:fitsharp,代码行数:10,代码来源:Service.cs

示例4: AddParseEvents

        /// <summary>
        /// Produces all events for the specified sentence chunks and adds them to the specified list.
        /// </summary>
        /// <param name="newEvents">A list of events to be added to.</param>
        /// <param name="chunks">Pre-chunked constituents of a sentence.</param>
        protected override void AddParseEvents(List<Event> newEvents, Parse[] chunks) {
            /** Frontier nodes built from node in a completed parse.  Specifically,
              * they have all their children regardless of the stage of parsing.*/

            var rightFrontier = new List<Parse>();
            var builtNodes = new List<Parse>();

            /** Nodes which characterize what the parse looks like to the parser as its being built.
             * Specifically, these nodes don't have all their children attached like the parents of
             * the chunk nodes do.*/
            var currentChunks = new Parse[chunks.Length];
            for (var ci = 0; ci < chunks.Length; ci++) {
                currentChunks[ci] = (Parse) chunks[ci].Clone();
                currentChunks[ci].PreviousPunctuationSet = chunks[ci].PreviousPunctuationSet;
                currentChunks[ci].NextPunctuationSet = chunks[ci].NextPunctuationSet;
                currentChunks[ci].Label = AbstractBottomUpParser.COMPLETE;
                chunks[ci].Label = AbstractBottomUpParser.COMPLETE;
            }
            for (var ci = 0; ci < chunks.Length; ci++) {
                //System.err.println("parserEventStream.addParseEvents: chunks="+Arrays.asList(chunks));
                var parent = chunks[ci].Parent;
                var prevParent = chunks[ci];
                
                //var off = 0;
                //build un-built parents
                if (!chunks[ci].IsPosTag) {
                    builtNodes.Add(chunks[ci]);
                    //builtNodes[off++] = chunks[ci];
                }

                //perform build stages
                while (parent.Type != AbstractBottomUpParser.TOP_NODE && parent.Label == null) {
                    if (parent.Label == null && prevParent.Type != parent.Type) {
                        //build level
                        // if (debug) System.err.println("Build: " + parent.Type + " for: " + currentChunks[ci]);
                        if (Type == ParserEventTypeEnum.Build) {
                            newEvents.Add(new Event(parent.Type, buildContextGenerator.GetContext(currentChunks, ci)));
                        }
                        builtNodes.Add(parent);
                        //builtNodes[off++] = parent;
                        var newParent = new Parse(currentChunks[ci].Text, currentChunks[ci].Span, parent.Type, 1, 0);
                        newParent.Add(currentChunks[ci], Rules);
                        newParent.PreviousPunctuationSet = currentChunks[ci].PreviousPunctuationSet;
                        newParent.NextPunctuationSet = currentChunks[ci].NextPunctuationSet;
                        currentChunks[ci].Parent = newParent;
                        currentChunks[ci] = newParent;
                        newParent.Label = Parser.BUILT;

                        //see if chunk is complete
                        if (LastChild(chunks[ci], parent)) {
                            if (Type == ParserEventTypeEnum.Check) {
                                newEvents.Add(new Event(AbstractBottomUpParser.COMPLETE,
                                    checkContextGenerator.GetContext(currentChunks[ci], currentChunks, ci, false)));
                            }
                            currentChunks[ci].Label = AbstractBottomUpParser.COMPLETE;
                            parent.Label = AbstractBottomUpParser.COMPLETE;
                        } else {
                            if (Type == ParserEventTypeEnum.Check) {
                                newEvents.Add(new Event(AbstractBottomUpParser.INCOMPLETE,
                                    checkContextGenerator.GetContext(currentChunks[ci], currentChunks, ci, false)));
                            }
                            currentChunks[ci].Label = AbstractBottomUpParser.INCOMPLETE;
                            parent.Label = AbstractBottomUpParser.COMPLETE;
                        }

                        chunks[ci] = parent;
                        //System.err.println("build: "+newParent+" for "+parent);
                    }
                    //TODO: Consider whether we need to set this label or train parses at all.

                    parent.Label = Parser.BUILT;
                    prevParent = parent;
                    parent = parent.Parent;
                }
                //decide to attach
                if (Type == ParserEventTypeEnum.Build) {
                    newEvents.Add(new Event(Parser.DONE, buildContextGenerator.GetContext(currentChunks, ci)));
                }
                //attach node
                string attachType = null;
                /** Node selected for attachment. */
                Parse attachNode = null;
                var attachNodeIndex = -1;
                if (ci == 0) {
                    var top = new Parse(currentChunks[ci].Text, new Span(0, currentChunks[ci].Text.Length),
                        AbstractBottomUpParser.TOP_NODE, 1, 0);
                    top.Insert(currentChunks[ci]);
                } else {
                    /** Right frontier consisting of partially-built nodes based on current state of the parse.*/
                    var currentRightFrontier = Parser.GetRightFrontier(currentChunks[0], Punctuation);
                    if (currentRightFrontier.Count != rightFrontier.Count) {
                        throw new InvalidOperationException("frontiers mis-aligned: " + currentRightFrontier.Count +
                                                            " != " + rightFrontier.Count + " " + currentRightFrontier +
                                                            " " + rightFrontier);
                        //System.exit(1);
//.........这里部分代码省略.........
开发者ID:lovethisgame,项目名称:SharpNL,代码行数:101,代码来源:ParserEventStream.cs


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