Java bigram分词

package SplitTest;
import java.util.Scanner;
public class SplitTest{
public static void main(String[] agrs) {
Scanner in = new Scanner(System.in);
String str = in.nextLine();
String[] ss = str.split(" ");
System.out.println("first = ");
String str1 = in.next();
System.out.println("Second = ");
String str2 = in.next();
for(int i = 0;i < ss.length-2;i++) {
if(str1.equals(ss[i]) && str2.equals(ss[i+1])) {
System.out.println(ss[i+2]);
}
}
}
}

你可能感兴趣的:(Java bigram分词)