org.apache.uima.resource.metadata.Capability Java Examples

The following examples show how to use org.apache.uima.resource.metadata.Capability. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CapabilitySection.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Handle add capability.
 */
private void handleAddCapability() {
  Capability newCset = addCapabilitySet();

  // update the GUI
  TreeItem item = new TreeItem(tt, SWT.NONE);
  item.setText(CAPABILITY_SET);
  item.setData(newCset);
  createLanguageHeaderGui(item);
  createSofaHeaderGui(item);

  item.setExpanded(true);
  tt.setSelection( item );
  if (tt.getItemCount() == 1)
    tt.getColumn(TITLE_COL).pack();
  finishAction();
}
 
Example #2
Source File: AddCapabilityFeatureDialog.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Instantiates a new adds the capability feature dialog.
 *
 * @param aSection the a section
 * @param aSelectedType the a selected type
 * @param c the c
 */
public AddCapabilityFeatureDialog(AbstractSection aSection, Type aSelectedType, Capability c) {
  super(
          aSection,
          "Specify features input and / or output",
          "Designate by mouse clicking one or more features in the Input and/or Output column, to designate as Input and/or Output press \"OK\"");
  selectedType = aSelectedType;
  allFeatures = selectedType.getFeatures().toArray(featureArray0);
  Arrays.sort(allFeatures);

  capability = c;
  TypeOrFeature[] localInputs = c.getInputs();
  String typeName = selectedType.getName();
  if (null != localInputs) {
    for (int i = 0; i < localInputs.length; i++) {
      if (localInputs[i].isType() && typeName.equals(localInputs[i].getName())) {
        inputNotAllowed = false;
        break;
      }
    }
  }
}
 
Example #3
Source File: SearchThread.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Match capabilities to.
 *
 * @param capabilities the capabilities
 * @param search the search
 * @param isInput the is input
 * @return true, if successful
 */
private boolean matchCapabilitiesTo(Capability[] capabilities, Pattern search, boolean isInput) {
  if (null == search)
    return true;
  for (int i = 0; i < capabilities.length; i++) {
    TypeOrFeature[] typeOrFeatures = isInput ? capabilities[i].getInputs() : capabilities[i]
            .getOutputs();
    if (null != typeOrFeatures) {
      for (int j = 0; j < typeOrFeatures.length; j++) {
        if (search.matcher(typeOrFeatures[j].getName()).find()) {
          return true;
        }
      }
    }
  }
  return false;
}
 
Example #4
Source File: SearchThread.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Delegate component matches capability reqs.
 *
 * @param rs the rs
 * @param inputTypeSearch the input type search
 * @param outputTypeSearch the output type search
 * @return true, if successful
 */
private boolean delegateComponentMatchesCapabilityReqs(ResourceCreationSpecifier rs,
        Pattern inputTypeSearch, Pattern outputTypeSearch) {

  if (inputTypeSearch == null && outputTypeSearch == null) {
    return true;
  }

  Capability[] capabilities = AbstractSection.getCapabilities(rs);
  if (capabilities == null || capabilities.length == 0) {
    return false;
  }

  boolean inputSatisfied = matchCapabilitiesTo(capabilities, inputTypeSearch, INPUT);
  boolean outputSatisfied = matchCapabilitiesTo(capabilities, outputTypeSearch, OUTPUT);
  return inputSatisfied && outputSatisfied;
}
 
Example #5
Source File: AbstractSection.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Adds the capability set.
 *
 * @return the capability
 */
protected Capability addCapabilitySet() {
  Capability newCset = UIMAFramework.getResourceSpecifierFactory().createCapability();
  // update the model
  AnalysisEngineMetaData md = getAnalysisEngineMetaData();
  Capability[] c = getCapabilities();
  if (c == null)
    md.setCapabilities(new Capability[] { newCset });
  else {
    Capability[] newC = new Capability[c.length + 1];
    System.arraycopy(c, 0, newC, 0, c.length);
    newC[c.length] = newCset;
    md.setCapabilities(newC);
  }
  return newCset;
}
 
