public class UIMACODAUtilities extends Object
Modifier and Type | Field and Description |
---|---|
private static String |
COMPLETE_ANNOTATION |
private static String |
COVERED_TEXT |
private static org.slf4j.Logger |
logger |
Constructor and Description |
---|
UIMACODAUtilities() |
Modifier and Type | Method and Description |
---|---|
static List<Object> |
adaptArgumentList(Method m,
List<Object> argumentList) |
static <T> void |
appendValuesToMultiList(List<List<T>> multiList,
List<? extends T> values) |
private static boolean |
canBeAssignedFrom(Class<?> dest,
Class<?> source)
A generalization of
Class.isAssignableFrom(Class) taking into consideration specific promotion
opportunities for RDF4J Nodes and the compatibility of the null value with any reference
type. |
static boolean |
checkMethodSuitability(Method method,
String methodName,
List<Class<?>> argumentTypes)
Checks that a method signature is compatible with the given method name and argument types.
|
static List<Object> |
evaluateConverterArgumentExpression(ConverterArgumentExpression expr,
com.google.common.collect.Multimap<String,Object> placeholder2valueMap) |
private static List<Object> |
explodeSingleConverterArgument(ConverterArgumentExpression arg,
com.google.common.collect.Multimap<String,Object> placeholder2valueMap) |
private static List<org.apache.uima.cas.FeatureStructure> |
getAllElemFromList(org.apache.uima.jcas.cas.FSList fsList) |
private static List<Class<?>> |
getArgumentTypes(List<Object> valueList) |
private static org.apache.uima.cas.FeatureStructure |
getElemFromListAtPos(org.apache.uima.jcas.cas.FSList fsList,
int pos) |
static String |
getMemoizationMapIfAny(PlaceholderStruct ph) |
private static List<StringOrFeatureStruct> |
getPrimitiveValuesFromArray(org.apache.uima.cas.Feature feature,
org.apache.uima.cas.FeatureStructure featStruct) |
private static List<StringOrFeatureStruct> |
getPrimitiveValuesFromList(org.apache.uima.cas.Feature feature,
org.apache.uima.cas.FeatureStructure featStruct) |
static org.eclipse.rdf4j.model.Value |
getRDFValueFromUIMAValue(PlaceholderStruct placeholder,
ComponentProvider cp,
CODAContext ctx) |
static org.eclipse.rdf4j.model.Value |
getRDFValueFromUIMAValue(PlaceholderStruct placeholder,
StringOrFeatureStruct valueOfFeatStruct,
ComponentProvider cp,
CODAContext ctx) |
static List<org.eclipse.rdf4j.model.Value> |
getRDFValuesFromUIMAValue(boolean hasFeaturePath,
Object initialValue,
String rdfType,
String literalDatatype,
String literalLang,
List<ConverterMention> converterList,
ComponentProvider cp,
CODAContext ctx,
com.google.common.collect.Multimap<String,Object> placeholder2valueMap,
Map<String,Map<org.apache.commons.lang3.tuple.Pair<ProjectionOperator,Object>,org.eclipse.rdf4j.model.Value>> memoizedProjectionsMaps,
String memoizationMapName)
Computes a (possibly empty) collection of ART Nodes through the execution of a converter.
|
static List<org.eclipse.rdf4j.model.Value> |
getRDFValuesFromUIMAValue(PlaceholderStruct placeholder,
StringOrFeatureStruct valueOfFeatStruct,
ComponentProvider cp,
CODAContext ctx,
com.google.common.collect.Multimap<String,Object> placeholder2valueMap,
Map<String,Map<org.apache.commons.lang3.tuple.Pair<ProjectionOperator,Object>,org.eclipse.rdf4j.model.Value>> memoizedProjectionsMap) |
static List<String> |
getSuperTypes(Class<?> inputAnnotationClass) |
private static List<StringOrFeatureStruct> |
getValueOfFeature(org.apache.uima.cas.FeatureStructure featStruct,
String[] path,
int posFeatPath) |
private static List<StringOrFeatureStruct> |
getValueOfFeatureFromArray(org.apache.uima.cas.FeatureStructure featStruct,
int posFeatPath,
String[] path,
boolean posSpecified,
int posArray) |
static StringOrFeatureStruct |
getValueOfFeatureFromFeatPathOneValue(org.apache.uima.jcas.tcas.Annotation ann,
String uimaTypeAndFeat)
Get a value (normally the first if more than one is present) in a particular annotation following the
feature path represented by uimaTypeAndFeat
|
private static List<StringOrFeatureStruct> |
getValueOfFeatureFromList(org.apache.uima.cas.FeatureStructure featStruct,
int posFeatPath,
String[] path,
boolean posSpecified,
int posList) |
static List<StringOrFeatureStruct> |
getValuesOfFeatureFromFeatPath(org.apache.uima.jcas.tcas.Annotation ann,
String uimaTypeAndFeat)
Get a list of values in a particular annotation following the feature path represented by
uimaTypeAndFeat
|
private static Map<String,Object> |
homogenizeMap(Map<String,Object> aMap) |
private static boolean |
isPrimitiveArray(org.apache.uima.cas.Feature feature) |
private static boolean |
isPrimitiveList(org.apache.uima.cas.Feature feature) |
private static Optional<org.eclipse.rdf4j.model.IRI> |
overrideDefaultNS(PlaceholderStruct placeholder,
CODAContext ctx) |
private static Map<String,Object> |
promoteMap(Map<String,Object> aMap,
Class<?> target) |
static Method |
searchSuitableTarget(Class<?> clazz,
String methodName,
List<Class<?>> argumentTypes)
Returns a method of the provided class having a signature compatible with the given method name and
argument types (see
checkMethodSuitability(Method, String, List) ). |
private static Method |
searchSuitableTargetForMultiArgs(Class<? extends Object> clazz,
String methodName,
List<List<Class<?>>> argumentMultiTypes)
Returns a method of the provided class having a signature compatible with the given method name and
each provided combination of argument types (see
checkMethodSuitability(Method, String, List) . |
static boolean |
validateFeathPathInProjRuleModel(ProjectionRulesModel prModel,
org.apache.uima.jcas.JCas jcas) |
private static org.slf4j.Logger logger
private static final String COVERED_TEXT
private static final String COMPLETE_ANNOTATION
public static StringOrFeatureStruct getValueOfFeatureFromFeatPathOneValue(org.apache.uima.jcas.tcas.Annotation ann, String uimaTypeAndFeat)
ann
- the annotation where the value will be taken fromuimaTypeAndFeat
- the feature pathpublic static List<StringOrFeatureStruct> getValuesOfFeatureFromFeatPath(org.apache.uima.jcas.tcas.Annotation ann, String uimaTypeAndFeat)
ann
- the annotation where the value will be taken fromuimaTypeAndFeat
- the feature pathprivate static List<StringOrFeatureStruct> getValueOfFeature(org.apache.uima.cas.FeatureStructure featStruct, String[] path, int posFeatPath)
private static boolean isPrimitiveArray(org.apache.uima.cas.Feature feature)
private static List<StringOrFeatureStruct> getPrimitiveValuesFromArray(org.apache.uima.cas.Feature feature, org.apache.uima.cas.FeatureStructure featStruct)
private static boolean isPrimitiveList(org.apache.uima.cas.Feature feature)
private static List<StringOrFeatureStruct> getPrimitiveValuesFromList(org.apache.uima.cas.Feature feature, org.apache.uima.cas.FeatureStructure featStruct)
private static List<StringOrFeatureStruct> getValueOfFeatureFromList(org.apache.uima.cas.FeatureStructure featStruct, int posFeatPath, String[] path, boolean posSpecified, int posList)
private static org.apache.uima.cas.FeatureStructure getElemFromListAtPos(org.apache.uima.jcas.cas.FSList fsList, int pos)
private static List<org.apache.uima.cas.FeatureStructure> getAllElemFromList(org.apache.uima.jcas.cas.FSList fsList)
private static List<StringOrFeatureStruct> getValueOfFeatureFromArray(org.apache.uima.cas.FeatureStructure featStruct, int posFeatPath, String[] path, boolean posSpecified, int posArray)
public static org.eclipse.rdf4j.model.Value getRDFValueFromUIMAValue(PlaceholderStruct placeholder, ComponentProvider cp, CODAContext ctx) throws ComponentProvisioningException, ConverterException
public static org.eclipse.rdf4j.model.Value getRDFValueFromUIMAValue(PlaceholderStruct placeholder, StringOrFeatureStruct valueOfFeatStruct, ComponentProvider cp, CODAContext ctx) throws ComponentProvisioningException, ConverterException
private static Optional<org.eclipse.rdf4j.model.IRI> overrideDefaultNS(PlaceholderStruct placeholder, CODAContext ctx)
public static List<org.eclipse.rdf4j.model.Value> getRDFValuesFromUIMAValue(PlaceholderStruct placeholder, StringOrFeatureStruct valueOfFeatStruct, ComponentProvider cp, CODAContext ctx, com.google.common.collect.Multimap<String,Object> placeholder2valueMap, Map<String,Map<org.apache.commons.lang3.tuple.Pair<ProjectionOperator,Object>,org.eclipse.rdf4j.model.Value>> memoizedProjectionsMap) throws ComponentProvisioningException, ConverterException
public static String getMemoizationMapIfAny(PlaceholderStruct ph)
public static List<org.eclipse.rdf4j.model.Value> getRDFValuesFromUIMAValue(boolean hasFeaturePath, Object initialValue, String rdfType, String literalDatatype, String literalLang, List<ConverterMention> converterList, ComponentProvider cp, CODAContext ctx, com.google.common.collect.Multimap<String,Object> placeholder2valueMap, Map<String,Map<org.apache.commons.lang3.tuple.Pair<ProjectionOperator,Object>,org.eclipse.rdf4j.model.Value>> memoizedProjectionsMaps, String memoizationMapName) throws ComponentProvisioningException, ConverterException
initialValue
is passed to the converter regardless of whether it is null
.
Usually, the client should not invoke this method if the initial value is null
, unless the
target converter does not require an input argument (as in the case of a random identifier generator).
Conversely, if a converter has an additional argument containing a non initialize placeholder, this
Immediately stops the computation, which returns an empty list.hasFeaturePath
- indicates if the originating node is associated with a feature pathinitialValue
- the initial value (extracted from the feature path)rdfType
- the kind of node to produce (i.e. either "literal" or "uri")literalDatatype
- the datatype of a literal (may be null
)literalLang
- the language tag of a literal (may be null
)converterList
- the list of converter mentions to evaluatecp
- the provider of CODA componentsctx
- the context for the execution of the converterplaceholder2valueMap
- a structure containing the nodes associated to placeholdersmemoizedProjectionsMaps
- memoized projectionsmemoizationMapName
- optional name of a memoization map o enable memoizationComponentProvisioningException
ConverterException
public static <T> void appendValuesToMultiList(List<List<T>> multiList, List<? extends T> values)
public static List<Object> evaluateConverterArgumentExpression(ConverterArgumentExpression expr, com.google.common.collect.Multimap<String,Object> placeholder2valueMap) throws ConverterException
ConverterException
public static Method searchSuitableTarget(Class<?> clazz, String methodName, List<Class<?>> argumentTypes)
checkMethodSuitability(Method, String, List)
).clazz
- methodName
- argumentTypes
- null
if none existsprivate static Method searchSuitableTargetForMultiArgs(Class<? extends Object> clazz, String methodName, List<List<Class<?>>> argumentMultiTypes)
checkMethodSuitability(Method, String, List)
.clazz
- methodName
- argumentMultiTypes
- null
if none existspublic static boolean checkMethodSuitability(Method method, String methodName, List<Class<?>> argumentTypes)
null
, the corresponding item inside the list argumentTypes
is
also null
. The compatibility between a method parameter type and the corresponding
argument type depends on whether the former can be assigned from the latter (see:
canBeAssignedFrom(Class, Class)
)method
- methodName
- argumentTypes
- private static boolean canBeAssignedFrom(Class<?> dest, Class<?> source)
Class.isAssignableFrom(Class)
taking into consideration specific promotion
opportunities for RDF4J Nodes and the compatibility of the null
value with any reference
type. The parameter source
may be null
, to indicate the type of a
null
value.dest
- source
- public static List<Object> adaptArgumentList(Method m, List<Object> argumentList) throws ConverterException
ConverterException
private static List<Object> explodeSingleConverterArgument(ConverterArgumentExpression arg, com.google.common.collect.Multimap<String,Object> placeholder2valueMap) throws ConverterException
ConverterException
private static Map<String,Object> homogenizeMap(Map<String,Object> aMap) throws ConverterException
ConverterException
private static Map<String,Object> promoteMap(Map<String,Object> aMap, Class<?> target) throws ConverterException
ConverterException
public static boolean validateFeathPathInProjRuleModel(ProjectionRulesModel prModel, org.apache.uima.jcas.JCas jcas) throws UnassignableFeaturePathException
UnassignableFeaturePathException
Copyright © 2022 ART Group, University of Rome, Tor Vergata. All rights reserved.