def loadparsers(): """Load grammars if necessary.""" if not PARSERS: for directory in glob.glob('grammars/*/'): _, lang = os.path.split(os.path.dirname(directory)) APP.logger.info('Loading grammar %r', lang) params = readparam(os.path.join(directory, 'params.prm')) params.resultdir = directory readgrammars(directory, params.stages, params.postagging, top=getattr(params, 'top', 'ROOT')) PARSERS[lang] = Parser(params) APP.logger.info('Grammar for %s loaded.', lang) assert PARSERS, 'no grammars found!'
def loadparsers(): """Load grammars if necessary.""" if not PARSERS: for directory in glob.glob('grammars/*/'): _, lang = os.path.split(os.path.dirname(directory)) APP.logger.info('Loading grammar %r', lang) params = readparam(os.path.join(directory, 'params.prm')) params.resultdir = directory readgrammars(directory, params.stages, params.postagging, params.transformations, top=getattr(params, 'top', 'ROOT')) PARSERS[lang] = Parser(params) APP.logger.info('Grammar for %s loaded.', lang) assert PARSERS, 'no grammars found!'
def loadgrammar(directory, limit): """Load grammar""" global PARSER, LIMIT params = readparam(os.path.join(directory, 'params.prm')) params.resultdir = directory readgrammars(directory, params.stages, params.postagging, params.transformations, top=getattr(params, 'top', 'ROOT'), cache=True) PARSER = Parser(params, loadtrees=True) LIMIT = limit print('phrasal labels', PARSER.phrasallabels) print('pos tags', PARSER.poslabels) print('function tags', PARSER.functiontags) print('morph tags', PARSER.morphtags)