本文整理汇总了Python中CharniakParser.loadModel方法的典型用法代码示例。如果您正苦于以下问题:Python CharniakParser.loadModel方法的具体用法?Python CharniakParser.loadModel怎么用?Python CharniakParser.loadModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CharniakParser
的用法示例。
在下文中一共展示了CharniakParser.loadModel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_parser_model
# 需要导入模块: import CharniakParser [as 别名]
# 或者: from CharniakParser import loadModel [as 别名]
def load_parser_model(self, model_dir, **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 self._parser_model_loaded:
raise RuntimeError('Parser is already loaded and can only be loaded once.')
if not exists(model_dir):
raise ValueError('Parser model directory %r does not exist.' % model_dir)
self._parser_model_loaded = True
self.parser_model_dir = model_dir
parser.loadModel(model_dir)
self.set_parser_options(**parser_options)
示例2: load_parsing_model
# 需要导入模块: import CharniakParser [as 别名]
# 或者: from CharniakParser import loadModel [as 别名]
def load_parsing_model(self, model_dir, language='En',
case_insensitive=False, nbest=50, small_corpus=True,
overparsing=21, debug=0, smoothPos=0):
"""Load the parsing model from model_dir and set parsing
options. In general, the default options should suffice. Note
that the parser does not allow loading multiple models within
the same process."""
if self._parser_model_loaded:
raise ValueError('Parser is already loaded and can only be loaded once.')
if not os.path.exists(model_dir):
raise ValueError('Parser model directory %r does not exist.' % model_dir)
self._parser_model_loaded = True
parser.loadModel(model_dir)
self.parser_model_dir = model_dir
parser.setOptions(language, case_insensitive, nbest, small_corpus,
overparsing, debug, smoothPos)
示例3: load_parser_model
# 需要导入模块: import CharniakParser [as 别名]
# 或者: from CharniakParser import loadModel [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)