其他

词法形态学

class

存储语言可能的形态学分析,并通过哈希值进行索引。为了节省每个词符的空间,词符仅知道其形态学分析的哈希值,因此形态属性的查询被委托给此类。参见MorphAnalysis了解存储单个形态学分析的容器。

Morphology.__init__ 方法

创建一个Morphology对象。

名称描述
stringsThe string store. StringStore

Morphology.add 方法

如果形态分析尚未存在,则将其插入到形态表中。 形态分析可以以字符串形式或以标签映射字典格式提供,格式遵循通用依存关系FEATS规范。返回新分析的哈希值。

名称描述
featuresThe morphological features. Union[Dict, str]

Morphology.get 方法

获取形态分析哈希值的 FEATS 字符串。

名称描述
morphThe hash of the morphological analysis. int

Morphology.feats_to_dict staticmethod

将字符串FEATS表示转换为特征和值的字典,格式与标签映射相同。

名称描述
featsThe morphological features in Universal Dependencies FEATS format. str

Morphology.dict_to_feats staticmethod

将特征和值的字典转换为字符串 FEATS 表示形式。

名称描述
feats_dictThe morphological features as a dictionary. Dict[str, str]

属性

名称描述
FEATURE_SEPThe FEATS feature separator. Default is |. str
FIELD_SEPThe FEATS field separator. Default is =. str
VALUE_SEPThe FEATS value separator. Default is ,. str

MorphAnalysis class

存储单一形态分析。

MorphAnalysis.__init__ 方法

从通用依存关系FEATS字符串或形态特征字典初始化一个MorphAnalysis对象。

名称描述
vocabThe vocab. Vocab
featuresThe morphological features. Union[Dict[str, str], str]

MorphAnalysis.__contains__ 方法

某个特征/值对是否在分析中。

名称描述
featureA feature/value pair. str

MorphAnalysis.__iter__ 方法

遍历分析中的特征/值对。

名称描述

MorphAnalysis.__len__ 方法

返回分析中的特征数量。

名称描述

MorphAnalysis.__str__ 方法

返回通用依存关系FEATS字符串格式的形态分析结果。

名称描述

MorphAnalysis.get 方法

通过字段检索特征的值。

名称描述
fieldThe field to retrieve. str
default v3.5.3The value to return if the field is not present. If unset or None, the default return value is []. Optional[List[str]]

MorphAnalysis.to_dict 方法

生成分析的字典表示,格式与标签映射相同。

名称描述

MorphAnalysis.from_id 类方法

根据给定的哈希ID创建形态分析。

名称描述
vocabThe vocab. Vocab
keyThe hash of the features string. int