edu.washington.cs.knowitall.nlp.extraction
Class SpanExtraction

java.lang.Object
  extended by edu.washington.cs.knowitall.nlp.extraction.SpanExtraction
Direct Known Subclasses:
ChunkedBinaryExtraction

public class SpanExtraction
extends Object

This class represents an extraction from a single sentence that is made up of one or more fields, each of which corresponds to a span in the sentence.

For example, a binary subject-verb-object relationship can be represented as a SentenceSpanExtraction with three fields: one for the subject, one for the verb phrase, and one for the object. This class keeps a reference to the sentence the extraction originated from, and the ranges of each field. Each field is represented as a ChunkedExtraction.

A SpanExtraction object is also equipped with a set of properties, mapping a String key to a String value.

Author:
afader

Constructor Summary
SpanExtraction(ChunkedExtraction[] fields)
          Constructs a new extraction from the given ChunkedExtractions.
SpanExtraction(ChunkedExtraction[] fields, String[] fieldNames)
          Constructs a new extraction from the given ChunkedExtractions.
SpanExtraction(ChunkedSentence sent, List<edu.washington.cs.knowitall.commonlib.Range> fieldRanges)
          Constructs a new extraction from the given sentence, with fields defined by the given ranges.
SpanExtraction(ChunkedSentence sent, List<edu.washington.cs.knowitall.commonlib.Range> fieldRanges, List<String> fieldNames)
          Constructs a new extraction from the given sentence, with fields defined by the given ranges and names.
SpanExtraction(List<ChunkedExtraction> fields)
          Constructs a new extraction from the given ChunkedExtractions.
SpanExtraction(List<ChunkedExtraction> fields, List<String> fieldNames)
          Constructs a new extraction from the given ChunkedExtractions.
 
Method Summary
 boolean equals(Object obj)
           
 ChunkedExtraction getField(int i)
           
 ChunkedExtraction getField(String name)
           
 String getFieldName(int i)
           
 List<String> getFieldNames()
           
 edu.washington.cs.knowitall.commonlib.Range getFieldRange(int i)
           
 edu.washington.cs.knowitall.commonlib.Range getFieldRange(String name)
           
 List<edu.washington.cs.knowitall.commonlib.Range> getFieldRanges()
           
 List<ChunkedExtraction> getFields()
           
 int getNumFields()
           
 Map<String,String> getProperties()
           
 String getProperty(String name)
           
 Set<String> getPropertyNames()
           
 ChunkedSentence getSentence()
           
 boolean hasField(String name)
           
 int hashCode()
           
 boolean hasProperty(String name)
          Checks whether this extraction has the given property.
 void setProperties(Map<String,String> props)
          Sets the properties to the given map.
 void setProperty(String name, String value)
          Sets the given property
 List<String> toBIOLayer()
          Returns a B/I/O encoding of this extraction as a list of strings.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpanExtraction

public SpanExtraction(ChunkedSentence sent,
                      List<edu.washington.cs.knowitall.commonlib.Range> fieldRanges,
                      List<String> fieldNames)
Constructs a new extraction from the given sentence, with fields defined by the given ranges and names.

Parameters:
sent -
ranges -
fieldNames -

SpanExtraction

public SpanExtraction(ChunkedSentence sent,
                      List<edu.washington.cs.knowitall.commonlib.Range> fieldRanges)
Constructs a new extraction from the given sentence, with fields defined by the given ranges. Uses the default field names of field0, field1, field2, etc.

Parameters:
sent -
ranges -

SpanExtraction

public SpanExtraction(List<ChunkedExtraction> fields)
Constructs a new extraction from the given ChunkedExtractions. These must all come from the same sentence. Uses the default field names of field0, field1, field2, etc.

Parameters:
fields -

SpanExtraction

public SpanExtraction(ChunkedExtraction[] fields)
Constructs a new extraction from the given ChunkedExtractions. These must all come from the same sentence. Uses the default field names of field0, field1, field2, etc.

Parameters:
fields -

SpanExtraction

public SpanExtraction(List<ChunkedExtraction> fields,
                      List<String> fieldNames)
Constructs a new extraction from the given ChunkedExtractions. These must all come from the same sentence.

Parameters:
fields -
fieldNames -

SpanExtraction

public SpanExtraction(ChunkedExtraction[] fields,
                      String[] fieldNames)
Constructs a new extraction from the given ChunkedExtractions. These must all come from the same sentence.

Parameters:
fields -
fieldNames -
Method Detail

getNumFields

public int getNumFields()
Returns:
the number of fields in this extraction

getFieldNames

public List<String> getFieldNames()
Returns:
the field names of this extraction

hasField

public boolean hasField(String name)
Parameters:
name -
Returns:
true if this extraction has the given named field

getSentence

public ChunkedSentence getSentence()
Returns:
the sentence

getFieldRanges

public List<edu.washington.cs.knowitall.commonlib.Range> getFieldRanges()
Returns:
the ranges of each field

getFields

public List<ChunkedExtraction> getFields()
Returns:
the fields

getFieldRange

public edu.washington.cs.knowitall.commonlib.Range getFieldRange(int i)
Parameters:
i -
Returns:
the range of the ith field

getFieldRange

public edu.washington.cs.knowitall.commonlib.Range getFieldRange(String name)
Parameters:
name -
Returns:
the range of the field with the given name

getField

public ChunkedExtraction getField(String name)
Parameters:
name -
Returns:
the field with the given name

getField

public ChunkedExtraction getField(int i)
Parameters:
i -
Returns:
the ith field

getFieldName

public String getFieldName(int i)
Parameters:
i -
Returns:
the name of the ith field

getProperties

public Map<String,String> getProperties()
Returns:
the map of property names to property values

setProperty

public void setProperty(String name,
                        String value)
Sets the given property

Parameters:
name - the name of the property
value - the value

setProperties

public void setProperties(Map<String,String> props)
Sets the properties to the given map.

Parameters:
props -

hasProperty

public boolean hasProperty(String name)
Checks whether this extraction has the given property.

Parameters:
name -
Returns:
true if this extraction has the given property

getProperty

public String getProperty(String name)
Parameters:
name -
Returns:
the value of the given property

getPropertyNames

public Set<String> getPropertyNames()
Returns:
the names of any properties that have been set

toBIOLayer

public List<String> toBIOLayer()
Returns a B/I/O encoding of this extraction as a list of strings. The list has the same length as the underlying sentence. The tags used in the B/I/O encoding are in the form B-FieldName0, I-FieldName0, ... for each field name.

Returns:
the B/I/O encoding as a list of strings

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object


Copyright © 2010-2012 University of Washington CSE. All Rights Reserved.