ckipnlp.container.parse module¶
This module provides containers for parsed sentences.
-
class
ckipnlp.container.parse.
ParseClause
(clause: Optional[str] = None, delim: str = '')[source]¶ Bases:
ckipnlp.container.base.BaseTuple
,ckipnlp.container.parse._ParseClause
A parse clause.
- Variables
clause (str) – the parse clause.
delim (str) – the punctuations after this clause.
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()
.'S(Head:Nab:中文字|particle:Td:耶)' # delim are ignored
- List format
Used for
from_list()
, andto_list()
.[ 'S(Head:Nab:中文字|particle:Td:耶)', # parse clause ',', # punctuations ]
- Dict format
Used for
from_dict()
andto_dict()
.{ 'clause': 'S(Head:Nab:中文字|particle:Td:耶)', # parse clause 'delim': ',', # punctuations }
-
class
ckipnlp.container.parse.
ParseSentence
(initlist=None)[source]¶ Bases:
ckipnlp.container.base.BaseList
A parse sentence.
Data Structure Examples
- Text format
Used for
to_text()
.[ # delim are ignored 'S(Head:Nab:中文字|particle:Td:耶)', # Clause 1 '%(particle:I:啊|manner:Dh:哈|manner:Dh:哈|time:Dh:哈), # Clause 2 ]
- List format
Used for
from_list()
, andto_list()
.[ [ # Clause 1 'S(Head:Nab:中文字|particle:Td:耶)', ',', ], [ # Clause 2 '%(particle:I:啊|manner:Dh:哈|manner:Dh:哈|time:Dh:哈), '。', ], ]
- Dict format
Used for
from_dict()
andto_dict()
.[ { # Clause 1 'clause': 'S(Head:Nab:中文字|particle:Td:耶)', 'delim': ',', }, { # Clause 2 'clause': '%(particle:I:啊|manner:Dh:哈|manner:Dh:哈|time:Dh:哈), 'delim': '。', }, ]
-
item_class
¶ alias of
ckipnlp.container.parse.ParseClause
-
class
ckipnlp.container.parse.
ParseParagraph
(initlist=None)[source]¶ Bases:
ckipnlp.container.base.BaseList
A list of parse sentence.
Data Structure Examples
- Text format
Used for
to_text()
.[ # delim are ignored [ # Sentence 1 'S(Head:Nab:中文字|particle:Td:耶)', '%(particle:I:啊|manner:Dh:哈|manner:Dh:哈|time:Dh:哈), ], [ # Sentence 2 None, 'VP(Head:VH11:完蛋|particle:Ta:了), 'S(agent:NP(apposition:Nba:畢卡索|Head:Nhaa:他)|Head:VE2:想)', ], ]
- List format
Used for
from_list()
, andto_list()
.[ [ # Sentence 1 [ 'S(Head:Nab:中文字|particle:Td:耶)', ',', ], [ '%(particle:I:啊|manner:Dh:哈|manner:Dh:哈|time:Dh:哈), '。', ], ], [ # Sentence 2 [ None, '「', ], [ 'VP(Head:VH11:完蛋|particle:Ta:了), '!」', ], [ 'S(agent:NP(apposition:Nba:畢卡索|Head:Nhaa:他)|Head:VE2:想)', '', ], ], ]
- Dict format
Used for
from_dict()
, andto_dict()
.[ [ # Sentence 1 { 'clause': 'S(Head:Nab:中文字|particle:Td:耶)', 'delim': ',', }, { 'clause': '%(particle:I:啊|manner:Dh:哈|manner:Dh:哈|time:Dh:哈), 'delim': '。', }, ], [ # Sentence 2 { 'clause': None, 'delim': '「', }, { 'clause': 'VP(Head:VH11:完蛋|particle:Ta:了), 'delim': '!」', }, { 'clause': 'S(agent:NP(apposition:Nba:畢卡索|Head:Nhaa:他)|Head:VE2:想)', 'delim': '', }, ], ]
-
item_class
¶