Package weka.associations.tertius
Class LiteralSet
- java.lang.Object
-
- weka.associations.tertius.LiteralSet
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,RevisionHandler
public abstract class LiteralSet extends java.lang.Object implements java.io.Serializable, java.lang.Cloneable, RevisionHandler
Class representing a set of literals, being either the body or the head of a rule.- Version:
- $Revision: 1.7 $
- Author:
- Amelie Deltour
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description LiteralSet()Constructor for a set that does not store its counter-instances.LiteralSet(Instances instances)Constructor initializing the set of counter-instances to all the instances.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddElement(Literal element)Add a Literal to this set.abstract booleancanKeep(Instance instance, Literal newLit)Test if an instance can be kept as a counter-instance, given a new literal.java.lang.Objectclone()Returns a shallow copy of this set.booleancontains(Literal lit)Test if this LiteralSet contains a given Literal.booleancounterInstance(Instance instance)Test if an instance is a counter-instance of this LiteralSet.booleancounterInstance(Instance individual, Instance part)Test if an individual instance, given a part instance of this individual, is a counter-instance of this LiteralSet.java.util.IteratorenumerateLiterals()Enumerate the literals contained in this set.doublegetCounterInstancesFrequency()Get the frequency of counter-instances of this LiteralSet in the data.intgetCounterInstancesNumber()Get the number of counter-instances of this LiteralSet.LiteralgetLastLiteral()Give the last literal added to this set.intgetType()Give the type of properties in this set (individual or part properties).booleanhasMaxCounterInstances()Test if all the intances are counter-instances.booleanisEmpty()Test if this set is empty.abstract booleanisIncludedIn(Rule otherRule)Test if this LiteralSet is included in a rule.booleannegationIncludedIn(LiteralSet otherSet)Test if the negation of this LiteralSet is included in another LiteralSet.intnumLiterals()Give the number of literals in this set.booleanoverFrequencyThreshold(double minFrequency)Test if this LiteralSet has more counter-instances than the threshold.abstract java.lang.StringtoString()Gives a String representation for this set of literals.voidupDate(Instances instances)Update the number of counter-instances of this set in the dataset.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface weka.core.RevisionHandler
getRevision
-
-
-
-
Constructor Detail
-
LiteralSet
public LiteralSet()
Constructor for a set that does not store its counter-instances.
-
LiteralSet
public LiteralSet(Instances instances)
Constructor initializing the set of counter-instances to all the instances.- Parameters:
instances- The dataset.
-
-
Method Detail
-
clone
public java.lang.Object clone()
Returns a shallow copy of this set. The structured is copied but the literals themselves are not copied.- Returns:
- A copy of this LiteralSet.
-
upDate
public void upDate(Instances instances)
Update the number of counter-instances of this set in the dataset. This method should be used is the set does not store its counter-instances.- Parameters:
instances- The dataset.
-
getCounterInstancesNumber
public int getCounterInstancesNumber()
Get the number of counter-instances of this LiteralSet.- Returns:
- The number of counter-instances.
-
getCounterInstancesFrequency
public double getCounterInstancesFrequency()
Get the frequency of counter-instances of this LiteralSet in the data.- Returns:
- The frequency of counter-instances.
-
overFrequencyThreshold
public boolean overFrequencyThreshold(double minFrequency)
Test if this LiteralSet has more counter-instances than the threshold.- Parameters:
minFrequency- The frequency threshold.- Returns:
- True if there are more counter-instances than the threshold.
-
hasMaxCounterInstances
public boolean hasMaxCounterInstances()
Test if all the intances are counter-instances.- Returns:
- True if all the instances are counter-instances.
-
addElement
public void addElement(Literal element)
Add a Literal to this set.- Parameters:
element- The element to add.
-
isEmpty
public final boolean isEmpty()
Test if this set is empty.- Returns:
- True if the set is empty.
-
numLiterals
public final int numLiterals()
Give the number of literals in this set.- Returns:
- The number of literals.
-
enumerateLiterals
public final java.util.Iterator enumerateLiterals()
Enumerate the literals contained in this set.- Returns:
- An Iterator for the literals.
-
getLastLiteral
public Literal getLastLiteral()
Give the last literal added to this set.- Returns:
- The last literal added.
-
negationIncludedIn
public boolean negationIncludedIn(LiteralSet otherSet)
Test if the negation of this LiteralSet is included in another LiteralSet.- Parameters:
otherSet- The other LiteralSet.- Returns:
- True if the negation of this LiteralSet is included in the other LiteralSet.
-
contains
public boolean contains(Literal lit)
Test if this LiteralSet contains a given Literal.- Parameters:
lit- The literal that is looked for.- Returns:
- True if this literal is contained in this LiteralSet.
-
getType
public int getType()
Give the type of properties in this set (individual or part properties).
-
counterInstance
public boolean counterInstance(Instance individual, Instance part)
Test if an individual instance, given a part instance of this individual, is a counter-instance of this LiteralSet.- Parameters:
individual- The individual instance.part- The part instance.- Returns:
- True if the individual is a counter-instance.
-
counterInstance
public boolean counterInstance(Instance instance)
Test if an instance is a counter-instance of this LiteralSet.- Parameters:
instance- The instance to test.- Returns:
- True if the instance is a counter-instance.
-
canKeep
public abstract boolean canKeep(Instance instance, Literal newLit)
Test if an instance can be kept as a counter-instance, given a new literal.- Parameters:
instance- The instance to test.newLit- The new literal.- Returns:
- True if the instance is still a counter-instance.
-
isIncludedIn
public abstract boolean isIncludedIn(Rule otherRule)
Test if this LiteralSet is included in a rule.- Parameters:
otherRule- The rule to test.- Returns:
- True if this set of literals is included in the rule.
-
toString
public abstract java.lang.String toString()
Gives a String representation for this set of literals.- Overrides:
toStringin classjava.lang.Object
-
-