本文整理汇总了Python中allennlp.common.Params.items方法的典型用法代码示例。如果您正苦于以下问题:Python Params.items方法的具体用法?Python Params.items怎么用?Python Params.items使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类allennlp.common.Params
的用法示例。
在下文中一共展示了Params.items方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dict_from_params
# 需要导入模块: from allennlp.common import Params [as 别名]
# 或者: from allennlp.common.Params import items [as 别名]
def dict_from_params(cls, params: Params) -> 'Dict[str, TokenIndexer]': # type: ignore
"""
We typically use ``TokenIndexers`` in a dictionary, with each ``TokenIndexer`` getting a
name. The specification for this in a ``Params`` object is typically ``{"name" ->
{indexer_params}}``. This method reads that whole set of parameters and returns a
dictionary suitable for use in a ``TextField``.
Because default values for token indexers are typically handled in the calling class to
this and are based on checking for ``None``, if there were no parameters specifying any
token indexers in the given ``params``, we return ``None`` instead of an empty dictionary.
"""
token_indexers = {}
for name, indexer_params in params.items():
token_indexers[name] = cls.from_params(indexer_params)
if token_indexers == {}:
token_indexers = None
return token_indexers