hultig.sumo
Class RuleList

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<Rule>
              extended by hultig.sumo.RuleList
All Implemented Interfaces:
Serializable, Cloneable, Iterable<Rule>, Collection<Rule>, Comparator<Rule>, List<Rule>, RandomAccess

public class RuleList
extends ArrayList<Rule>
implements Serializable, Comparator<Rule>

NOT YET WELL COMMENTED. Represents a collection of sentence compression/transformation rules. These rules were generated by the Aleph learning system, which is based on Inductive Logic Programming (ILP). The learned rules are saved into a file, and in this class it can be opened and their rules loaded, through the method loadFromFile(String, int). There is also a related method for loading rules from a given directory.

See Also:
Serialized Form

Nested Class Summary
static class RuleList.SortType
          The Sort criteria for the rules list.
 
Field Summary
static int ASCENDING
          Defines the ascending sorting criterion.
static int DESCENDING
          Defines the descending sorting criterion constant.
 RuleList.SortType STYPE
           
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
RuleList()
          The default constructor.
 
Method Summary
 int compare(Rule ra, Rule rb)
          Compare two rules based on their coverage values.
 void loadFromDir(String dirname, int mincover)
          Loads sentence reduction rules from a given directory.
 boolean loadFromFile(String fname, int mincover)
          Loads a set of sentence reduction rules, generated by Aleph, from a given text file.
static void main(String[] args)
          Exemplifies the main operation of this class.
 void print()
          Outputs the whole list of sentence reduction rules.
 void printEntailments()
           
 int removeDuplicateRules()
          Eliminates duplicate rules, from this rule list.
 void sort()
          Sorts this list of reduction rules, according to the specified comparator and criterion.
 void sort(int mode)
           
 void sort(int mode, RuleList.SortType stype)
           
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Field Detail

ASCENDING

public static final int ASCENDING
Defines the ascending sorting criterion.

See Also:
Constant Field Values

DESCENDING

public static final int DESCENDING
Defines the descending sorting criterion constant.

See Also:
Constant Field Values

STYPE

public RuleList.SortType STYPE
Constructor Detail

RuleList

public RuleList()
The default constructor.

Method Detail

loadFromFile

public boolean loadFromFile(String fname,
                            int mincover)
Loads a set of sentence reduction rules, generated by Aleph, from a given text file.

Parameters:
fname - The name of the file.
mincover - Loads rules having coverage greater than this parameter.
Returns:
The appropriate meaningful logical value.

loadFromDir

public void loadFromDir(String dirname,
                        int mincover)
Loads sentence reduction rules from a given directory. Any file having a name starting with "rset" and ending with a "txt" extension, will be scanned.

Parameters:
dirname - The directory from which to scan for rule files.
mincover - Loads rules having coverage greater than this parameter.

compare

public int compare(Rule ra,
                   Rule rb)
Compare two rules based on their coverage values.

Specified by:
compare in interface Comparator<Rule>
Parameters:
ra - The first rule.
rb - The second rule.
Returns:
A negative, zero, or positive value, meaning respectively ra < rb , ra = rb, or ra > rb.

sort

public void sort()
Sorts this list of reduction rules, according to the specified comparator and criterion.


sort

public void sort(int mode)

sort

public void sort(int mode,
                 RuleList.SortType stype)

removeDuplicateRules

public int removeDuplicateRules()
Eliminates duplicate rules, from this rule list.

Returns:
The number of duplications removed.

printEntailments

public void printEntailments()

print

public void print()
Outputs the whole list of sentence reduction rules.


main

public static void main(String[] args)
Exemplifies the main operation of this class.

Parameters:
args - The array of arguments.