| | |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.nio.file.Files; |
| | | import java.nio.file.Paths; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Stream; |
| | | |
| | |
| | | |
| | | public static void main(String[] args) throws Exception { |
| | | |
| | | test_StringSearch(); |
| | | test_WordsSearch(); |
| | | // test_StringSearch(); |
| | | // test_WordsSearch(); |
| | | |
| | | Map content = new HashMap(); |
| | | content = interceptWords("nihoahsodahioda美国,大萨达日本"); |
| | | System.out.println(content); |
| | | // test_StringSearchEx(); |
| | | // test_WordsSearchEx(); |
| | | // |
| | |
| | | // test_issues_74(); |
| | | } |
| | | |
| | | public static String interceptWords(String content) { |
| | | public static Map interceptWords(String content) { |
| | | List<String> list = new ArrayList<String>(); |
| | | list.add("美国"); |
| | | list.add("日本"); |
| | |
| | | StringSearch iwords = new StringSearch(); |
| | | iwords.SetKeywords(list); |
| | | |
| | | // boolean b = iwords.ContainsAny(test); |
| | | // if (b == false) { |
| | | // System.out.println("ContainsAny is Error."); |
| | | // } |
| | | Map res = new HashMap(); |
| | | |
| | | boolean b = iwords.ContainsAny(content); |
| | | if (b == false) { |
| | | System.out.println("ContainsAny is Error."); |
| | | } |
| | | |
| | | res.put("iswords",String.valueOf(b)); |
| | | |
| | | // |
| | | // String f = iwords.FindFirst(test); |
| | | // if (f != "中国") { |
| | |
| | | if (str.equals("我是***") == false) { |
| | | System.out.println("Replace is Error."); |
| | | } |
| | | return str; |
| | | res.put("content",str); |
| | | |
| | | String text = ""; |
| | | List<String> all = iwords.FindAll(content); |
| | | for (int i = 0; i < all.size(); i++) { |
| | | text += all.get(i) + ","; |
| | | } |
| | | String words = ""; |
| | | if(!text.equals("")){ |
| | | words = text.substring(0,text.length()-1); |
| | | } |
| | | |
| | | |
| | | res.put("words",words); |
| | | |
| | | return res; |
| | | } |
| | | |
| | | public static void test_StringSearch() { |