-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDis.java
More file actions
138 lines (130 loc) · 2.75 KB
/
Dis.java
File metadata and controls
138 lines (130 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import java.util.*;
import java.io.*;
class pair
{
int doc;
double val;
pair(int doc,double val)
{
this.doc = doc;
this.val = val;
}
}
class Sortbypair implements Comparator<pair>
{
public int compare(pair a, pair b)
{
if(a.val<b.val)
return 1;
if(b.val<a.val)
return -1;
return 0;
}
}
class Dis
{
public void printscore(double sum[][],ArrayList<String> arrd,ArrayList<String> arrq)
{
try
{
//for(int i=0;i<arrq.size();i++)
//{
FileWriter writer = new FileWriter("output.txt");
BufferedWriter buffer = new BufferedWriter(writer);
buffer.write("Final score for every query\n");
for(int i=0;i<arrq.size();i++)
{
if(arrq.get(i).length()<=100)
{
buffer.write(arrq.get(i));
for(int j=0;j<100-arrq.get(i).length();j++)
{
buffer.write(" ");
}
for(int j=0;j<arrd.size();j++)
{
buffer.write(" "+sum[i][j]);
}
buffer.write("\n");
}
else
{
buffer.write(arrq.get(i).substring(0,100));
for(int j=0;j<100-arrq.get(i).length();j++)
{
buffer.write(" ");
}
for(int j=0;j<arrd.size();j++)
{
buffer.write(" "+sum[i][j]);
}
int k=100;
buffer.write("\n");
buffer.write(arrq.get(i).substring(100));
buffer.write("\n");
}
}
buffer.close();
//}
}
catch(Exception e)
{
System.out.print(e.getMessage());
}
}
public void printtopscore(double sum[][],ArrayList<String> arrd,ArrayList<String> arrq,ArrayList<ArrayList<pair>> ans)
{
try
{
//for(int i=0;i<arrq.size();i++)
//{
FileWriter writer = new FileWriter("topscore.txt");
BufferedWriter buffer = new BufferedWriter(writer);
buffer.write("top score for every query\n");
for(int i=0;i<arrq.size();i++)
{
ArrayList<pair> ar = new ArrayList<>();
for(int j=0;j<arrd.size();j++)
{
ar.add(new pair(j,sum[i][j]));
}
Collections.sort(ar,new Sortbypair());
ans.add(ar);
if(arrq.get(i).length()<=50)
{
buffer.write(arrq.get(i));
for(int j=0;j<50-arrq.get(i).length();j++)
{
buffer.write(" ");
}
for(int j=0;j<10;j++)
{
buffer.write(" "+"(Doc"+ar.get(j).doc+":"+ar.get(j).val+")");
}
buffer.write("\n");
}
else
{
buffer.write(arrq.get(i).substring(0,50));
for(int j=0;j<50-arrq.get(i).length();j++)
{
buffer.write(" ");
}
for(int j=0;j<10;j++)
{
buffer.write(" "+"(Doc"+ar.get(j).doc+":"+ar.get(j).val+")");
}
buffer.write("\n");
buffer.write(arrq.get(i).substring(50));
buffer.write("\n");
}
}
buffer.close();
//}
}
catch(Exception e)
{
System.out.print(e.getMessage());
}
}
}