Fido Alpha 3.2

fido.db
Class LanguageMorphologyTable

java.lang.Object
  |
  +--fido.db.LanguageMorphologyTable

public class LanguageMorphologyTable
extends java.lang.Object

See Morphology for a description on morphology tags.


Constructor Summary
LanguageMorphologyTable()
           
 
Method Summary
 void add(java.lang.String language, java.lang.String tag, java.lang.String root, java.lang.String surface)
          Adds a new Morphology rule to a given language.
 void delete(java.lang.String language, java.lang.String tag, int row)
          Removes the rule from the specified table located at row row number.
 java.lang.String generate(java.lang.String language, java.lang.String tag, java.lang.String str)
          Generates a surface form from the first root form that matches the str within the MorphologyTag Morphology tag group.
 int hashCode(java.lang.String language, java.lang.String tag, java.lang.String rank)
           
 java.util.Collection list()
          Returns a dump of all Morphology rules for a language, suitable for display in a table.
 java.util.Collection listLanguages()
           
 java.util.Collection listTags()
          Returns the names of all MorphologyType entries in the list.
 void modify(java.lang.String language, java.lang.String tag, int rank, java.lang.String root, java.lang.String surface)
           
 void moveRuleDown(java.lang.String language, java.lang.String tag, int row)
          Moves the rules located at row down in priority.
 void moveRuleUp(java.lang.String language, java.lang.String tag, int row)
          Moves the rules located at row up in priority.
 java.util.Collection recognize(java.lang.String language, java.lang.String str)
          Returns a list of base forms that could be derived from applying any rule for the language.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LanguageMorphologyTable

public LanguageMorphologyTable()
Method Detail

add

public void add(java.lang.String language,
                java.lang.String tag,
                java.lang.String root,
                java.lang.String surface)
         throws FidoDatabaseException,
                MorphologyTagNotFoundException
Adds a new Morphology rule to a given language. The priority placement of the new rule is determined as An example would be:
Root FormSurface FormMorphology Type
childchildrenplural
deerdeerplural
*ch*chesplural
**splural
The first two rules are irregular, meaning the plural of the words do not follow a pattern. The last to rules are regular and form a pattern for any word that does not match any above irregular form.

When addRule() is called with the rule
Root FormSurface FormMorphology Type
goosegeeseplural
Above the root and surface forms do not contain a wildcard, so the rule is added at the top of the plural group.

When addRule() is called with the rule
Root FormSurface FormMorphology Type
*x*xesplural
Above the root and surface forms do contain a wildcard, so the rule is added before the first regular form. After the two above rule additions, the resulting rule order will be:
Root FormSurface FormMorphology Type
goosegeeseplural
childchildrenplural
deerdeerplural
*x*xesplural
*ch*chesplural
**splural

Parameters:
surface -
root -
Throws:
MorphologyTypeNotFoundException - thrown if the string type does not match a MorphologyType in the MorphologyTypeList.
java.sql.SQLException - Input / Output error saving Morphology
FidoDatabaseException
MorphologyTagNotFoundException

modify

public void modify(java.lang.String language,
                   java.lang.String tag,
                   int rank,
                   java.lang.String root,
                   java.lang.String surface)
            throws FidoDatabaseException
FidoDatabaseException

delete

public void delete(java.lang.String language,
                   java.lang.String tag,
                   int row)
            throws FidoDatabaseException
Removes the rule from the specified table located at row row number.

Parameters:
language - name of language table
row - row number to remove
Throws:
FidoDatabaseException - Input / Output error saving Morphology

moveRuleUp

public void moveRuleUp(java.lang.String language,
                       java.lang.String tag,
                       int row)
                throws FidoDatabaseException
Moves the rules located at row up in priority. Rules within each Morphology tag group are used in order to generate or recognize word forms. Moving up in priority means this rule will be used before the rule previously above it.

Parameters:
language - name of the language
row - row indicator to move up
Throws:
FidoDatabaseException - Input / Output error saving Morphology

moveRuleDown

public void moveRuleDown(java.lang.String language,
                         java.lang.String tag,
                         int row)
                  throws FidoDatabaseException
Moves the rules located at row down in priority. Rules within each Morphology type group are used in order to generate or recognize word forms. Moving down in priority means this rule will be used after the rule previously below it.

Parameters:
language - name of the language
row - row indicator to move down
Throws:
FidoDatabaseException - Input / Output error saving Morphology

list

public java.util.Collection list()
                          throws FidoDatabaseException
Returns a dump of all Morphology rules for a language, suitable for display in a table.
 index 0: row number, starting at 0
 index 1: root form
 index 2: surface form
 index 3: morphology type (such as plural)
 index 4: boolean string if the rule is used in recognition (true or false as a string)
 

Returns:
two dimensional array of Strings containing all rules
FidoDatabaseException

listLanguages

public java.util.Collection listLanguages()
                                   throws FidoDatabaseException
FidoDatabaseException

recognize

public java.util.Collection recognize(java.lang.String language,
                                      java.lang.String str)
                               throws FidoDatabaseException
Returns a list of base forms that could be derived from applying any rule for the language. The list will be of MorphologyRecognizeMatch classes, one for each potential base form. An example would be:
Root FormSurface FormMorphology Type
childchildrenplural
deerdeerplural
*ch*chesplural
**splural
*s*sesverb 3rd person singular
**sverb 3rd person singular
In the above rule set, the rule * -> *s appears in both plural form and 3rd person singular verb form. (plural: dog -> dogs and verb: run -> he runs). When the word run is passed to recognize(), two MorphologyRecognizeMatch classes are returned, one for a plural and one for the verb form. Both may be correct: He runs. and She had two runs in her stalkings. Only after the Grammar module has determined the part of speech will the system assign a Morphology modifier.

Parameters:
language - language to use
str - String to recognize base forms from
FidoDatabaseException
See Also:
MorphologyRecognizeMatch

generate

public java.lang.String generate(java.lang.String language,
                                 java.lang.String tag,
                                 java.lang.String str)
                          throws FidoDatabaseException
Generates a surface form from the first root form that matches the str within the MorphologyTag Morphology tag group. An example would be:
Root FormSurface FormMorphology Tag
childchildrenplural
deerdeerplural
*ch*chesplural
**splural
To generate the surface form for child based on the above table would produce children. Also any word ending with ch would produce a surface form ending in ches, such as church would produce churches.

Parameters:
str - String to generate a surface form for
tag - Morphology tag group to use
FidoDatabaseException

listTags

public java.util.Collection listTags()
                              throws FidoDatabaseException
Returns the names of all MorphologyType entries in the list. The type names are in alphabetical order.

Returns:
list of names in an array of String
FidoDatabaseException

hashCode

public int hashCode(java.lang.String language,
                    java.lang.String tag,
                    java.lang.String rank)
             throws FidoDatabaseException,
                    MorphologyNotFoundException
FidoDatabaseException
MorphologyNotFoundException

Fido Alpha 3.2