如何删除java中的停用词?(How to remove stop words in java?)

编程入门 行业动态 更新时间:2024-10-25 21:30:59
如何删除java中的停用词?(How to remove stop words in java?)

我想删除java中的停用词。

所以,我从文本文件中读取了停用词。

并存储设置

Set<String> stopWords = new LinkedHashSet<String>(); BufferedReader br = new BufferedReader(new FileReader("stopwords.txt")); String words = null; while( (words = br.readLine()) != null) { stopWords.add(words.trim()); } br.close();

而且,我读了另一个文本文件。

所以,我想删除文本文件中的重复字符串。

我怎么能够?

I want to remove stop words in java.

So, I read stop words from text file.

and store Set

Set<String> stopWords = new LinkedHashSet<String>(); BufferedReader br = new BufferedReader(new FileReader("stopwords.txt")); String words = null; while( (words = br.readLine()) != null) { stopWords.add(words.trim()); } br.close();

And, I read another text file.

So, I wanna remove to duplicate string in text file.

How can I?

最满意答案

你想从文件中删除重复的单词,下面是相同的高级逻辑。

读取文件 循环播放文件内容(即一次一行) 根据空间为该行提供字符串标记生成器 将每个标记添加到您的设置中。 这将确保您每个单词只有一个条目。 关闭文件

现在你已经设置了包含文件的所有唯一字。

You want to remove duplicate words from file, below is the high level logic for same.

Read File Loop through file content(i.e one line at a time) Have string tokenizer for that line based on space Add each each token to your set. This will make sure that you have only one entry per word. Close file

Now you have set that contains all the unique word of file.

更多推荐

本文发布于:2023-07-30 06:25:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1336712.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:remove   java   words   stop

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!