Search in sources :

Example 1 with SimpleEnumeratingScheme

use of de.lmu.ifi.dbs.elki.result.textwriter.naming.SimpleEnumeratingScheme in project elki by elki-project.

the class TextWriter method output.

/**
 * Stream output.
 *
 * @param db Database object
 * @param r Result class
 * @param streamOpener output stream manager
 * @param filter Filter pattern
 * @throws IOException on IO error
 */
@SuppressWarnings("unchecked")
public void output(Database db, Result r, StreamFactory streamOpener, Pattern filter) throws IOException {
    List<Relation<?>> ra = new LinkedList<>();
    List<OrderingResult> ro = new LinkedList<>();
    List<Clustering<?>> rc = new LinkedList<>();
    List<IterableResult<?>> ri = new LinkedList<>();
    List<SettingsResult> rs = new LinkedList<>();
    List<Result> otherres = new LinkedList<>();
    // Split result objects in different known types:
    {
        List<Result> results = ResultUtil.filterResults(db.getHierarchy(), r, Result.class);
        for (Result res : results) {
            if (filter != null) {
                final String nam = res.getShortName();
                if (nam == null || !filter.matcher(nam).find()) {
                    continue;
                }
            }
            if (res instanceof Database) {
                continue;
            }
            if (res instanceof Relation) {
                ra.add((Relation<?>) res);
                continue;
            }
            if (res instanceof OrderingResult) {
                ro.add((OrderingResult) res);
                continue;
            }
            if (res instanceof Clustering) {
                rc.add((Clustering<?>) res);
                continue;
            }
            if (res instanceof IterableResult) {
                ri.add((IterableResult<?>) res);
                continue;
            }
            if (res instanceof SettingsResult) {
                rs.add((SettingsResult) res);
                continue;
            }
            otherres.add(res);
        }
    }
    writeSettingsResult(streamOpener, rs);
    for (IterableResult<?> rii : ri) {
        writeIterableResult(streamOpener, rii);
    }
    for (Clustering<?> c : rc) {
        NamingScheme naming = new SimpleEnumeratingScheme(c);
        for (Cluster<?> clus : c.getAllClusters()) {
            writeClusterResult(db, streamOpener, (Clustering<Model>) c, (Cluster<Model>) clus, ra, naming);
        }
    }
    for (OrderingResult ror : ro) {
        writeOrderingResult(db, streamOpener, ror, ra);
    }
    for (Result otherr : otherres) {
        writeOtherResult(streamOpener, otherr);
    }
}
Also used : NamingScheme(de.lmu.ifi.dbs.elki.result.textwriter.naming.NamingScheme) ConfusionMatrixEvaluationResult(de.lmu.ifi.dbs.elki.evaluation.classification.ConfusionMatrixEvaluationResult) Relation(de.lmu.ifi.dbs.elki.database.relation.Relation) Database(de.lmu.ifi.dbs.elki.database.Database) Model(de.lmu.ifi.dbs.elki.data.model.Model) HandlerList(de.lmu.ifi.dbs.elki.utilities.HandlerList) SimpleEnumeratingScheme(de.lmu.ifi.dbs.elki.result.textwriter.naming.SimpleEnumeratingScheme)

Aggregations

Model (de.lmu.ifi.dbs.elki.data.model.Model)1 Database (de.lmu.ifi.dbs.elki.database.Database)1 Relation (de.lmu.ifi.dbs.elki.database.relation.Relation)1 ConfusionMatrixEvaluationResult (de.lmu.ifi.dbs.elki.evaluation.classification.ConfusionMatrixEvaluationResult)1 NamingScheme (de.lmu.ifi.dbs.elki.result.textwriter.naming.NamingScheme)1 SimpleEnumeratingScheme (de.lmu.ifi.dbs.elki.result.textwriter.naming.SimpleEnumeratingScheme)1 HandlerList (de.lmu.ifi.dbs.elki.utilities.HandlerList)1