rhoknp.units.base_phrase module

class rhoknp.units.base_phrase.BasePhrase(parent_index: int | None, dep_type: DepType | None, features: FeatureDict | None = None, rel_tags: RelTagList | None = None, memo_tag: MemoTag | None = None)[source]

Bases: Unit

基本句クラス.

PAT = re.compile('^\\+( (?P<pid>-1|\\d+)(?P<dtype>[DPAI]))?( (?P<feats>(<(?P<key>([^:\\"]|\\"[^\\"]*?\\")+?)(:(?P<value>([^>\\\\]|\\\\>?)+))?>)*))?$')
parent_index: int | None

係り先の基本句の文内におけるインデックス.

dep_type: DepType | None

係り受けの種類.

features: FeatureDict

素性.

rel_tags: RelTagList

基本句間関係.

memo_tag: MemoTag

タグ付けメモ.

pas: Pas

述語項構造.

entities: set[Entity]

参照しているエンティティ.

entities_nonidentical: set[Entity]

≒で参照しているエンティティ.

index

文内におけるインデックス.

property global_index: int

文書全体におけるインデックス.

property document: Document

文書.

Raises:

AttributeError – 解析結果にアクセスできない場合.

property sentence: Sentence

文.

property clause: Clause

節.

Raises:

AttributeError – 解析結果にアクセスできない場合.

property phrase: Phrase

文節.

property morphemes: list[Morpheme]

形態素のリスト.

property head: Morpheme

主辞の形態素.

property parent: BasePhrase | None

係り先の基本句.ないなら None.

Raises:

AttributeError – 解析結果にアクセスできない場合.

property children: list[BasePhrase]

この基本句に係っている基本句のリスト.

Raises:

AttributeError – 解析結果にアクセスできない場合.

property entities_all: set[Entity]

nonidentical も含めた参照している全エンティティの集合.

classmethod from_knp(knp_text: str) BasePhrase[source]

基本句クラスのインスタンスを KNP の解析結果から初期化.

Parameters:

knp_text – KNP の解析結果.

to_knp() str[source]

KNP フォーマットに変換.

get_coreferents(include_nonidentical: bool = False, include_self: bool = False) list[BasePhrase][source]

この基本句と共参照している基本句の集合を返却.

Parameters:
  • include_nonidentical – nonidentical なメンションを含めるなら True.

  • include_self – 自身を含めるなら True.

Returns:

共参照している基本句の集合.

static is_base_phrase_line(line: str) bool[source]

基本句行なら True を返す.