extractTerms
Class Occurrence

java.lang.Object
  extended byextractTerms.Occurrence
All Implemented Interfaces:
java.lang.Comparable, java.io.Serializable

public class Occurrence
extends java.lang.Object
implements java.io.Serializable, java.lang.Comparable

Contain an occurrence of units (String) pair or triple.

Number of occurrence of units pair or triple (int), lines positions in the input file (TreeSet of Integers) and names of text (Hashtable of Integers) wich contain the occurrence.

Relation (int), iteration (int) and typeName (String) of the occurrence.

May contain a measure (double).

Since:
18/07/2003
Version:
0.4 17/06/2004
Author:
Thomas Heitz for LRI Paris XI University
See Also:
Serialized Form

Constructor Summary
Occurrence(java.lang.String _unit1, java.lang.String _unit2)
          Partial Occurrence with just strings of units filled.
Occurrence(java.lang.String _unit1, java.lang.String _unit2, int _occ, java.util.TreeSet _lines, java.util.Hashtable _nameOfText, double _measure, int _relation, int _iteration, java.lang.String _typeName)
          Partial Occurrence with all fields filled.
Occurrence(java.lang.String _unit1, java.lang.String _unit2, java.lang.String _unit3)
          Partial Occurrence with just strings of units filled.
Occurrence(java.lang.String _unit1, java.lang.String _unit2, java.lang.String _unit3, int _occ, java.util.TreeSet _lines, java.util.Hashtable _nameOfText, double _measure, int _relation, int _iteration, java.lang.String _typeName)
          Full Occurrence with all fields filled.
 
Method Summary
 boolean addLine(int line)
          Add a line number if it doesn't already exist.
 boolean addNameOfText(java.lang.String _nameOfText)
          Add a name of text if it doesn't already exist.
 int compareTo(java.lang.Object obj)
          Compares an Occurrence with another Occurrence on their units content in ascending alphabetical order.
 boolean equals(java.lang.Object obj)
          Test the equality of 2 Occurrence objects on their units content.
 int getIteration()
          Returns the number of the iteration when this term was extracted.
 java.lang.String getKey()
          Returns the concatenation of the term's units.
 java.util.TreeSet getLines()
          Returns the list of lines of this occurrence in the text where it was extract.
 java.util.Iterator getLinesIterator()
          Returns an iterator to read successively the value of lines of this occurrence.
 double getMeasure()
          Returns the value of the measure for this occurrence.
 java.lang.Double getMeasureDbl()
          Same as getMeasure() but of Double type.
 java.lang.String getMeasureString()
          Returns the String of the formatted value of the measure for this occurrence.
 java.util.Hashtable getNamesOfText()
          Returns the table of names of text where occurrence appears.
 int getOcc()
          Returns the number of occurrence.
 java.lang.Integer getOccInt()
          Same as getOcc() but of Integer type.
 int getRelation()
          Returns the position of the element in the list of units selector that was selected for this term.
static java.lang.String getTag(java.lang.String unit, java.lang.String separator)
          Returns the string after the separator contains in the unit.
 java.lang.String getTypeName()
          Returns the type name of this term.
 java.lang.String getUnit1()
          Returns the first unit of the term.
 java.lang.String getUnit2()
          Returns the second unit of the term.
 java.lang.String getUnit3()
          Returns the third unit of the term.
static java.lang.String getWord(java.lang.String unit, java.lang.String separator)
          Returns the string before the separator contains in the unit.
 boolean hasLines()
          Returns true if this occurrence has at less one line in the list of its lines where it appears.
 int incrementOcc()
          Increment by 1 the number of occurrence for this occurrence.
 boolean is2Units()
          Returns true if it is a 2 units occurrence.
 boolean is3Units()
          Returns true if it is a 3 units occurrence.
 void setIteration(int _iteration)
          Set the number of the iteration.
 void setMeasure(double _measure)
          Set the value of the measure.
 void setRelation(int _relation)
          Set the number of the relation.
 void setTypeName(java.lang.String _typeName)
          Set the name of the type.
 java.lang.String toString()
          Returns the string representation of an occurrence.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Occurrence

public Occurrence(java.lang.String _unit1,
                  java.lang.String _unit2)
Partial Occurrence with just strings of units filled.

See Also:
full constructor

Occurrence

public Occurrence(java.lang.String _unit1,
                  java.lang.String _unit2,
                  java.lang.String _unit3)
Partial Occurrence with just strings of units filled.

See Also:
full constructor

Occurrence

public Occurrence(java.lang.String _unit1,
                  java.lang.String _unit2,
                  int _occ,
                  java.util.TreeSet _lines,
                  java.util.Hashtable _nameOfText,
                  double _measure,
                  int _relation,
                  int _iteration,
                  java.lang.String _typeName)
Partial Occurrence with all fields filled.

See Also:
full constructor

Occurrence

public Occurrence(java.lang.String _unit1,
                  java.lang.String _unit2,
                  java.lang.String _unit3,
                  int _occ,
                  java.util.TreeSet _lines,
                  java.util.Hashtable _nameOfText,
                  double _measure,
                  int _relation,
                  int _iteration,
                  java.lang.String _typeName)
Full Occurrence with all fields filled.

