public class WordSegmentation
{
public static void main(String[] args)
{
String[] stopList = { "an", "and", "are", "as", "at", "be", "by",
"for", "from", "has", "he", "in", "is", "it", "its", "of",
"on", "that", "the", "to", "was", "were", "will", "with" };
String doc = "The search trees overcome many issues of hash dictionary";
java.util.Arrays.sort(stopList);
String[] result = doc.toLowerCase().split("
\\W");
for(int i=0;i<result.length;i++)
{
if(result[i].equals(""))
continue;
if(java.util.Arrays.binarySearch(stopList,result[i])<0)
System.out.println(result[i]);
}
}
}
[此贴子已经被作者于2010-12-12 08:24:12编辑过]