edu.stanford.nlp.ling.tokensregex
Class MatchedExpression

java.lang.Object
  extended by edu.stanford.nlp.ling.tokensregex.MatchedExpression
Direct Known Subclasses:
TimeExpression

public class MatchedExpression
extends java.lang.Object

Matched Expression represents a chunk of text that was matched from an original segment of text)

Author:
Angel Chang

Nested Class Summary
static class MatchedExpression.SingleAnnotationExtractor
          Function that takes a CoreMap, applies a extraction function to it, to get a value Also contains information on how to construct a final annotation.
 
Field Summary
protected  CoreMap annotation
           
protected  Interval<java.lang.Integer> charOffsets
          Character offsets (relative to original text)
protected  Interval<java.lang.Integer> chunkOffsets
          Chunk offsets (relative to chunking on top of original text)
static Function<CoreMap,Interval<java.lang.Integer>> COREMAP_TO_CHAR_OFFSETS_INTERVAL_FUNC
           
static Function<CoreMap,Interval<java.lang.Integer>> COREMAP_TO_TOKEN_OFFSETS_INTERVAL_FUNC
           
static java.util.Comparator<MatchedExpression> EXPR_LENGTH_COMPARATOR
           
static java.util.Comparator<MatchedExpression> EXPR_LENGTH_PRIORITY_COMPARATOR
           
static java.util.Comparator<MatchedExpression> EXPR_ORDER_COMPARATOR
           
static java.util.Comparator<MatchedExpression> EXPR_PRIORITY_COMPARATOR
           
static java.util.Comparator<MatchedExpression> EXPR_PRIORITY_LENGTH_COMPARATOR
           
static Function<MatchedExpression,Interval<java.lang.Integer>> EXPR_TO_TOKEN_OFFSETS_INTERVAL_FUNC
           
static java.util.Comparator<MatchedExpression> EXPR_TOKEN_OFFSET_COMPARATOR
           
static java.util.Comparator<MatchedExpression> EXPR_TOKEN_OFFSETS_NESTED_FIRST_COMPARATOR
           
protected  MatchedExpression.SingleAnnotationExtractor extractFunc
          Function indicating how to extract an value from annotation built from this expression
protected  java.lang.String text
          Text representing the matched expression
protected  Interval<java.lang.Integer> tokenOffsets
          Token offsets (relative to original text tokenization)
 Value value
           
 
Constructor Summary
MatchedExpression(Interval<java.lang.Integer> charOffsets, Interval<java.lang.Integer> tokenOffsets, MatchedExpression.SingleAnnotationExtractor extractFunc, double priority, double weight)
           
MatchedExpression(MatchedExpression me)
           
 
Method Summary
 boolean extractAnnotation(Env env, CoreMap sourceAnnotation)
           
 boolean extractAnnotation(Env env, java.util.List<? extends CoreMap> source)
           
protected  boolean extractAnnotation(java.util.List<? extends CoreMap> source, java.util.Map<java.lang.Class,CoreMapAttributeAggregator> chunkAggregators)
           
 CoreMap getAnnotation()
           
 Interval<java.lang.Integer> getCharOffsets()
           
 Interval<java.lang.Integer> getChunkOffsets()
           
 int getOrder()
           
 double getPriority()
           
 java.lang.String getText()
           
 Interval<java.lang.Integer> getTokenOffsets()
           
 Value getValue()
           
 boolean isIncludeNested()
           
static
<T extends MatchedExpression>
java.util.List<T>
removeNested(java.util.List<T> chunks)
           
static
<T extends MatchedExpression>
java.util.List<T>
removeNullValues(java.util.List<T> chunks)
           
static
<T extends MatchedExpression>
java.util.List<T>
removeOverlapping(java.util.List<T> chunks)
           
static java.util.List<? extends CoreMap> replaceMerged(java.util.List<? extends CoreMap> list, java.util.List<? extends MatchedExpression> matchedExprs)
           
static java.util.List<? extends CoreMap> replaceMergedUsingTokenOffsets(java.util.List<? extends CoreMap> list, java.util.List<? extends MatchedExpression> matchedExprs)
           
 void setIncludeNested(boolean includeNested)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

text

protected java.lang.String text
Text representing the matched expression


charOffsets

protected Interval<java.lang.Integer> charOffsets
Character offsets (relative to original text)


tokenOffsets

protected Interval<java.lang.Integer> tokenOffsets
Token offsets (relative to original text tokenization)


