public class DisposeText extends Object
文件名:DisposeText.java
用途:用于对文件中的文本进行处理,以简化日常工作中对文本的内容的测试
编码时间:2019年7月4日 07:08
修改时间:2019年7月11日 09:12
Constructor and Description |
---|
DisposeText() |
Modifier and Type | Method and Description |
---|---|
static List<String> |
compareFileWord(List<String> testList,
List<String> targetList)
用于将两个词语集合进行比较,并返回待测集合不在目标集合中的元素
|
static List<String> |
splitText(String text,
String... regexs)
用于对文本按照切分符多次切分,返回最终的切分结果
|
static LinkedHashMap<String,Integer> |
statistics(List<String> wordList)
用于统计每个内容在集合中出现的次数
|
static String |
textDelDuplication(String text)
该方法用于对文本进行去重,保留不重复的字符
|
static List<String> |
wordDelDuplication(List<String> textList)
该方法用于对文本中单词进行去重,输出不重复单词
|
public static List<String> compareFileWord(List<String> testList, List<String> targetList)
testList
- 待测试集合targetList
- 目标集合IllegalDataException
- 未指定集合时抛出的异常public static String textDelDuplication(String text)
text
- 待去重的文本public static List<String> splitText(String text, String... regexs)
注意:切分符必须使用正则表达式的写法,例如按照“.”进行切分,则必须传入“\\.”
text
- 需要切分的内容regexs
- 切分符号组public static List<String> wordDelDuplication(List<String> textList)
textList
- 待去重的词语集合public static LinkedHashMap<String,Integer> statistics(List<String> wordList)
wordList
- 需要统计的集合Copyright © 2024. All rights reserved.