Example #6
Source File: AnalysisSequenceCapabilityNode.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
   * Creates a new AnalysisSequenceCapabilityNode from an AnalysisEngine reference
   * 
   * @param aKey
   *          key for AnalysisEngine to be executed at this point in sequence
   * @param aCasProcessor
   *          reference to the AnalysisEngine instance
   * @param aResultSpec
   *          result specification to be passed to this AnalysisEngine
   */
  public AnalysisSequenceCapabilityNode(String aKey, CasObjectProcessor aCasProcessor,
          ResultSpecification aResultSpec) {
    mCasProcessorKey = aKey;
    mCasProcessor = aCasProcessor;
    mResultSpec = aResultSpec;
    mCapabilityContainer = null;

    // check if analysis engine is available
    if (mCasProcessor != null) {
      // get capabilities of the current analysis engine
      Capability[] capabilities = mCasProcessor.getProcessingResourceMetaData().getCapabilities();

      // create capability container and compile only output capabilities
//      mCapabilityContainer = new CapabilityContainer(capabilities, false, true);
      mCapabilityContainer = new ResultSpecification_impl();
      mCapabilityContainer.addCapabilities(capabilities);
    }
  }
 
Example #7
Source File: TypeCapabilityTest.java    From uima-uimafit with Apache License 2.0 6 votes vote down vote up
@Test
public void testTC() throws ResourceInitializationException {
  AnalysisEngineDescription aed = AnalysisEngineFactory.createEngineDescription(
          Annotator4.class, typeSystemDescription);
  Capability[] capabilities = aed.getAnalysisEngineMetaData().getCapabilities();
  assertEquals(1, capabilities.length);
  Capability capability = capabilities[0];
  TypeOrFeature[] inputs = capability.getInputs();
  assertEquals(1, inputs.length);
  assertEquals("org.apache.uima.fit.type.Token", inputs[0].getName());
  assertTrue(inputs[0].isType());

  TypeOrFeature[] outputs = capability.getOutputs();
  assertEquals(1, outputs.length);
  assertEquals("org.apache.uima.fit.type.Token:pos", outputs[0].getName());
  assertFalse(outputs[0].isType());

}
 
Example #8
Source File: CapabilityLanguageFlowController.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
public static FlowControllerDescription getDescription() {
  FlowControllerDescription desc = getResourceSpecifierFactory().createFlowControllerDescription();
  
  desc.setImplementationName(CapabilityLanguageFlowController.class.getName());
  
  ProcessingResourceMetaData metaData = desc.getFlowControllerMetaData();
  metaData.setName("Capability Language Flow Controller");
  metaData.setDescription("Simple FlowController that uses a linear fow but may skip\n" + 
      "\t\tsome of the AEs in the flow if they do not handle the language\n" + 
      "\t\tof the current document or if their outputs have already been\n" + 
      "\t\tproduced by a previous AE in the flow.");
  metaData.setVendor("The Apache Software Foundation");
  metaData.setVersion("1.0");
  
  Capability capability = getResourceSpecifierFactory().createCapability();
  metaData.setCapabilities(new Capability[] { capability });
      
  return desc;
}
 
