Subcommand normalizationΒΆ
Apply normalization to given input
usage: benchmarkstt-tools normalization [--log] [-i file] [-o file]
[--config file [section] [encoding]]
[--lowercase] [--regex search replace]
[--replace search replace]
[--replacewords search replace]
[--unidecode]
[--log-level {critical,fatal,error,warn,warning,info,debug,notset}]
[--help]
Named ArgumentsΒΆ
--log | show normalization logs (warning: for large files with many normalization rules this will cause a significant performance penalty and a lot of output data) Default: False |
--log-level | Possible choices: critical, fatal, error, warn, warning, info, debug, notset Set the logging output level Default: warning |
input and output filesΒΆ
You can provide multiple input and output files, each preceded by -i and -o respectively. If no input file is given, only one output file can be used. If using both multiple input and output files there should be an equal amount of each. Each processed input file will then be written to the corresponding output file.
-i, --inputfile | |
read input from this file, defaults to STDIN | |
-o, --outputfile | |
write output to this file, defaults to STDOUT |
available normalizersΒΆ
A list of normalizers to execute on the input, can be one or more normalizers which are applied sequentially. The program will automatically find the normalizer in benchmarkstt.normalization.core, then benchmarkstt.normalization and finally in the global namespace.
--config | Use config file notation to define normalization rules. This notation is a list of normalizers, one per line. Each normalizer that is based needs a file is followed by a file name of a csv, and can be optionally followed by the file encoding (if different than default). All options are loaded in from this csv and applied to the normalizer. The normalizers can be any of the core normalizers, or you can refer to your own normalizer class (like you would use in a python import, eg. my.own.package.MyNormalizerClass).
The normalization rules are applied top-to-bottom and follow this format: [normalization]
# This is a comment
# (Normalizer2 has no arguments)
lowercase
# loads regex expressions from regexrules.csv in "utf 8" encoding
regex regexrules.csv "utf 8"
# load another config file, [section1] and [section2]
config configfile.ini section1
config configfile.ini section2
# loads replace expressions from replaces.csv in default encoding
replace replaces.csv
| ||||||||||||||||||
--lowercase | Lowercase the text
| ||||||||||||||||||
--regex | Simple regex replace. By default the pattern is interpreted case-sensitive. Case-insensitivity is supported by adding inline modifiers. You might want to use capturing groups to preserve the case. When replacing a character not captured, the information about its case is lost... Eg. would replace "HAHA! Hahaha!" to "HeHe! Hehehe!":
No regex flags are set by default, you can set them yourself though in the regex, and combine them at will, eg. multiline, dotall and ignorecase. Eg. would replace "New<CRLF>line" to "newline":
| ||||||||||||||||||
--replace | Simple search replace
| ||||||||||||||||||
--replacewords | Simple search replace that only replaces "words", the first letter will be checked case insensitive as well with preservation of case..
| ||||||||||||||||||
--unidecode | Unidecode characters to ASCII form, see Python's Unidecode package for more info.
|