*/
public static void main(String[] args) throws IOException
{
int num_instances = 200;
int countNonNull=0;
CSVFileWriter out = new CSVFileWriter("clusteringDistancesCSV.csv", ',');
Vector<String> headers = new Vector<String>();
headers.add("Euclidean");
headers.add("Manhattan");
out.writeFields(headers);
CSVFileReader in1 = new CSVFileReader("csv_out.csv", ',');
// skip the headers
Vector<String> fields1 = in1.readFields();
fields1 = in1.readFields();
int count1 = 0;
while (fields1 != null)
{
String id1 = fields1.get(0) + fields1.get(1);
Object[] bagOfWordsTfIdf1 = fields1.subList(4, fields1.size())
.toArray();
TextInstance instance1 = new TextInstance(bagOfWordsTfIdf1, id1);
CSVFileReader in2 = new CSVFileReader("csv_out.csv", ',');
Vector<String> fields2 = in2.readFields();
fields2 = in2.readFields();
TextInstance instance2;
Object[] bagOfWordsTfIdf2;
int count2=0;
while (fields2 != null)
{
String id2 = fields2.get(0) + fields2.get(1);
bagOfWordsTfIdf2 = fields2.subList(4, fields2.size()).toArray();
instance2 = new TextInstance(bagOfWordsTfIdf2, id2);
Vector<String> distances = new Vector<String>();
double d1 = TextInstance.computeEuclideanDistance(
instance1, instance2);
distances.add(d1+"");
distances.add(TextInstance.computeManhattanDistance(instance1, instance2)
+ "");
out.writeFields(distances);
fields2 = in2.readFields();
count2++;
if(count2==num_instances) break;
}
fields1 = in1.readFields();
count1++;
if(count1==num_instances) break;
}
out.close();
System.out.println(countNonNull);
}