跳转到主要内容

c++ mosestokenizer

项目描述

fast-mosestokenizer 是 moses tokenizer 的 C++ 实现,在 NLP 研究人员中颇受欢迎。

使用此软件包而非原始的 perl 实现的原因是为了便携性。有了 C++ 源代码,您可以在几乎所有语言中使用此库。

C++ 脚本是从 mosesdecoder 存储库的 contrib/c++tokenizer 调整而来。

基准测试

fast-mosestokenizer 速度也很快。在英语中,它比 tokenizer.perl 快约 6 倍,比 sacremoses 快 15 倍。

有关更多信息,请参阅 ./bench/README.md

安装

使用 linuxosx>=10.15 的 Python 用户可以直接从 PyPI 安装。

pip install fast-mosestokenizer

有关更多信息,请参阅 ./INSTALL.md

使用(命令行工具)

# Piping is the standard way to configure input and output stream.
# mosestokenizer would apply tokenization to each line of the input stream.
mosestokenizer en < infile > outfile

# For a full list of options, refer to the help message.
mosestokenizer -h

使用(Python)

# Usage patterns are mostly the same as sacremoses.
>>> from mosestokenizer import MosesTokenizer

>>> tokenizer = MosesTokenizer('en')
>>> tokenizer.tokenize("""
The English name of Singapore is an anglicisation of the native Malay name for
the country, Singapura, which was in turn derived from the Sanskrit word for
lion city (romanised: Siṃhapura; Brahmi: 𑀲𑀺𑀁𑀳𑀧𑀼𑀭; literally "lion city"; siṃha
means "lion", pura means "city" or "fortress").[8]
""")
[
  'The', 'English', 'name', 'of', 'Singapore', 'is', 'an', 'anglicisation',
  'of', 'the', 'native', 'Malay', 'name', 'for', 'the', 'country', ',',
  'Singapura', ',', 'which', 'was', 'in', 'turn', 'derived', 'from', 'the',
  'Sanskrit', 'word', 'for', 'lion', 'city', '(', 'romanised', ':',
  'Siṃhapura', ';', 'Brahmi', ':', '𑀲𑀺𑀁𑀳𑀧𑀼𑀭', ';', 'literally', '"', 'lion',
  'city', '"', ';', 'siṃha', 'means', '"', 'lion', '"', ',', 'pura', 'means',
  '"', 'city', '"', 'or', '"', 'fortress', '"', ')', '.', '[', '8', ']'
]

项目详情


下载文件

下载适用于您平台的项目文件。如果您不确定该选择哪个,请了解有关安装包的更多信息。

源分发

此版本没有可用的源分发文件。请参阅有关生成分发存档的教程。

构建分发

fast_mosestokenizer-0.0.8.2-cp38-cp38-manylinux1_x86_64.whl (802.0 kB 查看哈希值)

上传时间 CPython 3.8

fast_mosestokenizer-0.0.8.2-cp38-cp38-macosx_10_15_x86_64.whl (736.9 kB 查看哈希值)

上传时间 CPython 3.8 macOS 10.15+ x86-64

fast_mosestokenizer-0.0.8.2-cp37-cp37m-manylinux1_x86_64.whl (801.2 kB 查看哈希值)

上传时间 CPython 3.7m

fast_mosestokenizer-0.0.8.2-cp37-cp37m-macosx_10_15_x86_64.whl (736.0 kB 查看哈希值)

上传时间 CPython 3.7m macOS 10.15+ x86-64

fast_mosestokenizer-0.0.8.2-cp36-cp36m-manylinux1_x86_64.whl (801.1 kB 查看哈希值)

上传时间 CPython 3.6m

fast_mosestokenizer-0.0.8.2-cp36-cp36m-macosx_10_15_x86_64.whl (736.0 kB 查看哈希值)

上传时间 CPython 3.6m macOS 10.15+ x86-64

由以下支持