Package org.apache.uima.analysis_engine

Examples of org.apache.uima.analysis_engine.TypeOrFeature


  /**
   * @see org.apache.uima.analysis_engine.metadata.Capability#addOutputType(java.lang.String,
   *      boolean)
   */
  public void addOutputType(String aTypeName, boolean aAllAnnotatorFeatures) {
    TypeOrFeature type = UIMAFramework.getResourceSpecifierFactory().createTypeOrFeature();
    type.setType(true);
    type.setName(aTypeName);
    type.setAllAnnotatorFeatures(aAllAnnotatorFeatures);

    TypeOrFeature[] oldArr = getOutputs();
    TypeOrFeature[] newArr = new TypeOrFeature[oldArr.length + 1];
    System.arraycopy(oldArr, 0, newArr, 0, oldArr.length);
    newArr[newArr.length - 1] = type;
View Full Code Here


  /**
   * @see org.apache.uima.analysis_engine.metadata.Capability#addOutputFeature(java.lang.String)
   */
  public void addOutputFeature(String aFeatureName) {
    TypeOrFeature feat = UIMAFramework.getResourceSpecifierFactory().createTypeOrFeature();
    feat.setType(false);
    feat.setName(aFeatureName);

    TypeOrFeature[] oldArr = getOutputs();
    TypeOrFeature[] newArr = new TypeOrFeature[oldArr.length + 1];
    System.arraycopy(oldArr, 0, newArr, 0, oldArr.length);
    newArr[newArr.length - 1] = feat;
View Full Code Here

            && typesOrFeatureNames[0].equals(TypeCapability.NO_DEFAULT_VALUE)) {
      return new TypeOrFeature[0];
    } else {
      List<TypeOrFeature> typesOrFeatures = new ArrayList<TypeOrFeature>();
      for (String name : typesOrFeatureNames) {
        TypeOrFeature tof = new TypeOrFeature_impl();
        tof.setName(name);
        if (name.indexOf(":") == -1) {
          tof.setType(true);
        } else {
          tof.setType(false);
        }
        typesOrFeatures.add(tof);
      }
      return typesOrFeatures.toArray(new TypeOrFeature[typesOrFeatures.size()]);
    }
View Full Code Here

      // get inputs/outputs for this entry
      TypeOrFeature[] entryInps = entry.getInputs();
      TypeOrFeature[] entryOuts = entry.getOutputs();
      // add/merge inputs in Hashtable
      for (int i = 0; i < entryInps.length; i++) {
        TypeOrFeature nextTof = entryInps[i];
        String name = nextTof.getName();
        TypeOrFeature prevTof = (TypeOrFeature) mergedInputs.get(name);
        if (prevTof != null) {
          // choose next or prev, if it's 'type'
          if (prevTof.isType()) {
            // leave more general one
            if (!prevTof.isAllAnnotatorFeatures() && nextTof.isAllAnnotatorFeatures())
              mergedInputs.put(name, nextTof);
          }
        } else
          // add next ToF
          mergedInputs.put(name, nextTof);
      }
      // add/merge outputs in Hashtable
      for (int i = 0; i < entryOuts.length; i++) {
        TypeOrFeature nextTof = entryOuts[i];
        String name = nextTof.getName();
        TypeOrFeature prevTof = (TypeOrFeature) mergedOutputs.get(name);
        if (prevTof != null) {
          // choose next or prev, if it's 'type'
          if (prevTof.isType()) {
            // leave more general one
            if (!prevTof.isAllAnnotatorFeatures() && nextTof.isAllAnnotatorFeatures())
              mergedOutputs.put(name, nextTof);
          }
        } else
          // add next ToF
          mergedOutputs.put(name, nextTof);
      }
    }
    // create merged Capability object and add merged inputs/outputs
    Capability mergedCapability = rsFactory.createCapability();
    // add merged inputs
    Enumeration inpsList = mergedInputs.keys();
    while (inpsList.hasMoreElements()) {
      String name = (String) inpsList.nextElement();
      TypeOrFeature tof = (TypeOrFeature) mergedInputs.get(name);
      if (tof.isType())
        mergedCapability.addInputType(name, tof.isAllAnnotatorFeatures());
      else
        mergedCapability.addInputFeature(name);
    }
    // add merged outputs
    Enumeration outsList = mergedOutputs.keys();
    while (outsList.hasMoreElements()) {
      String name = (String) outsList.nextElement();
      TypeOrFeature tof = (TypeOrFeature) mergedOutputs.get(name);
      if (tof.isType())
        mergedCapability.addOutputType(name, tof.isAllAnnotatorFeatures());
      else
        mergedCapability.addOutputFeature(name);
    }
    // put merged Capability in the array
    Capability[] mergedArray = new Capability[1];
