gate.creole.morph
Class Interpret

java.lang.Object
  extended bygate.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.


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
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
private  Method[] methods
          This variables keeps the record of available methods for the morphing
private  CompiledRules rules
          This varilable stores the compiles versions of rules
private  Storage variables
          Instance of Storage class, which is used store all the variables details
 
Constructor Summary
Interpret()
          Constructor
 
Method Summary
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  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
private  String getMethodName(String method)
          This method is used to find the method definition But it can recognize only String, boolean and int types for Example: stem(2,"ed","d") ==> stem(int,java.lang.String,java.lang.String);
private  String[] getParameterValues(String method)
          This method finds the actual parameter values
 void init(URL ruleFileURL)
          It starts the actual program
private  void interpretProgram()
          This method reads each line of the program and interpret them
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)
          Once all the rules have been loaded in the system, now its time to start the morpher, which will find out the base word rule
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


rules

private CompiledRules rules
This varilable stores the compiles versions of rules


affix

private String affix
This variables holds the affix

Constructor Detail

Interpret

public Interpret()
Constructor

Method Detail

init

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

Throws:
ResourceInstantiationException

runMorpher

public String runMorpher(String word,
                         String category)
Once all the rules have been loaded in the system, now its time to start the morpher, which will find out the base word rule

Parameters:
word - input to the program
Returns:
root word

getMethodName

private String getMethodName(String method)
This method is used to find the method definition But it can recognize only String, boolean and int types for Example: stem(2,"ed","d") ==> stem(int,java.lang.String,java.lang.String);

Parameters:
method -
Returns:
the definition of the method

getParameterValues

private String[] getParameterValues(String method)
This method finds the actual parameter values

Parameters:
method - from which parameters are required to be found
Returns:
parameter values

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

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