程序不能实现筛选出长度由1到8的高频短语,输出结果也没有导出。。。。

。。。。其实想实现功能是图片中算法的功能啦。。可是。。。代码真的不会。。。。
小女子跪求各位兄弟姐妹们,能让我早点回家。。。。。在这里谢谢各位了。悬赏66,希望大家都6666666
图片说明
We use C[·] to index a word in the corpus string and |C|to denote the corpus size. The ⊕ operator is for concatecating two words or phrases. Alg. 1 returns a keyvalue dictionary f. Its keys are vocabulary U containing all frequent phrases P, and words U n P. Its values are theirraw frequenc。。

我自己也找了一个代码。。但是。。。结果不尽如人意。。大姐们大兄弟们 可以运行看一下。。。。
FCimport java.io.BufferedReader;
import java.io.FileReader;
import java.util.LinkedHashMap;
import java.util.Vector;

class tt{
public String phrase;
public int count;
}
public class searchphrase{
private static LinkedHashMap phrase = new LinkedHashMap();
static tt[] max_phrase;
private static Vector SeparateString(String s)
{
Vector vector = new Vector();
String temp = "";
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i)!=' ') {
temp+=s.charAt(i);
}else {
if (temp!="") {
vector.add(temp);
temp="";
}
}
}
if (temp!="") {
vector.add(temp);
return vector;
}
return vector;
}
private static void swap(int pos, int count, String phrase ){
int i;
if (max_phrase[pos-1].count for (i = pos-1;i>0; i--) {
if (max_phrase[i-1].count>max_phrase[i].count) {
break;
}
}
max_phrase[pos].count=max_phrase[i].count;
max_phrase[pos].phrase=max_phrase[i].phrase;
max_phrase[i].count=count;
max_phrase[i].phrase=phrase;
}
}
private static void adjust_max(int count,String phrase) {
int i,j;
if (count<=max_phrase[max_phrase.length-1].count) {
return;
}
for (i = max_phrase.length-1; i>=0; i--) {
if (max_phrase[i].phrase.equals(phrase)) {
max_phrase[i].count=count;
if (i>0) {
swap(i, count, phrase);
}
return;
}
}
max_phrase[max_phrase.length-1].count=count;
max_phrase[max_phrase.length-1].phrase=phrase;
if (i>0) {
swap(max_phrase.length-1, count, phrase);
}
}
private static void js(Vector v,int n ) {
String s;
for (int i = 0; i < v.size()-n+1; i++) {
s="";
for (int j = i; j < i+n; j++) {
s+=v.get(j)+" ";

}
int count =1;

String a=String.valueOf(s.hashCode());
if(phrase.containsKey(a)){
count=Integer.parseInt(phrase.get(a).toString());
count++;
}
String count1 = String.valueOf(count);
phrase.put(a, count1);
adjust_max(count, s);
}
}
public static void main(String[] args) {
try {
long t;
int m,n;
String path;
m=Integer.parseInt(args[0]);
n=Integer.parseInt(args[1]);

path = args[2];
max_phrase = new tt[m];
for (int i = 0; i < m; i++) {
max_phrase[i]=new tt();
max_phrase[i].count=0;
max_phrase[i].phrase="";
}
t=(new java.util.Date()).getTime();
java.io.FileReader fr=new FileReader(path);
java.io.BufferedReader br = new BufferedReader(fr);
String s;
Vector v = null;
while ((s=br.readLine())!=null) {
v=SeparateString(s);
js(v, n);

}
for (int i = 0; i < m; i++) {
System.out.println(max_phrase[i].phrase);
System.out.println(max_phrase[i].count);
System.out.println();
}
t=(new java.util.Date().getTime()-t);
System.out.println(t);
System.out.println("ms");
} catch (Exception e) {
// TODO: handle exception
}
}
}

筛选出 高频短语 ,就用treemap把 各个单词出现总次数记录下来,treemap是有序的

同意一楼的建议!用treemap把单词和出现的次数存起来,用单词做键,出现次数做值,用值做一个排序,就可以啦