Package org.codemap.tasks

Source Code of org.codemap.tasks.ComputeMapInstanceTask

package org.codemap.tasks;

import org.codemap.Configuration;
import org.codemap.MapInstance;
import org.codemap.Point;
import org.codemap.util.MapScheme;

import ch.akuhn.hapax.index.LatentSemanticIndex;
import ch.akuhn.util.ProgressMonitor;
import ch.akuhn.values.Arguments;
import ch.akuhn.values.TaskValue;
import ch.akuhn.values.Value;

public class ComputeMapInstanceTask extends TaskValue<MapInstance> {

    public ComputeMapInstanceTask(Value<Integer> size,
            Value<LatentSemanticIndex> index,
            Value<Configuration> configuration) {
        super(makeName(size), size, index, configuration);
    }

    private static String makeName(Value<Integer> size) {
        return String.format("Creating map (%d x %d pixel)", size.getValue(), size.getValue());
    }

    @Override
    protected MapInstance computeValue(ProgressMonitor monitor, Arguments args) {
        int size = args.nextOrFail();
        final LatentSemanticIndex index = args.nextOrFail();
        Configuration configuration = args.nextOrFail();
        return configuration.withSize(size, new MapScheme<Double>() {
            @Override
            public Double forLocation(Point location) {
//                return Math.max(1, Math.log(index.getDocumentLength(location.getDocument())));
//                return Math.cbrt(index.getDocumentLength(location.getDocument()));
                return Math.sqrt(index.getDocumentLength(location.getDocument()));
            }
        });
    }
}

TOP

Related Classes of org.codemap.tasks.ComputeMapInstanceTask

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.