ckipnlp.driver.classic module

This module provides drivers with CkipClassic backend.

class ckipnlp.driver.classic.CkipClassicWordSegmenter(*, lazy=False, do_pos=False, lexicons=None)[source]

Bases: ckipnlp.driver.base.BaseDriver

The CKIP word segmentation driver with CkipClassic backend.

Parameters
  • lazy (bool) – Lazy initialize the driver.

  • do_pos (bool) – Returns POS-tag or not

  • lexicons (Iterable[Tuple[str, str]]) – A list of the lexicon words and their POS-tags.

__call__(*, text)

Apply word segmentation.

Parameters

text (TextParagraph) — The sentences.

Returns
  • ws (TextParagraph) — The word-segmented sentences.

  • pos (TextParagraph) — The part-of-speech sentences. (returns if do_pos is set.)

class ckipnlp.driver.classic.CkipClassicConParser(*, lazy=False)[source]

Bases: ckipnlp.driver.classic._CkipClassicConParser

The CKIP constituency parsing driver with CkipClassic backend.

Parameters

lazy (bool) – Lazy initialize the driver.

__call__(*, ws, pos)

Apply constituency parsing.

Parameters
Returns

conparse (ParseSentence) — The constituency-parsing sentences.

class ckipnlp.driver.classic.CkipClassicConParserClient(*, lazy=False, **opts)[source]

Bases: ckipnlp.driver.classic._CkipClassicConParser

The CKIP constituency parsing driver with CkipClassic client backend.

Parameters
  • lazy (bool) – Lazy initialize the driver.

  • username (string) – (optional) The username of CkipClassicParserClient.

  • password (string) – (optional) The password of CkipClassicParserClient.

Notes

Please register an account at http://parser.iis.sinica.edu.tw/v1/reg.exe and set the environment variables $CKIPPARSER_USERNAME and $CKIPPARSER_PASSWORD.

__call__(*, ws, pos)

Apply constituency parsing.

Parameters
Returns

conparse (ParseSentence) — The constituency-parsing sentences.