如何标记文本文件的集合? [英] How to tokenize a collection of text file?

查看:84
本文介绍了如何标记文本文件的集合?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理Information Retrieval字段。对于这个项目,我需要Tokenize一组文档,如文本文件。我已经完成了如何标记字符串和一个文本文件。但是在文本文件中我只能在空格上进行标记,不能使用连字符或逗号等。所以,我需要实际上将其标记为的Java代码。获取时的字符,或 - 或等的文本文件集合。请帮忙....

解决方案

只需简单地替换空格即可。 "在带有逗号,的代码中对其他角色进行标记化。

但是你很可能希望所有提到的字符一起成为一个标记分隔符。然后使用正则表达式进行标记:

展开 | 选择 | Wrap | 行号


非常感谢...我能够在获取空白区域时对文本文件进行标记化任何其他标点符号。现在我想要标记文本文件的集合,而不仅仅是单个文本文件。

我在这里附加我的代码。一个错误已经发生,我无法找到为什么实际上它是发生的历史。





附加文件
filetoken.txt (1.1 KB,498 views)


好的,这是文件中的代码。我把它直接放在这里使用代码标签而不是文本文件,因为这样他人就更容易阅读(并理解并根据行号提供帮助)。出于同样的原因,我通过删除已注释掉的代码进行清理,然后正确缩进。

清理原始代码:

展开 | 选择 | Wrap | 行号

I am working on Information Retrieval field.For this project I need to Tokenize a collection of documents such as text files. I have done how to tokenize a string and one text file.but in the text file i am able to tokenize on the whitespace only,not able to work on hyphen or comma etc.So,I need the java code which will actually tokenize the character while getting , or - or '' etc for a collection of text files. pls help pls....

解决方案

Just simply replace the whitespace " " in the code with a comma "," etc. to tokenize on other characters.
But most likely you want all of the mentioned characters together to be a token separator. Then tokenize by using regular Expression:

Expand|Select|Wrap|Line Numbers


thank you very much...I am able to tokenize the text file on getting white space and any other punctuation.Now I want to tokenize a collection of text files not only a single text file.
I am attaching my code here.one error has occured and i am unable to find why actualy it is occuring.

Attached Files
filetoken.txt (1.1 KB, 498 views)


Ok, here is the code from the file. I put it here directly using code tags instead of a text file, because then it''s easier for others to read (and understand and providing help based on the line number). For the same reason, I cleaned up by removing commented-out code and then indented it properly.
Cleaned-up original code:

Expand|Select|Wrap|Line Numbers


这篇关于如何标记文本文件的集合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