public class JCoReFeaturePath extends Object implements org.apache.uima.cas.FeaturePath
FeatureValuePath which seems to be able to handle
arrays. However, it is marked deprecated and shouldn't be used any more. The
new interface to use is the FeaturePath interface. Problem is, it
seemingly can't handle arrays very well.
The current implementation is quite preliminary. It can only be used via
getValueAsString(FeatureStructure), i.e. even numeric types are
returned as strings. The workflow is as follows: ======= A simple
implementation of a feature path, originally adapted to the needs of the
EntityEvaluatorConverter. It is currently not supposed to serve as a full
UIMA FeaturePath replacement. However, it is thinkable that the
implementation will be extended in the future by whomever requires a feature
path more capable of what the original UIMA implementation can do.
UIMA discloses the FeatureValuePath which seems to be able to handle
arrays. However, it is marked deprecated and shouldn't be used any more. The
new interface to use is the FeaturePath interface. Problem is, it
seemingly can't handle arrays very well.
The current implementation is quite preliminary. It can only be used via
getValueAsString(FeatureStructure), i.e. even numeric types are
returned as strings. The workflow is as follows: >>>>>>>
7ad7536ab9d5d42fc932c6811c7ffbe15d509c29
JulesFeaturePath fp = new JulesFeaturePath();
fp.initialize("/resourceEntryList[0]/entryId");
String entryId = fp.getValueAsString(gene);
<<<<<<< HEAD This example retrieves the entry ID of the first
ResourceEntry of a Gene annotation.
Feature paths can be any sequence of feature base names in the form
/feature1/feature2/feature3. The last feature must be
primitive-valued. If any of the features is an array, the index must be
given, e.g. /feature1/feature2[2]/feature3. Otherwise, an array
index out of bounds (-1) exception will be thrown. ======= This example
retrieves the entry ID of the first ResourceEntry of a Gene
annotation.
Feature paths can be any sequence of feature base names in the form
/feature1/feature2/feature3. The last feature must be
primitive-valued. If any of the features is an array, the index must be
given, e.g. /feature1/feature2[2]/feature3. Otherwise, an array
index out of bounds (-1) exception will be thrown. >>>>>>>
7ad7536ab9d5d42fc932c6811c7ffbe15d509c29
| 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.replacementsFile - FileNotFoundExceptionIOExceptionpublic Object getDefaultReplacementValue()
public void setDefaultReplacementValue(Object defaultReplacementValue)
replaceUnmappedValues is set to
true. Defaults to null.defaultReplacementValue - public void clearReplacementCache()
Copyright © 2016 JULIE Lab Jena, Germany. All rights reserved.