The following content has not been substantially tested. Because the author did not use the relevant needs, just a temporary rise, according to their own ideas to explore. No consideration has been given to pay ranking, word priority, search volume ranking, timeliness and other factors. Entertainment for a while, may be really do this kind of search God joke, bear their own blind thinking.
2. Segmentation matching with simple algorithm:
/**Simple algorithm * Split the statements entered in the user input box to maximize the matching query * @param str: Query content entered by user * Red_Ant 20181124 */ public static final String PUTUATION = ". ,,': ∶;?''""〝〞ˆˇ﹕︰﹔﹖﹑·¨....¸;!´?!~—ˉ|‖"〃`@﹫¡¿﹏﹋﹌︴Shan﹟#﹩$﹠&﹪%*﹡﹢﹦﹤‐ ̄¯―﹨ˆ˜﹍﹎+=<__-\\ˇ~﹉﹊()〈〉‹›﹛﹜『』〖〗[]<>〔〕{}「」[]︵︷︿︹︽_﹁﹃︻︶︸﹀︺︾ˉ﹂﹄︼"; public static List<String> dealInputStr(String str) { /*After we input the content for query, there will always be some priority displayed at the top (except for the paid ranking) * Suppose that the final result of the query is of type String */ //1. Create a collection to store the final results List<String> resultLst = new ArrayList<String>(); //2. The highest priority is to regard the user's input as a whole to find out List<String> strLst = selectStrFromDataBase(str);//Query from the corresponding library, content. Different methods, omitted here! if(strLst.size() > 0) { resultLst.addAll(strLst); } //3. Then we use the punctuation in user input to divide the input statement into different STRs [take common punctuation as an example] //The author also thinks that punctuation has many differences and priorities. Come on, don't go into it. String[] strs = str.split(""); int strsLength = strs.length; List<Integer> num = new ArrayList<Integer>(); for (int i = 0; i < strsLength; i++) { if(PUTUATION.contains(strs[i])) { num.add(i); } } //The input statement is segmented according to the position of punctuation int j = 0;//Store intercept string location /*Used to store the results after punctuation * According to this result, the cell segmentation is carried out */ String ss; List<String> pttstrLst = new ArrayList<String>(); for (int i = 0; i < num.size(); i++) { if(i == num.size()-1) { ss = str.substring(j); }else { ss = str.substring(j, num.get(i)); } pttstrLst.add(ss); strLst = selectStrFromDataBase(ss); if(strLst.size() > 0) { resultLst.addAll(strLst); } j = num.get(i) + 1; } /*4,Cell segmentation based on the result of punctuation * The content after segmentation is matched to the cell lexicon respectively by the way of the left and right adjacent truncation of the character number gradually - 1 * For every n words reduced, there may be n+1 until there are only two words left. */ String ss1; for (int i = 0; i < pttstrLst.size(); i++) { //jugeWord(String str), the method of querying database is omitted! ss = pttstrLst.get(i); int len = ss.length() - 2; int s = 0; int strlen = ss.length(); while (len > 1) { int len1 = strlen - 2; while (len1 < strlen-1) { ss1 = ss.substring(s, len1); if(!jugeWord(ss1)) { strLst = selectStrFromDataBase(ss1); if(strLst.size() > 0) { resultLst.addAll(strLst); } } s++; len1++; } len--; } } return resultLst; }
[notice]
The above methods have not been applied in real scenes, and there are many factors that have not been considered. The author thinks that if this method works well, there are many things worth considering and optimizing.