ckipnlp.container.coref module¶
This module provides containers for coreference sentences.
- class ckipnlp.container.coref.CorefToken(word, coref, idx, **kwargs)[source]¶
Bases:
BaseTuple
,_CorefToken
A coreference token.
- Variables
word (str) – the token word.
coref (Tuple[int, str]) –
the coreference ID and type. None if not a coreference source or target.
- type:
’source’: coreference source.
’target’: coreference target.
’zero’: null element coreference target.
idx (Tuple[int, int]) – the node indexes (clause index, token index) in parse tree. idx[1] = None if this node is a null element or the punctuations.
Note
This class is an subclass of
tuple
. To change the attribute, please create a new instance instead.Data Structure Examples
- Text format
Used for
to_text()
.'畢卡索_0'
- List format
Used for
from_list()
andto_list()
.[ '畢卡索', # token word (0, 'source'), # coref ID and type (2, 2), # node index ]
- Dict format
Used for
from_dict()
andto_dict()
.{ 'word': '畢卡索', # token word 'coref': (0, 'source'), # coref ID and type 'idx': (2, 2), # node index }
- class ckipnlp.container.coref.CorefSentence(initlist=None)[source]¶
Bases:
BaseSentence
A list of coreference sentence.
Data Structure Examples
- Text format
Used for
to_text()
.# Token segmented by \u3000 (full-width space) '「 完蛋 了 !」 , 畢卡索_0 他_0 想'
- List format
Used for
from_list()
andto_list()
.[ [ '「', None, (0, None,), ], [ '完蛋', None, (1, 0,), ], [ '了', None, (1, 1,), ], [ '!」', None, (1, None,), ], [ '畢卡索', (0, 'source'), (2, 2,), ], [ '他', (0, 'target'), (2, 3,), ], [ '想', None, (2, 4,), ], ]
- Dict format
Used for
from_dict()
andto_dict()
.[ { 'word': '「', 'coref': None, 'idx': (0, None,), }, { 'word': '完蛋', 'coref': None, 'idx': (1, 0,), }, { 'word': '了', 'coref': None, 'idx': (1, 1,), }, { 'word': '!」', 'coref': None, 'idx': (1, None,), }, { 'word': '畢卡索', 'coref': (0, 'source'), 'idx': (2, 2,), }, { 'word': '他', 'coref': (0, 'target'), 'idx': (2, 3,), }, { 'word': '想', 'coref': None, 'idx': (2, 4,), }, ]
- item_class¶
alias of
CorefToken
- class ckipnlp.container.coref.CorefParagraph(initlist=None)[source]¶
Bases:
BaseList
A list of coreference sentence.
Data Structure Examples
- Text format
Used for
to_text()
.[ '「 完蛋 了 !」 , 畢卡索_0 他_0 想', # Sentence 1 '但是 None_0 也 沒有 辦法', # Sentence 1 ]
- List format
Used for
from_list()
andto_list()
.[ [ # Sentence 1 [ '「', None, (0, None,), ], [ '完蛋', None, (1, 0,), ], [ '了', None, (1, 1,), ], [ '!」', None, (1, None,), ], [ '畢卡索', (0, 'source'), (2, 2,), ], [ '他', (0, 'target'), (2, 3,), ], [ '想', None, (2, 4,), ], ], [ # Sentence 2 [ '但是', None, (0, 1,), ], [ None, (0, 'zero'), (0, None,), ], [ '也', None, (0, 2,), ], [ '沒有', None, (0, 3,), ], [ '辦法', None, (0, 5,), ], ], ]
- Dict format
Used for
from_dict()
andto_dict()
.[ [ # Sentence 1 { 'word': '「', 'coref': None, 'idx': (0, None,), }, { 'word': '完蛋', 'coref': None, 'idx': (1, 0,), }, { 'word': '了', 'coref': None, 'idx': (1, 1,), }, { 'word': '!」', 'coref': None, 'idx': (1, None,), }, { 'word': '畢卡索', 'coref': (0, 'source'), 'idx': (2, 2,), }, { 'word': '他', 'coref': (0, 'target'), 'idx': (2, 3,), }, { 'word': '想', 'coref': None, 'idx': (2, 4,), }, ], [ # Sentence 2 { 'word': '但是', 'coref': None, 'idx': (0, 1,), }, { 'word': None, 'coref': (0, 'zero'), 'idx': (0, None,), }, { 'word': '也', 'coref': None, 'idx': (0, 2,), }, { 'word': '沒有', 'coref': None, 'idx': (0, 3,), }, { 'word': '辦法', 'coref': None, 'idx': (0, 5,), }, ], ]
- item_class¶
alias of
CorefSentence