Package org.apache.uima.analysis_engine

Examples of org.apache.uima.analysis_engine.TypeOrFeature


  }

  public void testAddCapabilitiesWithoutLanguage() throws Exception {
     try {
      
        TypeOrFeature t4 = new TypeOrFeature_impl();
        t4.setType(true);
        t4.setName("AnotherFakeType");
        t4.setAllAnnotatorFeatures(false);

        // capability 4 - using t4 but now language
        Capability cap4 = new Capability_impl();
        TypeOrFeature[] tofs4 = { t4 };
        cap4.setOutputs(tofs4);
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

      // 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

  }

  public void testAddCapabilitiesWithoutLanguage() throws Exception {
     try {
      
        TypeOrFeature t4 = new TypeOrFeature_impl();
        t4.setType(true);
        t4.setName("AnotherFakeType");
        t4.setAllAnnotatorFeatures(false);

        // capability 4 - using t4 but now language
        Capability cap4 = new Capability_impl();
        TypeOrFeature[] tofs4 = { t4 };
        cap4.setOutputs(tofs4);
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

   * @return
   */
  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

  /**
   * @see org.apache.uima.analysis_engine.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

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

    TypeOrFeature[] oldArr = getInputs();
    TypeOrFeature[] newArr = new TypeOrFeature[oldArr.length + 1];
    System.arraycopy(oldArr, 0, newArr, 0, oldArr.length);
    newArr[newArr.length - 1] = feat;
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.