/**
   * @param args
   * @throws Exception
   */
  void analyseResult(DBScan algo, Instances data) throws Exception {
    FileWriter fw = new FileWriter(new File("topictrackresult"));
    BufferedWriter bw = new BufferedWriter(fw);
    StringBuilder sb = new StringBuilder();
    FastVector resultset = new FastVector();
    for (int i = 0; i < algo.numberOfClusters(); i++) {
      ArrayList<String> oneCluster = new ArrayList<String>();
      resultset.addElement(oneCluster);
    }

    for (int i = 0; i < algo.database.size(); i++) {
      DataObject dataObject = algo.database.getDataObject(Integer.toString(i));
      int IDraw = Integer.parseInt(dataObject.getKey());
      int ID = (int) data.instance(IDraw).value(0);
      String title = findFileNameWithID(ID);
      if (DataObject.NOISE != dataObject.getClusterLabel()) {
        int label = dataObject.getClusterLabel();
        ArrayList<String> filenamelib = (ArrayList<String>) resultset.elementAt(label);
        filenamelib.add(title);
      }
    }

    sb.append("The generated Clusters are:\n");
    for (int i = 0; i < algo.numberOfClusters(); i++) {
      sb.append("\r\n cluster" + i + "\n");
      ArrayList<String> filenamelib = (ArrayList<String>) resultset.elementAt(i);
      Iterator iter = filenamelib.iterator();
      while (iter.hasNext()) {
        String title = (String) iter.next();
        sb.append(title + "\n");
      }
    }

    bw.write(sb.toString());
    bw.close();
    fw.close();
  }
Exemple #2
0
 /**
  * Inserts a new dataObject into the database
  *
  * @param dataObject
  */
 public void insert(DataObject dataObject) {
   treeMap.put(dataObject.getKey(), dataObject);
 }