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 ...
随机推荐
- ZK框架笔记5、事件
事件是org.zkoss.zk.ui.event.Event类,它通知应用程序发生了什么事情.每一种类型的事件都由一个特定的类来表示. 要响应一个事件,应用程序必须为事 ...
- nutch中bin/crawl和bin/nutch crawl的用法(转)
针对上一篇文章中出现的问题:Command crawl is deprecated, please use bin/crawl instead错误信息,今天在官网上查阅了一下,进行了总结. 官网lin ...
- 转: python 利用EMQ实现消费者和生产者模型
消费者 """ 测试emq-消费者 @author me """ import paho.mqtt.client as mqtt impor ...
- Josephus排列
思考与分析: 对于m为常数,能够用循环链表,用head,tail标志头尾指针使其易于表示循环结构.循环输出后删除结点n次,每次外层循环时.内层都固定循环m次.所以执行时间为O(mn)=O(n). 对于 ...
- php 面象对象类自动加载
//自动加载第一步 function myload($class) { require('./'.$class.'.class.php'); } //注册一个函数为自动触发函数 spl_autoloa ...
- laydate 和 Vue 奇怪的清空问题
laydate的input,会自动被清空,当别的input修改的时候.改成这样既可解决 <td><input type="text" id="retur ...
- Android收起虚拟键盘
关于收起虚拟键盘,网上能找到的大多是这个: InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_M ...
- 【ZT】NUMA架构的CPU -- 你真的用好了么?
本文从NUMA的介绍引出常见的NUMA使用中的陷阱,继而讨论对于NUMA系统的优化方法和一些值得关注的方向. 文章欢迎转载,但转载时请保留本段文字,并置于文章的顶部 作者:卢钧轶(cenalulu) ...
- poj Buy Tickets
题目链接:http://poj.org/problem?id=2828 类似的题目:http://www.cnblogs.com/lovychen/p/3674048.html 测试数据: in: 4 ...
- CCNA2.0笔记_IP连接排错
IPv4 路由排错 ping tracert traceroute telnet show mac address-table show interfaces fastEthernet 0/1 sho ...