|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.itc.irst.tcc.ties.data.patterns.Pattern
A Pattern object represents a specific sequence of features
derived from the left or right context of a given example.
The class implements the Serializable interface
so that instances may be saved to disk if desired.
Feature,
Serialized Form| Field Summary | |
private int |
hashCode
The hash code value for this Pattern |
(package private) static org.apache.log4j.Logger |
logger
Define a static logger variable so that it references the Logger instance named Pattern. |
private java.util.List |
pattern
The Pattern. |
private int |
pattType
The Pattern type |
static int |
PREFIX
The prefix constant. |
static int |
SUFFIX
The suffix constant. |
| Constructor Summary | |
|
Pattern(int pattType)
Allocates a new Pattern object containing no tokens. |
private |
Pattern(int pattType,
java.util.List tokens,
int hashCode)
Allocates a new Pattern object that represents the
sequence of tokens currently contained in the feat list argument. |
| Method Summary | |
void |
addToken(Feature feat)
Adds the specified feat in this Pattern, if the Pattern is a PREFIX
inserts the specified feat at the first position and shifts the element currently
at first position (if any) and any subsequent elements to the right (adds one to
their indices); otherwise, if the Pattern is a SUFFIX adds the
specified feat at the ending in this Pattern |
private void |
addToken(Feature feat,
boolean b)
Adds the specified feat in this Pattern, if the Pattern is a PREFIX
inserts the specified feat at the first position and shifts the element currently
at first position (if any) and any subsequent elements to the right (adds one to
their indices); otherwise, if the Pattern is a SUFFIX adds the
specified feat at the ending in this Pattern |
boolean |
containsAll(Feature feat)
Returns true if this Pattern contains all the tokens equals to the
specified feat. |
Pattern |
duplicate()
Returns a copy of this Pattern. |
boolean |
endsWith(Pattern suffix)
Tests if this Pattern ends with the specified suffix. |
boolean |
equals(java.lang.Object anObject)
Compares this Pattern to the specified object. |
Feature |
firstElement()
Returns the first component (the item at index 0) of this Pattern. |
Feature |
get(int index)
Returns the Feature object at the specified index. |
int |
getPatternType()
Returns the Pattern type. |
Feature |
getTokenAt(int index)
Returns the Feature object at the specified index. |
java.util.List |
getTokens()
Returns the Pattern as a list of Feature objects. |
int |
hashCode()
Returns the hash code value for this Pattern. |
boolean |
isEmpty()
Tests if this Pattern has no components. |
Feature |
lastElement()
Returns the last component (the item at index Pattern.size() - 1) of this Pattern. |
int |
length()
Returns the number of tokens in this Pattern. |
static void |
main(java.lang.String[] args)
|
void |
rehash()
Forces to recompute the hash code value for this Pattern. |
void |
setTokenAt(Feature feat,
int index)
Sets the feat at the specified index of this
Pattern to be the specified feat. |
boolean |
startsWith(Pattern prefix)
Tests if this Pattern starts with the specified prefix. |
boolean |
startsWith(Pattern prefix,
int toffset)
Tests if this Pattern starts with the specified prefix. |
Pattern |
subpattern(int beginIndex)
Returns a new Pattern that is a subpattern of this Pattern. |
Pattern |
subpattern(int beginIndex,
int endIndex)
Returns a new Pattern that is a subpattern of this Pattern. |
java.lang.String |
toString()
Returns a String object representing this Pattern. |
java.lang.String |
toXML()
Returns a String object representing this Pattern in XML. |
Pattern |
trim(Feature feat)
Trims the specified argument from the begining and end of this Pattern. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
static org.apache.log4j.Logger logger
Pattern.
public static final int PREFIX
public static final int SUFFIX
private java.util.List pattern
private int hashCode
private int pattType
| Constructor Detail |
public Pattern(int pattType)
Pattern object containing no tokens.
pattType - the Pattern type.
private Pattern(int pattType,
java.util.List tokens,
int hashCode)
Pattern object that represents the
sequence of tokens currently contained in the feat list argument.
pattType - the Pattern type.tokens - the sequence of tokens.hashCode - the hash code.| Method Detail |
public java.util.List getTokens()
Feature objects.
Feature objects.public Feature getTokenAt(int index)
Feature object at the specified index.
index - an index into this Pattern.
java.lang.IndexOutOfBoundsException - index is out of range (index < 0 || index >= length()).public Feature get(int index)
Feature object at the specified index.
index - an index into this Pattern.
java.lang.IndexOutOfBoundsException - index is out of range (index < 0 || index >= length()).public Feature firstElement()
java.util.NoSuchElementException - if this Pattern has no components.public Feature lastElement()
java.util.NoSuchElementException - if this Pattern has no components.public int getPatternType()
public Pattern trim(Feature feat)
public boolean containsAll(Feature feat)
true if this Pattern contains all the tokens equals to the
specified feat.
feat - an index into this Pattern.
true if this Pattern contains all the tokens equals to the
specified feat; false otherwise;
public boolean startsWith(Pattern prefix,
int toffset)
prefix - the prefix.toffset - where to begin looking in the Pattern.
true if the feat sequence represented by the
argument is a prefix of the feat sequence represented by
this Pattern; false otherwise.public boolean startsWith(Pattern prefix)
prefix - the prefix.
true if the feat sequence represented by the
argument is a prefix of the feat sequence represented by
this Pattern; false otherwise.public boolean endsWith(Pattern suffix)
suffix - the suffix.
true if the feat sequence represented by the
argument is a suffix of the feat sequence represented by
this object; false otherwise.public int length()
public void addToken(Feature feat)
PREFIX
inserts the specified feat at the first position and shifts the element currently
at first position (if any) and any subsequent elements to the right (adds one to
their indices); otherwise, if the Pattern is a SUFFIX adds the
specified feat at the ending in this Pattern
feat - the Pattern feat to be added.
private void addToken(Feature feat,
boolean b)
PREFIX
inserts the specified feat at the first position and shifts the element currently
at first position (if any) and any subsequent elements to the right (adds one to
their indices); otherwise, if the Pattern is a SUFFIX adds the
specified feat at the ending in this Pattern
feat - the Pattern feat to be added.b - true if the feat has to be added in reverse order.public void rehash()
public int hashCode()
public boolean equals(java.lang.Object anObject)
true
if and only if the argument is not null and is a Pattern
object that represents the same sequence of tokens as this object.
anObject - the object to compare this Pattern against.
true if the Pattern are equal; false otherwise.public final boolean isEmpty()
true if this Pattern has no components;
false otherwise.
public void setTokenAt(Feature feat,
int index)
index of this
Pattern to be the specified feat. The previous feat at that
position is discarded.
The index must be a value greater than or equal to 0
and less than the current length of the Pattern.
feat - what the feat is to be set to.index - the specified index.
java.lang.ArrayIndexOutOfBoundsException - if the index was invalid.public java.lang.String toString()
public java.lang.String toXML()
public Pattern subpattern(int beginIndex)
beginIndex - the beginning index, inclusive.
java.lang.IndexOutOfBoundsException - if the beginIndex
or the endIndex is out of range.
public Pattern subpattern(int beginIndex,
int endIndex)
beginIndex and extends to the feat at index
endIndex - 1.
beginIndex - the beginning index, inclusive.endIndex - the ending index, exclusive.
java.lang.IndexOutOfBoundsException - if the beginIndex
or the endIndex is out of range.public Pattern duplicate()
public static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||