class_docstr: Chart parser for CCGs.
  Based largely on the ChartParser class from NLTK.
class_docstr_tok: ["Chart","parser","for","CCGs",".","Based","largely","on","the","ChartParser","class","from","NLTK","."]
code: def parse(self, tokens):
      tokens = list(tokens)
      chart = CCGChart(list(tokens))
      lex = self._lexicon
  
      # Initialize leaf edges.
      for index in range(chart.num_leaves()):
          for token in lex.categories(chart.leaf(index)):
              new_edge = CCGLeafEdge(index, token, chart.leaf(index))
              chart.insert(new_edge, ())
  
      # Select a span for the new edges
      for span in range(2, chart.num_leaves() + 1):
          for start in range(0, chart.num_leaves() - span + 1):
              # Try all possible pairs of edges that could generate
              # an edge for that span
              for part in range(1, span):
                  lstart = start
                  mid = start + part
                  rend = start + span
  
                  for left in chart.select(span=(lstart, mid)):
                      for right in chart.select(span=(mid, rend)):
                          # Generate all possible combinations of the two edges
                          for rule in self._rules:
                              edges_added_by_rule = 0
                              for newedge in rule.apply(
                                  chart, lex, left, right
                              ):
                                  edges_added_by_rule += 1
  
      # Output the resulting parses
      return chart.parses(lex.start())
  
imports: import itertools
  from nltk.ccg.combinator import *
  from nltk.ccg.combinator import BackwardApplication, BackwardBx, BackwardComposition, BackwardSx, BackwardT, ForwardApplication, ForwardComposition, ForwardSubstitution, ForwardT
  from nltk.ccg.lexicon import Token, fromstring
  from nltk.ccg.logic import *
  from nltk.parse import ParserI
  from nltk.parse.chart import AbstractChartRule, Chart, EdgeI
  from nltk.sem.logic import *
  from nltk.tree import Tree
label_desc: Use image node_id 3 for calling the CCGChartParser obj's underlying member method code with example usage: obj.parse(tokens) and returns: chart