public class JCoReFeaturePath extends Object implements org.apache.uima.cas.FeaturePath
FeaturePath interface and adds some capabilities to it.
Note that it also is currently missing some capabilities, most importantly it only does not implement
a range of interface methods. However, it is able to query arbitrary feature values through its
getValue(FeatureStructure, int) method, even if the methods to retrieve specific types of feature
values (integers, floats, bytes etc) are currently not implemented. The JCoReFeaturePath uses the the
same syntax as traditional UIMA feature paths but is also able to address specific indices in
multi-valued features. Suppose you have a Gene annotation and want to create feature paths to access
various information of the annotation. Then you could specify the following feature paths in the
constructor of a new JCoReFeaturePath:
/specificType: Returns the string value of the specificType feature/resourceEntryList: Returns the FSArray holding the ResourceEntry instances of the gene (a resource entry is a pointer into a database which is the 'resource')/resourceEntryList/entryId: Returns the entryId feature values of all ResourceEntry instances as an array/resourceEntryList[0]/entryId: Returns the entryId feature value of the first ResourceEntry instance/resourceEntryList[-1]/entryId: Returns the entryId feature value of the last ResourceEntry instancecoveredText(): Calls Annotation.getCoveredText on the annotation pointed to with the feature pathtypeName(): Calls Object.getClass().getName() on the annotation pointed to by the feature path./arguments[0]/:coveredText(): Returns the document text covered by the first Argument of the EventMention.annotation.getCoveredText() Feature Value Replacement| Constructor and Description |
|---|
JCoReFeaturePath() |
| Modifier and Type | Method and Description |
|---|---|
void |
addFeature(org.apache.uima.cas.Feature feat) |
void |
clearReplacementCache()
Important only if using value replacements.
|
protected Object |
getArrayElement(org.apache.uima.cas.CommonArrayFS sa,
Map<?,?> replacements,
Method getter,
Method setter,
int index) |
Boolean |
getBooleanValue(org.apache.uima.cas.FeatureStructure fs) |
Byte |
getByteValue(org.apache.uima.cas.FeatureStructure fs) |
Object |
getDefaultReplacementValue() |
Double |
getDoubleValue(org.apache.uima.cas.FeatureStructure fs) |
org.apache.uima.cas.Feature |
getFeature(int i) |
String |
getFeaturePath() |
protected Object |
getFeatureValueFromFeatureStructure(org.apache.uima.cas.FeatureStructure fs,
org.apache.uima.cas.Feature feature,
Map<?,?> replacements)
Returns the value of the feature feature of the feature
structure fs.
|
Float |
getFloatValue(org.apache.uima.cas.FeatureStructure fs) |
org.apache.uima.cas.FeatureStructure |
getFSValue(org.apache.uima.cas.FeatureStructure fs) |
Integer |
getIntValue(org.apache.uima.cas.FeatureStructure fs) |
Long |
getLongValue(org.apache.uima.cas.FeatureStructure fs) |
protected String |
getObjectValueAsString(Object objectValue)
Get a String representation for a single primitive value.
|
boolean |
getReplaceUnmappedValues()
Returns true if feature values not contained in the replacement
map are to be replaced by a default value.
|
Short |
getShortValue(org.apache.uima.cas.FeatureStructure fs) |
String |
getStringValue(org.apache.uima.cas.FeatureStructure fs) |
org.apache.uima.cas.TypeClass |
getTypClass(org.apache.uima.cas.FeatureStructure fs) |
org.apache.uima.cas.Type |
getType(org.apache.uima.cas.FeatureStructure fs) |
Object |
getValue(org.apache.uima.cas.FeatureStructure fs,
int startFeatureIndex)
Begins to traverse the feature path from position
startFeatureIndex and returns whatever values lie at the end of
the feature path.
|
String |
getValueAsString(org.apache.uima.cas.FeatureStructure fs) |
String |
getValueAsString(org.apache.uima.cas.FeatureStructure fs,
boolean doReplacements)
If using replacements, please note the comment at
clearReplacementCache(). |
String[] |
getValueAsStringArray(org.apache.uima.cas.FeatureStructure fs)
Returns the feature path values without performing value replacements.
|
String[] |
getValueAsStringArray(org.apache.uima.cas.FeatureStructure fs,
boolean doReplacements) |
List<String> |
getValueAsStringList(org.apache.uima.cas.FeatureStructure fs)
Returns the feature path values without performing value replacements.
|
List<String> |
getValueAsStringList(org.apache.uima.cas.FeatureStructure fs,
boolean doReplacements) |
void |
initialize(String featurePath) |
void |
initialize(String featurePath,
Map<?,?> replacements) |
String |
ll_getValueAsString(int fsRef,
org.apache.uima.cas.impl.LowLevelCAS llCas) |
void |
loadReplacementsFromFile(String replacementsFile)
Reads a replacement file with lines of the form
originalValue=replacementValue and immediately populates the
internal replacement table with those entries. |
static Map<String,String> |
readReplacementsFromFile(String replacementsFile)
Reads a replacement file with lines of the form
originalValue=replacementValue and returns the respective
map. |
static Map<String,String> |
readReplacementsFromInputStream(InputStream is)
Reads a replacement file with lines of the form
originalValue=replacementValue and returns the respective
map. |
Object |
replaceValue(org.apache.uima.cas.FeatureStructure fs)
When using this method, please note the comment at
clearReplacementCache(). |
void |
setDefaultReplacementValue(Object defaultReplacementValue)
Sets a default replacement value to be used when there is no replacement
for a feature value and
replaceUnmappedValues is set to
true. |
void |
setReplaceUnmappedValues(boolean replaceWithNullValues)
For the work with replacements, please note the comment of
clearReplacementCache(). |
int |
size() |
void |
typeInit(org.apache.uima.cas.Type featurePathType) |
public int size()
size in interface org.apache.uima.cas.FeaturePathpublic org.apache.uima.cas.Feature getFeature(int i)
getFeature in interface org.apache.uima.cas.FeaturePathpublic void addFeature(org.apache.uima.cas.Feature feat)
addFeature in interface org.apache.uima.cas.FeaturePathpublic void initialize(String featurePath) throws org.apache.uima.cas.CASException
initialize in interface org.apache.uima.cas.FeaturePathorg.apache.uima.cas.CASExceptionpublic void initialize(String featurePath, Map<?,?> replacements) throws org.apache.uima.cas.CASException
org.apache.uima.cas.CASExceptionpublic void typeInit(org.apache.uima.cas.Type featurePathType)
throws org.apache.uima.cas.CASException
typeInit in interface org.apache.uima.cas.FeaturePathorg.apache.uima.cas.CASExceptionpublic Object replaceValue(org.apache.uima.cas.FeatureStructure fs)
clearReplacementCache().fs - public Object getValue(org.apache.uima.cas.FeatureStructure fs, int startFeatureIndex)
fs - startFeatureIndex - protected Object getArrayElement(org.apache.uima.cas.CommonArrayFS sa, Map<?,?> replacements, Method getter, Method setter, int index) throws IllegalAccessException, InvocationTargetException
protected Object getFeatureValueFromFeatureStructure(org.apache.uima.cas.FeatureStructure fs, org.apache.uima.cas.Feature feature, Map<?,?> replacements)
fs - feature - replacements - public String[] getValueAsStringArray(org.apache.uima.cas.FeatureStructure fs, boolean doReplacements)
public String[] getValueAsStringArray(org.apache.uima.cas.FeatureStructure fs)
fs - public List<String> getValueAsStringList(org.apache.uima.cas.FeatureStructure fs, boolean doReplacements)
public List<String> getValueAsStringList(org.apache.uima.cas.FeatureStructure fs)
fs - protected String getObjectValueAsString(Object objectValue)
objectValue - public String getValueAsString(org.apache.uima.cas.FeatureStructure fs)
getValueAsString in interface org.apache.uima.cas.FeaturePathpublic String getValueAsString(org.apache.uima.cas.FeatureStructure fs, boolean doReplacements)
clearReplacementCache().fs - doReplacements - public void setReplaceUnmappedValues(boolean replaceWithNullValues)
clearReplacementCache().replaceWithNullValues - public boolean getReplaceUnmappedValues()
public String ll_getValueAsString(int fsRef, org.apache.uima.cas.impl.LowLevelCAS llCas)
ll_getValueAsString in interface org.apache.uima.cas.FeaturePathpublic org.apache.uima.cas.Type getType(org.apache.uima.cas.FeatureStructure fs)
getType in interface org.apache.uima.cas.FeaturePathpublic org.apache.uima.cas.TypeClass getTypClass(org.apache.uima.cas.FeatureStructure fs)
getTypClass in interface org.apache.uima.cas.FeaturePathpublic String getFeaturePath()
getFeaturePath in interface org.apache.uima.cas.FeaturePathpublic String getStringValue(org.apache.uima.cas.FeatureStructure fs)
getStringValue in interface org.apache.uima.cas.FeaturePathpublic Integer getIntValue(org.apache.uima.cas.FeatureStructure fs)
getIntValue in interface org.apache.uima.cas.FeaturePathpublic Boolean getBooleanValue(org.apache.uima.cas.FeatureStructure fs)
getBooleanValue in interface org.apache.uima.cas.FeaturePathpublic Byte getByteValue(org.apache.uima.cas.FeatureStructure fs)
getByteValue in interface org.apache.uima.cas.FeaturePathpublic Double getDoubleValue(org.apache.uima.cas.FeatureStructure fs)
getDoubleValue in interface org.apache.uima.cas.FeaturePathpublic Float getFloatValue(org.apache.uima.cas.FeatureStructure fs)
getFloatValue in interface org.apache.uima.cas.FeaturePathpublic Long getLongValue(org.apache.uima.cas.FeatureStructure fs)
getLongValue in interface org.apache.uima.cas.FeaturePathpublic Short getShortValue(org.apache.uima.cas.FeatureStructure fs)
getShortValue in interface org.apache.uima.cas.FeaturePathpublic org.apache.uima.cas.FeatureStructure getFSValue(org.apache.uima.cas.FeatureStructure fs)
getFSValue in interface org.apache.uima.cas.FeaturePathpublic void loadReplacementsFromFile(String replacementsFile) throws FileNotFoundException, IOException
originalValue=replacementValue and immediately populates the
internal replacement table with those entries.replacementsFile - FileNotFoundExceptionIOExceptionpublic static Map<String,String> readReplacementsFromFile(String replacementsFile) throws FileNotFoundException, IOException
originalValue=replacementValue and returns the respective
map.replacementsFile - FileNotFoundExceptionIOExceptionpublic static Map<String,String> readReplacementsFromInputStream(InputStream is) throws FileNotFoundException, IOException
originalValue=replacementValue and returns the respective
map.is - FileNotFoundExceptionIOExceptionpublic Object getDefaultReplacementValue()
public void setDefaultReplacementValue(Object defaultReplacementValue)
replaceUnmappedValues is set to
true. Defaults to null.defaultReplacementValue - public void clearReplacementCache()
Copyright © 2018 JULIE Lab Jena, Germany. All rights reserved.