extractTerms
Class LocalRule

java.lang.Object
  extended byextractTerms.LocalRule
All Implemented Interfaces:
java.io.Serializable

public class LocalRule
extends java.lang.Object
implements java.io.Serializable

Local rule used for improving relevancy of extraction. These rules are designed to be used on Occurrence object. The result of the application of these rules is true or false.

Grammar of the local rules language :

 SOURCE -> E
 E -> F | not E | E and E | E or E
 F -> (UNIT, PART, STRING, STATUS, TYPE)
 UNIT -> 1 | 2 | 3
 PART -> prefix | suffix | contain | tag | contain_regex | tag_regex
 STRING -> [^SEPARATOR]+
 SEPARATOR -> '/' or any other character
 STATUS -> ACCEPTED | REJECTED
 TYPE - > any string
 

Since:
07/08/2003
Version:
0.2 28/07/2004
Author:
Thomas Heitz for LRI Paris XI University
See Also:
Occurrence, Serialized Form

Field Summary
static int ACCEPTED
          Type of status
static int AND
          Binary operator.
static int CONTAIN
          Type of part.
static int CONTAIN_REGEX
          Type of part.
static int NO_OPERATOR
          Denote a rule with no operator.
static int NOT
          Unary operator.
static int OR
          Binary operator.
static int PREFIX
          Type of part.
static int REJECTED
          Type of status
static int SUFFIX
          Type of part.
static int TAG
          Type of part.
static int TAG_REGEX
          Type of part.
 
Constructor Summary
LocalRule(int _operator, LocalRule _nestedRule1, LocalRule _nestedRule2)
          Local rule constructor for the operators NOT, AND and OR which don't need to have filled all the fields of the object.
LocalRule(int _operator, LocalRule _nestedRule1, LocalRule _nestedRule2, int _unit, int _part, java.lang.String _string, char _separator, int _status, java.lang.String _type)
          Creates a new instance of LocalRule.
 
Method Summary
 boolean apply(Occurrence occ)
          Returns true if the rule apply to the Occurrence.
 LocalRule getNestedRule1()
          Returns the first nested local rule of this rule.
 LocalRule getNestedRule2()
          Returns the secaond nested local rule of this rule.
 int getOperator()
          Returns the operator of the rule.
 int getPart()
          Returns the type of part that define how the rule is applied.
 int getSeparator()
          Returns the separator of the unit.
 int getStatus()
          Returns the status of the rule.
 java.lang.String getString()
          Returns the string to use with part of the rule.
 java.lang.String getType()
          Returns the type of the rule.
 int getUnit()
          Returns the number of the unit where the rule is applied.
 java.lang.String toString()
          Returns the string representation of a LocalRule.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_OPERATOR

public static final int NO_OPERATOR
Denote a rule with no operator.

See Also:
Constant Field Values

NOT

public static final int NOT
Unary operator.

See Also:
Constant Field Values

OR

public static final int OR
Binary operator.

See Also:
Constant Field Values

AND

public static final int AND
Binary operator.

See Also:
Constant Field Values

PREFIX

public static final int PREFIX
Type of part.

See Also:
Constant Field Values

SUFFIX

public static final int SUFFIX
Type of part.

See Also:
Constant Field Values

CONTAIN

public static final int CONTAIN
Type of part.

See Also:
Constant Field Values

TAG

public static final int TAG
Type of part.

See Also:
Constant Field Values

CONTAIN_REGEX

public static final int CONTAIN_REGEX
Type of part.

See Also:
Constant Field Values

TAG_REGEX

public static final int TAG_REGEX
Type of part.

See Also:
Constant Field Values

ACCEPTED

public static final int ACCEPTED
Type of status

See Also:
Constant Field Values

REJECTED

public static final int REJECTED
Type of status

See Also:
Constant Field Values
Constructor Detail

LocalRule

public LocalRule(int _operator,
                 LocalRule _nestedRule1,
                 LocalRule _nestedRule2)
Local rule constructor for the operators NOT, AND and OR which don't need to have filled all the fields of the object.

See Also:
full constructor

LocalRule

public LocalRule(int _operator,
                 LocalRule _nestedRule1,
                 LocalRule _nestedRule2,
                 int _unit,
                 int _part,
                 java.lang.String _string,
                 char _separator,
                 int _status,
                 java.lang.String _type)
Creates a new instance of LocalRule.

Parameters:
_operator - AND, OR, NOT or NO_OPERATOR if this is the last operand of the rule.
_nestedRule1 - a nested LocalRule with AND, OR, NOT operator.
_nestedRule2 - a nested LocalRule with AND, OR operator.
_unit - unit of application of the rule. 1, 2 or 3 only if units triple.
_part - part of application of the rule. PREFIX, SUFFIX, CONTAIN or TAG...
_string - string to use with part of the rule to test the Occurrence. Invariant : musn't contains SEPARATOR char.
_separator - used to split unit in word and tag.
_status - ACCEPTED or REJECTED status of the result of the rule
_type - type of the Occurrence objects selected by the rule
Method Detail

getUnit

public int getUnit()
Returns the number of the unit where the rule is applied.

Returns:
number of the unit

getPart

public int getPart()
Returns the type of part that define how the rule is applied.

Returns:
type of part

getString

public java.lang.String getString()
Returns the string to use with part of the rule.

Returns:
the string of rule

getSeparator

public int getSeparator()
Returns the separator of the unit.

Returns:
the separator of the unit

getStatus

public int getStatus()
Returns the status of the rule.

Returns:
the status of the rule

getType

public java.lang.String getType()
Returns the type of the rule.

Returns:
the type of the rule

getOperator

public int getOperator()
Returns the operator of the rule.

Returns:
the operator of the rule

getNestedRule1

public LocalRule getNestedRule1()
Returns the first nested local rule of this rule.

Returns:
the first nested local rule

getNestedRule2

public LocalRule getNestedRule2()
Returns the secaond nested local rule of this rule.

Returns:
the second nested local rule

apply

public boolean apply(Occurrence occ)
Returns true if the rule apply to the Occurrence.

Parameters:
occ - Occurrence onto apply rules
Returns:
true only and only if the rule apply to the Occurrence.

toString

public java.lang.String toString()
Returns the string representation of a LocalRule.

Returns:
the string representation of a LocalRule