ckipnlp.container.util.wspos module¶
This module provides containers for word-segmented sentences with part-of-speech-tags.
-
class
ckipnlp.container.util.wspos.
WsPosToken
[source]¶ Bases:
ckipnlp.container.base.BaseTuple
,ckipnlp.container.util.wspos._WsPosToken
A word with POS-tag.
- Variables
word (str) – the word.
pos (str) – the POS-tag.
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
from_text()
andto_text()
.'中文字(Na)' # word / POS-tag
- Dict format
Used for
from_dict()
andto_dict()
.{ 'word': '中文字', # word 'pos': 'Na', # POS-tag }
- List format
Used for
from_list()
andto_list()
.[ '中文字', # word 'Na', # POS-tag ]
-
class
ckipnlp.container.util.wspos.
WsPosSentence
[source]¶ Bases:
object
A helper class for data conversion of word-segmented and part-of-speech sentences.
-
classmethod
from_text
(data)[source]¶ Convert text format to word-segmented and part-of-speech sentences.
- Parameters
data (str) – text such as
'中文字(Na)\u3000喔(T)'
.- Returns
SegSentence
– the word sentenceSegSentence
– the POS-tag sentence.
-
static
to_text
(word, pos)[source]¶ Convert text format to word-segmented and part-of-speech sentences.
- Parameters
word (
SegSentence
) – the word sentencepos (
SegSentence
) – the POS-tag sentence.
- Returns
str – text such as
'中文字(Na)\u3000喔(T)'
.
-
classmethod
-
class
ckipnlp.container.util.wspos.
WsPosParagraph
[source]¶ Bases:
object
A helper class for data conversion of word-segmented and part-of-speech sentence lists.
-
classmethod
from_text
(data)[source]¶ Convert text format to word-segmented and part-of-speech sentence lists.
- Parameters
data (Sequence[str]) – list of sentences such as
'中文字(Na)\u3000喔(T)'
.- Returns
SegParagraph
– the word sentence listSegParagraph
– the POS-tag sentence list.
-
static
to_text
(word, pos)[source]¶ Convert text format to word-segmented and part-of-speech sentence lists.
- Parameters
word (
SegParagraph
) – the word sentence listpos (
SegParagraph
) – the POS-tag sentence list.
- Returns
List[str] – list of sentences such as
'中文字(Na)\u3000喔(T)'
.
-
classmethod