Displays this parse using Penn Treebank-style formatting.
493646
public void show() {
    final StringBuffer sb = new StringBuffer(this.text.length() * 4);
    show(sb);
    System.out.println(sb);
  }
712756
def dumptree(self, pn):
        
        page = self.readpage(pn)
        print("%06x: preceeding = %06x, reccount = %04x" % (pn, page.preceeding, page.count))
        for ent in page.index:
            print("    %s" % ent)
        if page.preceeding:
            self.dumptree(page.preceeding)
            for ent in page.index:
                self.dumptree(ent.page)
439424
def _pprint(dic):
    """"""
    for key, value in dic.items():
        print("        {0}: {1}".format(key, value))
939004
def display(self, ret, indent, prefix, out):
        '''
        
        '''
        if isinstance(ret, six.string_types):
            lines = ret.split('\n')
            for line in lines:
                out += '{0}{1}{2}{3}{4}\n'.format(
                        self.colors['RED'],
                        ' ' * indent,
                        prefix,
                        line,
                        self.colors['ENDC'])
        elif isinstance(ret, dict):
            for key in sorted(ret):
                val = ret[key]
                out += '{0}{1}{2}{3}{4}:\n'.format(
                        self.colors['CYAN'],
                        ' ' * indent,
                        prefix,
                        key,
                        self.colors['ENDC'])
                out = self.display(val, indent + 4, '', out)
        return out
463132
function tree (toc, tpl) {
  if ( tpl === void 0 ) tpl = '';

  if (!toc || !toc.length) { return '' }

  toc.forEach(function (node) {
    tpl += "<li><a class=\"section-link\" href=\"" + (node.slug) + "\">" + (node.title) + "</a></li>";
    if (node.children) {
      tpl += "<li><ul class=\"children\">" + (tree(node.children)) + "</li></ul>";
    }
  });

  return tpl
}
948986
private ParseTree parseTryStatement() {
    SourcePosition start = getTreeStartLocation();
    eat(TokenType.TRY);
    ParseTree body = parseBlock();
    ParseTree catchBlock = null;
    if (peek(TokenType.CATCH)) {
      catchBlock = parseCatch();
    }
    ParseTree finallyBlock = null;
    if (peek(TokenType.FINALLY)) {
      finallyBlock = parseFinallyBlock();
    }
    if (catchBlock == null && finallyBlock == null) {
      reportError("'catch' or 'finally' expected.");
    }
    return new TryStatementTree(getTreeLocation(start), body, catchBlock, finallyBlock);
  }
1147211
private void parse(String text, int start, int valueStart, int valueStop, int dictStart, int dictStop)
   {
      m_field = text.substring(start, valueStart);
      if (valueStop - valueStart <= 1)
      {
         m_value = null;
      }
      else
      {
         m_value = text.substring(valueStart + 1, valueStop);
      }
      if (dictStop - dictStart > 1)
      {
         for (int s = getNextOpeningParenthesisPosition(text, dictStart); s >= 0 && s < dictStop;)
         {
            int e = getClosingParenthesisPosition(text, s);
            m_records.add(new Record(text, s, e));
            s = getNextOpeningParenthesisPosition(text, e);
         }
      }
   }
37380
def display(result, stream):
    
    if result is None:
        return
    elif isinstance(result, basestring):
        pass
    elif isinstance(result, collections.Mapping):
        result = u'\n'.join(u'%s=%s' % (k, v) for
                            k, v in result.iteritems() if v is not None)
    elif isinstance(result, collections.Iterable):
        result = u'\n'.join(unicode(x) for x in result if x is not None)
    else:
        result = unicode(result)
    stream.write(result.encode('utf8'))
    stream.write('\n')
