Skip to main content

tkzs

Installation

pip install tkzs

Use a simple tokenizer

from tkzs.tokenizers import re_tokenizer

txt = "Contrastive Fine-tuning Improves Robustness for Neural Rankers"

re_tokenizer(txt)

Use a spacy word tokenizer

from tkzs.tokenizers import SpacyTokenizer

txt = "Contrastive Fine-tuning Improves Robustness for Neural Rankers"

tokenizer = SpacyTokenizer(name='en_core_web_sm')

tokenizer.tokenize(txt)

Use a word encoder

from tkzs.encoders import WordEncoder
from tkzs.tokenizers import re_tokenizer

docs = [
    "Contrastive Fine-tuning Improves Robustness for Neural Rankers",
    "Unsupervised Neural Machine Translation for Low-Resource Domains via Meta-Learning",
    "Spatial Dependency Parsing for Semi-Structured Document Information Extraction"
    ]

encoder = WordEncoder(tokenizer=re_tokenizer)

encoder.fit(docs)

encoder.batch_tokenize(docs) # return a list of tokenized sequence

encoder.encode_batch(docs) # return a tensor of size [batch_size, max_length]

Use a byte encoder

from tkzs.encoders import ByteEncoder
from tkzs.tokenizers import re_tokenizer

docs = [
    "Contrastive Fine-tuning Improves Robustness for Neural Rankers",
    "Unsupervised Neural Machine Translation for Low-Resource Domains via Meta-Learning",
    "Spatial Dependency Parsing for Semi-Structured Document Information Extraction"
    ]

encoder = ByteEncoder()

# return a tensor of shape [Batch, Word, Char]
encoder.encode_batch(docs, char_padding='center', word_length=None, tokenizer=re_tokenizer)

Metadata

Release files for tkzs 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tkzs 0.0.7
File Size Uploaded
tkzs-0.0.7.tar.gz 3.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tkzs 0.0.7
File Interpreter ABI Platform
tkzs-0.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 8.3 kB

Release files / tkzs-0.0.7.tar.gz

Download URL tkzs-0.0.7.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
adc675ce823291dd51798b614a635c3abb74b5d1874d1b3762a4ef4066a9351a
BLAKE2b-256 checksum
How to use checksums
82095b21c022753826f3ad606879957c828487a5bc7ba43824396144614d6979
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/3.10.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

Release files / tkzs-0.0.7-py3-none-any.whl

Download URL tkzs-0.0.7-py3-none-any.whl
Size 4.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
52c9ec2c35dc4102a08789d4682499e9deddf6180707454bcec37523955990b3
BLAKE2b-256 checksum
How to use checksums
02dd48fb191e9ec83d1f1a8f3e758b6d7c2e385f8f47b5a8d00442bb14b9eba1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/3.10.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9

Release history Release notifications | RSS feed

This release

0.0.7 This release

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page