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


C++ Parse::setLabel方法代码示例

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


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

示例1: addParseEvents

                void ParserEventStream::addParseEvents(std::vector<Event*> &parseEvents, Parse chunks[])
                {
                  /// <summary>
                  /// Frontier nodes built from node in a completed parse.  Specifically,
                  /// they have all their children regardless of the stage of parsing.
                  /// </summary>
                  std::vector<Parse*> rightFrontier = std::vector<Parse*>();
                  std::vector<Parse*> builtNodes = std::vector<Parse*>();
                  /// <summary>
                  /// 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.
                  /// </summary>
                  Parse currentChunks[sizeof(chunks) / sizeof(chunks[0])];
                  for (int ci = 0;ci < sizeof(chunks) / sizeof(chunks[0]);ci++)
                  {
                    currentChunks[ci] = static_cast<Parse*>(chunks[ci]->clone());
                    currentChunks[ci]->setPrevPunctuation(chunks[ci]->getPreviousPunctuationSet());
                    currentChunks[ci]->setNextPunctuation(chunks[ci]->getNextPunctuationSet());
                    currentChunks[ci]->setLabel(Parser::COMPLETE);
                    chunks[ci]->setLabel(Parser::COMPLETE);
                  }
                  for (int ci = 0;ci < sizeof(chunks) / sizeof(chunks[0]);ci++)
                  {
                    //System.err.println("parserEventStream.addParseEvents: chunks="+Arrays.asList(chunks));
                    Parse *parent = chunks[ci]->getParent();
                    Parse *prevParent = chunks[ci];
                    int off = 0;
                    //build un-built parents
                    if (!chunks[ci]->isPosTag())
                    {
                      builtNodes.push_back(off++,chunks[ci]);
                    }
                    //perform build stages
                    while (parent->getType() != AbstractBottomUpParser::TOP_NODE && parent->getLabel() == "")
                    {
                      if (parent->getLabel() == "" && prevParent->getType() != parent->getType())
                      {
                        //build level
                        if (debug)
                            System::err::println("Build: " + parent->getType() + " for: " + currentChunks[ci]);
                        if (etype == opennlp::tools::parser::BUILD)
                        {
                          parseEvents.push_back(new Event(parent->getType(), buildContextGenerator->getContext(currentChunks, ci)));
                        }
                        builtNodes.push_back(off++,parent);
                        Parse *newParent = new Parse(currentChunks[ci]->getText(),currentChunks[ci]->getSpan(),parent->getType(),1,0);
                        newParent->add(currentChunks[ci],rules);
                        newParent->setPrevPunctuation(currentChunks[ci]->getPreviousPunctuationSet());
                        newParent->setNextPunctuation(currentChunks[ci]->getNextPunctuationSet());
                        currentChunks[ci]->setParent(newParent);
                        currentChunks[ci] = newParent;
                        newParent->setLabel(Parser::BUILT);
                        //see if chunk is complete
                        if (lastChild(chunks[ci], parent))
                        {
                          if (etype == opennlp::tools::parser::CHECK)
                          {
                            parseEvents.push_back(new Event(Parser::COMPLETE, checkContextGenerator->getContext(currentChunks[ci],currentChunks, ci,false)));
                          }
                          currentChunks[ci]->setLabel(Parser::COMPLETE);
                          parent->setLabel(Parser::COMPLETE);
                        }
                        else
                        {
                          if (etype == opennlp::tools::parser::CHECK)
                          {
                            parseEvents.push_back(new Event(Parser::INCOMPLETE, checkContextGenerator->getContext(currentChunks[ci],currentChunks,ci,false)));
                          }
                          currentChunks[ci]->setLabel(Parser::INCOMPLETE);
                          parent->setLabel(Parser::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->setLabel(Parser::BUILT);
                      prevParent = parent;
                      parent = parent->getParent();
                    }
                    //decide to attach
                    if (etype == opennlp::tools::parser::BUILD)
                    {
                      parseEvents.push_back(new Event(Parser::DONE, buildContextGenerator->getContext(currentChunks, ci)));
                    }
                    //attach node
                    std::string attachType = "";
                    /// <summary>
                    /// Node selected for attachment. </summary>
                    Parse *attachNode = 0;
                    int attachNodeIndex = -1;
                    if (ci == 0)
                    {
                      Parse *top = new Parse(currentChunks[ci]->getText(),new Span(0,currentChunks[ci]->getText()->length()),AbstractBottomUpParser::TOP_NODE,1,0);
                      top->insert(currentChunks[ci]);
                    }
                    else
                    {
                      /// <summary>
//.........这里部分代码省略.........
开发者ID:benlm54,项目名称:myassist-repo,代码行数:101,代码来源:ParserEventStream.cpp


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