boost-tokenizer分词库学习
boost-tokenizer学习
tokenizer库是一个专门用于分词(token)的字符串处理库;
可以使用简单易用的方法把一个字符串分解成若干个单词;
tokenizerl类是该库的核心,它以容器的外观提供分词序列;
TokenizerFunc:专门的分词函数对象,默认使用空格和标点分词
- char_delimiters_separator 使用标点符号分词
- char_separator 使用字符集合作为分词符
- escaped_list_separator 使用CSV的逗号分割
- offset_separator 使用偏移量来分词
缺陷:
1、只支持使用单个字符进行分词;
2、对wstring(UNICODE)缺乏完善的考虑;
正则表达式xpressive和string_algo可以提供更好的实现,可以对字符串操作工作的更好!
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
/*
tokenizer库是一个专门用于分词(token)的字符串处理库; 可以使用简单易用的方法把一个字符串分解成若干个单词; tokenizerl类是该库的核心,它以容器的外观提供分词序列; TokenizerFunc:专门的分词函数对象,默认使用空格和标点分词 char_delimiters_separator 使用标点符号分词 char_separator 使用字符集合作为分词符 escaped_list_separator 使用CSV的逗号分割 offset_separator 使用偏移量来分词 缺陷: 正则表达式xpressive和string_algo可以提供更好的实现,可以对字符串操作工作的更好! /* // It seems that MSVC does not like the unqualified use of iterator, public: typedef iter iterator; tokenizer(Iterator first, Iterator last, template <typename Container> template <typename Container> void assign(Iterator first, Iterator last){ void assign(Iterator first, Iterator last, const TokenizerFunc& f){ template <typename Container> template <typename Container> iter begin() const { return iter(f_,first_,last_); } */ /************************************************************************/ /************************************************************************/ using namespace boost; template<typename T> int main(void) string str2 = "I,love,my,town!"; //char_separator string str4 = ";!!;Hello|world||-Michael--Joessy;yoo;handsome|"; char_separator<char> sep2("-;", "|", keep_empty_tokens); //escaped_list_separator //offset_separator }; cin.get(); |
boost-tokenizer分词库学习的更多相关文章
- 【Todo】Boost安装与学习
现在这里找下载包 http://sourceforge.net/projects/boost 我找的是 1_62_0 下面是从公司wiki上找到的一个说明. boost & thrift安装步 ...
- 【Boost】boost::tokenizer详解
分类: [C++]--[Boost]2012-12-28 21:42 2343人阅读 评论(0) 收藏 举报 目录(?)[+] tokenizer 库提供预定义好的四个分词对象, 其中char ...
- boost::tokenizer详解
tokenizer 库提供预定义好的四个分词对象, 其中char_delimiters_separator已弃用. 其他如下: 1. char_separator char_separator有两个构 ...
- boost::tuple 深入学习解说
#include<iostream> #include<string> #include<boost/tuple/tuple.hpp> #include<bo ...
- Boost线程库学习笔记
一.创建一个线程 创建线程 boost::thread myThread(threadFun); 需要注意的是:参数可以是函数对象或者函数指针.并且这个函数无参数,并返回void类型. 当一个thre ...
- boost asio io_service学习笔记
构造函数 构造函数的主要动作就是调用CreateIoCompletionPort创建了一个初始iocp. Dispatch和post的区别 Post一定是PostQueuedCompletionSta ...
- boost timer代码学习笔记
socket连接中需要判断超时 所以这几天看了看boost中计时器的文档和示例 一共有五个例子 从简单的同步等待到异步调用超时处理 先看第一个例子 // timer1.cpp: 定义控制台应用程序的入 ...
- Boost.Coroutine2:学习使用Coroutine(协程)
function(函数)routine(例程)coroutine (协程) 函数,例程以及协程都是指一系列的操作的集合. 函数(有返回值)以及例程(没有返回值)也被称作subroutine(子例程), ...
- Lucene 中的Tokenizer, TokenFilter学习
lucene中的TokenStream,TokenFilter之间关系 TokenStream是一个能够在被调用后产生语汇单元序列的类,其中有两个类型:Tokenizer和TokenFilte ...
随机推荐
- Python 二维码解码
二维码解析 Python中关于二维码解析的现成模块有很多,比较著名的就是Zbar以及ZXing.然而很不幸的是,官方的版本都是支持到python2.x,下面是在python2.x的例子: import ...
- 微信小程序innerAudioContext接口
voice:function(){ var word = this.data.word; var src = 'https://--/'+word['word']+'.mp3'; console.lo ...
- HTML 的超链接 a 标签中如何设置其宽度和高度?
HTML 的超链接 a 标签中如何设置其宽度和高度? 在DIV CSS布局中,html 中 a 超链接标签,直接对其设置宽度和高度不能生效,设置宽度和高度也不起作用,这里为大家分享如何实现 a 标签宽 ...
- 【Statistics】CAP曲线
功能描述 CAP曲线(Cumulative Accuracy Profile)/Power Curve(准确率/AR)是描述整个评级结果下,累计违约客户比例与累计客户比例的关系. 在完美的模型下,CA ...
- Linux命令-网络命令:lastlog
last 显示所有用户最后登录信息(会显示系统用户) last -u 只看某一个用户wangyunpeng的最后登录信息 last -u 查看系统用户root的最后登录信息 root用户的ID是0.从 ...
- Shell 基础笔记
1-22-shell脚本的基础 本节所讲内容: shell 基本语法 变量 第1章 什么是SHELL?.. 2 1.1 shell编程.. 3 第2章 shell变量及运用.. ...
- mysql创建账号对应的数据库方法
增加一个用户mydb密码为123450, 让他只可以在(localhost/%)%表示可以支持远程上登录,并可以对数据库mydata5_db进行查询.插入.修改.删除的操作. grant select ...
- [个人开发人员赚钱九]做一个日收入10元的APP!
[导语]尽管讲了非常多个人开发人员的文章.但新手开发人员怎样赚自己的第一个10块钱.确是最难的事情.群里有人说都不知道干什么app赚钱.全然没有想法.而且常常问我有什么高速赚钱的方法.我仅仅能遗憾地 ...
- Oracle之配置客户端登陆多个远程数据库
一.引言 一直搞不明白Oracle数据库的客户端是怎么回事,怎么配置,前几天由于工作中需要用到Oracle,而且需要连接两个不同的数据库,就通过上网和请教同事终于把客户端的配置搞定了,记录之,学习之 ...
- 【网络爬虫】Httpclient4.X中使用HTTPS的方法采集12306网站
HttpClient请求https的实例: package train; import java.io.IOException; import java.security.NoSuchAlgorith ...