1076868
def parse_dis_tree(self, dis_tree, indent=0):
        """"""
        tree_type = get_tree_type(dis_tree)
        assert tree_type in SUBTREE_TYPES
        if tree_type == 'Root':
            # replace generic root node with tree root
            old_root_id = self.root
            root_id = get_node_id(dis_tree, self.ns)
            self.root = root_id
            self.add_node(root_id)
            self.remove_node(old_root_id)

            children = dis_tree[1:]
            for child in children:
                child_id = get_node_id(child, self.ns)
                self.add_edge(
                    root_id, child_id,
                    #~ attr_dict={self.ns+':rel_type': relation_type},
                    edge_type=EdgeTypes.dominance_relation)

                self.parse_dis_tree(child, indent=indent+1)

        else: # tree_type in ('Nucleus', 'Satellite')
            node_id = get_node_id(dis_tree, self.ns)
            node_type = get_node_type(dis_tree)
            relation_type = get_relation_type(dis_tree)
            if node_type == 'leaf':
                edu_text = get_edu_text(dis_tree[-1])
                self.add_node(node_id, attr_dict={
                    self.ns+':text': edu_text,
                    'label': u'{0}: {1}'.format(node_id, edu_text[:20])})
                if self.tokenized:
                    edu_tokens = edu_text.split()
                    for i, token in enumerate(edu_tokens):
                        token_node_id = '{0}_{1}'.format(node_id, i)
                        self.tokens.append(token_node_id)
                        self.add_node(token_node_id, attr_dict={self.ns+':token': token,
                                                                'label': token})
                        self.add_edge(node_id, '{0}_{1}'.format(node_id, i))

            else: # node_type == 'span'
                self.add_node(node_id, attr_dict={self.ns+':rel_type': relation_type,
                                                  self.ns+':node_type': node_type})
                children = dis_tree[3:]
                child_types = get_child_types(children)

                expected_child_types = set(['Nucleus', 'Satellite'])
                unexpected_child_types = set(child_types).difference(expected_child_types)
                assert not unexpected_child_types, \
                    "Node '{0}' contains unexpected child types: {1}\n".format(
                        node_id, unexpected_child_types)

                if 'Satellite' not in child_types:
                    # span only contains nucleii -> multinuc
                    for child in children:
                        child_node_id = get_node_id(child, self.ns)
                        self.add_edge(node_id, child_node_id, attr_dict={
                            self.ns+':rel_type': relation_type})

                elif len(child_types['Satellite']) == 1 and len(children) == 1:
                    if tree_type == 'Nucleus':
                        child = children[0]
                        child_node_id = get_node_id(child, self.ns)
                        self.add_edge(
                            node_id, child_node_id,
                            attr_dict={self.ns+':rel_type': relation_type},
                            edge_type=EdgeTypes.dominance_relation)
                    else:
                        assert tree_type == 'Satellite'
                        raise NotImplementedError("I don't know how to combine two satellites")

                elif len(child_types['Satellite']) == 1 and len(child_types['Nucleus']) == 1:
                    # standard RST relation, where one satellite is dominated by one nucleus
                    nucleus_index = child_types['Nucleus'][0]
                    satellite_index = child_types['Satellite'][0]

                    nucleus_node_id = get_node_id(children[nucleus_index], self.ns)
                    satellite_node_id = get_node_id(children[satellite_index], self.ns)
                    self.add_edge(node_id, nucleus_node_id, attr_dict={self.ns+':rel_type': 'span'},
                                  edge_type=EdgeTypes.spanning_relation)
                    self.add_edge(nucleus_node_id, satellite_node_id,
                                  attr_dict={self.ns+':rel_type': relation_type},
                                  edge_type=EdgeTypes.dominance_relation)
                else:
                    raise ValueError("Unexpected child combinations: {}\n".format(child_types))

                for child in children:
                    self.parse_dis_tree(child, indent=indent+1)
3750
def _parse_summary(tag, parser, parent):
    
    summary = DocElement(tag, parser, parent)
    parent.docstring.append(summary)
39424
def parse(self):
        
        standard_formatters = re.compile(r'\((.+?)\)', re.IGNORECASE)
        return standard_formatters.findall(self._fmt)
557479
def _parse(self):
        """"""
        while self._cur_token['type'] in (TT.ws, TT.lbreak):
            self._skip_whitespace()
            self._skip_newlines()

        self._data = self._parse_value()

        return self._data
282675
public static void main(String[] args) throws IOException {
    if (args.length == 0) {
      System.err.println("Usage: java opennlp.tools.english.TreebankChunker model < tokenized_sentences");
      System.exit(1);
    }
    TreebankChunker chunker = new TreebankChunker(args[0]);
    java.io.BufferedReader inReader = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
    for (String line = inReader.readLine(); line != null; line = inReader.readLine()) {
      if (line.equals("")) {
        System.out.println();
      }
      else {
        String[] tts = line.split(" ");
        String[] tokens = new String[tts.length];
        String[] tags = new String[tts.length];
        for (int ti=0,tn=tts.length;ti<tn;ti++) {
          String[] tt = tts[ti].split("/");
          tokens[ti]=tt[0];
          tags[ti]=tt[1]; 
        }
        String[] chunks = chunker.chunk(tokens,tags);
        //System.err.println(java.util.Arrays.asList(chunks));
        for (int ci=0,cn=chunks.length;ci<cn;ci++) {
          if (ci > 0 && !chunks[ci].startsWith("I-") && !chunks[ci-1].equals("O")) {
            System.out.print(" ]");
          }            
          if (chunks[ci].startsWith("B-")) {
            System.out.print(" ["+chunks[ci].substring(2));
          }
          /*
           else {
           System.out.print(" ");
           }
           */
          System.out.print(" "+tokens[ci]+"/"+tags[ci]);
        }
        if (!chunks[chunks.length-1].equals("O")) {
          System.out.print(" ]");
        }
        System.out.println();
      }
    }
  }
