ckipnlp.container.coref module

This module provides containers for co-reference sentences.

class ckipnlp.container.coref.CorefToken[source]

Bases: ckipnlp.container.base.BaseTuple, ckipnlp.container.coref._CorefToken

A co-reference token.

Variables
  • word (str) – the token word.

  • coref (Tuple[int, str]) –

    the co-reference ID and type. None if not a co-reference source or target.

    • type:
      • ’source’: co-reference source.

      • ’target’: co-reference target.

      • ’zero’: null element co-reference target.

  • idx (int) – the node index in parsed tree.

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_list().

'畢卡索_0'
Dict format

Used for from_dict() and to_dict().

{
    'word': '畢卡索',        # token word
    'coref': (0, 'source'), # coref ID and type
    'idx': 2,               # node index
}
List format

Used for from_list() and to_list().

[
    '畢卡索',       # token word
    (0, 'source'), # coref ID and type
    2,             # node index
]
from_text = NotImplemented
to_text()[source]
class ckipnlp.container.coref.CorefSentence(initlist=None)[source]

Bases: ckipnlp.container.base.BaseSentence

A list of co-reference sentence.

Data Structure Examples

Text format

Used for to_list().

'畢卡索_0 他_0 想' # Token segmented by \u3000 (full-width space)
Dict format

Used for from_dict() and to_dict().

[
    { 'word': '畢卡索', 'coref': (0, 'source'), 'idx': 2, }, # coref-token 1
    { 'word': '他', 'coref': (0, 'target'), 'idx': 3, },    # coref-token 2
    { 'word': '想', 'coref': None, 'idx': 4, },             # coref-token 3
]
List format

Used for from_list() and to_list().

[
    [ '畢卡索', (0, 'source'), 2, ], # coref-token 1
    [ '他', (0, 'target'), 3, ],    # coref-token 2
    [ '想', None, 4, ],             # coref-token 3
]
item_class

alias of CorefToken

from_text = NotImplemented
to_text()[source]
class ckipnlp.container.coref.CorefParagraph(initlist=None)[source]

Bases: ckipnlp.container.base.BaseList

A list of co-reference sentence.

Data Structure Examples

Text format

Used for to_list().

[
    '畢卡索_0 他_0 想', # Sentence 1
    'None_0 完蛋 了',  # Sentence 2
]
Dict format

Used for from_dict() and to_dict().

[
    [ # Sentence 1
        { 'word': '畢卡索', 'coref': (0, 'source'), 'idx': 2, },
        { 'word': '他', 'coref': (0, 'target'), 'idx': 3, },
        { 'word': '想', 'coref': None, 'idx': 4, },
    ],
    [ # Sentence 2
        { 'word': None, 'coref': (0, 'zero'), None, },
        { 'word': '完蛋', 'coref': None, 'idx': 1, },
        { 'word': '了', 'coref': None, 'idx': 2, },
    ],
]
List format

Used for from_list() and to_list().

[
    [ # Sentence 1
        [ '畢卡索', (0, 'source'), 2, ],
        [ '他', (0, 'target'), 3, ],
        [ '想', None, 4, ],
    ],
    [ # Sentence 2
        [ None, (0, 'zero'), None, ],
        [ '完蛋', None, 1, ],
        [ '了', None, 2, ],
    ],
]
item_class

alias of CorefSentence

from_text = NotImplemented