Parameters:
_unit1 - string of the first unit of the occurrence ; couldn't be null.
_unit2 - string of the second unit of the occurrence ; couldn't be null.
_unit3 - string of the third unit of the occurrence ; couldn't be null.
_occ - number of occurrence for these concatenated units ; superior or equal to 1.
_lines - contain lines (Integer) of occurrence.
_nameOfText - contain number of occurrence (Integer) indexed by name of text ; invariant : the sum of all number of occurrence is equal to occ field.
_measure - contain the value of the measure.
_relation - position of the element in the list of units selector that was selected for this term
_iteration - number of the iteration when this term was extracted
_typeName - three first letters of the type name according to the list of types in the Expression panel
Method Detail

getOcc

public int getOcc()
Returns the number of occurrence.

Returns:
the number occurence always superior or equal to 1.

getOccInt

public java.lang.Integer getOccInt()
Same as getOcc() but of Integer type.

Returns:
the number occurence of Integer type.
See Also:
getOcc()

getUnit1

public java.lang.String getUnit1()
Returns the first unit of the term.

Returns:
the non-null string of the first unit.

getUnit2

public java.lang.String getUnit2()
Returns the second unit of the term.

Returns:
the non-null string of the second unit.

getUnit3

public java.lang.String getUnit3()
Returns the third unit of the term.

Returns:
the string of the third unit ; it may be null if the term is a couple of units.

getKey

public java.lang.String getKey()
Returns the concatenation of the term's units.

Returns:
the non-null string concatenation.

getMeasure

public double getMeasure()
Returns the value of the measure for this occurrence.

Returns:
the value of measure ; may be equal to Double.NaN if the measure value of the term wasn't added.

getMeasureDbl

public java.lang.Double getMeasureDbl()
Same as getMeasure() but of Double type.

Returns:
the value measure of Double type.
See Also:
getMeasure()

getMeasureString

public java.lang.String getMeasureString()
Returns the String of the formatted value of the measure for this occurrence.

Returns:
the String value of measure ; may be the empty string if the measure value of the term wasn't added.

getLines

public java.util.TreeSet getLines()
Returns the list of lines of this occurrence in the text where it was extract.

Returns:
an ascending sorted list of lines (Integer) ; may be empty if the lines of the occurrence wasn't added.

getLinesIterator

public java.util.Iterator getLinesIterator()
Returns an iterator to read successively the value of lines of this occurrence.

Returns:
an iterator of lines (Integer) ; may be empty if the lines of the occurrence wasn't added.

getNamesOfText

public java.util.Hashtable getNamesOfText()
Returns the table of names of text where occurrence appears. Each name is linked to the number of occurrence for this text name.

Returns:
an hash table of number of occurrence (Integer) indexed by name of text.

getRelation

public int getRelation()
Returns the position of the element in the list of units selector that was selected for this term.

Returns:
the number of the relation.

getIteration

public int getIteration()
Returns the number of the iteration when this term was extracted.

Returns:
the number of the iteration.

getTypeName

public java.lang.String getTypeName()
Returns the type name of this term.

Returns:
the type name of this term.

is2Units

public boolean is2Units()
Returns true if it is a 2 units occurrence.

Returns:
true if and only if it is a 2 units occurrence ; invariant : o.is2Units() != o.is3Units().

is3Units

public boolean is3Units()
Returns true if it is a 3 units occurrence.

Returns:
true if and only if it is a 3 units occurrence ; invariant : o.is2Units() != o.is3Units().

hasLines

public boolean hasLines()
Returns true if this occurrence has at less one line in the list of its lines where it appears.

Returns:
true if and only if one or more lines is contain in the list of lines.

setMeasure

public void setMeasure(double _measure)
Set the value of the measure.


incrementOcc

public int incrementOcc()
Increment by 1 the number of occurrence for this occurrence.

Returns:
the new number of occurrence.

addLine

public boolean addLine(int line)
Add a line number if it doesn't already exist.

Returns:
true if the set did not already contain the line.

addNameOfText

public boolean addNameOfText(java.lang.String _nameOfText)
Add a name of text if it doesn't already exist.

Returns:
true if the Hashtable did not already contain the _nameOfText.

setIteration

public void setIteration(int _iteration)
Set the number of the iteration.


setRelation

public void setRelation(int _relation)
Set the number of the relation.


setTypeName

public void setTypeName(java.lang.String _typeName)
Set the name of the type.


toString

public java.lang.String toString()
Returns the string representation of an occurrence.

Returns:
the string representation ; only the units or if the format is define the units plus the measure value, the number of occurrences and the number of texts where present.

getWord

public static java.lang.String getWord(java.lang.String unit,
                                       java.lang.String separator)
Returns the string before the separator contains in the unit.

Parameters:
unit - the unit to split
separator - the separator used to split the unit in two
Returns:
the string before the separator contains in the unit

getTag

public static java.lang.String getTag(java.lang.String unit,
                                      java.lang.String separator)
Returns the string after the separator contains in the unit.

Parameters:
unit - the unit to split
separator - the separator used to split the unit in two
Returns:
the string after the separator contains in the unit

compareTo

public int compareTo(java.lang.Object obj)
Compares an Occurrence with another Occurrence on their units content in ascending alphabetical order.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
obj - the reference object with which to compare.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

equals

public boolean equals(java.lang.Object obj)
Test the equality of 2 Occurrence objects on their units content.

Parameters:
obj - the reference object with which to compare.
Returns:
true if this object is the same as the obj argument; false otherwise.