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


Python CharniakParser.loadHeadInfoOnly方法代码示例

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


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

示例1: load_parser_model

# 需要导入模块: import CharniakParser [as 别名]
# 或者: from CharniakParser import loadHeadInfoOnly [as 别名]
    def load_parser_model(self, model_dir, terms_only=False,
                          heads_only=False, **parser_options):
        """Load the parsing model from model_dir and set parsing
        options. In general, the default options should suffice but see
        the set_parser_options() method for details. Note that the parser
        does not allow loading multiple models within the same process
        (calling this function twice will raise a RuntimeError).

        If terms_only is True, we will not load the full parsing model,
        just part of speech tag information (intended for tools which
        only call things like Tree.evaluate()). If heads_only is True,
        we will only load head finding information (for things like
        Tree.dependencies(). If both are set to True, both of these will
        be loaded but the full parsing model will not."""
        if RerankingParser._parser_model_loaded:
            raise RuntimeError('Parser is already loaded and can only '
                               'be loaded once.')
        try:
            model_dir = str(model_dir)
        except UnicodeEncodeError:
            raise ValueError('Parser model directory %r must be an ASCII '
                             'string.' % model_dir)
        if not exists(model_dir):
            raise ValueError('Parser model directory %r does not exist.' %
                             model_dir)
        if not (terms_only or heads_only):
            RerankingParser._parser_model_loaded = True
            RerankingParser._parser_heads_loaded = True
            RerankingParser._parser_terms_loaded = True
            self.parser_model_dir = model_dir
            parser.loadModel(model_dir)
            self.set_parser_options(**parser_options)
        else:
            if terms_only:
                RerankingParser._parser_terms_loaded = True
                parser.loadTermsOnly(model_dir)
            if heads_only:
                RerankingParser._parser_heads_loaded = True
                parser.loadHeadInfoOnly(model_dir)
开发者ID:pkclaus,项目名称:bllip-parser,代码行数:41,代码来源:RerankingParser.py


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