Home

Awesome

quntoken

New Hungarian tokenizer based on quex and huntoken. This tool is also integrated into the e-magyar language processing system under the name emToken.

Requirements

Developer requirements:

Install

pip3 install quntoken

Usage

Command line

quntoken reads plain text in UTF-8 from STDIN and writes to STDOUT.

The default (and recommended) format of output is TSV. It has two columns. The first contains the token, the second contains the white space sequence after the token. Sentence boundaries are marked with empty lines.

Example: tokenizing input.txt file, writing the TSV output into output.tsv file.

quntoken <input.txt >output.tsv

Optional arguments:

  -h, --help            show this help message and exit
  -f {json,raw,spl,tsv,xml}, --form {json,raw,spl,tsv,xml}
                        Valid formats: json, tsv, xml and spl (sentence per
                        line, ignores mode). Default format: tsv.
  -m {sentence,token}, --mode {sentence,token}
                        Modes: sentence or token (does not apply for
                        form=spl). Default: token
  -c, --conll-text      Add CoNLL text metafield to contain the detokenized
                        sentence (only for mode == token and format == tsv).
                        Default: False
  -w, --word-break      Eliminate word break from end of lines.
  -v, --version         show program's version number and exit

Python API

quntoken.tokenize(inp=sys.stdin, form='tsv', mode='token', word_break=False, conll_text=False)

Entry point, returns an iterator object. Parameters:

Example:

from quntoken import tokenize

for tok in tokenize(open('input.txt')):
    print(tok, end='')