i have text file of this form:
0 file:/home/lenovo/mallet/cleantweet/2428741 1 0.2406223358908781 3 0.15934924694515487 0 0.1308610400682012 7 0.11295822676896845 9 0.08688547882921284 8 0.08077578857630009 4 0.0784313725490196 6 0.06045751633986928 5 0.029269678886047173 2 0.020389315146348393
1 file:/home/lenovo/mallet/cleantweet/28397802 1 0.3631535947712418 7 0.1323529411764706 0 0.0988562091503268 8 0.08905228758169935 3 0.07026143790849673 4 0.06004901960784314 9 0.05800653594771242 5 0.049836601307189546 6 0.04861111111111111 2 0.0298202614379085
..more entries like this.
I need to store the double values in an 2-d array. the last value in this path is id file:/home/lenovo/mallet/cleantweet/2428741. and integer values are some topics. the array should be like this a[u1][t1]= 0.1308610400682012 a[u2][t2]=0.020389315146348393 etc..
code =java
String line[],a[];
ArrayList<String> list = new ArrayList<String>();
ArrayList<Integer> u = new ArrayList<Integer>();
List<Map<Integer,Double>>prob;
public static void main(String[] args) throws FileNotFoundException, IOException, Exception {
String s=null,usr[];
String str[]=null;
int i=0,user=0;
lda2 ld= new lda2();
FileReader fr = new FileReader("/home/lenovo/mallet/mydata_inferdoctopics");
BufferedReader br = new BufferedReader(fr);
while ((s = br.readLine()) != null){
ld.list.add(s);
// System.out.println(ld.list
ld.a=s.split("\t");
System.out.println(ld.a.length);
usr = ld.a[1].split("/");
ld.u.add(Integer.parseInt(usr[5]));
user++;
}
String[] listarray = new String [ld.list.size()];
int mat[][]= new int [user][10];
for( i=0;i<ld.list.size();i++){
listarray[i] = ld.list.get(i);
// System.out.println(listarray[i]);
}
double b[];
for(int k=0;k<listarray.length;k++){
System.out.println(listarray[k]);
str= listarray[k].split("\t");
Map<Integer,Double> pr = new TreeMap<Integer,Double>();
for(int j=2;j<str.length{
// System.out.println(str[j]);
pr.put(Integer.parseInt(str[j]),Double.parseDouble(str[j+1]));
j=j+2;
}
// ld.prob.add(pr);
int key[];
for (Map.Entry<Integer,Double> entry : pr.entrySet()) {
System.out.println("z:"+entry.getKey()+"\t"+"prob: "+ entry.getValue());
}
}
[/code]
am i going in correct way?