public static void main(String[] args) { File nameFile = new File("C:/2545/ordered_artists.dat"); Vector<String> names = new Vector<String>(); try { BufferedReader in = new BufferedReader(new FileReader(nameFile)); String line = null; while ((line = in.readLine()) != null) { names.add(line); System.out.println("added '" + line + "'"); } } catch (FileNotFoundException e1) { e1.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } FileCoOccurenceCounter counter = new FileCoOccurenceCounter("C:/2545/", names, ".html", 150); DataMatrix dm = counter.getCoOccMatrix(); File fileData = new File("C:/2545/cooccurrences150b.dat"); try { Writer ow = new BufferedWriter(new FileWriter(fileData)); for (int i = 0; i < dm.getNumberOfRows(); i++) { Vector<Double> row = dm.getRow(i); for (int j = 0; j < row.size(); j++) { ow.write(row.elementAt(j).toString() + "\t"); } ow.write("\n"); } ow.flush(); ow.close(); } catch (Exception e) { } }
public DataMatrix getCoOccMatrix() { DataMatrix coOccMatrix = new DataMatrix("CoOccurence Matrix"); try { int i = 0; for (String bandName : bandDirectoryMapping.keySet()) { System.out.println(bandName); coOccMatrix.insertRow(countCoOccurences(bandName), i++); } } catch (SizeMismatchException e) { e.printStackTrace(); } return coOccMatrix; }