View Full Code Here

      case TYPE: {
        AddCapabilityTypeDialog dialog = new AddCapabilityTypeDialog(this, c, editItem);
        if (dialog.open() == Window.CANCEL)
          return;

        TypeOrFeature typeInput = getTypeOrFeature(c.getInputs(), getFullyQualifiedName(editItem));

        if (dialog.inputs[0]) {
          if (null == typeInput) {
            c.addInputType(dialog.types[0], true);
            // add all-features
            getOrCreateAllFeatItem(editItem, INPUT_COL, INPUT);
          }
        } else if (null != typeInput) { // check for any input features done in dialog
          c.setInputs(typeOrFeatureArrayRemove(c.getInputs(), typeInput));
          removeAllFeatItemGui(editItem, INPUT_COL);
        }

        TypeOrFeature typeOutput = getTypeOrFeature(c.getOutputs(), getFullyQualifiedName(editItem));

        if (dialog.outputs[0]) {
          if (null == typeOutput) {
            c.addOutputType(dialog.types[0], true);
            getOrCreateAllFeatItem(editItem, OUTPUT_COL, OUTPUT);
View Full Code Here

  private void removeFeature(Capability c, TableTreeItem removeItem) {
    String shortFeatureName = removeItem.getText(NAME_COL);
    if (shortFeatureName.equals(ALL_FEATURES)) {
      if (isInput(removeItem)) {
        TypeOrFeature tfItem = getTypeOrFeature(c.getInputs(), getFullyQualifiedName(removeItem
                .getParentItem()));
        tfItem.setAllAnnotatorFeatures(false);
      }
      if (isOutput(removeItem) /* || isUpdate(removeItem) */) {
        TypeOrFeature tfItem = getTypeOrFeature(c.getOutputs(), getFullyQualifiedName(removeItem
                .getParentItem()));
        tfItem.setAllAnnotatorFeatures(false);
      }
    } else {
      String featureNameToRemove = getFullyQualifiedName(removeItem.getParentItem()) + ":"
              + removeItem.getText(NAME_COL);
      if (isInput(removeItem))
View Full Code Here

    finishAction();
  }

  private TypeOrFeature newFeature(String name) {
    TypeOrFeature result = new TypeOrFeature_impl();
    result.setType(false);
    result.setName(name);
    return result;
  }
View Full Code Here

   *          AllFeatures value
   */
  private TypeOrFeature[] setAllFeatures(TypeOrFeature[] items, String typeName,
          boolean isAllFeatures) {

    TypeOrFeature type = getTypeOrFeature(items, typeName);

    if (null != type) {
      type.setAllAnnotatorFeatures(isAllFeatures);
      return items;
    }

    // If get here, case = Type declared as Output(input) or not at all while all Features
    // declared as Input (output)
View Full Code Here

    setTypeSystem(aTypeSystem);
    compile();
  }
   
  private TypeOrFeature createTypeOrFeature(String name, boolean isType, boolean aAllAnnotatorFeatures) {
    TypeOrFeature r = new TypeOrFeature_impl();
    r.setType(isType);
    r.setName(name);
    if (isType) {
      r.setAllAnnotatorFeatures(aAllAnnotatorFeatures);
    }
    return r;
  }
View Full Code Here

  /**
   * @see org.apache.uima.resource.metadata.Capability#addInputType(java.lang.String,
   *      boolean)
   */
  public void addInputType(String aTypeName, boolean aAllAnnotatorFeatures) {
    TypeOrFeature type = UIMAFramework.getResourceSpecifierFactory().createTypeOrFeature();
    type.setType(true);
    type.setName(aTypeName);
    type.setAllAnnotatorFeatures(aAllAnnotatorFeatures);

    TypeOrFeature[] oldArr = getInputs();
    TypeOrFeature[] newArr = new TypeOrFeature[oldArr.length + 1];
    System.arraycopy(oldArr, 0, newArr, 0, oldArr.length);
    newArr[newArr.length - 1] = type;
View Full Code Here

TOP

Related Classes of org.apache.uima.analysis_engine.TypeOrFeature

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.