本文整理匯總了Java中org.apache.uima.cas.Feature.getRange方法的典型用法代碼示例。如果您正苦於以下問題:Java Feature.getRange方法的具體用法?Java Feature.getRange怎麽用?Java Feature.getRange使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.uima.cas.Feature
的用法示例。
在下文中一共展示了Feature.getRange方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: detectRoleUimaType
import org.apache.uima.cas.Feature; //導入方法依賴的package包/類
private Type detectRoleUimaType(UimaBratMapping.Builder mpBuilder, Feature roleFeat,
String shortTypeNameHint) {
Type uRoleType;
if (shortTypeNameHint == null) {
if (hasCollectionRange(roleFeat)) {
uRoleType = getCollectionElementType(roleFeat);
} else {
uRoleType = roleFeat.getRange();
}
} else {
uRoleType = mpBuilder.getUimaTypeByShortName(shortTypeNameHint);
if (!ts.subsumes(roleFeat.getRange(), uRoleType)) {
throw new IllegalStateException(String.format(
"%s is not subtype of %s", uRoleType, roleFeat.getRange()));
}
}
return uRoleType;
}
示例2: getPrimitiveFeatureValue
import org.apache.uima.cas.Feature; //導入方法依賴的package包/類
/**
* see section 4.2.1 of the UIMA References documentation.
*
* @param view
* @param featureStructure
* @param feature
* @return The feature value.
*/
private static Object getPrimitiveFeatureValue(
JCas view,
FeatureStructure featureStructure,
Feature feature) throws CleartkExtractorException {
TypeSystem typeSystem = view.getTypeSystem();
Type type = feature.getRange();
if (type.equals(typeSystem.getType("uima.cas.Boolean")))
return featureStructure.getBooleanValue(feature);
else if (type.equals(typeSystem.getType("uima.cas.Double")))
return featureStructure.getDoubleValue(feature);
else if (type.equals(typeSystem.getType("uima.cas.Float")))
return featureStructure.getFloatValue(feature);
else if (type.equals(typeSystem.getType("uima.cas.Byte")))
return featureStructure.getByteValue(feature);
else if (type.equals(typeSystem.getType("uima.cas.Short")))
return featureStructure.getShortValue(feature);
else if (type.equals(typeSystem.getType("uima.cas.Integer")))
return featureStructure.getIntValue(feature);
else if (type.equals(typeSystem.getType("uima.cas.Long")))
return featureStructure.getLongValue(feature);
else if (type.equals(typeSystem.getType("uima.cas.String")))
return featureStructure.getStringValue(feature);
else
throw CleartkExtractorException.notPrimitive(feature);
}
示例3: getValueOfFeature
import org.apache.uima.cas.Feature; //導入方法依賴的package包/類
@Override
public UimaPrimitive getValueOfFeature(TypeSystem typeSystem, Feature feature, FeatureStructure featureStructure) throws NlpTabException {
FeatureStructure targetFS = featureStructure.getFeatureValue(feature);
UimaPrimitive uimaPrimitive;
if (targetFS != null) {
uimaPrimitive = getValueOfFS(typeSystem, targetFS);
} else {
Type range = feature.getRange();
String rangeShortName = range.getShortName();
uimaPrimitive = new UimaPrimitive(null, rangeShortName);
}
return uimaPrimitive;
}
示例4: notPrimitive
import org.apache.uima.cas.Feature; //導入方法依賴的package包/類
public static CleartkExtractorException notPrimitive(Feature feature) {
String key = KEY_PREFIX + "notPrimitive";
return new CleartkExtractorException(
DEFAULT_RESOURCE_BUNDLE,
key,
feature.getDomain(),
feature.getRange());
}
示例5: notPrimitiveArray
import org.apache.uima.cas.Feature; //導入方法依賴的package包/類
public static CleartkExtractorException notPrimitiveArray(Feature feature) {
String key = KEY_PREFIX + "notPrimitiveArray";
return new CleartkExtractorException(
DEFAULT_RESOURCE_BUNDLE,
key,
feature.getDomain(),
feature.getRange());
}
示例6: isValidPath
import org.apache.uima.cas.Feature; //導入方法依賴的package包/類
public static boolean isValidPath(Type type, String path, JCas view) {
String[] pathMembers = path.split("/");
Type pathMemberType = type; // will be set to type of last path member
// feature type
for (String pathMember : pathMembers) {
Feature feature = pathMemberType.getFeatureByBaseName(pathMember);
if (feature == null) {
return false;
}
pathMemberType = feature.getRange();
if (pathMemberType.isArray())
pathMemberType = pathMemberType.getComponentType();
}
return isValidType(pathMemberType, view.getTypeSystem());
}
示例7: getPrimitiveArrayFeatureValue
import org.apache.uima.cas.Feature; //導入方法依賴的package包/類
private static Object[] getPrimitiveArrayFeatureValue(
JCas view,
FeatureStructure featureStructure,
Feature feature) throws CleartkExtractorException {
TypeSystem typeSystem = view.getTypeSystem();
Type type = feature.getRange();
if (type.isArray()) {
Type componentType = type.getComponentType();
FeatureStructure featureValue = featureStructure.getFeatureValue(feature);
if (componentType.equals(typeSystem.getType("uima.cas.String"))) {
return ((StringArray) featureValue).toArray();
} else if (componentType.equals(typeSystem.getType("uima.cas.Boolean"))) {
return Arrays.asList(((BooleanArray) featureValue).toArray()).toArray();
} else if (componentType.equals(typeSystem.getType("uima.cas.Double"))) {
return Arrays.asList(((DoubleArray) featureValue).toArray()).toArray();
} else if (componentType.equals(typeSystem.getType("uima.cas.Float"))) {
return Arrays.asList(((FloatArray) featureValue).toArray()).toArray();
} else if (componentType.equals(typeSystem.getType("uima.cas.Byte"))) {
return Arrays.asList(((ByteArray) featureValue).toArray()).toArray();
} else if (componentType.equals(typeSystem.getType("uima.cas.Short"))) {
return Arrays.asList(((ShortArray) featureValue).toArray()).toArray();
} else if (componentType.equals(typeSystem.getType("uima.cas.Integer"))) {
return Arrays.asList(((IntegerArray) featureValue).toArray()).toArray();
} else if (componentType.equals(typeSystem.getType("uima.cas.Long"))) {
return Arrays.asList(((LongArray) featureValue).toArray()).toArray();
}
} else
throw CleartkExtractorException.notPrimitiveArray(feature);
return null;
}
示例8: onParse
import org.apache.uima.cas.Feature; //導入方法依賴的package包/類
@Override
protected <FST extends FeatureStructure> void onParse(Matcher regexMatcher,
CompositeMatcher.Builder<FST> builder) {
String featName = regexMatcher.group(1);
String subMatchersDesc = regexMatcher.group(2);
List<String> subMatcherStrings = newArrayList(
split(subMatchersDesc, SUBMATCHER_DELIMITER_CHARS));
Feature feature = getFeature(builder.getTargetType(), featName, true);
Type featRange = feature.getRange();
if (featRange.isPrimitive()) {
if (subMatcherStrings.equals(Arrays.asList("primitive"))) {
// handle primitive-ranged feature
builder.addPrimitiveFeatureMatcher(featName);
return;
}
throw new IllegalStateException(String.format(
"Illegal matcher description for primitive feature %s:\n%s",
feature, subMatcherStrings));
}
if (MatchingUtils.isCollectionType(featRange)) {
// handle array-or-collection-ranged feature
Boolean ignoreOrder = null;
if (subMatcherStrings.contains("unordered")) {
ignoreOrder = true;
subMatcherStrings.remove("unordered");
}
if (subMatcherStrings.contains("ordered")) {
ignoreOrder = false;
subMatcherStrings.remove("ordered");
}
Type componentType = MatchingUtils.getComponentType(featRange);
if (componentType.isPrimitive()) {
subMatcherStrings.remove("primitive");
if (!subMatcherStrings.isEmpty()) {
throw new IllegalStateException(
String.format(
"Illegal matcher description for primitive collection feature %s:\n%s",
feature, subMatcherStrings));
}
builder.addPrimitiveCollectionFeatureMatcher(featName, ignoreOrder);
} else {
CompositeMatcher.Builder<?> elemMatcherBuilder = parseSubMatcher(
subMatcherStrings, componentType);
builder.addFSCollectionFeatureMatcher(featName, elemMatcherBuilder,
ignoreOrder);
}
} else {
// handle non-primitive-ranged feature
CompositeMatcher.Builder<?> valueMatcherBuilder = parseSubMatcher(
subMatcherStrings, featRange);
builder.addFSFeatureMatcher(featName, valueMatcherBuilder);
}
}