Skip to main content

Lucytok

Lucene's boring English tokenizers recreated for Python. Compatible with SearchArray.

Lets you configure a handful of normal tokenization rules like ascii folding, posessive removal, both types of porter stemming, English stopwords, etc.

Usage

Creating a tokenizer close to Elasticsearch's default english analyzer

from lucytok import english
es_english = english("Nsp->NNN->l->sNNN->1")
tokenized = es_english("The quick brown fox jumps over the lazy døg")
print(tokenized)

Outputs

['_', 'quick', 'brown', 'fox', 'jump', 'over', '_', 'lazi', 'døg']

Make a tokenizer with ASCII folding...

from lucytok import english
es_english_folded = english("asp->NNN->l->sNNN->1")
print(es_english_folded("The quick brown fox jumps over the lazy døg"))
['_', 'quick', 'brown', 'fox', 'jump', 'over', '_', 'lazi', 'dog']

Split compounds and convert British to American spelling...

from lucytok import english
es_british = english("asp->NNN->l->scbN->1")
print(es_british("The watercolour fox jumps over the lazy døg"))
['_', 'water', 'color', 'fox', 'jump', 'over', '_', 'lazi', 'dog']

Spec

Create a tokenizer using the following settings (these concepts correspond to their Elasticsearch counterparts):


#  |- ASCII fold (a) or not (N)
#  ||- Standard (s) or WS tokenizer (w)
#  ||- Remove possessive suffixes (p) or not (N)
#  |||
# "NsN->NNN->N->NNNN->N"
#       |||  |  ||||  |
#       |||  |  ||||  |- Porter stem version (1) or version (2) vs N/0 for none
#       |||  |  ||||- Manually convert irregular plurals (p) or not (N)
#       |||  |  |||- Split Compounds (c) or not (N)
#       |||  |  ||- Convert british to american spelling (b) or not (N)
#       |||  |  |- Blank out stopwords (s) or not (N)
#       |||  |- Lowercase (l) or not (N)
#       |||- Split on letter/number transitions (n) or not (N)
#       ||- Split on case changes (c) or not (N)
#       |- Split on punctuation (p) or not (N)


# "NsN->NNN->N->NNN->N"
#  ---
#  (tokenization)

# "NsN->NNN->N->NNNN->N"
#       ---
#       (word splitting on rules, like WordDelimeterFilter in Lucene)

# "NsN->NNN->N->NNNN->N"
#            -
#            (lowercasing or not)

# "NsN->NNN->N->NNNN->N"
#               ----
#               (dictionary based splitting stopwords -> compounds -> british/american English -> irregular plurals)

# "NsN->NNN->N->NNNN->N"
#                     - stemming (porter)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lucytok-0.1.9.tar.gz (33.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lucytok-0.1.9-py3-none-any.whl (33.1 kB view details)

Uploaded Python 3

File details

Details for the file lucytok-0.1.9.tar.gz.

File metadata

  • Download URL: lucytok-0.1.9.tar.gz
  • Upload date:
  • Size: 33.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.6 Darwin/24.1.0

File hashes

Hashes for lucytok-0.1.9.tar.gz
Algorithm Hash digest
SHA256 53d00c6cec459e81b5ae8a9ba037295dbe0df32e26760c782bc8b1663bdd626a
MD5 c1403bb4329adea56cfeebf4a955741e
BLAKE2b-256 140b69e809d4824d5fa9eee68c34c46e5ce5253dd9f0959ce50988994d8a0436

See more details on using hashes here.

File details

Details for the file lucytok-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: lucytok-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 33.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.6 Darwin/24.1.0

File hashes

Hashes for lucytok-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 1c9abe1d154f514f9013a92498b12610b15b48429f8e63cc624eded5fd533e34
MD5 f79d3d5296d32e1ba02c70075967a6dc
BLAKE2b-256 4c1919b7005f9c8ec3556d515dd0556dbd75c01f79f5a393736ad99ada9c91ef

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page