Package org.apache.uima.resource.metadata

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


  private String checkDuplSofaName() {

    Capability[] cSets = capabilitySection.getCapabilities();
    // check for dis-allowed duplicates in other capability sets
    for (int i = 0; i < cSets.length; i++) {
      Capability ci = cSets[i];
      if (ci == capability)
        continue;
      // "reverse" i and o - if input validate name not exist as output in other sets, etc.
      String[] sofaNames = isInput ? ci.getOutputSofas() : ci.getInputSofas();
      if (null != sofaNames)
        for (int j = 0; j < sofaNames.length; j++) {
          if (sofaName.equals(sofaNames[j]))
            return "This name exists as an " + (isInput ? "output" : "input")
                    + " in some capability set.  Please choose another name, or "
View Full Code Here


  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());

  }
View Full Code Here

      t2.setAllAnnotatorFeatures(true);
      mTypesAndFeatures = new TypeOrFeature[] { t1, f1, t2 };

      // create capability[] for language tests
      // capability 1 - using t1
      Capability cap1 = new Capability_impl();
      String[] languages1 = { "en", "de", "en-US", "en-GB" };
      TypeOrFeature[] tofs1 = { t1 };
      cap1.setLanguagesSupported(languages1);
      cap1.setOutputs(tofs1);

      // capability 2 - using f1
      Capability cap2 = new Capability_impl();
      String[] languages2 = { "ja", "en" };
      TypeOrFeature[] tofs2 = { f1 };
      cap2.setLanguagesSupported(languages2);
      cap2.setOutputs(tofs2);

      // capability 3 - using t2
      Capability cap3 = new Capability_impl();
      String[] languages3 = { "x-unspecified" };
      TypeOrFeature[] tofs3 = { t2 };
      cap3.setLanguagesSupported(languages3);
      cap3.setOutputs(tofs3);

      // make capability array with the above specified values
      capabilities = new Capability[] { cap1, cap2, cap3 };

      // make languages array
View Full Code Here

        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 });
View Full Code Here

      AnalysisEngineDescription primitiveDesc = new AnalysisEngineDescription_impl();
      primitiveDesc.setPrimitive(true);
      primitiveDesc
              .setAnnotatorImplementationName("org.apache.uima.analysis_engine.impl.TestAnnotator");
      primitiveDesc.getMetaData().setName("Test Primitive TAE");
      Capability cap = new Capability_impl();
      cap.addOutputType("NamedEntity", true);
      cap.addOutputType("DocumentStructure", true);
      Capability[] caps = new Capability[] {cap};
      primitiveDesc.getAnalysisEngineMetaData().setCapabilities(caps);
      _testProcess(primitiveDesc);

      // test simple aggregate TextAnalysisEngine (again using TestAnnotator class)
View Full Code Here

    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]);
      }
    }
  }
View Full Code Here

      TypeSystemDescription typeSys = new TypeSystemDescription_impl();
      typeSys.addType("foo.Bar", "test", "uima.tcas.Annotation");
      typeSys.addType("NamedEntity", "test", "uima.tcas.Annotation");
      typeSys.addType("DocumentStructure", "test", "uima.tcas.Annotation");
      mSimpleDesc.getAnalysisEngineMetaData().setTypeSystem(typeSys);
      Capability cap = new Capability_impl();
      cap.addOutputType("NamedEntity", true);
      cap.addOutputType("DocumentStructure", true);
      Capability[] caps = new Capability[] {cap};
       mSimpleDesc.getAnalysisEngineMetaData().setCapabilities(caps);

      mAggDesc = new AnalysisEngineDescription_impl();
      mAggDesc.setPrimitive(false);
View Full Code Here

      md.setDescription("Does not do anything useful.");
      md.setVersion("1.0");
      md.setTypeSystem(typeSystem);
      md.setTypePriorities(typePriorities);
      md.setFsIndexes(new FsIndexDescription[] { index, index2 });
      Capability cap1 = new Capability_impl();
      cap1.setDescription("First fake capability");
      cap1.addOutputType("Fake", false);
      cap1.addOutputFeature("TestFeature");
      Capability cap2 = new Capability_impl();
      cap2.setDescription("Second fake capability");
      cap2.addInputType("Fake", true);
      cap2.addOutputType("Fake", true);
      // SimplePrecondition precond1 = new SimplePrecondition_impl();
      // precond1.setFeatureDescription(feature1);
      // precond1.setComparisonValue(new String[]{"en,de"});
      // precond1.setPredicate(SimplePrecondition.LANGUAGE_SUBSUMED);
      // cap1.setPreconditions(new Precondition[]{precond1});
