All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gov.sandia.cognition.learning.function.categorization.AbstractCategorizer Maven / Gradle / Ivy

There is a newer version: 4.0.1
Show newest version
/*
 * File:                AbstractCategorizer.java
 * Authors:             Justin Basilico
 * Company:             Sandia National Laboratories
 * Project:             Cognitive Foundry
 * 
 * Copyright April 07, 2009, Sandia Corporation.
 * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive 
 * license for use of this work by or on behalf of the U.S. Government. Export 
 * of this program may require a license from the United States Government. 
 * See CopyrightHistory.txt for complete details.
 * 
 */

package gov.sandia.cognition.learning.function.categorization;

import gov.sandia.cognition.util.AbstractCloneableSerializable;
import java.util.LinkedHashSet;
import java.util.Set;

/**
 * An abstract implementation of the {@code Categorizer} interface. Keeps track
 * of the set of categories.
 *
 * @param   The type of the input the categorizer can use.
 * @param   The type of category output by the categorizer.
 * @author  Justin Basilico
 * @since   3.0
 */
public abstract class AbstractCategorizer
    extends AbstractCloneableSerializable
    implements Categorizer
{
    /** The set of categories that are the possible output values of the
     *  categorizer. */
    protected Set categories;

    /**
     * Creates a new {@code AbstractCategorizer} with an empty category set.
     */
    public AbstractCategorizer()
    {
        this(new LinkedHashSet());
    }

    /**
     * Creates a new {@code AbstractCategorizer} with the given category set.
     *
     * @param   categories
     *      The categories.
     */
    public AbstractCategorizer(
        final Set categories)
    {
        super();

        this.setCategories(categories);
    }

    @Override
    public AbstractCategorizer clone()
    {
        @SuppressWarnings("unchecked")
        AbstractCategorizer clone =
            (AbstractCategorizer) super.clone();
        clone.setCategories( new LinkedHashSet( this.getCategories() ) );
        return clone;
    }

    public Set getCategories()
    {
        return this.categories;
    }

    /**
     * Sets the Set of possible categories, which are the output values.
     *
     * @param   categories The list of possible output categories.
     */
    protected void setCategories(
        final Set categories)
    {
        this.categories = categories;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy