private boolean checkType(Type t) { return t.isPrimitive(); }
public static boolean isPrimitiveFeature(Feature aFeature) { return aFeature.getRange().isPrimitive(); } }
public static boolean isPrimitiveFeature(Feature aFeature) { return aFeature.getRange().isPrimitive(); } }
private boolean isSpanLayer(TypeSystem aTS, Type aType) { // A UIMA type can be a span layer if... // ... there are only primitive features or slot features List<Feature> nonPrimitiveFeatures = aType.getFeatures().stream() .filter(f -> !isBuiltInFeature(f)) .filter(f -> !(f.getRange().isPrimitive() || isSlotFeature(aTS, f))) .collect(Collectors.toList()); return nonPrimitiveFeatures.isEmpty(); }
private boolean isSpanLayer(TypeSystem aTS, Type aType) { // A UIMA type can be a span layer if... // ... there are only primitive features or slot features List<Feature> nonPrimitiveFeatures = aType.getFeatures().stream() .filter(f -> !isBuiltInFeature(f)) .filter(f -> !(f.getRange().isPrimitive() || isSlotFeature(aTS, f))) .collect(Collectors.toList()); return nonPrimitiveFeatures.isEmpty(); }
public FSCollectionFeatureMatcher(Feature feature, Matcher<E> elemMatcher, boolean ignoreOrder) { super(feature, elemMatcher, ignoreOrder); Type elemType = getComponentType(feature.getRange()); if (elemType.isPrimitive()) { throw new IllegalArgumentException(String.format( "Feature '%s' (of type '%s') range is array of primitives", feature, feature.getDomain())); } }
public PrimitiveFeatureMatcher(Feature feature) { this.feature = feature; if (!feature.getRange().isPrimitive()) { throw new IllegalArgumentException(String.format( "Feature %s.%s is not primitive", feature.getDomain(), feature)); } // TODO if (feature.getRange().getName().equals("uima.cas.Float") || feature.getRange().getName().equals("uima.cas.Double")) { throw new UnsupportedOperationException( "Floating point types matching is not implemented yet"); } }
public static void collect(Set<FeatureStructure> aFSes, FeatureStructure aFS) { if (aFS != null && !aFSes.contains(aFS)) { aFSes.add(aFS); for (Feature f : aFS.getType().getFeatures()) { if (!f.getRange().isPrimitive() && !CAS.FEATURE_BASE_NAME_SOFA.equals(f.getShortName())) { collect(aFSes, aFS.getFeatureValue(f)); } } } }
/** * Gets the value. * * @return the value */ public Object getValue() { if (mFeature.getRange().isPrimitive()) { return Primitives.getPrimitive(mStructure, mFeature); } return mStructure.getFeatureValue(mFeature); }
public static void collect(Set<FeatureStructure> aFSes, FeatureStructure aFS) { if (aFS != null && !aFSes.contains(aFS)) { aFSes.add(aFS); for (Feature f : aFS.getType().getFeatures()) { if (!f.getRange().isPrimitive() && !CAS.FEATURE_BASE_NAME_SOFA.equals(f.getShortName())) { collect(aFSes, aFS.getFeatureValue(f)); } } } }
public static void collect(Set<FeatureStructure> aFSes, FeatureStructure aFS) { if (aFS != null && !aFSes.contains(aFS)) { aFSes.add(aFS); for (Feature f : aFS.getType().getFeatures()) { if (!f.getRange().isPrimitive() && !CAS.FEATURE_BASE_NAME_SOFA.equals(f.getShortName())) { collect(aFSes, aFS.getFeatureValue(f)); } } } }
public static boolean isReferenceFeature(Type type, String featureName) { return isFSArray(type) || !type.getFeatureByBaseName(featureName).getRange().isPrimitive(); }
public static void setFeature(FeatureStructure aFS, String aFeature, short... aValue) { Feature feat = getMandatoryFeature(aFS, aFeature); if (feat.getRange().isPrimitive()) { requireSingleValue(feat, aValue); aFS.setShortValue(feat, aValue[0]); } else if (aValue == null) { aFS.setFeatureValue(feat, null); } else { aFS.setFeatureValue(feat, createShortArray(aFS.getCAS(), aValue)); } }
public static void setFeature(FeatureStructure aFS, String aFeature, double... aValue) { Feature feat = getMandatoryFeature(aFS, aFeature); if (feat.getRange().isPrimitive()) { requireSingleValue(feat, aValue); aFS.setDoubleValue(feat, aValue[0]); } else if (aValue == null) { aFS.setFeatureValue(feat, null); } else { aFS.setFeatureValue(feat, createDoubleArray(aFS.getCAS(), aValue)); } }
public static void setFeature(FeatureStructure aFS, String aFeature, byte... aValue) { Feature feat = getMandatoryFeature(aFS, aFeature); if (feat.getRange().isPrimitive()) { requireSingleValue(feat, aValue); aFS.setByteValue(feat, aValue[0]); } else if (aValue == null) { aFS.setFeatureValue(feat, null); } else { aFS.setFeatureValue(feat, createByteArray(aFS.getCAS(), aValue)); } }
public static void setFeature(FeatureStructure aFS, String aFeature, boolean... aValue) { Feature feat = getMandatoryFeature(aFS, aFeature); if (feat.getRange().isPrimitive()) { requireSingleValue(feat, aValue); aFS.setBooleanValue(feat, aValue[0]); } else if (aValue == null) { aFS.setFeatureValue(feat, null); } else { aFS.setFeatureValue(feat, createBooleanArray(aFS.getCAS(), aValue)); } }
public static void setFeature(FeatureStructure aFS, String aFeature, long... aValue) { Feature feat = getMandatoryFeature(aFS, aFeature); if (feat.getRange().isPrimitive()) { requireSingleValue(feat, aValue); aFS.setLongValue(feat, aValue[0]); } else if (aValue == null) { aFS.setFeatureValue(feat, null); } else { aFS.setFeatureValue(feat, createLongArray(aFS.getCAS(), aValue)); } }
default <V> V getFeatureValue(AnnotationFeature aFeature, FeatureStructure aFS) { Object value; Feature f = aFS.getType().getFeatureByBaseName(aFeature.getName()); if (f.getRange().isPrimitive()) { value = FSUtil.getFeature(aFS, aFeature.getName(), Object.class); } else if (FSUtil.isMultiValuedFeature(aFS, f)) { value = FSUtil.getFeature(aFS, aFeature.getName(), List.class); } else { value = FSUtil.getFeature(aFS, aFeature.getName(), FeatureStructure.class); } return (V) wrapFeatureValue(aFeature, aFS.getCAS(), value); }
public static void setFeature(FeatureStructure aFS, String aFeature, float... aValue) { Feature feat = getMandatoryFeature(aFS, aFeature); if (feat.getRange().isPrimitive()) { requireSingleValue(feat, aValue); aFS.setFloatValue(feat, aValue[0]); } else if (aValue == null) { aFS.setFeatureValue(feat, null); } else if (feat.getRange().isArray()) { aFS.setFeatureValue(feat, createFloatArray(aFS.getCAS(), aValue)); } else { aFS.setFeatureValue(feat, createFloatList(aFS.getCAS(), aValue)); } }
public static void setFeature(FeatureStructure aFS, String aFeature, int... aValue) { Feature feat = getMandatoryFeature(aFS, aFeature); if (feat.getRange().isPrimitive()) { requireSingleValue(feat, aValue); aFS.setIntValue(feat, aValue[0]); } else if (aValue == null) { aFS.setFeatureValue(feat, null); } else if (feat.getRange().isArray()) { aFS.setFeatureValue(feat, createIntArray(aFS.getCAS(), aValue)); } else { aFS.setFeatureValue(feat, createIntegerList(aFS.getCAS(), aValue)); } }