View Full Code Here

      dataPath += string + File.pathSeparator;
    }
    rm.setDataPath(dataPath);
   
    Map<String, String> typeNameMap = new HashMap<String, String>();
    Capability capability = uimaFactory.createCapability();
    // String defaultTypeSystem2 = defaultTypeSystem.replaceAll("/", "\\\\");
    File defaultTypeSystemFile = new File(defaultTypeSystem);
    if (!defaultTypeSystemFile.exists()) {
      System.out.println("Does not exist: " + defaultTypeSystemFile.getName());
    }
    TypeSystemDescription initialTypeSystem = UIMAFramework.getXMLParser()
            .parseTypeSystemDescription(new XMLInputSource(defaultTypeSystemFile));
    CAS cas = CasCreationUtils.createCas(initialTypeSystem, null, new FsIndexDescription[0]);
    fillTypeNameMap(typeNameMap, cas.getTypeSystem());
    cas.release();
    List<Import> importList = new ArrayList<Import>();
    Import_impl import_impl = new Import_impl();
    if (option.isImportByName()) {
      String name = initialTypeSystem.getName();
      import_impl.setName(name);
    } else if (option.isResolveImports()) {
      String absoluteLocation = initialTypeSystem.getSourceUrlString();
      import_impl.setLocation(absoluteLocation);
    } else {
      String relativeLocation = getRelativeLocation(defaultTypeSystemFile.getAbsolutePath(),
              typeSystemOutput);
      import_impl.setLocation(relativeLocation);
    }
    importList.add(import_impl);
    for (String eachName : desc.getImportedTypeSystems()) {
      String locate = RutaEngine.locate(eachName, enginePaths, ".xml");
      if(locate == null) {
        throw new FileNotFoundException("Build process can't find " + eachName + " in "
                + mainScript);
      }
      File file = new File(locate);
      TypeSystemDescription each = getTypeSystemDescriptor(file, option);
      if (each != null) {
        fillTypeNameMap(typeNameMap, each);
        import_impl = new Import_impl();
        if (option.isImportByName()) {
          import_impl.setName(eachName);
        } else if (option.isResolveImports()) {
          String absoluteLocation = each.getSourceUrlString();
          import_impl.setLocation(absoluteLocation);
        } else {
          String relativeLocation = getRelativeLocation(file.getAbsolutePath(), typeSystemOutput);
          import_impl.setLocation(relativeLocation);
        }
        importList.add(import_impl);
      } else {
        throw new FileNotFoundException("Build process can't find " + eachName + " in "
                + mainScript);
      }
    }
    for (String eachName : desc.getImportedScripts()) {
      String locate = RutaEngine.locate(eachName, enginePaths, "TypeSystem.xml");
      File file = new File(locate);
      TypeSystemDescription each = getTypeSystemDescriptor(file, option);
      if (each != null) {
        fillTypeNameMap(typeNameMap, each);
        import_impl = new Import_impl();
        if (option.isImportByName()) {
          import_impl.setName(eachName + "TypeSystem");
        } else if (option.isResolveImports()) {
          String absoluteLocation = each.getSourceUrlString();
          import_impl.setLocation(absoluteLocation);
        } else {
          String relativeLocation = getRelativeLocation(file.getAbsolutePath(), typeSystemOutput);
          import_impl.setLocation(relativeLocation);
        }
        importList.add(import_impl);
      } else {
        throw new FileNotFoundException("Build process can't find " + eachName + " in "
                + mainScript);
      }
    }

    Import[] newImports = importList.toArray(new Import[0]);
    typeSystemDescription.setImports(newImports);
    if (option.isResolveImports()) {
      try {
        typeSystemDescription.resolveImports(rm);
      } catch (InvalidXMLException e) {
        throw new RutaBuildException("Failed to resolve imported Type Systems", e);
      }
    }

    // TODO hotfixes: where do I get the final types??
    Set<String> finalTypes = new HashSet<String>();
    finalTypes.addAll(Arrays.asList(new String[] { "uima.cas.Boolean", "uima.cas.Byte",
        "uima.cas.Short", "uima.cas.Integer", "uima.cas.Long", "uima.cas.Float", "uima.cas.Double",
        "uima.cas.BooleanArray", "uima.cas.ByteArray", "uima.cas.ShortArray",
        "uima.cas.IntegerArray", "uima.cas.LongArray", "uima.cas.FloatArray",
        "uima.cas.DoubleArray", "uima.cas.StringArray", "uima.cas.FSArray" }));

    int typeIndex = 0;
    for (String eachType : desc.getTypeShortNames()) {
      StringTriple typeTriple = desc.getTypeTriples().get(typeIndex);
      typeTriple = resolveType(typeTriple, typeNameMap, mainScript);
      if (typeSystemDescription.getType(typeTriple.getName()) != null) {
        continue;
      }
      if (!finalTypes.contains(typeTriple.getParent())) {
        TypeDescription newType = typeSystemDescription.addType(typeTriple.getName(),
                typeTriple.getDescription(), typeTriple.getParent());
        capability.addInputType(typeTriple.getName(), false);
        capability.addOutputType(typeTriple.getName(), false);
        Collection<StringTriple> collection = desc.getFeatures().get(eachType);
        if (collection != null) {
          for (StringTriple eachFeature : collection) {
            eachFeature = resolveFeature(eachFeature, typeNameMap);
            newType.addFeature(eachFeature.getName(), eachFeature.getDescription(),
View Full Code Here

   */
  protected ResultSpecification computeAnalysisComponentResultSpec(
          ResultSpecification inputResultSpec, Capability[] capabilities) {
    ResultSpecification newResultSpec = new ResultSpecification_impl();
    for (int i = 0; i < capabilities.length; i++) {
      Capability cap = capabilities[i];
      TypeOrFeature[] outputs = cap.getOutputs();
      String[] languages = cap.getLanguagesSupported();
      if (languages.length == 0) {
        languages = new String[] { "x-unspecified" };
      }
      for (int j = 0; j < outputs.length; j++) {
        for (int k = 0; k < languages.length; k++) {
View Full Code Here

TOP

Related Classes of org.apache.uima.resource.metadata.Capability

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.