ckipclient

 
Classes
       
 

 
class CKIPClient(builtins.object)
    A Python client for the Chinese Word Segmentation System (see ckipsvr.iis.sinica.edu.tw)
provided by Academia Sinica Chinese Knowledge and Information Processing (CKIP) Group.
 
  Methods defined here:
__init__(self, ip:str, port:int, usr:str, pwd:str, wait:int=0)
Initialize the client.
 
:param ip: CKIP server IP.
:type ip: str
:param port: CKIP server port.
:type port: int
:param usr: CKIP server username.
:type usr: str
:param pwd: CKIP server password.
:type pwd: str
:param wait: Number of seconds to wait before segmenting.
             Used to prevent overwhelming requests.
:type wait: int
safe_segment(self, text:str, pos:bool=True, retry:int=5) -> list
Segment the text into words, retry if an error occurred.
 
:param text: Text to be segmented.
             Characters that cannot be encoded in big5 will be replaced by '?'.
:type text: str
:param pos: Return part of speech or not.
:type pos: bool
:param retry: Maximum number of retries.
:type retry: int
:return: List of sentences, each sentence is a list of words.
         Each word is a tuple of (word, part of speech) if pos is true.
         Otherwise, it contains just the word.
:rtype: list
segment(self, text:str, pos:bool=True) -> list
Segment the text into words.
 
:param text: Text to be segmented.
             Characters that cannot be encoded in big5 will be replaced by '?'.
:type text: str
:param pos: Return part of speech or not.
:type pos: bool
:return: List of sentences, each sentence is a list of words.
         Each word is a tuple of (word, part of speech) if pos is true.
         Otherwise, it contains just the word.
:rtype: list