chunkOffsets

protected Interval<java.lang.Integer> chunkOffsets
Chunk offsets (relative to chunking on top of original text)


annotation

protected CoreMap annotation

extractFunc

protected MatchedExpression.SingleAnnotationExtractor extractFunc
Function indicating how to extract an value from annotation built from this expression


value

public Value value

COREMAP_TO_TOKEN_OFFSETS_INTERVAL_FUNC

public static final Function<CoreMap,Interval<java.lang.Integer>> COREMAP_TO_TOKEN_OFFSETS_INTERVAL_FUNC

COREMAP_TO_CHAR_OFFSETS_INTERVAL_FUNC

public static final Function<CoreMap,Interval<java.lang.Integer>> COREMAP_TO_CHAR_OFFSETS_INTERVAL_FUNC

EXPR_TO_TOKEN_OFFSETS_INTERVAL_FUNC

public static Function<MatchedExpression,Interval<java.lang.Integer>> EXPR_TO_TOKEN_OFFSETS_INTERVAL_FUNC

EXPR_PRIORITY_COMPARATOR

public static final java.util.Comparator<MatchedExpression> EXPR_PRIORITY_COMPARATOR

EXPR_ORDER_COMPARATOR

public static final java.util.Comparator<MatchedExpression> EXPR_ORDER_COMPARATOR

EXPR_LENGTH_COMPARATOR

public static final java.util.Comparator<MatchedExpression> EXPR_LENGTH_COMPARATOR

EXPR_TOKEN_OFFSET_COMPARATOR

public static final java.util.Comparator<MatchedExpression> EXPR_TOKEN_OFFSET_COMPARATOR

EXPR_TOKEN_OFFSETS_NESTED_FIRST_COMPARATOR

public static final java.util.Comparator<MatchedExpression> EXPR_TOKEN_OFFSETS_NESTED_FIRST_COMPARATOR

EXPR_PRIORITY_LENGTH_COMPARATOR

public static final java.util.Comparator<MatchedExpression> EXPR_PRIORITY_LENGTH_COMPARATOR

EXPR_LENGTH_PRIORITY_COMPARATOR

public static final java.util.Comparator<MatchedExpression> EXPR_LENGTH_PRIORITY_COMPARATOR
Constructor Detail

MatchedExpression

public MatchedExpression(MatchedExpression me)

MatchedExpression

public MatchedExpression(Interval<java.lang.Integer> charOffsets,
                         Interval<java.lang.Integer> tokenOffsets,
                         MatchedExpression.SingleAnnotationExtractor extractFunc,
                         double priority,
                         double weight)
Method Detail

extractAnnotation

public boolean extractAnnotation(Env env,
                                 CoreMap sourceAnnotation)

extractAnnotation

public boolean extractAnnotation(Env env,
                                 java.util.List<? extends CoreMap> source)

extractAnnotation

protected boolean extractAnnotation(java.util.List<? extends CoreMap> source,
                                    java.util.Map<java.lang.Class,CoreMapAttributeAggregator> chunkAggregators)

getCharOffsets

public Interval<java.lang.Integer> getCharOffsets()

getTokenOffsets

public Interval<java.lang.Integer> getTokenOffsets()

getChunkOffsets

public Interval<java.lang.Integer> getChunkOffsets()

getPriority

public double getPriority()

getOrder

public int getOrder()

isIncludeNested

public boolean isIncludeNested()

setIncludeNested

public void setIncludeNested(boolean includeNested)

getText

public java.lang.String getText()

getAnnotation

public CoreMap getAnnotation()

getValue

public Value getValue()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

replaceMerged

public static java.util.List<? extends CoreMap> replaceMerged(java.util.List<? extends CoreMap> list,
                                                              java.util.List<? extends MatchedExpression> matchedExprs)

replaceMergedUsingTokenOffsets

public static java.util.List<? extends CoreMap> replaceMergedUsingTokenOffsets(java.util.List<? extends CoreMap> list,
                                                                               java.util.List<? extends MatchedExpression> matchedExprs)

removeNullValues

public static <T extends MatchedExpression> java.util.List<T> removeNullValues(java.util.List<T> chunks)

removeNested

public static <T extends MatchedExpression> java.util.List<T> removeNested(java.util.List<T> chunks)

removeOverlapping

public static <T extends MatchedExpression> java.util.List<T> removeOverlapping(java.util.List<T> chunks)


Stanford NLP Group