Example #9
Source File: AnalysisEngineUtils.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a FSMatchConstraint used when formatting the CAS for output. This constraint filters
 * the feature structures in the CAS so that the only feature structures that are outputted are
 * those of types specified in the Analysis Engine's capability specification.
 * 
 * @param aMetaData
 *          metadata for the text analysis engine that is producing the results to be filtered
 * 
 * @return the filter to be passed to {@link TCasFormatter#format(CAS,FSMatchConstraint)}.
 */
public static FSMatchConstraint createOutputFilter(AnalysisEngineMetaData aMetaData) {
  // get a list of the AE's output type names
  Set<String> outputTypes = new TreeSet<>();
  // outputTypes.add("Document"); //always output the document
  Capability[] capabilities = aMetaData.getCapabilities();
  for (int i = 0; i < capabilities.length; i++) {
    TypeOrFeature[] outputs = capabilities[i].getOutputs();
    for (int j = 0; j < outputs.length; j++) {
      if (outputs[j].isType()) {
        outputTypes.add(outputs[j].getName());
      }
    }
  }

  FSTypeConstraint constraint = ConstraintFactory.instance().createTypeConstraint();

  for (String typeName  : outputTypes) {
    // add type to constraint
    constraint.add(typeName);
  }
  return constraint;
}
 
Example #10
Source File: TypeSection.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Capability visit.
 *
 * @param v the v
 * @return true, if successful
 */
private boolean capabilityVisit(CapabilityVisitor v) {
  Capability[] c = getCapabilities();
  for (int ic = 0; ic < c.length; ic++) {
    TypeOrFeature[] inputs = c[ic].getInputs();

    for (int i = 0; i < inputs.length; i++) {
      if (v.visit(inputs[i]))
        return true;
    }

    TypeOrFeature[] outputs = c[ic].getOutputs();

    for (int i = 0; i < outputs.length; i++) {
      if (v.visit(outputs[i]))
        return true;
    }
  }
  return false;
}
 
Example #11
Source File: CapabilitySection.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Dialog for language.
 *
 * @param c the c
 * @param dialog the dialog
 * @return the int
 */
private int dialogForLanguage(Capability c, CommonInputDialog dialog) {
  for (;;) {
    if (dialog.open() == Window.CANCEL)
      return Window.CANCEL;

    String[] languages = c.getLanguagesSupported();
    boolean alreadySpecified = false;
    for (int i = 0; i < languages.length; i++) {
      if (languages[i].equals(dialog.getValue())) {
        Utility
                .popMessage(
                        "Language spec already defined",
                        "The language specification you entered is already specified.\nPlease enter a different specification, or Cancel this operation."
                                + "\n\nLanguage: " + dialog.getValue(), MessageDialog.ERROR);
        alreadySpecified = true;
        break;
      }
    }
    if (!alreadySpecified)
      break;
  }
  return Window.OK;
}
 
Example #12
Source File: CapabilitySection.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Handle add edit feature.
 *
 * @param selItem the sel item
 * @param itemKind the item kind
 */
private void handleAddEditFeature(TreeItem selItem, int itemKind) {
  if (itemKind == FEAT)
    selItem = selItem.getParentItem();

  Capability c = getCapabilityFromTreeItem(selItem.getParentItem());
  String typeName = getFullyQualifiedName(selItem);

  // using the CAS to get all the inherited features
  Type type = editor.getCurrentView().getTypeSystem().getType(typeName);

  AddCapabilityFeatureDialog dialog = new AddCapabilityFeatureDialog(this, type, c);
  if (dialog.open() == Window.CANCEL)
    return;

  addOrEditFeature(dialog, typeName, selItem, c);
}
 
Example #13
Source File: AnalysisEngineDescription_impl.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
private boolean declaresSofa(AnalysisEngineDescription aDesc, String aSofaName) {
  Capability[] caps = aDesc.getAnalysisEngineMetaData().getCapabilities();
  for (int i = 0; i < caps.length; i++) {
    String[] sofas = caps[i].getOutputSofas();
    for (int j = 0; j < sofas.length; j++) {
      if (aSofaName.equals(sofas[j])) {
        return true;
      }
    }
    sofas = caps[i].getInputSofas();
    for (int j = 0; j < sofas.length; j++) {
      if (aSofaName.equals(sofas[j])) {
        return true;
      }
    }
  }
  return false;
}
 
Example #14
Source File: ResultSpecification_impl.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * @see org.apache.uima.analysis_engine.ResultSpecification#addCapabilities(org.apache.uima.resource.metadata.Capability[],
 *      boolean)
 */
