mark.nlp.data
Class SparseBagInstance

java.lang.Object
  |
  +--mark.nlp.data.Instance
        |
        +--mark.nlp.data.SparseBagInstance
All Implemented Interfaces:
Bag

public class SparseBagInstance
extends Instance
implements Bag

An instance that is also a bag of objects.


Constructor Summary
SparseBagInstance(int category, SparseBag bag)
          Initializes the instance.
SparseBagInstance(TokenInstance tokenInstance, ObjectMap vocabulary)
          Initializes the sparse bag instance.
 
Method Summary
 SparseBag bag()
          Returns the instance's bag.
 java.util.Iterator iterator()
          Returns an iterator over the object types.
 double num()
          Returns the number of object occurrences in the bag.
 double num(java.lang.Object o)
          Returns the number of object type o occurrences in the bag.
 int numTypes()
          Returns the number of object types with non-zero occurrences.
 
Methods inherited from class mark.nlp.data.Instance
category, setCategory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SparseBagInstance

public SparseBagInstance(TokenInstance tokenInstance,
                         ObjectMap vocabulary)
Initializes the sparse bag instance.

Parameters:
tokenInstance - the instance's category and tokens.
vocabulary - the instance's vocabulary.

SparseBagInstance

public SparseBagInstance(int category,
                         SparseBag bag)
Initializes the instance.

Parameters:
category - the instance's category.
bag - the instance's sparse bag.
Method Detail

bag

public SparseBag bag()
Returns the instance's bag.

Returns:
the instance's bag.

numTypes

public int numTypes()
Description copied from interface: Bag
Returns the number of object types with non-zero occurrences.

Specified by:
numTypes in interface Bag
Returns:
the number of object types with non-zero occurrences.
See Also:
mark.nlp.data

iterator

public java.util.Iterator iterator()
Description copied from interface: Bag
Returns an iterator over the object types.

Specified by:
iterator in interface Bag
Returns:
the iterator.
See Also:
mark.nlp.data

num

public double num(java.lang.Object o)
Description copied from interface: Bag
Returns the number of object type o occurrences in the bag.

Specified by:
num in interface Bag
Parameters:
o - the object.
Returns:
the number of o occurrences.
See Also:
mark.nlp.data

num

public double num()
Description copied from interface: Bag
Returns the number of object occurrences in the bag.

Specified by:
num in interface Bag
Returns:
the number of object occurrences.
See Also:
mark.nlp.data