Minor changes for the interface....
the return values are now objects so that for a valid featurePath that
is not set "null" can be returned. In the old version this case must be
handled with an exception.
public interface FeaturePath {
public void initialize(String featurePath) throws
ResourceInitializationException;
public void typeSystemInit(Type featurePathType) throws
ResourceProcessException;
public String getValueAsString(FeatureStructure fs);
public Type getType(FeatureStructure fs);
public TypeClass getTypClass(FeatureStructure fs);
public String getFeaturePath();
public String getStringValue(FeatureStructure fs);
public Integer getIntValue(FeatureStructure fs);
public Boolean getBooleanValue(FeatureStructure fs);
public Byte getByteValue(FeatureStructure fs);
public Double getDoubleValue(FeatureStructure fs);
public Float getFloatValue(FeatureStructure fs);
public Long getLongValue(FeatureStructure fs);
public Short getShortValue(FeatureStructure fs);
public FeatureStructure getFSValue(FeatureStructure fs);
}
-- Michael
Michael Baessler wrote:
Hi,
In several UIMA components (e.g. RegexAnnotator, DictionaryAnnotator,
SimpleServer,...) and applications I had to implement some feature
path functionality.
Most of the time it was the access to the value of the specified
feature path. Since it is now implemented in several places I would
like to add this functionality to the uima-core
project as helper class that can be used anywhere.
I know that we already have FeaturePath implementation in the core but
I think this is not very intuitive and does not match most use cases.
My suggestion for the FeaturePath interface is shown below:
public interface FeaturePath {
public void initialize(String featurePath);
public void typeSystemInit(Type featurePathType);
public String getValueAsString(FeatureStructure fs);
public Type getType(FeatureStructure fs);
public TypeCode getTyp(FeatureStructure fs);
public String getFeaturePath();
public String getStringValue(FeatureStructure fs);
public int getIntValue(FeatureStructure fs);
public boolean getBooleanValue(FeatureStructure fs);
public byte getByteValue(FeatureStructure fs);
public double getDoubleValue(FeatureStructure fs);
public float getFloatValue(FeatureStructure fs);
public long getLongValue(FeatureStructure fs);
public short getShortValue(FeatureStructure fs);
public String getFSValue();
}
Some more details about some of the methods:
initialize(): The user initialize the feature path object with
"/my/feature/path" where "my", "feature" and "path" are the path
elements. The elements get parsed.
typeSystemInit(): The type for which the feature path should be
evaluated is specified here. The method will also check if the
specified feature path can be valid.
getValueAsString(): Returns the value of the feature path as String
representation.
All other method signatures are aligned with the FeatureStructure
getters() and will also have the same behavior. They will throw a
CASRuntimeException if the feature path
cannot be evaluated on the given FeatureStructure.
In addition to the getters we can also provide setters to set a
feature path value like for example
public int setIntValue(FeatureStructure fs, int intValue);
I would like to add the interface to the org.apache.uima.cas package
and the implementation to org.apache.uima.cas.impl.
In addition to the basic feature path values I would like to allow
some built in functions like:
/my/feature/path:coveredText()
/my/feature/path:Id()
These are evaluated if and only if getValueAsString(FeatureStructure
fs) is called.
What do others think?
-- Michael