public void addCapabilities(Capability[] capabilities, boolean outputs) {
  if (null == capabilities) {
    return;
  }
  for (Capability capability : capabilities) {
    TypeOrFeature[] tofs = outputs ? capability.getOutputs() : capability.getInputs();
    
    for (TypeOrFeature tof : tofs) {
      String typeName = tof.getName();
      if (!tof.isType()) {
        int i = typeName.indexOf(TypeSystem.FEATURE_SEPARATOR);
        String shortFeatName = typeName.substring(i+1);
        typeName = typeName.substring(0, i);
        rsTypesMap.add(typeName, shortFeatName, capability.getLanguagesSupported(), false);
      } else {
        rsTypesMap.add(typeName, tof.isAllAnnotatorFeatures(), capability.getLanguagesSupported(), false);
      }
    }
  }
  setCompileNeeded();
}
 
Example #15
Source File: AnalysisEngineImplBase.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
protected void normalizeIsoLangCodes(ProcessingResourceMetaData md) {
  if (md == null) {
    return;
  }
  Capability[] capabilities = md.getCapabilities();
  if (capabilities == null) {
    return;
  }
  for (int i = 0; i < capabilities.length; i++) {
    Capability c = capabilities[i];
    String[] languages = c.getLanguagesSupported();
    for (int j = 0; j < languages.length; j++) {
      languages[j] = Language.normalize(languages[j]);
    }
  }
}
 
Example #16
Source File: PearRuntimeTest.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
public void testPearSofaMapping() throws Exception {
    AnalysisEngineDescription desc = createAeDescriptionFromPears(new String[]{"pearTests/pearSofaMap.pear"});
    Capability[] capabilities = new Capability[]{UIMAFramework.getResourceSpecifierFactory().createCapability()};
    capabilities[0].setInputSofas(new String[] {"_InitialView"});
    capabilities[0].setOutputSofas(new String[] {"GermanDocument"});
    desc.getAnalysisEngineMetaData().setCapabilities(capabilities);
    SofaMapping[] sofaMappings = new SofaMapping[] 
      {UIMAFramework.getResourceSpecifierFactory().createSofaMapping(),
       UIMAFramework.getResourceSpecifierFactory().createSofaMapping()};
//    <componentKey>ProjectForPear_pear</componentKey>
//    <componentSofaName>EnglishDocument</componentSofaName>
//    <aggregateSofaName>_InitialView</aggregateSofaName>
  
    sofaMappings[0].setComponentKey("Pear0");
    sofaMappings[1].setComponentKey("Pear0");
    sofaMappings[0].setComponentSofaName("EnglishDocument");
    sofaMappings[1].setComponentSofaName("GermanDocument");
    sofaMappings[0].setAggregateSofaName("_InitialView");
    sofaMappings[1].setAggregateSofaName("GermanDocument");
    desc.setSofaMappings(sofaMappings);
    CAS cas = runDesc(desc);
  }
 
Example #17
Source File: AnalysisEnginePoolTest.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * @see junit.framework.TestCase#setUp()
 */
protected void setUp() throws Exception {
  try {
    super.setUp();
    mSimpleDesc = new AnalysisEngineDescription_impl();
    mSimpleDesc.setFrameworkImplementation(Constants.JAVA_FRAMEWORK_NAME);
    mSimpleDesc.setPrimitive(true);
    mSimpleDesc.getMetaData().setName("Test Primitive TAE");
    mSimpleDesc
            .setAnnotatorImplementationName("org.apache.uima.analysis_engine.impl.TestAnnotator");
    mSimpleDesc.getMetaData().setName("Simple Test");
    Capability cap = new Capability_impl();
    cap.addOutputType("NamedEntity", true);
    cap.addOutputType("DocumentStructure", true);
    Capability[] caps = new Capability[] {cap};
    mSimpleDesc.getAnalysisEngineMetaData().setCapabilities(caps);
  } catch (Exception e) {
    JUnitExtension.handleException(e);
  }
}
 
