gate.creole.morph
Class ParsingFunctions

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

public class ParsingFunctions
extends Object

Title: ParsingFunctions.java

Description: This class implements all static methods, which can be used for various purposes, like converting rules defined by users into the regular expressions, finding varilable type from its value type etc.


Field Summary
static int AND
           
static int AND_PLUS
           
static int AND_STAR
           
static short IRREG_STEM
           
static short NULL_STEM
           
static int OR
           
static int OR_PLUS
           
static int OR_STAR
           
static short SEMIREG_STEM
           
static short STEM
           
 
Constructor Summary
ParsingFunctions()
           
 
Method Summary
static ArrayList andFSMs(String line, HashSet initStates, Interpret owner)
          (abc) -> a -> b -> c ->
static ArrayList andPlusFSMs(String line, HashSet initStates, Interpret owner)
          (abc)+ -> a -> b -> c -> null -> a -> b -> c -> a
static ArrayList andStarFSMs(String line, HashSet initStates, Interpret owner)
          (abc)*
static String convertToRegExp(String line, Storage storage)
          This method convert the expression which has been entered by the user in the .rul file (i.e. rules defined by the user), into the expression which are recognized by the regular expression Patterns
static HashSet createFSMs(String string, int type, HashSet initStates, Interpret owner)
           
static int findVariableType(String varValue)
          This method takes the value of the variable and tells the user what type of value is from CharacterRange, CharacterSet, StringSet
private static int getIndex(HashSet states)
           
static short getMethodIndex(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);
static 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);
static String[] getParameterValues(String method)
          This method finds the actual parameter values
static PatternPart[] getPatternParts(String line)
           
static boolean isBoolean(String value)
          This method checks for the string if it is a valid integer value
static boolean isInteger(String value)
          This method checks for the string if it is a valid integer value
private static FSMState next(char ch, HashSet states)
           
static String[] normlizePattern(String line)
           
static ArrayList orFSMs(String line, HashSet initStates, Interpret owner)
          [abc] -> a, -> b, -> c
static ArrayList orPlusFSMs(String line, HashSet initStates, Interpret owner)
          [abc]+ each element can travel to itself and can travel to next one
static ArrayList orStarFSMs(String line, HashSet initStates, Interpret owner)
          [abc]* each element can have reference to adjecent ones and to itself
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OR

public static final int OR
See Also:
Constant Field Values

AND

public static final int AND
See Also:
Constant Field Values

OR_PLUS

public static final int OR_PLUS
See Also:
Constant Field Values

AND_PLUS

public static final int AND_PLUS
See Also:
Constant Field Values

OR_STAR

public static final int OR_STAR
See Also:
Constant Field Values

AND_STAR

public static final int AND_STAR
See Also:
Constant Field Values

IRREG_STEM

public static final short IRREG_STEM
See Also:
Constant Field Values

NULL_STEM

public static final short NULL_STEM
See Also:
Constant Field Values

SEMIREG_STEM

public static final short SEMIREG_STEM
See Also:
Constant Field Values

STEM

public static final short STEM
See Also:
Constant Field Values
Constructor Detail

ParsingFunctions

public ParsingFunctions()
Method Detail

findVariableType

public static int findVariableType(String varValue)
This method takes the value of the variable and tells the user what type of value is from CharacterRange, CharacterSet, StringSet

Parameters:
varValue - value for which to find the variable type
Returns:
ERROR_CODE = -4, STRING_SET_CODE = 0, CHARACTER_RANGE_CODE = 1, CHARACTER_SET_CODE = 2;

isInteger

public static boolean isInteger(String value)
This method checks for the string if it is a valid integer value

Parameters:
value - value to be checked for its type to be integer
Returns:
if value is an integer returns true, false otherwise

isBoolean

public static boolean isBoolean(String value)
This method checks for the string if it is a valid integer value

Parameters:
value - value to be checked for its type to be integer
Returns:
if value is an integer returns true, false otherwise

normlizePattern

public static String[] normlizePattern(String line)

getPatternParts

public static PatternPart[] getPatternParts(String line)

getMethodName

public static 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

getMethodIndex

public static short getMethodIndex(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

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

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

createFSMs

public static HashSet createFSMs(String string,
                                 int type,
                                 HashSet initStates,
                                 Interpret owner)
Parameters:
string -
type -
initState -
Returns:

next

private static FSMState next(char ch,
                             HashSet states)

getIndex

private static int getIndex(HashSet states)

andFSMs

public static ArrayList andFSMs(String line,
                                HashSet initStates,
                                Interpret owner)
(abc) -> a -> b -> c ->

Parameters:
line -
initState -
Returns:

orFSMs

public static ArrayList orFSMs(String line,
                               HashSet initStates,
                               Interpret owner)
[abc] -> a, -> b, -> c

Parameters:
line -
initState -
Returns:

orPlusFSMs

public static ArrayList orPlusFSMs(String line,
                                   HashSet initStates,
                                   Interpret owner)
[abc]+ each element can travel to itself and can travel to next one

Parameters:
line -
initState -
Returns:

andPlusFSMs

public static ArrayList andPlusFSMs(String line,
                                    HashSet initStates,
                                    Interpret owner)
(abc)+ -> a -> b -> c -> null -> a -> b -> c -> a

Parameters:
line -
initState -
Returns:

orStarFSMs

public static ArrayList orStarFSMs(String line,
                                   HashSet initStates,
                                   Interpret owner)
[abc]* each element can have reference to adjecent ones and to itself

Parameters:
line -
initState -
Returns:

andStarFSMs

public static ArrayList andStarFSMs(String line,
                                    HashSet initStates,
                                    Interpret owner)
(abc)*

Parameters:
line -
initState -
Returns:

convertToRegExp

public static String convertToRegExp(String line,
                                     Storage storage)
This method convert the expression which has been entered by the user in the .rul file (i.e. rules defined by the user), into the expression which are recognized by the regular expression Patterns

Parameters:
line - rule defined by the user
storage - this method internally requires values of the used variables to replace the them with their values in the expression
Returns:
newly generated regular expression