rhoknp.props.semantics module

class rhoknp.props.semantics.SemanticsDict(semantics: dict[str, str | bool] | None = None, is_nil: bool = False)[source]

Bases: dict[str, str | bool]

形態素の意味情報を表すクラス.

NIL = 'NIL'
PAT = re.compile('(?P<sems>("[^"]+?")|NIL)')
SEM_PAT = re.compile('(?P<key>[^:\\s]+)(:(?P<value>\\S+))?(\\s|$)')
is_nil() bool[source]

NIL なら True.

classmethod from_sstring(sstring: str) SemanticsDict[source]

意味情報文字列をパースして辞書型に変換する.

例:”代表表記:日本/にほん 地名:国” -> {“代表表記”: “日本/にほん”, “地名”: “国”}

Parameters:

sstring – KNP 形式における意味情報文字列.

to_sstring() str[source]

意味情報文字列に変換.