Example #18
Source File: ResultSpecification_implTest.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
public void testAddCapabilities() throws Exception {
  try {
    // create ResultSpecification with capabilities
    ResultSpecification_impl resultSpecLanguage = new ResultSpecification_impl();
    // add capabilities to the result spec
    resultSpecLanguage.addCapabilities(capabilities);

    // check
    TypeOrFeature[] result = resultSpecLanguage.getResultTypesAndFeatures();
    // sort array before check
    Arrays.sort(result);
    Arrays.sort(mTypesAndFeatures);
    Assert.assertEquals(mTypesAndFeatures.length, result.length);
    for (int i = 0; i < result.length; i++) {
      Assert.assertEquals(mTypesAndFeatures[i], result[i]);
    }
    
    // test defaulting - if no language, should be x-unspecified
    resultSpecLanguage = new ResultSpecification_impl();
    resultSpecLanguage.addCapabilities(new Capability[] {cap4});
    assertTrue(resultSpecLanguage.containsFeature("FakeType:FakeFeature"));
    assertTrue(resultSpecLanguage.containsFeature("FakeType:FakeFeature", "en"));
  } catch (Exception e) {
    JUnitExtension.handleException(e);
  }
}
 
Example #19
Source File: ResultSpecification_implTest.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
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);

     // create ResultSpecification with capabilities
    ResultSpecification_impl resultSpec = new ResultSpecification_impl();
    // add capabilities to the result spec
    resultSpec.addCapabilities(new Capability[] { cap4 });

    assertTrue(resultSpec.containsType("AnotherFakeType"));
  } catch (Exception e) {
    JUnitExtension.handleException(e);
  }
}
 
Example #20
Source File: AnalysisEngineMetaData_impl.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * @see org.apache.uima.analysis_engine.metadata.AnalysisEngineMetaData#setCapabilities(Capability[])
 */
public void setCapabilities(Capability[] aCapabilities) {
  if (aCapabilities == null) {
    throw new UIMA_IllegalArgumentException(UIMA_IllegalArgumentException.ILLEGAL_ARGUMENT,
            new Object[] { "null", "aCapabilities", "setCapabilities" });
  }
  mCapabilities = aCapabilities;
}
 
Example #21
Source File: AnalysisEngineMetaData_impl.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Gets whether this AE is sofa-aware. This is a derived property that cannot be set directly. An
 * AE is sofa-aware if and only if it declares at least one input sofa or output sofa.
 * 
 * @return true if this component is sofa-aware, false if it is sofa-unaware.
 */
public boolean isSofaAware() {
  Capability[] capabilities = getCapabilities();
  if (capabilities != null) {
    for (int i = 0; i < capabilities.length; i++) {
      if (capabilities[i].getInputSofas().length > 0
              || capabilities[i].getOutputSofas().length > 0) {
        return true;
      }
    }
  }
  return false;
}
 
Example #22
Source File: AnalysisEngineDescription_impl.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
protected boolean capabilitiesContainSofa(String aSofaName, boolean aOutput) {
  Capability[] caps = this.getAnalysisEngineMetaData().getCapabilities();
  for (int i = 0; i < caps.length; i++) {
    String[] sofas = aOutput ? caps[i].getOutputSofas() : caps[i].getInputSofas();
    for (int j = 0; j < sofas.length; j++) {
      if (aSofaName.equals(sofas[j])) {
        return true;
      }
    }
  }
  return false;
}
 
Example #23
Source File: SofaNamingInAggregateTest.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Test whether the output sofa specified in the AE descriptor are in the AE meta data.
 * 
 */