1022355
def _format_subtree(self, subtree):
        """"""
        subtree['children'] = list(subtree['children'].values())
        for child in subtree['children']:
            self._format_subtree(child)
        return subtree
1021467
private ParseTree parseArrayLiteral() {
    // ArrayLiteral :
    //   [ Elisionopt ]
    //   [ ElementList ]
    //   [ ElementList , Elisionopt ]
    //
    // ElementList :
    //   Elisionopt AssignmentOrSpreadExpression
    //   ElementList , Elisionopt AssignmentOrSpreadExpression
    //
    // Elision :
    //   ,
    //   Elision ,

    SourcePosition start = getTreeStartLocation();
    ImmutableList.Builder<ParseTree> elements = ImmutableList.builder();

    eat(TokenType.OPEN_SQUARE);
    Token trailingCommaToken = null;
    while (peek(TokenType.COMMA) || peek(TokenType.SPREAD) || peekAssignmentExpression()) {
      trailingCommaToken = null;
      if (peek(TokenType.COMMA)) {
        elements.add(new NullTree(getTreeLocation(getTreeStartLocation())));
      } else {
        if (peek(TokenType.SPREAD)) {
          recordFeatureUsed(Feature.SPREAD_EXPRESSIONS);
          elements.add(parseSpreadExpression());
        } else {
          elements.add(parseAssignmentExpression());
        }
      }
      if (!peek(TokenType.CLOSE_SQUARE)) {
        trailingCommaToken = eat(TokenType.COMMA);
      }
    }
    eat(TokenType.CLOSE_SQUARE);

    maybeReportTrailingComma(trailingCommaToken);

    return new ArrayLiteralExpressionTree(
        getTreeLocation(start), elements.build());
  }
963465
def parse_string(xml):
    
    string = ""
    # Traverse all the <sentence> elements in the XML.
    dom = XML(xml)
    for sentence in dom(XML_SENTENCE):
        _anchors.clear()     # Populated by calling _parse_tokens().
        _attachments.clear() # Populated by calling _parse_tokens().
        # Parse the language from <sentence language="">.
        language = sentence.get(XML_LANGUAGE, "en")
        # Parse the token tag format from <sentence token="">.
        # This information is returned in TokenString.tags,
        # so the format and order of the token tags is retained when exporting/importing as XML.
        format = sentence.get(XML_TOKEN, [WORD, POS, CHUNK, PNP, REL, ANCHOR, LEMMA])
        format = not isinstance(format, basestring) and format or format.replace(" ","").split(",")
        # Traverse all <chunk> and <chink> elements in the sentence.
        # Find the <word> elements inside and create tokens.
        tokens = []
        for chunk in sentence:
            tokens.extend(_parse_tokens(chunk, format))
        # Attach PNP's to their anchors.
        # Keys in _anchors have linked anchor chunks (each chunk is a list of tokens).
        # The keys correspond to the keys in _attachments, which have linked PNP chunks.
        if ANCHOR in format:
            A, P, a, i = _anchors, _attachments, 1, format.index(ANCHOR)
            for id in sorted(A.keys()):
                for token in A[id]:
                    token[i] += "-"+"-".join(["A"+str(a+p) for p in range(len(P[id]))])
                    token[i]  = token[i].strip("O-")
                for p, pnp in enumerate(P[id]):
                    for token in pnp: 
                        token[i] += "-"+"P"+str(a+p)
                        token[i]  = token[i].strip("O-")
                a += len(P[id])
        # Collapse the tokens to string.
        # Separate multiple sentences with a new line.
        tokens = ["/".join([tag for tag in token]) for token in tokens]
        tokens = " ".join(tokens)
        string += tokens + "\n"
    # Return a TokenString, which is a unicode string that transforms easily
    # into a plain str, a list of tokens, or a Sentence.
    try:
        if MBSP: from mbsp import TokenString
        return TokenString(string.strip(), tags=format, language=language)
    except:
        return TaggedString(string.strip(), tags=format, language=language)
131546
def show_formats():
    
    fmts = {
        "ann": "Kvis annotation",
        "reg": "DS9 regions file",
        "fits": "FITS Binary Table",
        "csv": "Comma separated values",
        "tab": "tabe separated values",
        "tex": "LaTeX table format",
        "html": "HTML table",
        "vot": "VO-Table",
        "xml": "VO-Table",
        "db": "Sqlite3 database",
        "sqlite": "Sqlite3 database"}
    supported = get_table_formats()
    print("Extension |     Description       | Supported?")
    for k in sorted(fmts.keys()):
        print("{0:10s} {1:24s} {2}".format(k, fmts[k], k in supported))
    return