org.eml.MMAX2.annotation.markables
Class MarkableHelper

java.lang.Object
  extended by org.eml.MMAX2.annotation.markables.MarkableHelper

public class MarkableHelper
extends java.lang.Object


Field Summary
static java.lang.String legacyDefaultValue
           
static int LONGER_BEFORE_SHORTER
           
static int SHORTER_BEFORE_LONGER
           
 
Constructor Summary
MarkableHelper()
          Creates a new instance of MarkableHelper
 
Method Summary
static boolean before(int e1End, int e2Start)
           
static boolean before(Markable m1, Markable m2)
           
static boolean before(MMAX2QueryResultTuple t1, MMAX2QueryResultTuple t2, int list1ColSpec, int list2ColSpec)
          This returns true if t1 appears before t2, false otherwise.
static boolean beforeStrict(int e1End, int e2Start)
           
static boolean beforeStrict(Markable m1, Markable m2)
           
static boolean beforeStrict(MMAX2QueryResultTuple t1, MMAX2QueryResultTuple t2, int list1ColSpec, int list2ColSpec)
          This returns true if t1 appears before t2, false otherwise.
static boolean during(int t1Start, int t1End, int t2Start, int t2End)
           
static boolean during(Markable m1, Markable m2)
           
static boolean during(MMAX2QueryResultTuple t1, MMAX2QueryResultTuple t2, int list1ColSpec, int list2ColSpec)
          This returns true if t1 starts at the same time as or after t2 starts, and t1 ends at the same time as or before t2 ends, false otherwise.
static boolean duringFragments(java.lang.String[][] m1Frags, java.lang.String[][] m2Frags)
           
static boolean duringStrict(Markable m1, Markable m2)
           
static boolean duringStrict(MMAX2QueryResultTuple t1, MMAX2QueryResultTuple t2, int list1ColSpec, int list2ColSpec)
          This returns true if t1 starts at the same time as or after t2 starts, and t1 ends at the same time as or before t2 ends, and if t1 and t2 are not identical,false otherwise.
static java.lang.String encodeXML(java.lang.String inString)
           
static boolean equalFragments(java.lang.String[][] m1Frags, java.lang.String[][] m2Frags)
           
static boolean equals(int t1Start, int t1End, int t2Start, int t2End)
           
static boolean equals(Markable m1, Markable m2)
           
static boolean equals(MMAX2QueryResultTuple t1, MMAX2QueryResultTuple t2, int list1ColSpec, int list2ColSpec)
          This returns true if t1 and t2 span the same sequence of discourse elements, false otherwise.
static boolean finishes(int t1End, int t2End)
           
static boolean finishes(Markable m1, Markable m2)
           
static boolean finishes(MMAX2QueryResultTuple t1, MMAX2QueryResultTuple t2, int list1ColSpec, int list2ColSpec)
          This returns true if t1 ends at the same time as t2 ends, and starts at the same time as or after t2 starts, false otherwise.
static boolean finishesStrict(int t1Start, int t1End, int t2Start, int t2End)
           
static boolean finishesStrict(Markable m1, Markable m2)
           
static boolean finishesStrict(MMAX2QueryResultTuple t1, MMAX2QueryResultTuple t2, int list1ColSpec, int list2ColSpec)
          This returns true if t1 ends at the same time as t2 ends, and t1 starts after t2 starts, false otherwise.
static int getDistanceInDiscoursePositions(Markable m1, Markable m2)
           
static int getDistanceInDiscoursePositions(MMAX2QueryResultTupleElement e1, MMAX2QueryResultTupleElement e2)
           
static int getFollowingValidDiscourseElementPosition(Markable markable, java.lang.String[] currentFragment, int currentPos)
          Needed if Markables contain suppressed Discourse elements.
static java.lang.String getFormattedAttributeString(Markable markable)
           
