public static boolean isCollectionType(Type type) { // TODO what about FSList ? return type.isArray(); }
/** * TODO: Are there any Feature Structures other than FSArray that link * annotations (e.g. FSList)? * * @param annotationType * @return */ public static boolean isFSArray(Type annotationType) { boolean isFSArray = false; if (annotationType.isArray()) { isFSArray = true; } return isFSArray; }
@Override public void typeChanged(Type newType) { selectedType = newType; if (newType.isArray()) { enableSizeEnter(labelAndText); } else { disableSizeEnter(); } parent.pack(true); } });
/** * @param feat * @return true if the range type of the given feature allows multiple * values */ public static boolean hasCollectionRange(Feature feat) { // TODO handle lists return feat.getRange().isArray(); }
/** * Instantiates a new array value. * * @param arrayFS the array FS * @param slot the slot */ public ArrayValue(FeatureStructure arrayFS, int slot) { if (!arrayFS.getType().isArray()) { throw new IllegalArgumentException("The arrayFS parameter must contain an array type FS!"); } this.arrayFS = arrayFS; this.slot = slot; }
public static List<FeatureStructure> toList(Feature targetFeat, FeatureStructure fs) { if (fs == null) { return null; } // TODO handle lists if (targetFeat.getRange().isArray()) { return new ArrayList<FeatureStructure>( FSCollectionFactory.create((ArrayFS) fs)); } else { throw new UnsupportedOperationException(); } }
@Override public List<Type> getDirectSubtypes(Type type) { if (type.isArray()) { return new ArrayList<Type>(); } IntVector sub = this.tree.get(((TypeImpl) type).getCode()); final int max = sub.size(); List<Type> list = new ArrayList<Type>(max); for (int i = 0; i < max; i++) { list.add(this.types.get(sub.get(i))); } return list; }
public static Type getCollectionElementType(Feature targetFeat) { // TODO handle lists if (targetFeat.getRange().isArray()) { return targetFeat.getRange().getComponentType(); } else { throw new UnsupportedOperationException(); } }
public static boolean isMultiValuedFeature(TypeSystem aTypeSystem, Feature feat) { if (feat == null) { return false; } return feat.getRange().isArray() || isListType(aTypeSystem, feat.getRange()); }
public void rehydrate(final JCas jCas, final Map<Long, BaleenAnnotation> annotations) { // We need to consider if the feature is an array and it this.value is an array. if (feature.getRange().isArray()) { rehydrateArray(jCas, annotations); } else { rehydrateSingle(annotations); } }
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()); }
private void assignAnnotationByTypeInWindow(FeatureStructure annotation, Feature feature, MatchContext context, Type type) { List<AnnotationFS> inWindow = this.getAnnotationsInWindow(context.getAnnotation(), type); if (feature.getRange().isArray()) { annotation.setFeatureValue(feature, UIMAUtils.toFSArray(this.getJCas(), inWindow)); } else { if (inWindow != null && !inWindow.isEmpty()) { AnnotationFS a = inWindow.get(0); annotation.setFeatureValue(feature, a); } else { annotation.setFeatureValue(feature, null); } } }
public static boolean isSlotFeature(Feature aFeature) { if (aFeature.getRange().isArray()) { Type elementType = aFeature.getRange().getComponentType(); return elementType.getFeatureByBaseName(FEAT_SLOT_TARGET) != null && elementType.getFeatureByBaseName(FEAT_SLOT_ROLE) != null; } return false; }
public static boolean isSlotFeature(Feature aFeature) { if (aFeature.getRange().isArray()) { Type elementType = aFeature.getRange().getComponentType(); return elementType.getFeatureByBaseName(FEAT_SLOT_TARGET) != null && elementType.getFeatureByBaseName(FEAT_SLOT_ROLE) != null; } return false; }
private static boolean isSlotFeature(TypeSystem aTypeSystem, Feature feat) { // This could be written more efficiently using a single conjunction. The reason this // has not been done is to facilitate debugging. boolean multiValued = feat.getRange().isArray() || aTypeSystem .subsumes(aTypeSystem.getType(CAS.TYPE_NAME_LIST_BASE), feat.getRange()); if (!multiValued) { return false; } boolean linkInheritsFromTop = CAS.TYPE_NAME_TOP .equals(aTypeSystem.getParent(feat.getRange().getComponentType()).getName()); boolean hasTargetFeature = feat.getRange().getComponentType() .getFeatureByBaseName(FEAT_SLOT_TARGET) != null; boolean hasRoleFeature = feat.getRange().getComponentType() .getFeatureByBaseName(FEAT_SLOT_ROLE) != null; return linkInheritsFromTop && hasTargetFeature && hasRoleFeature; }
private static boolean isSlotFeature(TypeSystem aTypeSystem, Feature feat) { // This could be written more efficiently using a single conjunction. The reason this // has not been done is to facilitate debugging. boolean multiValued = feat.getRange().isArray() || aTypeSystem .subsumes(aTypeSystem.getType(CAS.TYPE_NAME_LIST_BASE), feat.getRange()); if (!multiValued) { return false; } boolean linkInheritsFromTop = CAS.TYPE_NAME_TOP .equals(aTypeSystem.getParent(feat.getRange().getComponentType()).getName()); boolean hasTargetFeature = feat.getRange().getComponentType() .getFeatureByBaseName(FEAT_SLOT_TARGET) != null; boolean hasRoleFeature = feat.getRange().getComponentType() .getFeatureByBaseName(FEAT_SLOT_ROLE) != null; return linkInheritsFromTop && hasTargetFeature && hasRoleFeature; }
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)); } }
public static void setFeature(FeatureStructure aFS, String aFeature, String... aValue) { Feature feat = getMandatoryFeature(aFS, aFeature); if (feat.getRange().isPrimitive()) { requireSingleValue(feat, aValue); aFS.setStringValue(feat, aValue[0]); } else if (aValue == null) { aFS.setFeatureValue(feat, null); } else if (feat.getRange().isArray()) { aFS.setFeatureValue(feat, createStringArray(aFS.getCAS(), aValue)); } else { aFS.setFeatureValue(feat, createStringList(aFS.getCAS(), aValue)); } }
public static void setFeature(FeatureStructure aFS, String aFeature, FeatureStructure... aValue) { Feature feat = getMandatoryFeature(aFS, aFeature); if (feat.getRange().isArray()) { aFS.setFeatureValue(feat, createArrayFS(aFS.getCAS(), aValue)); } else if (aValue == null) { aFS.setFeatureValue(feat, null); } else if (isListType(aFS.getCAS().getTypeSystem(), feat.getRange())) { aFS.setFeatureValue(feat, createFSList(aFS.getCAS(), aValue)); } else { requireSingleValue(feat, aValue); aFS.setFeatureValue(feat, aValue[0]); } }