public void testGetOutputSofas() throws Exception {
  try {
    Capability[] capabilities = aggregateAE.getAnalysisEngineMetaData().getCapabilities();
    String[] outputSofas = capabilities[0].getOutputSofas();
    Assert.assertEquals(2, outputSofas.length);
    Assert.assertEquals("OutputTranslator1", outputSofas[0]);
    Assert.assertEquals("OutputTranslator2", outputSofas[1]);
  } catch (Exception e) {
    JUnitExtension.handleException(e);
  }
}
 
Example #24
Source File: AggregateAnalysisEngine_impl.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Gets an array containing all capabilities of all components of this aggregate
 * 
 * @return all capabilities of all components of this aggregate
 */
private Capability[] getAllComponentCapabilities() {
  ArrayList<Capability> capabilityList = new ArrayList<>();
  Iterator<ProcessingResourceMetaData> iter = _getComponentMetaData().values().iterator();
  while (iter.hasNext()) {
  	ProcessingResourceMetaData md = iter.next();
    capabilityList.addAll(Arrays.asList(md.getCapabilities()));
  }
  Capability[] capabilityArray = new Capability[capabilityList.size()];
  capabilityList.toArray(capabilityArray);
  return capabilityArray;
}
 
Example #25
Source File: AnalysisSequenceCapabilityNode.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
   * Creates a new AnalysisSequenceCapabilityNode from a AnalysisEngine Key. This is to be used when
   * a direct reference to a AnalysisEngine is not available.
   * 
   * @param aCasProcessorKey
   *          Key of a AnalysisEngine
   * @param aCasProcessorCapabilities
   *          Capabilities for this AnalysisEngine
   * @param aResultSpec
   *          result specification to be passed to this AnalysisEngine
   */
  public AnalysisSequenceCapabilityNode(String aCasProcessorKey,
          Capability[] aCasProcessorCapabilities, ResultSpecification aResultSpec) {
    mCasProcessorKey = aCasProcessorKey;
    mResultSpec = aResultSpec;
    mCasProcessor = null;

    // analysis engine is not set, so we cannot create capabilityContainer
//    mCapabilityContainer = new CapabilityContainer(aCasProcessorCapabilities, false, true);
    mCapabilityContainer = new ResultSpecification_impl();
    mCapabilityContainer.addCapabilities(aCasProcessorCapabilities);
  }
 
Example #26
Source File: SofaNamingInAggregateTest.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Test the whether input sofa specified in the AE descriptar are in the AE meta data.
 * 
 */
public void testGetInputSofas() throws Exception {
  try {
    Capability[] capabilities = aggregateAE.getAnalysisEngineMetaData().getCapabilities();
    String[] inputSofas = capabilities[0].getInputSofas();
    Assert.assertEquals(1, inputSofas.length);
    Assert.assertEquals("SourceDocument", inputSofas[0]);
  } catch (Exception e) {
    JUnitExtension.handleException(e);
  }
}
 
Example #27
Source File: ProcessingContainer_Impl.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Sets component's input/output capabilities.
 *
 * @param aMetadata       component capabilities
 */
@Override
public void setMetadata(ProcessingResourceMetaData aMetadata) {
  metadata = aMetadata;
  Capability[] capabilities = metadata.getCapabilities();
  for (int j = 0; capabilities != null && j < capabilities.length; j++) {
    Capability capability = capabilities[j];
    TypeOrFeature[] tORf = capability.getInputs();
    if (tORf != null) {
      String newKey;
      boolean modified = false;
      // Convert the types if necessary
      for (int i = 0; i < tORf.length; i++) {
        newKey = tORf[i].getName();
        if (tORf[i].getName().indexOf(
                org.apache.uima.collection.impl.cpm.Constants.SHORT_DASH_TERM) > -1) {
          newKey = StringUtils.replaceAll(tORf[i].getName(),
                  org.apache.uima.collection.impl.cpm.Constants.SHORT_DASH_TERM,
                  org.apache.uima.collection.impl.cpm.Constants.LONG_DASH_TERM);
          modified = true;
        }
        if (tORf[i].getName().indexOf(
                org.apache.uima.collection.impl.cpm.Constants.SHORT_COLON_TERM) > -1) {
          newKey = StringUtils.replaceAll(tORf[i].getName(),
                  org.apache.uima.collection.impl.cpm.Constants.SHORT_COLON_TERM,
                  org.apache.uima.collection.impl.cpm.Constants.LONG_COLON_TERM);
          modified = true;
        }
        if (modified) {
          tORf[i].setName(newKey);
          modified = false;
        }
      }
    }
  }

}
 