static int getPreceedingValidDiscourseElementPosition(Markable markable, java.lang.String[] currentFragment, int currentPos)
          This method returns the discourse position of the next valid (i.e.
static java.lang.String getSpan(Markable markable)
           
static java.lang.String getSpan(java.lang.String[][] fragments)
           
static java.lang.String getTransposedSpan(java.lang.String oldSpan, java.lang.String oldLang, java.util.ArrayList absoluteWords)
           
static boolean matches(Markable markable, java.lang.String _attribute, java.lang.String _value, int type, boolean _negated)
          This method is used for matching queries that are NOT RegExps .
static boolean matches(MMAX2DiscourseElement de, java.lang.String _attribute, java.lang.String _value, int type, boolean _negated)
          This method is used for matching queries that are NOT RegExps .
static boolean matchesAll(Markable markable, MMAX2MatchingCriterion criterion)
          Used by MMAX query.
static boolean matchesAll(MMAX2DiscourseElement de, MMAX2MatchingCriterion criterion)
          Used by MMAX query.
static boolean matchesAny(Markable markable, MMAX2MatchingCriterion criterion)
          Used by MMAX query.
static boolean matchesAny(MMAX2DiscourseElement de, MMAX2MatchingCriterion criterion)
          Used by MMAX query.
static boolean matchesRegExp(Markable markable, java.lang.String _attribute, java.lang.String _value, int type, boolean _negated)
          This is used for matching queries with RegExp values.
static boolean matchesRegExp(MMAX2DiscourseElement de, java.lang.String _attribute, java.lang.String _value, int type, boolean _negated)
          This is used for matching queries with RegExp values.
static boolean meets(int e1End, int e2Start)
           
static boolean meets(Markable m1, Markable m2)
           
static boolean meets(MMAX2QueryResultTuple t1, MMAX2QueryResultTuple t2, int list1ColSpec, int list2ColSpec)
          This returns true if t1 ends directly before t2 begins (no overlap), false otherwise.
static boolean overlaps_left(int e1Start, int e1End, int e2Start, int e2End)
           
static boolean overlaps_left(Markable m1, Markable m2)
           
static boolean overlaps_left(MMAX2QueryResultTuple t1, MMAX2QueryResultTuple t2, int list1ColSpec, int list2ColSpec)
           
static boolean overlaps_right(int e1Start, int e1End, int e2Start, int e2End)
           
static boolean overlaps_right(Markable m1, Markable m2)
           
static boolean overlaps_right(MMAX2QueryResultTuple t1, MMAX2QueryResultTuple t2, int list1ColSpec, int list2ColSpec)
          This returns true if t1 starts before t2 starts and t1 ends after t2 starts but before t2 ends, false otherwise.
static java.util.HashMap parseAttributesToHashMap(java.lang.String attribs)
           
static java.util.ArrayList[] parseAttributesToLists(java.lang.String attribs)
           
static java.util.ArrayList parseCompleteSpan(java.lang.String span)
          This method parses the value of a span attribute and returns all elements in an ArrayList.
static java.lang.String[][] parseSpan(java.lang.String span)
          This method parses the value of a span attribute and returns an Array with one Array per fragment.
static java.util.ArrayList parseSpanFragment(java.lang.String span)
          This method parses the value of a DE's span attribute and returns all elements in an ArrayList.
static java.lang.String[] parseSpanFragmentToArray(java.lang.String span)
          This method parses the value of a span fragment (either word_1..word_4 or word_3) and returns an array of all elements.
static void register(Markable markable, boolean updateHash)
          This method
static void removeDuplicateDiscoursePositions(java.util.ArrayList DEs)
           
static void setDisplayPositions(Markable markable)
          For each fragment this Markable contains, this method sets the associated display positions in displayStart- and displayEndPosition, by setting displayStartPositions, displayEndPositions, discourseElementStartPositions, leftmostDisplayPosition, rightmostDisplayPosition.
static void sort(java.util.ArrayList markables, java.util.Comparator comp)
           
static boolean spans(MMAX2QueryResultTuple t1, MMAX2QueryResultTuple t2, int list1ColSpec, int list2ColSpec)
          This returns true if t1 and t2 start and end at the same positions regardless of discontinuity false otherwise.
static boolean starts(int e1Start, int e1End, int e2Start, int e2End)
           
static boolean starts(Markable m1, Markable m2)
           
static boolean starts(MMAX2QueryResultTuple t1, MMAX2QueryResultTuple t2, int list1ColSpec, int list2ColSpec)
          This returns true if t1 starts at the same time as t2 starts, and t1 ends at the same time as or before t2 ends, false otherwise.
static boolean startsStrict(int e1Start, int e1End, int e2Start, int e2End)
           
static boolean startsStrict(Markable m1, Markable m2)
           
static boolean startsStrict(MMAX2QueryResultTuple t1, MMAX2QueryResultTuple t2, int list1ColSpec, int list2ColSpec)
          This returns true if t1 starts at the same time as t2 starts, and t1 ends before t2 ends, false otherwise.
static java.lang.String[][] toFragments(java.util.ArrayList DEs)
          This class receives an ArrayList of MMAX2DiscourseElement objects representing one markable, and returns an array of arrays of Strings to be used as a markables fragment field.
static java.lang.String[][] toFragments(java.util.ArrayList IDs, MMAX2Discourse discourse)
          This class receives an ArrayList of MMAX2DiscourseElement IDs representing one markable, and returns an array of arrays of Strings to be used as a markables fragment field.
static java.lang.String toKWICString(Markable markable)
          This returns a string representation of the current markable as a 'Key Word In Context'.
static java.lang.String toKWICString(Markable markable, int maxWidth)
          This returns a string representation of the current markable as a 'Key Word In Context'.
static java.lang.String toKWICString(java.lang.String wordID, MMAX2Discourse discourse)
          This returns a string representation of the current markable as a 'Key Word In Context'.
static java.lang.String toXMLElement(Markable markable)
          This method converts this Markable into an XML String representation for file storage.
static java.lang.String transposeMarkable(Markable toTranspose, java.lang.String oldLang, java.util.ArrayList absoluteWords)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LONGER_BEFORE_SHORTER

public static final int LONGER_BEFORE_SHORTER
See Also:
Constant Field Values

SHORTER_BEFORE_LONGER

public static final int SHORTER_BEFORE_LONGER
See Also:
Constant Field Values

legacyDefaultValue

public static final java.lang.String legacyDefaultValue
See Also:
Constant Field Values
Constructor Detail

MarkableHelper

public MarkableHelper()
Creates a new instance of MarkableHelper

Method Detail

sort

public static void sort(java.util.ArrayList markables,
                        java.util.Comparator comp)

getFormattedAttributeString

public static java.lang.String getFormattedAttributeString(Markable markable)

toFragments

public static java.lang.String[][] toFragments(java.util.ArrayList DEs)
This class receives an ArrayList of MMAX2DiscourseElement objects representing one markable, and returns an array of arrays of Strings to be used as a markables fragment field.


toFragments

public static java.lang.String[][] toFragments(java.util.ArrayList IDs,
                                               MMAX2Discourse discourse)
This class receives an ArrayList of MMAX2DiscourseElement IDs representing one markable, and returns an array of arrays of Strings to be used as a markables fragment field.


removeDuplicateDiscoursePositions

public static void removeDuplicateDiscoursePositions(java.util.ArrayList DEs)

beforeStrict

public static boolean beforeStrict(MMAX2QueryResultTuple t1,
                                   MMAX2QueryResultTuple t2,
                                   int list1ColSpec,
                                   int list2ColSpec)
This returns true if t1 appears before t2, false otherwise. t1 is 'before' t2 if t1 ends before t2 begins. For discontinuous markables, the end of the last fragment of t1 and the beginning of the first fragment of t2 is considered.


beforeStrict

public static boolean beforeStrict(Markable m1,
                                   Markable m2)

beforeStrict

public static boolean beforeStrict(int e1End,
                                   int e2Start)

before

public static boolean before(MMAX2QueryResultTuple t1,
                             MMAX2QueryResultTuple t2,
                             int list1ColSpec,
                             int list2ColSpec)
This returns true if t1 appears before t2, false otherwise. t1 is 'before' t2 if t1 ends before t2 begins. For discontinuous markables, the end of the last fragment of t1 and the beginning of the first fragment of t2 is considered.


before

public static boolean before(Markable m1,
                             Markable m2)

before

public static boolean before(int e1End,
                             int e2Start)

meets

public static boolean meets(MMAX2QueryResultTuple t1,
                            MMAX2QueryResultTuple t2,
                            int list1ColSpec,
                            int list2ColSpec)
This returns true if t1 ends directly before t2 begins (no overlap), false otherwise. For discontinuous markables, the end of the last fragment of t1 and the beginning of the first fragment of t2 is considered.


meets

public static boolean meets(Markable m1,
                            Markable m2)

meets

public static boolean meets(int e1End,
                            int e2Start)

starts

public static boolean starts(Markable m1,
                             Markable m2)

starts

public static boolean starts(int e1Start,
                             int e1End,
                             int e2Start,
                             int e2End)

startsStrict

public static boolean startsStrict(Markable m1,
                                   Markable m2)

startsStrict

public static boolean startsStrict(int e1Start,
                                   int e1End,
                                   int e2Start,
                                   int e2End)

overlaps_right

public static boolean overlaps_right(MMAX2QueryResultTuple t1,
                                     MMAX2QueryResultTuple t2,
                                     int list1ColSpec,
                                     int list2ColSpec)
This returns true if t1 starts before t2 starts and t1 ends after t2 starts but before t2 ends, false otherwise. For discontinuous markables, the beginning of the first fragment of t1 and t2 and the end of the last fragment of t1 and t2 is considered.


overlaps_left

public static boolean overlaps_left(MMAX2QueryResultTuple t1,
                                    MMAX2QueryResultTuple t2,
                                    int list1ColSpec,
                                    int list2ColSpec)

overlaps_right

public static boolean overlaps_right(Markable m1,
                                     Markable m2)

overlaps_left

public static boolean overlaps_left(Markable m1,
                                    Markable m2)

overlaps_right

public static boolean overlaps_right(int e1Start,
                                     int e1End,
                                     int e2Start,
                                     int e2End)

overlaps_left

public static boolean overlaps_left(int e1Start,
                                    int e1End,
                                    int e2Start,
                                    int e2End)

finishes

public static boolean finishes(Markable m1,
                               Markable m2)

finishes

public static boolean finishes(int t1End,
                               int t2End)

finishesStrict

public static boolean finishesStrict(Markable m1,
                                     Markable m2)

finishesStrict

public static boolean finishesStrict(int t1Start,
                                     int t1End,
                                     int t2Start,
                                     int t2End)

during

public static boolean during(MMAX2QueryResultTuple t1,
                             MMAX2QueryResultTuple t2,
                             int list1ColSpec,
                             int list2ColSpec)
This returns true if t1 starts at the same time as or after t2 starts, and t1 ends at the same time as or before t2 ends, false otherwise. For discontinuous markables, each fragment of t1 must be completely within (i.e. during) some fragment of t2.


starts

public static boolean starts(MMAX2QueryResultTuple t1,
                             MMAX2QueryResultTuple t2,
                             int list1ColSpec,
                             int list2ColSpec)
This returns true if t1 starts at the same time as t2 starts, and t1 ends at the same time as or before t2 ends, false otherwise. For discontinuous markables, each fragment of t1 must be completely within (i.e. during) some fragment of t2, and t1 and t2 must start at the same position.


finishes

public static boolean finishes(MMAX2QueryResultTuple t1,
                               MMAX2QueryResultTuple t2,
                               int list1ColSpec,
                               int list2ColSpec)
This returns true if t1 ends at the same time as t2 ends, and starts at the same time as or after t2 starts, false otherwise. For discontinuous markables, each fragment of t1 must be completely within (i.e. during) some fragment of t2, and t1 and t2 must end at the same position.


startsStrict

public static boolean startsStrict(MMAX2QueryResultTuple t1,
                                   MMAX2QueryResultTuple t2,
                                   int list1ColSpec,
                                   int list2ColSpec)
This returns true if t1 starts at the same time as t2 starts, and t1 ends before t2 ends, false otherwise. For discontinuous markables, each fragment of t1 must be completely within (i.e. during) some fragment of t2, and t1 and t2 must start at the same position, and t1 must end before t2.


finishesStrict

public static boolean finishesStrict(MMAX2QueryResultTuple t1,
                                     MMAX2QueryResultTuple t2,
                                     int list1ColSpec,
                                     int list2ColSpec)
This returns true if t1 ends at the same time as t2 ends, and t1 starts after t2 starts, false otherwise. For discontinuous markables, each fragment of t1 must be completely within (i.e. during) some fragment of t2, and t1 and t2 must end at the same position, and t1 must start after t2 starts.


during

public static boolean during(Markable m1,
                             Markable m2)

during

public static boolean during(int t1Start,
                             int t1End,
                             int t2Start,
                             int t2End)

duringFragments

public static boolean duringFragments(java.lang.String[][] m1Frags,
                                      java.lang.String[][] m2Frags)

duringStrict

public static boolean duringStrict(MMAX2QueryResultTuple t1,
                                   MMAX2QueryResultTuple t2,
                                   int list1ColSpec,
                                   int list2ColSpec)
This returns true if t1 starts at the same time as or after t2 starts, and t1 ends at the same time as or before t2 ends, and if t1 and t2 are not identical,false otherwise. For discontinuous markables, each fragment of t1 must be completely within (i.e. during) some fragment of t2.


duringStrict

public static boolean duringStrict(Markable m1,
                                   Markable m2)

equals

public static boolean equals(MMAX2QueryResultTuple t1,
                             MMAX2QueryResultTuple t2,
                             int list1ColSpec,
                             int list2ColSpec)
This returns true if t1 and t2 span the same sequence of discourse elements, false otherwise. Discontinuous tuples are compared fragment for fragment.


spans

public static boolean spans(MMAX2QueryResultTuple t1,
                            MMAX2QueryResultTuple t2,
                            int list1ColSpec,
                            int list2ColSpec)
This returns true if t1 and t2 start and end at the same positions regardless of discontinuity false otherwise.


equalFragments

public static boolean equalFragments(java.lang.String[][] m1Frags,
                                     java.lang.String[][] m2Frags)

equals

public static boolean equals(Markable m1,
                             Markable m2)

equals

public static boolean equals(int t1Start,
                             int t1End,
                             int t2Start,
                             int t2End)

toKWICString

public static final java.lang.String toKWICString(java.lang.String wordID,
                                                  MMAX2Discourse discourse)
This returns a string representation of the current markable as a 'Key Word In Context'.


toKWICString

public static final java.lang.String toKWICString(Markable markable)
This returns a string representation of the current markable as a 'Key Word In Context'.


toKWICString

public static final java.lang.String toKWICString(Markable markable,
                                                  int maxWidth)
This returns a string representation of the current markable as a 'Key Word In Context'.


register

public static final void register(Markable markable,
                                  boolean updateHash)
This method


getFollowingValidDiscourseElementPosition

public static final int getFollowingValidDiscourseElementPosition(Markable markable,
                                                                  java.lang.String[] currentFragment,
                                                                  int currentPos)
Needed if Markables contain suppressed Discourse elements.


getPreceedingValidDiscourseElementPosition

public static final int getPreceedingValidDiscourseElementPosition(Markable markable,
                                                                   java.lang.String[] currentFragment,
                                                                   int currentPos)
This method returns the discourse position of the next valid (i.e. non-empty) DiscourseElement in currentFragment, moving from currentPos -1 to the left. (Needed if Markables contain suppressed Discourse elements.)


setDisplayPositions

public static final void setDisplayPositions(Markable markable)
For each fragment this Markable contains, this method sets the associated display positions in displayStart- and displayEndPosition, by setting displayStartPositions, displayEndPositions, discourseElementStartPositions, leftmostDisplayPosition, rightmostDisplayPosition.


transposeMarkable

public static final java.lang.String transposeMarkable(Markable toTranspose,
                                                       java.lang.String oldLang,
                                                       java.util.ArrayList absoluteWords)

getTransposedSpan

public static final java.lang.String getTransposedSpan(java.lang.String oldSpan,
                                                       java.lang.String oldLang,
                                                       java.util.ArrayList absoluteWords)

toXMLElement

public static final java.lang.String toXMLElement(Markable markable)
This method converts this Markable into an XML String representation for file storage.


encodeXML

public static final java.lang.String encodeXML(java.lang.String inString)

matchesRegExp

public static final boolean matchesRegExp(Markable markable,
                                          java.lang.String _attribute,
                                          java.lang.String _value,
                                          int type,
                                          boolean _negated)
This is used for matching queries with RegExp values.


matchesRegExp

public static final boolean matchesRegExp(MMAX2DiscourseElement de,
                                          java.lang.String _attribute,
                                          java.lang.String _value,
                                          int type,
                                          boolean _negated)
This is used for matching queries with RegExp values.


matches

public static final boolean matches(Markable markable,
                                    java.lang.String _attribute,
                                    java.lang.String _value,
                                    int type,
                                    boolean _negated)
This method is used for matching queries that are NOT RegExps .


matches

public static final boolean matches(MMAX2DiscourseElement de,
                                    java.lang.String _attribute,
                                    java.lang.String _value,
                                    int type,
                                    boolean _negated)
This method is used for matching queries that are NOT RegExps .


getSpan

public static final java.lang.String getSpan(java.lang.String[][] fragments)

getSpan

public static final java.lang.String getSpan(Markable markable)

matchesAny

public static final boolean matchesAny(Markable markable,
                                       MMAX2MatchingCriterion criterion)
Used by MMAX query.


matchesAny

public static final boolean matchesAny(MMAX2DiscourseElement de,
                                       MMAX2MatchingCriterion criterion)
Used by MMAX query.


matchesAll

public static final boolean matchesAll(Markable markable,
                                       MMAX2MatchingCriterion criterion)
Used by MMAX query.


matchesAll

public static final boolean matchesAll(MMAX2DiscourseElement de,
                                       MMAX2MatchingCriterion criterion)
Used by MMAX query.


getDistanceInDiscoursePositions

public static final int getDistanceInDiscoursePositions(Markable m1,
                                                        Markable m2)

getDistanceInDiscoursePositions

public static final int getDistanceInDiscoursePositions(MMAX2QueryResultTupleElement e1,
                                                        MMAX2QueryResultTupleElement e2)

parseAttributesToHashMap

public static final java.util.HashMap parseAttributesToHashMap(java.lang.String attribs)

parseAttributesToLists

public static final java.util.ArrayList[] parseAttributesToLists(java.lang.String attribs)

parseSpan

public static final java.lang.String[][] parseSpan(java.lang.String span)
This method parses the value of a span attribute and returns an Array with one Array per fragment. Spans of the form word_x..word_y will be expanded to include all intermediate ids


parseSpanFragmentToArray

public static final java.lang.String[] parseSpanFragmentToArray(java.lang.String span)
This method parses the value of a span fragment (either word_1..word_4 or word_3) and returns an array of all elements. Spans of the form word_x..word_y are expanded to include all intermediate ids.


parseCompleteSpan

public static final java.util.ArrayList parseCompleteSpan(java.lang.String span)
This method parses the value of a span attribute and returns all elements in an ArrayList. Spans of the form word_x..word_y will be expanded to include all intermediate ids


parseSpanFragment

public static final java.util.ArrayList parseSpanFragment(java.lang.String span)
This method parses the value of a DE's span attribute and returns all elements in an ArrayList. Spans of the form word_x..word_y are expanded to include all intermediate ids