def load_parser(grammar_url, trace=0, parser=None, chart_class=None, beam_size=0, **load_args):
 grammar = load(grammar_url, **load_args)
 if (not isinstance(grammar, CFG)):
  raise ValueError('The grammar must be a CFG, or a subclass thereof.')
 if isinstance(grammar, PCFG):
  if (parser is None):
   parser = InsideChartParser
  return parser(grammar, trace=trace, beam_size=beam_size)
 elif isinstance(grammar, FeatureGrammar):
  if (parser is None):
   parser = FeatureChartParser
  if (chart_class is None):
   chart_class = FeatureChart
  return parser(grammar, trace=trace, chart_class=chart_class)
 else:
  if (parser is None):
   parser = ChartParser
  if (chart_class is None):
   chart_class = Chart
  return parser(grammar, trace=trace, chart_class=chart_class)

def load_parser ( grammar_url , trace = 0 , parser = None , chart_class = None , beam_size = 0 , ** load_args ) : grammar = load ( grammar_url , ** load_args ) if ( not isinstance ( grammar , CFG ) ) : raise ValueError ( 'The grammar must be a CFG, or a subclass thereof.' ) if isinstance ( grammar , PCFG ) : if ( parser is None ) : parser = InsideChartParser return parser ( grammar , trace = trace , beam_size = beam_size ) elif isinstance ( grammar , FeatureGrammar ) : if ( parser is None ) : parser = FeatureChartParser if ( chart_class is None ) : chart_class = FeatureChart return parser ( grammar , trace = trace , chart_class = chart_class ) else : if ( parser is None ) : parser = ChartParser if ( chart_class is None ) : chart_class = Chart return parser ( grammar , trace = trace , chart_class = chart_class )
load a grammar from a file .