基于C++的快速Unicode基于MG的令牌记录器
fasttokenizer的Python项目详细描述
快速标记器
FastTokenizer是一个用于执行与语言无关的标记器 使用unicode信息进行标记化。在
而最初的目标是为了 机器翻译,相同的标记器足够通用,可以进行调整 由于NLP的处理能力 语言和书写系统的范围。在
FastTokenizer的一些显著特性是
- 提供只是适当数量的标记化。
- 分段设计为直观和基于规则。 这种格式非常适合于下游的NLP模型,如子词建模, RNN或变压器。在
- 也设计得不那么咄咄逼人。 这样可以减少令牌的数量,从而使模型运行得更快。在
- 适用于任何语言/书写系统。在
- 交叉编程语言。在
- 执行格式保留unicode规范化。在
- 在WMT和GLUE等任务上,性能匹配或超过moses标记器。在
- 标记化可以反转。
- 但是,应该使用自定义的desegmenter来实现所需的格式 因为去分段是高度用例驱动的。在
与其他网络标记器的比较
Source: 他的表现遭到《天空体育》评论员内维尔的批评。
Segmenter: ['他的表现遭到', '《', '天空体育', '》', '评论员内维尔的批评', '。']
Moses: ['他的表现遭到《天空体育》评论员内维尔的批评。']
Spacy Tokenizer: ['他的表现遭到《天空体育》评论员内维尔的批评。']
Tweet Tokenizer: ['他的表现遭到', '《', '天空体育', '》', '评论员内维尔的批评', '。']
NLTK Tokenizer: ['他的表现遭到《天空体育》评论员内维尔的批评。'
Source: AirPods耳機套
Segmenter: ['AirPods', '耳機套']
Moses: ['AirPods耳機套']
Spacy Tokenizer: ['AirPods耳機套']
Tweet Tokenizer: ['AirPods耳機套']
NLTK Tokenizer: ['AirPods耳機套']
Source: A typical master's programme has a duration of 1-1.5 years.
Segmenter: ['A', 'typical', "master's", 'programme', 'has', 'a', 'duration', 'of', '1', '@-@', '1.5', 'years', '.']
Moses: ['A', 'typical', 'master', "'s", 'programme', 'has', 'a', 'duration', 'of', '1', '@-@', '1.5', 'years', '.']
Spacy Tokenizer: ['A', 'typical', "master's", 'programme', 'has', 'a', 'duration', 'of', '1-1.5', 'years.']
Tweet Tokenizer: ['A', 'typical', "master's", 'programme', 'has', 'a', 'duration', 'of', '1-1', '.', '5', 'years', '.']
NLTK Tokenizer: ['A', 'typical', 'master', "'s", 'programme', 'has', 'a', 'duration', 'of', '1-1.5', 'years', '.']
安装
C++ +EH3>
很快就到了。在
Python
^{pr2}$使用
C++ +EH3>#include<fasttokenizer/segmenter.h>Segmentersegmenter=Segmenter(args.protected_dash_split);std::stringtext="Hello World!";std::stringoutput;// Normalizeoutput=segmenter.normalize(text)// Segmentoutput=segmenter.segment(text)// Normalize and segment in one function// Reduce string to icu::UnicodeString overheadoutput=segmenter.normalize_and_segment(text);// Desegmentoutput=segmenter.desegment(text);
Python
importfasttokenizersegmenter=fasttokenizer.Segmenter()text="Hello World!"# Normalizeoutput:str=segmenter.normalize(text)# Segmentoutput:str=segmenter.segment()# Normalize and segmentoutput:str=segmenter.normalize_and_segment(text)# Output of segment is str.# To get tokens, you can split by whitespace.tokens=output.split()# Desegmentoutput:str=segmenter.desegment(text)
标签:
- 项目
标签: