package com;
import java.util.ArrayList;
import java.util.List;
public class Segmentation1 {
private List<String> dictionary = new ArrayList<String>();
private String request = "北京大学生前来应聘";
public void setDictionary() {
dictionary.add("北京");
dictionary.add("北京大学");
dictionary.add("大学");
dictionary.add("大学生");
dictionary.add("生前");
dictionary.add("前来");
dictionary.add("应聘");
}
public String leftMax() {
String response = "";
String s = "";
for(int i=0; i<request.length(); i++) {
s += request.charAt(i);
if(isIn(s, dictionary) && aheadCount(s, dictionary)==1) {
response += (s + "/");
s = "";
} else if(aheadCount(s, dictionary) > 0) {
} else {
response += (s + "/");
s = "";
}
}
return response;
}
private boolean isIn(String s, List<String> list) {
for(int i=0; i<list.size(); i++) {
if(s.equals(list.get(i))) return true;
}
return false;
}
private int aheadCount(String s, List<String> list) {
int count = 0;
for(int i=0; i<list.size(); i++) {
if((s.length()<=list.get(i).length()) && (s.equals(list.get(i).substring(0, s.length())))) count ++;
}
return count;
}
public static void main(String[] args) {
Segmentation1 seg = new Segmentation1();
seg.setDictionary();
String response1 = seg.leftMax();
System.out.println(response1);
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有