Overview | Package | Class | Tree | Deprecated | Index | Help | |||
PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--chomps.Chompy
Field Summary | |
java.lang.String[] | heads
After a call to update() heads holds an array of rule heads for quick reference. |
int | ruleCount
ruleCount holds the number of rules at the last call to update(). |
java.lang.String[][] | tails
After a call to update() tails holds an array of string arrays representing the atoms of the rule tails for quick reference. |
Method Summary | |
void | addRule(java.lang.String head,
java.lang.String tail)
Adds a rule to the Chompy world. |
void | clearAdded()
Resets the number of rules added since the last call to getAdded() or clearAdded() to zero. |
void | delete()
Deletes all the rules in the Chompy world. |
void | delete(int index)
Deletes the rule with the given index. |
int | getAdded()
Gets the number of rules added since the last call to getAdded() or clearAdded(). |
java.lang.String | getRule(int index)
Gets the rule with the given index. |
int | getRuleCount()
Gets the number of rules in the Chompy world. |
java.lang.String[] | getRuleList()
Gets a formatted list of all the rules in the Chompy world. |
boolean | isa(java.lang.String source,
java.lang.String target)
Parses the source String to see if it is of the form of the target String. |
void | save(java.lang.String filename)
Saves all the rules in the Chompy world to the given filename. |
java.lang.String | toString()
Returns a string describing the current Chompy object. |
void | update()
Updates the list of rule heads and tails. |
Methods inherited from class java.lang.Object | |
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait |
Field Detail |
public java.lang.String[] heads
public java.lang.String[][] tails
public int ruleCount
Method Detail |
public void addRule(java.lang.String head, java.lang.String tail) throws InvalidRuleException
head = tail1 + tail2 + ... + tailnWhere there must be one or more tail arguments. The head must always be a single atom (i.e. a string of ASCII characters with no spaces). Each tail is also a single atom. The tail is passed to addRule as a String of atoms separated by spaces e.g.:
chompy.addRule("Sentence", "NP VP");Which would evaluate to:
SENTENCE = NP + VPEach rule is counted when it is added, and this count is reset when getAdded() or clearAdded() are called.
head
- A string representing the head of the rule.
tail
- A string of atoms separated by spaces.public int getAdded()
public void clearAdded()
public java.lang.String[] getRuleList()
(index) head = tail1 + tail2 + ... + tailnThe list of formatted output is returned as a String array.
public java.lang.String getRule(int index) throws java.lang.IndexOutOfBoundsException
head tail1 tail2 ... tailne.g.
SENTENCE NP VP
index
- The index of the rule to get.public int getRuleCount()
public void delete()
public void delete(int index) throws java.lang.IndexOutOfBoundsException
index
- The index of the rule to delete.public void save(java.lang.String filename) throws java.io.IOException
filename
- The filename to save the world to.public boolean isa(java.lang.String source, java.lang.String target)
source
- The source String to check.
target
- The target String to look for.public void update()
public java.lang.String toString()
Overview | Package | Class | Tree | Deprecated | Index | Help | |||
PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |