ckipnlp.util.ws module

class ckipnlp.util.ws.WsWord[source]

Bases: tuple

A word-segmented word.

word

str – the word.

pos

str – the post-tag.

classmethod from_text(text)[source]

Create a WsWord object from ckipnlp.ws.CkipWs output.

Parameters:text (str) – A word from ckipnlp.ws.CkipWs output.
to_text()[source]

Transform to plain text.

to_dict()[source]

Transform to python dict/list.

to_json(**kwargs)[source]

Transform to JSON format.

class ckipnlp.util.ws.WsSentence(initlist=None)[source]

Bases: collections.UserList

A word-segmented sentence.

item_class

alias of WsWord

classmethod from_text(text)[source]

Create WsSentence object from ckipnlp.ws.CkipWs output.

Parameters:text (str) – A sentence from ckipnlp.ws.CkipWs output.
to_text()[source]

Transform to plain text.

to_dict()[source]

Transform to python dict/list.

to_json(**kwargs)[source]

Transform to JSON format.

class ckipnlp.util.ws.WsSentenceList(initlist=None)[source]

Bases: collections.UserList

A list of word-segmented sentence.

item_class

alias of WsSentence

classmethod from_text(text_list)[source]

Create WsSentenceList object from ckipnlp.ws.CkipWs output.

Parameters:text_list (List[str]) – A list of sentence from ckipnlp.ws.CkipWs output.
to_text()[source]

Transform to plain text.

to_dict()[source]

Transform to python dict/list.

to_json(**kwargs)[source]

Transform to JSON format.