Example #28
Source File: CapabilitySection.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Handle add sofa.
 *
 * @param selItem the sel item
 * @param itemKind the item kind
 */
private void handleAddSofa(TreeItem selItem, int itemKind) {
  if (itemKind == CS)
    selItem = selItem.getItems()[1];
  else if (itemKind == LANG || itemKind == TYPE)
    selItem = selItem.getParentItem().getItems()[1];
  else if (itemKind == LANG_ITEM || itemKind == FEAT || itemKind == SOFA_ITEM)
    selItem = selItem.getParentItem().getParentItem().getItems()[1];

  Capability c = getCapabilityFromTreeItem(selItem.getParentItem());
  AddSofaDialog dialog = new AddSofaDialog(this, c);
  if (dialog.open() == Window.CANCEL)
    return;

  // dialog.isInput, dialog.sofaName
  if (dialog.isInput)
    c.setInputSofas(stringArrayAdd(c.getInputSofas(), dialog.sofaName));
  else
    c.setOutputSofas(stringArrayAdd(c.getOutputSofas(), dialog.sofaName));

  TreeItem item = new TreeItem(selItem, SWT.NONE);
  setGuiSofaName(item, dialog.sofaName, dialog.isInput);
  selItem.setExpanded(true);
  pack04();

  sofaMapSection.markStale();
  finishAction();
}
 
Example #29
Source File: Pipeline.java    From bluima with Apache License 2.0 5 votes vote down vote up
/** Add this crd's capabilities for other downstream aeds. */
private void addCapabilities(CollectionReaderDescription crd) {

    for (Capability capability : crd.getCollectionReaderMetaData()
            .getCapabilities()) {
        for (TypeOrFeature output : capability.getOutputs()) {
            // LOG.info("add @TypeCapability: " + output.getName());
            outputTypes.add(output.getName());
        }
    }
}
 
Example #30
Source File: CapabilitySection.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Handle add lang.
 *
 * @param selItem the sel item
 * @param itemKind the item kind
 */
private void handleAddLang(TreeItem selItem, int itemKind) {
  if (itemKind == CS)
    selItem = selItem.getItems()[0]; // lang is 1st item in capability set
  else if (itemKind == LANG_ITEM)
    selItem = selItem.getParentItem();
  else if (itemKind == TYPE || itemKind == SOFA)
    selItem = selItem.getParentItem().getItems()[0];
  else if (itemKind == FEAT || itemKind == SOFA_ITEM)
    selItem = selItem.getParentItem().getParentItem().getItems()[0];
  Capability c = getCapabilityFromTreeItem(selItem.getParentItem());
  CommonInputDialog dialog = new CommonInputDialog(
          this,
          "Add Language",
          "Enter a two letter ISO-639 language code, followed optionally by a two-letter ISO-3166 country code (Examples: fr or fr-CA)",
          CommonInputDialog.LANGUAGE);
  if (dialogForLanguage(c, dialog) == Window.CANCEL)
    return;

  c.setLanguagesSupported(stringArrayAdd(c.getLanguagesSupported(), dialog.getValue()));

  // update GUI
  TreeItem lItem = new TreeItem(selItem, SWT.NONE);
  lItem.setData(LANG_TITLE);
  lItem.setText(NAME_COL, dialog.getValue());
  selItem.setExpanded(true);
  pack04();
  finishAction();
}