使用boost的正则库来过滤一篇文章的多余单词

hmsuccess 2009-02-19 03:16:31
使用boost的正则库来过滤一篇文章的多余单词,这些单词如a an the that this which what where however等一些无意义的单词,
不知道有没有什么好的方法,谢谢
...全文
218 19 打赏 收藏 转发到动态 举报
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
alan001 2009-02-28
  • 打赏
  • 举报
回复
mark
lzh9955 2009-02-28
  • 打赏
  • 举报
回复
up
hmsuccess 2009-02-28
  • 打赏
  • 举报
回复
[Quote=引用 16 楼 waizqfor 的回复:]
引用 15 楼 hmsuccess 的回复:
那么,我这么问
比如在搜索引擎中,关于英文的分词技术,怎么过滤掉那些无用的东西
谢谢

http://jerrie.9hy.com/contents/1209364234.phtml这有介绍
[/Quote]
谢谢
waizqfor 2009-02-20
  • 打赏
  • 举报
回复
[Quote=引用 15 楼 hmsuccess 的回复:]
那么,我这么问
比如在搜索引擎中,关于英文的分词技术,怎么过滤掉那些无用的东西
谢谢
[/Quote]
http://jerrie.9hy.com/contents/1209364234.phtml这有介绍
hmsuccess 2009-02-20
  • 打赏
  • 举报
回复
那么,我这么问
比如在搜索引擎中,关于英文的分词技术,怎么过滤掉那些无用的东西
谢谢
zqz981 2009-02-19
  • 打赏
  • 举报
回复
mark
hmsuccess 2009-02-19
  • 打赏
  • 举报
回复
program_options?哦
我先看看,谢谢
lightnut 2009-02-19
  • 打赏
  • 举报
回复
boost::program_options + boost::regex
要去掉的垃圾由boost::program_options 提供就可以了.
hmsuccess 2009-02-19
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 wuyu637 的回复:]
建个垃圾单词表,把这个表里的单词读入的一个hash表中,


然后读入过滤即可。。
[/Quote]
当初,我也是这么想的,读入一个单词,然后在垃圾集合中找对应的,如果有的话删除,没有就保留,
可是我觉得可能效率有点慢,谢谢
wuyu637 2009-02-19
  • 打赏
  • 举报
回复
建个垃圾单词表,把这个表里的单词读入的一个hash表中,


然后读入过滤即可。。
  • 打赏
  • 举报
回复
这个用泛型unique就可以搞定了啊,需要boost吗?
hmsuccess 2009-02-19
  • 打赏
  • 举报
回复
还有,就是去掉的单词不止这些,还有其他无意义的
waizqfor 2009-02-19
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 hmsuccess 的回复:]
引用 3 楼 baihacker 的回复:
C/C++ code#include <string>#include <iostream>#include <boost/regex.hpp>usingnamespacestd;usingnamespaceboost;intmain()
{//直接replace会有公共前缀的问题//两边加上空白符吧...还有\t之类没有写,只作示例regex word_reg("a | an | the | that | this | which | what | where | however");stringstr="this is an apple. where is the pig? that is it";
str=regex_replace(str,…
[/Quote]
查找一个一个的去掉 跟这个比起来差不多撒
old-six-programmer 2009-02-19
  • 打赏
  • 举报
回复
要不你想怎样

那就读配置文件
[Quote=引用 5 楼 hmsuccess 的回复:]
引用 3 楼 baihacker 的回复:
C/C++ code#include <string>#include <iostream>#include <boost/regex.hpp>usingnamespacestd;usingnamespaceboost;intmain()
{//直接replace会有公共前缀的问题//两边加上空白符吧...还有\t之类没有写,只作示例regex word_reg("a | an | the | that | this | which | what | where | however");stringstr="this is an apple. where is the pig? that is it";
str=regex_replace(str,…
[/Quote]
hmsuccess 2009-02-19
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 baihacker 的回复:]
C/C++ code#include<string>#include<iostream>#include<boost/regex.hpp>usingnamespacestd;usingnamespaceboost;intmain()
{//直接replace会有公共前缀的问题//两边加上空白符吧...还有\t之类没有写,只作示例regex word_reg("a | an | the | that | this | which | what | where | however");stringstr="this is an apple. where is the pig? that is it";
str=regex_replace(str, word_reg,"@");
cout<<str<<endl;…
[/Quote]
您这样是把所有需要去掉的单词全部写出来,然后replace掉,可以是可以
但是我总觉得有点麻烦
ch1oE 2009-02-19
  • 打赏
  • 举报
回复
学习。。还没用过boost。。。惭愧。。。
baihacker 2009-02-19
  • 打赏
  • 举报
回复
#include <string>
#include <iostream>
#include <boost/regex.hpp>
using namespace std;
using namespace boost;

int main()
{
//直接replace会有公共前缀的问题
//两边加上空白符吧...还有\t之类没有写,只作示例
regex word_reg(" a | an | the | that | this | which | what | where | however");
string str ="this is an apple. where is the pig? that is it";
str = regex_replace(str, word_reg, "@");
cout << str << endl;
return 0;
}
waizqfor 2009-02-19
  • 打赏
  • 举报
回复
帮顶!~~ 先想想
baihacker 2009-02-19
  • 打赏
  • 举报
回复
直接replace掉?

65,211

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