|
Fido Alpha 3.2 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--fido.db.WordClassificationTable
This class maintains a list of word classifications, which are patterns
used to classify words based on the characters that compise it. The
list of classifications are stored in an ordered table, so that the
order of the patterns are maintained. Also, moveRowUp()
and moveRowDown()
can change the priority of a classification.
The order is importantant, as more generic patterns near the end match a
larger group of words.
Patterns:
Character | Description |
---|---|
N | a number 0 to 9 repeating one to many times |
A | alpha character a to z and A to Z repeating one to many times |
E | Either number or alpha repeating one to many times. In practice, these are usually hostnames, variables, or some computer identifier. Therefore, this class will require the first character to be an alpha. |
C | Any character, exception forward slash and back slash, repeating one to many times. This type is used in Unix and Dos path names. |
[] | All chars listed optionally appearing once |
{} | Any char listed optionally appearing once |
() | All chars listend repeating at least once, possibly many times |
The following table contains sample patterns of word classes:
(Note: Order in the patterns is significant. Therefore, more general
patterns should appear at the bottom of the list)
Pattern | Class Type | Notes |
---|---|---|
$N[.N] | Money value | The '$' (dollar sign) is not a special character, therefore must be matched explicitly. The pattern reads: A word starting with a dollar sign, zero to many numbers, and optionally, a decimal point and more numbers. |
N/N/N | Date | The slashes in this pattern must match explicitly. |
(C/)C | Unix path | This pattern looks for any character besides a slash, as specified by the 'C'. Then matches a slash. This pattern can be repeated as many times as necessary. The final 'C' accepts any characters following the final slash. Since the letter classes, such as 'C', can match zero characters, the word can start or end in a slash. |
[A:](C\)C | Dos path | Similar to the Unix path pattern, this pattern accepts an alpha character followed by a colon for Dos drive letters. |
N:N | Time | Two numbers separated by a colon. Note the pattern does not require the first number to be in the range of 0 to 23. Nor does it limit the first number to be only two digits. |
N.N.N.N | IP Address | As in the Time pattern, the individual components do not have to be valid ip numbers. This is one example where order in the table is important, because this pattern will catch four numbers separated by periods. The next pattern will catch four groups of characters if this pattern does not match. |
E(.E) | Internet hostname | Matches a string of alpha and numeric characters, followed by at least one period, then more alpha and numeric chars. Matches internet hostnames such as www.yahoo.com |
{+-}N[.N] | Number | The first part of this pattern allows either a plus or minus to precede the number, but does not require one. |
E | Default | This is a catch all pattern if any of the above patterns fail to match. |
Constructor Summary | |
WordClassificationTable()
Creates a new WordClassificationTable instance. |
Method Summary | |
void |
add(java.lang.String pattern,
java.lang.String grammarString,
int objectId,
java.lang.String description)
Adds a new classification to the end of the list. |
WordSense |
classify(java.lang.String str)
Attempts to match the list of patterns in the WordClassifications to the user string parameter. |
void |
delete(int row)
Removes the new classification at the row specified in the row paramter. |
int |
hashCode(java.lang.String rank)
Creates a hash value for a given row. |
java.util.Collection |
list()
Returns a array of Strings containing all Word Classifications. |
void |
modify(int row,
java.lang.String pattern,
java.lang.String grammarString,
int objectId,
java.lang.String description)
Replaces the new classification at the row specified in the row paramter with a row containing the parameter information. |
void |
moveRowDown(int row)
Moves the row specified by row down in priority. |
void |
moveRowUp(int row)
Moves the row specified by row up in priority. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public WordClassificationTable()
Method Detail |
public java.util.Collection list() throws FidoDatabaseException
FidoDatabaseException
public void moveRowUp(int row) throws FidoDatabaseException
java.sql.SQLException
- Input / Output error saving WordClassifications object
to database
FidoDatabaseException
public void moveRowDown(int row) throws FidoDatabaseException
FidoIOException
- Input / Output error saving WordClassifications object
to database
FidoDatabaseException
public void add(java.lang.String pattern, java.lang.String grammarString, int objectId, java.lang.String description) throws FidoDatabaseException, ObjectNotFoundException, GrammarParseException, GrammarLinkNotFoundException
pattern
- Regular expression type string for matching word characters
FidoIOException
- Input / Output error saving WordClassifications object
to database
FidoDatabaseException
ObjectNotFoundException
GrammarParseException
GrammarLinkNotFoundException
public void modify(int row, java.lang.String pattern, java.lang.String grammarString, int objectId, java.lang.String description) throws FidoDatabaseException, ObjectNotFoundException, GrammarParseException, GrammarLinkNotFoundException
row
- integer row value to replacepattern
- Regular expression type string for matching word characters
FidoIOException
- Input / Output error saving WordClassifications object
to database
FidoDatabaseException
ObjectNotFoundException
GrammarParseException
GrammarLinkNotFoundException
public void delete(int row) throws FidoDatabaseException
row
- integer row value to replace
FidoIOException
- Input / Output error saving WordClassifications object
to database
FidoDatabaseException
public WordSense classify(java.lang.String str) throws FidoDatabaseException, GrammarParseException, GrammarLinkNotFoundException
FidoDatabaseException
GrammarParseException
GrammarLinkNotFoundException
public int hashCode(java.lang.String rank) throws FidoDatabaseException, ClassificationNotFoundException
FidoDatabaseException
- Thrown if the database had an error.
ClassificationNotFoundException
- Thrown if the parameters did not specify
a row in the table.
|
Fido Alpha 3.2 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |