Examples of TypeSystemDescription


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

      primitiveDesc.setPrimitive(true);
      primitiveDesc
              .setAnnotatorImplementationName("org.apache.uima.analysis_engine.impl.TestAnnotator");
      primitiveDesc.getMetaData().setName("Test Primitive TAE");

      TypeSystemDescription tsd = new TypeSystemDescription_impl();
      tsd.addType("NamedEntity", "", "uima.tcas.Annotation");
      tsd.addType("DocumentStructure", "", "uima.cas.TOP");
      primitiveDesc.getAnalysisEngineMetaData().setTypeSystem(tsd);
      cap = new Capability_impl();
      cap.addOutputType("NamedEntity", true);
      cap.addOutputType("DocumentStructure", true);
      caps = new Capability[] {cap};
View Full Code Here

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

      AnalysisEngineDescription desc = new AnalysisEngineDescription_impl();
      desc.setPrimitive(true);
      desc.getMetaData().setName("Test Primitive TAE");
      desc.setAnnotatorImplementationName("org.apache.uima.analysis_engine.impl.TestAnnotator");

      TypeSystemDescription typeSystem = new TypeSystemDescription_impl();
      TypeDescription type1 = typeSystem.addType("Type1", "Test Type One",
              CAS.TYPE_NAME_ANNOTATION);
      FeatureDescription feat1 = new FeatureDescription_impl();
      feat1.setName("Feature1");
      feat1.setRangeTypeName(CAS.TYPE_NAME_INTEGER);
      type1.setFeatures(new FeatureDescription[] { feat1 });
      TypeDescription type2 = typeSystem.addType("Type2", "Test Type Two",
              CAS.TYPE_NAME_ANNOTATION);
      FeatureDescription feat2 = new FeatureDescription_impl();
      feat2.setName("Feature2");
      feat2.setRangeTypeName("EnumType");
      type2.setFeatures(new FeatureDescription[] { feat2 });
      TypeDescription enumType = typeSystem.addType("EnumType", "Test Enumerated Type",
              "uima.cas.String");
      enumType.setAllowedValues(new AllowedValue[] { new AllowedValue_impl("One", "First Value"),
          new AllowedValue_impl("Two", "Second Value") });
      desc.getAnalysisEngineMetaData().setTypeSystem(typeSystem);
View Full Code Here

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

      ae.initialize(desc, Collections.EMPTY_MAP);
      // initialize method automatically calls processDelegateAnalysisEngineMetaData()

      // test results of merge
      // TypeSystem
      TypeSystemDescription typeSys = ae.getAnalysisEngineMetaData().getTypeSystem();
      Assert.assertEquals(8, typeSys.getTypes().length);

      TypeDescription type0 = typeSys.getType("NamedEntity");
      Assert.assertNotNull(type0);
      Assert.assertEquals("uima.tcas.Annotation", type0.getSupertypeName());
      Assert.assertEquals(1, type0.getFeatures().length);

      TypeDescription type1 = typeSys.getType("Person");
      Assert.assertNotNull(type1);
      Assert.assertEquals("NamedEntity", type1.getSupertypeName());
      Assert.assertEquals(1, type1.getFeatures().length);

      TypeDescription type2 = typeSys.getType("Place");
      Assert.assertNotNull(type2);
      Assert.assertEquals("NamedEntity", type2.getSupertypeName());
      Assert.assertEquals(3, type2.getFeatures().length);

      TypeDescription type3 = typeSys.getType("Org");
      Assert.assertNotNull(type3);
      Assert.assertEquals("uima.tcas.Annotation", type3.getSupertypeName());
      Assert.assertEquals(0, type3.getFeatures().length);

      TypeDescription type4 = typeSys.getType("DocumentStructure");
      Assert.assertNotNull(type4);
      Assert.assertEquals("uima.tcas.Annotation", type4.getSupertypeName());
      Assert.assertEquals(0, type4.getFeatures().length);

      TypeDescription type5 = typeSys.getType("Paragraph");
      Assert.assertNotNull(type5);
      Assert.assertEquals("DocumentStructure", type5.getSupertypeName());
      Assert.assertEquals(0, type5.getFeatures().length);

      TypeDescription type6 = typeSys.getType("Sentence");
      Assert.assertNotNull(type6);
      Assert.assertEquals("DocumentStructure", type6.getSupertypeName());
      Assert.assertEquals(0, type6.getFeatures().length);

      TypeDescription type7 = typeSys.getType("test.flowController.Test");
      Assert.assertNotNull(type7);
      Assert.assertEquals("uima.tcas.Annotation", type7.getSupertypeName());
      Assert.assertEquals(1, type7.getFeatures().length);

      // TypePriorities
View Full Code Here

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

          throws URISyntaxException {
    if (aOptions == null) {
      aOptions = Collections.EMPTY_MAP;
    }

    TypeSystemDescription tsDesc = uimaFactory.createTypeSystemDescription();

    // try to get descriptive info from EAnnotation with NS "http://uima.apache.org",
    // on the first EPackage in the Resource
    EPackage ePackage = (EPackage) aEcoreResource.getContents().get(0);
    EAnnotation eannot = ePackage.getEAnnotation("http://uima.apache.org");
    if (eannot != null) {
      tsDesc.setName((String) eannot.getDetails().get("name"));
      tsDesc.setDescription((String) eannot.getDetails().get("description"));
      tsDesc.setVendor((String) eannot.getDetails().get("vendor"));
      tsDesc.setVersion((String) eannot.getDetails().get("version"));
    }

    // convert types
    List types = new ArrayList();
    Iterator iter = aEcoreResource.getContents().iterator();
    while (iter.hasNext()) {
      Object obj = iter.next();
      if (obj instanceof EPackage) {
        ePackage2UimaTypes((EPackage) obj, types, aOptions);
      }
    }
    TypeDescription[] typeArr = new TypeDescription[types.size()];
    types.toArray(typeArr);
    tsDesc.setTypes(typeArr);
    return tsDesc;
  }
View Full Code Here

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

      return;
    }

    Map options = new HashMap();
    // options.put(OPTION_GENERATE_UIMA_LIST_TYPES, Boolean.TRUE);
    TypeSystemDescription tsDesc = ecore2UimaTypeSystem(args[0], options);

    FileOutputStream os = new FileOutputStream(args[1]);
    try {
      tsDesc.toXML(os);
    } finally {
      os.close();
    }

    // test creating a CAS
View Full Code Here

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

   * @param casTS Type system containing all known types.
   * @throws InvalidXMLException When import cannot be resolved.
   */
  private void importDeclaredTypesystems(TypeSystem casTS) throws InvalidXMLException {
    String[] descriptors = typesystems.toArray(new String[typesystems.size()]);
    TypeSystemDescription ts = TypeSystemDescriptionFactory.createTypeSystemDescription(descriptors);
    ts.resolveImports();
    for (TypeDescription td : ts.getTypes()) {
      Type type = casTS.getType(td.getName());
      if (type != null) {
        addType(type);
      } else {
        throw new RuntimeException("Type '" + td.getName() + "' not found");
View Full Code Here

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

   *
   * @param typesystem  Type system describing the package to load.
   * @param packageName Package to load or null to load all packages.
   */
  public void importPackageFromTypeSystem(String typesystem, String packageName, String alias) {
    TypeSystemDescription tsd = TypeSystemDescriptionFactory.createTypeSystemDescription(typesystem);
    try {
      tsd.resolveImports();
    } catch (InvalidXMLException e) {
      throw new RuntimeException("Cannot resolve imports in " + typesystem, e);
    }

    for (TypeDescription td : tsd.getTypes()) {
      String qname = td.getName();
      if (packageName == null ||
          (qname.startsWith(packageName) && qname.indexOf('.', packageName.length() + 1) == -1)) {
        // td is in packageName
        if (alias != null) {
View Full Code Here

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

  public void save() {
    AnnotationCheckTreeNode root = (AnnotationCheckTreeNode) treeView.getInput();
    AnnotationCheckTreeNode[] children = root.getChildren();
    List<CheckDocument> docs = new ArrayList<CheckDocument>(oldDocs);
    TypeSystemDescription tsd = null;
    try {
      tsd = UIMAFramework.getXMLParser().parseTypeSystemDescription(
              new XMLInputSource(typeSystem.getText()));
      tsd.resolveImports();
    } catch (InvalidXMLException e) {
      RutaAddonsPlugin.error(e);
    } catch (IOException e) {
      RutaAddonsPlugin.error(e);
    }
View Full Code Here

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

    try {
      acView = (AnnotationCheckView) HandlerUtil.getActiveWorkbenchWindow(event).getWorkbench()
              .getActiveWorkbenchWindow().getActivePage().showView(AnnotationCheckView.ID);
      AnnotationCheckComposite composite = (AnnotationCheckComposite) acView.getComposite();
      List<String> types = new ArrayList<String>();
      TypeSystemDescription tsd = UIMAFramework.getXMLParser().parseTypeSystemDescription(
              new XMLInputSource(new File(composite.getTypeSystem())));
      tsd.resolveImports();
      TypeDescription[] systemTypes = tsd.getTypes();
      for (TypeDescription typeDescription : systemTypes) {
        types.add(typeDescription.getName());
      }
      Collections.sort(types);
View Full Code Here

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

    File preFile = new File(preFilePath);
    if (preFile.exists() == false || StringUtils.isEmpty(preFilePath)) {
      printErrorDialog("The preprocessing file was not found!");
      return null;
    }
    TypeSystemDescription defaultTypeSystemDescription = null;
    List<String> types = new ArrayList<String>();
    try {
      String tsDesc = RutaProjectUtils.getTypeSystemDescriptorPath(location, resource.getProject())
              .toPortableString();

      defaultTypeSystemDescription = UIMAFramework.getXMLParser().parseTypeSystemDescription(
              new XMLInputSource(new File(tsDesc)));
      defaultTypeSystemDescription.resolveImports();
      TypeDescription[] systemTypes = defaultTypeSystemDescription.getTypes();
      for (TypeDescription typeDescription : systemTypes) {
        types.add(typeDescription.getName());
      }
      Collections.sort(types);
    } catch (InvalidXMLException e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.