gate.creole.morph
Class Interpret

java.lang.Object
  extended by gate.creole.morph.Interpret

public class Interpret
extends Object

Title: Interpret.java

Description: This is the main class which which should be invoked to load the rule file in the system and then to execute the program to find the root word and the affix to it.


Nested Class Summary
(package private)  class Interpret.CharClass
           
 
Field Summary
private  String affix
          This variables holds the affix
private  ReadFile file
          instance of the ReadFile class which reads the file and stores each line of the given program in the arraylist which can be read using different methods of the ReadFile class
protected  boolean foundRule
           
(package private)  ArrayList fsms
           
protected  FSMState initialState
          The initial state of the FSM that backs this morpher
private  boolean isDefineRulesSession
          Boolean variables to keep track on which section is being read
private  boolean isDefineVarSession
          Boolean variables to keep track on which section is being read
protected  HashSet lastStates
           
private  Method[] methods
          This variables keeps the record of available methods for the morphing
(package private)  MorphFunctions morphInst
           
private  Pattern nPat
           
protected  int patternIndex
           
(package private)  ArrayList patterns
           
private  Storage variables
          Instance of Storage class, which is used store all the variables details
private  Pattern vPat
           
 
Constructor Summary
Interpret()
           
 
Method Summary
 void addState(char ch, FSMState fsm, int index)
           
private  void defineRulesCommand()
          This method processes the command to define the rule section
private  void defineVarsCommand()
          This method processes the command to define the variable section
private  void drawFSM()
           
private  void drawFSM(FSMState st, String space)
           
protected  String executeRHS(String word, String category, RHS rhs)
           
protected  String executeRHSes(TreeSet rhses, String word, String category)
           
private  String executeRule(String word, RHS rhs)
           
private  int findCommandType(String line)
          This method interprets the line and finds out the type of command and returns the integer indicating the type of the command
private  void generateError(String mess)
          Generates the error and stop the execution
 String getAffix()
          This method tells what was the affix to the provided word
 FSMState getInitialState()
           
 int getPatternIndex()
           
 FSMState getState(char ch, int index)
           
private  HashSet getStates(char ch, HashSet states)
           
 void init(URL ruleFileURL)
          It starts the actual program
private  void interpretProgram()
          This method reads each line of the program and interpret them
private  HashSet intersect(HashSet a, HashSet b)
           
private  boolean isMethodAvailable(String method)
          This method takes a method signature and searches if the method
static void main(String[] args)
          Main method
private  void prepareListOfMorphMethods()
          This method prepares the list of available methods in the MorphFunctions class
private  void readProgram()
          read the program file
private  void ruleDeclarationCommand(String line)
          This method processes the command to declare the rule
 String runMorpher(String word, String category)
          lookup
private  boolean validCategory(String category)
           
private  void variableDeclarationCommand(String line)
          This method processes the command to declare the variable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

file

private ReadFile file
instance of the ReadFile class which reads the file and stores each line of the given program in the arraylist which can be read using different methods of the ReadFile class


isDefineVarSession

private boolean isDefineVarSession
Boolean variables to keep track on which section is being read


isDefineRulesSession

private boolean isDefineRulesSession
Boolean variables to keep track on which section is being read


variables

private Storage variables
Instance of Storage class, which is used store all the variables details


methods

private Method[] methods
This variables keeps the record of available methods for the morphing


affix

private String affix
This variables holds the affix


vPat

private Pattern vPat

nPat

private Pattern nPat

morphInst

MorphFunctions morphInst

patterns

ArrayList patterns

fsms

ArrayList fsms

initialState

protected FSMState initialState
The initial state of the FSM that backs this morpher


lastStates

protected HashSet lastStates

patternIndex

protected int patternIndex

foundRule

protected boolean foundRule
Constructor Detail

Interpret

public Interpret()
Method Detail

init

public void init(URL ruleFileURL)
          throws ResourceInstantiationException
It starts the actual program

Parameters:
ruleFileName -
Throws:
ResourceInstantiationException

addState

public void addState(char ch,
                     FSMState fsm,
                     int index)

getState

public FSMState getState(char ch,
                         int index)

getStates

private HashSet getStates(char ch,
                          HashSet states)

validCategory

private boolean validCategory(String category)

runMorpher

public String runMorpher(String word,
                         String category)
lookup

Parameters:
singleItem - a single string to be looked up by the gazetteer
Returns:
set of the Lookups associated with the parameter

getPatternIndex

public int getPatternIndex()

executeRHSes

protected String executeRHSes(TreeSet rhses,
                              String word,
                              String category)

executeRHS

protected String executeRHS(String word,
                            String category,
                            RHS rhs)

executeRule

private String executeRule(String word,
                           RHS rhs)

prepareListOfMorphMethods

private void prepareListOfMorphMethods()
                                throws ResourceInstantiationException
This method prepares the list of available methods in the MorphFunctions class

Throws:
ResourceInstantiationException

readProgram

private void readProgram()
                  throws ResourceInstantiationException
read the program file

Throws:
ResourceInstantiationException

interpretProgram

private void interpretProgram()
                       throws ResourceInstantiationException
This method reads each line of the program and interpret them

Throws:
ResourceInstantiationException

findCommandType

private int findCommandType(String line)
This method interprets the line and finds out the type of command and returns the integer indicating the type of the command

Parameters:
line - The program command to be interpreted
Returns:
and int value

defineVarsCommand

private void defineVarsCommand()
                        throws ResourceInstantiationException
This method processes the command to define the variable section

Throws:
ResourceInstantiationException

defineRulesCommand

private void defineRulesCommand()
                         throws ResourceInstantiationException
This method processes the command to define the rule section

Throws:
ResourceInstantiationException

variableDeclarationCommand

private void variableDeclarationCommand(String line)
                                 throws ResourceInstantiationException
This method processes the command to declare the variable

Parameters:
line -
Throws:
ResourceInstantiationException

ruleDeclarationCommand

private void ruleDeclarationCommand(String line)
                             throws ResourceInstantiationException
This method processes the command to declare the rule

Parameters:
line -
Throws:
ResourceInstantiationException

intersect

private HashSet intersect(HashSet a,
                          HashSet b)

drawFSM

private void drawFSM()

drawFSM

private void drawFSM(FSMState st,
                     String space)

isMethodAvailable

private boolean isMethodAvailable(String method)
This method takes a method signature and searches if the method

Parameters:
method -
Returns:
a boolean value.

generateError

private void generateError(String mess)
                    throws ResourceInstantiationException
Generates the error and stop the execution

Parameters:
mess - - message to be displayed as an error on the standard output
Throws:
ResourceInstantiationException

main

public static void main(String[] args)
                 throws ResourceInstantiationException
Main method

Parameters:
args -
Throws:
ResourceInstantiationException

getAffix

public String getAffix()
This method tells what was the affix to the provided word

Returns:
affix

getInitialState

public FSMState getInitialState()