ckipnlp.ws package

class ckipnlp.ws.CkipWs(*, logger=False, inifile=None, **kwargs)[source]

Bases: object

The CKIP word segmentation driver.

Parameters:
  • logger (bool) – enable logger.
  • inifile (str) – the path to the INI file.
Other Parameters:
 

** – the configs for CKIPWS, ignored if inifile is set. Please refer ckipnlp.util.ini.create_ws_ini().

Danger

Never instance more than one object of this class!

apply(text)[source]

Segment a sentence.

Parameters:text (str) – the input sentence.
Returns:str – the output sentence.

Hint

One may also call this method as __call__().

apply_list(ilist)[source]

Segment a list of sentences.

Parameters:ilist (List[str]) – the list of input sentences.
Returns:List[str] – the list of output sentences.
apply_file(ifile, ofile, uwfile='')[source]

Segment a file.

Parameters:
  • ifile (str) – the input file.
  • ofile (str) – the output file (will be overwritten).
  • uwfile (str) – the unknown word file (will be overwritten).