|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.stanford.nlp.util.Pair<E,E>
edu.stanford.nlp.util.Interval<E>
public class Interval<E extends Comparable<E>>
Represents a interval of a generic type E that is comparable. An interval is an ordered pair where the first element is less than the second. Only full intervals are currently supported (i.e. both endpoints has to be specified - cannot be null) Provides functions for computing relationships between intervals. For flags that indicate relationship between two intervals, the following convention is used: SS = relationship between start of first interval and start of second interval SE = relationship between start of first interval and end of second interval ES = relationship between end of first interval and start of second interval EE = relationship between end of first interval and end of second interval
Nested Class Summary | |
---|---|
static class |
Interval.RelType
RelType gives the basic types of relations between two intervals |
Field Summary | |
---|---|
static int |
INTERVAL_OPEN_BEGIN
Flag indicating that an interval's begin point is not inclusive (by default, begin points are inclusive) |
static int |
INTERVAL_OPEN_END
Flag indicating that an interval's end point is not inclusive (by default, begin points are inclusive) |
protected static int |
REL_FLAGS_AFTER
|
protected static int |
REL_FLAGS_BEFORE
|
static int |
REL_FLAGS_EE_AFTER
The first interval ends after the second ends |
static int |
REL_FLAGS_EE_BEFORE
The first interval ends before the second ends |
static int |
REL_FLAGS_EE_SAME
Both intervals have the same end point |
protected static int |
REL_FLAGS_EE_SHIFT
|
static int |
REL_FLAGS_EE_UNKNOWN
The relationship between the end points of the two intervals is unknown (used for fuzzy intervals) |
static int |
REL_FLAGS_ES_AFTER
The end point of the first interval is after the start point of the second interval (the two intervals overlap) |
static int |
REL_FLAGS_ES_BEFORE
The end point of the first interval is before the start point of the second interval (the first interval is before the second) |
static int |
REL_FLAGS_ES_SAME
The end point of the first interval is the same as the start point of the second interval (the first interval is before the second) |
protected static int |
REL_FLAGS_ES_SHIFT
|
static int |
REL_FLAGS_ES_UNKNOWN
The relationship between the end point of the first interval and the start point of the second interval is unknown (used for fuzzy intervals) |
static int |
REL_FLAGS_INTERVAL_AFTER
The first interval is entirely after the second interval (the start of the first interval happens after the end of the second) |
static int |
REL_FLAGS_INTERVAL_ALMOST_AFTER
|
static int |
REL_FLAGS_INTERVAL_ALMOST_BEFORE
|
static int |
REL_FLAGS_INTERVAL_ALMOST_SAME
|
static int |
REL_FLAGS_INTERVAL_BEFORE
The first interval is entirely before the second interval (the end of the first interval happens before the start of the second) |
static int |
REL_FLAGS_INTERVAL_CONTAIN
The first interval contains the second interval. |
static int |
REL_FLAGS_INTERVAL_FUZZY
|
static int |
REL_FLAGS_INTERVAL_INSIDE
The first interval is inside the second interval. |
static int |
REL_FLAGS_INTERVAL_OVERLAP
The first interval overlaps with the second interval. |
static int |
REL_FLAGS_INTERVAL_SAME
The intervals are the same (have the same start and end points). |
static int |
REL_FLAGS_INTERVAL_UNKNOWN
It is uncertain what the relationship between the two intervals are... |
protected static int |
REL_FLAGS_SAME
|
static int |
REL_FLAGS_SE_AFTER
The start point of the first interval is after the end point of the second interval (the second interval is before the first) |
static int |
REL_FLAGS_SE_BEFORE
The start point of the first interval is before the end point of the second interval (the two intervals overlap) |
static int |
REL_FLAGS_SE_SAME
The start point of the first interval is the same as the end point of the second interval (the second interval is before the first) |
protected static int |
REL_FLAGS_SE_SHIFT
|
static int |
REL_FLAGS_SE_UNKNOWN
The relationship between the start point of the first interval and the end point of the second interval is unknown (used for fuzzy intervals) |
static int |
REL_FLAGS_SS_AFTER
The first interval starts after the second starts |
static int |
REL_FLAGS_SS_BEFORE
The first interval starts before the second starts |
static int |
REL_FLAGS_SS_SAME
Both intervals have the same start point |
protected static int |
REL_FLAGS_SS_SHIFT
|
static int |
REL_FLAGS_SS_UNKNOWN
The relationship between the start points of the two intervals is unknown (used for fuzzy intervals) |
protected static int |
REL_FLAGS_UNKNOWN
|
Fields inherited from class edu.stanford.nlp.util.Pair |
---|
first, second |
Fields inherited from interface edu.stanford.nlp.util.HasInterval |
---|
OFFSET_COMPARATOR |
Constructor Summary | |
---|---|
protected |
Interval(E a,
E b,
int flags)
|
Method Summary | ||
---|---|---|
protected int |
addIntervalRelationFlags(int flags,
boolean checkFuzzy)
|
|
static boolean |
checkFlagExclusiveSet(int flags,
int flag,
int mask)
Utility function to check if a particular flag is set exclusively given a particular set of flags and a mask |
|
static boolean |
checkFlagSet(int flags,
int flag)
Utility function to check if a particular flag is set given a particular set of flags |
|
static boolean |
checkMultipleBitSet(int flags)
Utility function to check if multiple bits are set for flags |
|
int |
compareIntervalOrder(Interval<E> other)
Returns order of another interval compared to this one |
|
boolean |
contains(E p)
Checks whether the point p is contained inside this interval |
|
boolean |
equals(Object o)
|
|
Interval |
expand(Interval<E> other)
Returns (smallest) interval that contains both this and the other interval |
|
static int |
extractRelationSubflags(int flags,
int shift)
|
|
E |
getBegin()
Returns the start point |
|
E |
getEnd()
Returns the end point |
|
Interval<E> |
getInterval()
Returns this interval |
|
Interval.RelType |
getRelation(Interval<E> other)
Returns the relationship of this interval to the other interval The most specific relationship from the following is returned. |
|
int |
getRelationFlags(Interval<E> other)
Return set of flags indicating possible relationships between this interval and another interval. |
|
int |
hashCode()
|
|
boolean |
includesBegin()
Returns whether the start endpoint is included in the interval |
|
boolean |
includesEnd()
Returns whether the end endpoint is included in the interval |
|
Interval |
intersect(Interval<E> other)
Returns interval that is the intersection of this and the other interval Returns null if intersect is null |
|
boolean |
isIntervalComparable(Interval<E> other)
Checks whether this interval is comparable with another interval comes before or after |
|
protected static
|
max(E a,
E b)
|
|
protected static
|
min(E a,
E b)
|
|
boolean |
overlaps(Interval<E> other)
Check whether this interval overlaps with the other interval (i.e. |
|
static
|
toInterval(E a,
E b)
Create an interval with the specified endpoints in the specified order, Returns null if a does not come before b (invalid interval) |
|
static
|
toInterval(E a,
E b,
int flags)
Create an interval with the specified endpoints in the specified order, using the specified flags. |
|
protected int |
toRelFlags(int comp,
int shift)
|
|
static
|
toValidInterval(E a,
E b)
Create an interval with the specified endpoints, reordering them as needed |
|
static
|
toValidInterval(E a,
E b,
int flags)
Create an interval with the specified endpoints, reordering them as needed, using the specified flags |
Methods inherited from class edu.stanford.nlp.util.Pair |
---|
asList, compareTo, first, internedStringPair, makePair, prettyLog, readStringPair, save, second, setFirst, setSecond, stringIntern, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static int INTERVAL_OPEN_BEGIN
public static int INTERVAL_OPEN_END
protected static final int REL_FLAGS_SAME
protected static final int REL_FLAGS_BEFORE
protected static final int REL_FLAGS_AFTER
protected static final int REL_FLAGS_UNKNOWN
protected static final int REL_FLAGS_SS_SHIFT
protected static final int REL_FLAGS_SE_SHIFT
protected static final int REL_FLAGS_ES_SHIFT
protected static final int REL_FLAGS_EE_SHIFT
public static final int REL_FLAGS_SS_SAME
|---- interval 1 ----? |---- interval 2 ----?
public static final int REL_FLAGS_SS_BEFORE
|---- interval 1 ----? |---- interval 2 ----? or |-- interval 1 --? |---- interval 2 ----?
public static final int REL_FLAGS_SS_AFTER
|---- interval 1 ----? |---- interval 2 ----? or |---- interval 1 ----? |-- interval 2 --?
public static final int REL_FLAGS_SS_UNKNOWN
public static final int REL_FLAGS_SE_SAME
|---- interval 1 ----? ?---- interval 2 ---|
public static final int REL_FLAGS_SE_BEFORE
|---- interval 1 ----? ?---- interval 2 ---|
public static final int REL_FLAGS_SE_AFTER
|---- interval 1 ---? ?-- interval 2 ---|
public static final int REL_FLAGS_SE_UNKNOWN
public static final int REL_FLAGS_ES_SAME
?---- interval 1 ---| |---- interval 2 ----?
public static final int REL_FLAGS_ES_BEFORE
?-- interval 1 ---| |---- interval 2 ---?
public static final int REL_FLAGS_ES_AFTER
?---- interval 1 ---| |---- interval 2 ----?
public static final int REL_FLAGS_ES_UNKNOWN
public static final int REL_FLAGS_EE_SAME
?---- interval 1 ----| ?---- interval 2 ----|
public static final int REL_FLAGS_EE_BEFORE
?---- interval 1 ----| ?---- interval 2 ----| or ?-- interval 1 --| ?---- interval 2 ----|
public static final int REL_FLAGS_EE_AFTER
?---- interval 1 ----| ?---- interval 2 ----| or ?---- interval 1 ----| ?-- interval 2 --|
public static final int REL_FLAGS_EE_UNKNOWN
public static final int REL_FLAGS_INTERVAL_SAME
|---- interval 1 ----| |---- interval 2 ----|
public static final int REL_FLAGS_INTERVAL_BEFORE
?---- interval 1 ----| |---- interval 2 ----?
public static final int REL_FLAGS_INTERVAL_AFTER
|---- interval 1 ----? ?---- interval 2 ----|
public static final int REL_FLAGS_INTERVAL_OVERLAP
public static final int REL_FLAGS_INTERVAL_INSIDE
|---- interval 1 ----| |---- interval 2 -----------|
public static final int REL_FLAGS_INTERVAL_CONTAIN
|---- interval 1 -----------| |---- interval 2 ----|
public static final int REL_FLAGS_INTERVAL_UNKNOWN
public static final int REL_FLAGS_INTERVAL_ALMOST_SAME
public static final int REL_FLAGS_INTERVAL_ALMOST_BEFORE
public static final int REL_FLAGS_INTERVAL_ALMOST_AFTER
public static final int REL_FLAGS_INTERVAL_FUZZY
Constructor Detail |
---|
protected Interval(E a, E b, int flags)
Method Detail |
---|
public static <E extends Comparable<E>> Interval<E> toInterval(E a, E b)
E
- type of the interval endpointsa
- start endpointsb
- end endpoint
public static <E extends Comparable<E>> Interval<E> toInterval(E a, E b, int flags)
E
- type of the interval endpointsa
- start endpointsb
- end endpointflags
- flags characterizing the interval
public static <E extends Comparable<E>> Interval<E> toValidInterval(E a, E b)
E
- type of the interval endpointsa
- one of the endpointsb
- the other endpoint
public static <E extends Comparable<E>> Interval<E> toValidInterval(E a, E b, int flags)
E
- type of the interval endpointsa
- one of the endpointsb
- the other endpointflags
- flags characterizing the interval
public Interval<E> getInterval()
getInterval
in interface HasInterval<E extends Comparable<E>>
public E getBegin()
public E getEnd()
protected static <E extends Comparable<E>> E max(E a, E b)
protected static <E extends Comparable<E>> E min(E a, E b)
public boolean contains(E p)
p
- point to check
public Interval expand(Interval<E> other)
other
- - Other interval to include
public Interval intersect(Interval<E> other)
other
- interval with which to intersect
public boolean overlaps(Interval<E> other)
other
- interval to compare with
public boolean includesBegin()
public boolean includesEnd()
public boolean isIntervalComparable(Interval<E> other)
other
- interval to compare withpublic int compareIntervalOrder(Interval<E> other)
other
- Interval to compare with
protected int toRelFlags(int comp, int shift)
public int getRelationFlags(Interval<E> other)
other
- Interval with which to compare with
protected int addIntervalRelationFlags(int flags, boolean checkFuzzy)
public static int extractRelationSubflags(int flags, int shift)
public static boolean checkMultipleBitSet(int flags)
flags
- flags to check
public static boolean checkFlagSet(int flags, int flag)
flags
- flags to checkflag
- bit for flag of interest (is this flag set or not)
public static boolean checkFlagExclusiveSet(int flags, int flag, int mask)
flags
- flags to checkflag
- bit for flag of interest (is this flag set or not)mask
- bitmask of bits to check
public Interval.RelType getRelation(Interval<E> other)
other
- The other interval with which to compare with
public boolean equals(Object o)
equals
in class Pair<E extends Comparable<E>,E extends Comparable<E>>
public int hashCode()
hashCode
in class Pair<E extends Comparable<E>,E extends Comparable<E>>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |