Examples of TypeSystemDescription


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

  }

  public void testCreateCasCollection() throws Exception {
    try {
      // create two Type System description objects
      TypeSystemDescription tsd1 = new TypeSystemDescription_impl();
      TypeDescription supertype = tsd1.addType("test.Super", "", "uima.tcas.Annotation");
      supertype.addFeature("testfeat", "", "uima.cas.Integer");
      TypeDescription subtype = tsd1.addType("test.Sub", "", "test.Super");
      subtype.addFeature("testfeat", "", "uima.cas.Integer");

      TypeSystemDescription tsd2 = new TypeSystemDescription_impl();
      TypeDescription fooType = tsd1.addType("test.Foo", "", "uima.cas.TOP");
      fooType.addFeature("bar", "", "uima.cas.String");

      // create index and priorities descriptions
View Full Code Here

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

              new XMLInputSource(descFile));
      Map mergedTypes = new HashMap();
      ProcessingResourceMetaData mergedMetaData = CasCreationUtils
              .mergeDelegateAnalysisEngineMetaData(desc, UIMAFramework.newDefaultResourceManager(),
                      mergedTypes, null);
      TypeSystemDescription typeSys = mergedMetaData.getTypeSystem();
      TypePriorities pri = mergedMetaData.getTypePriorities();
      FsIndexCollection indexColl = mergedMetaData.getFsIndexCollection();

      // test results of merge
      // Type System
      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);

      // Place has merged features, Person has different supertype
View Full Code Here

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

   * @throws Exception
   */
  public static CAS getCASfromXCAS(File tsFile, File xcasFile) throws Exception{
    try {
      Object tsDescriptor = UIMAFramework.getXMLParser().parse(new XMLInputSource(tsFile));
      TypeSystemDescription tsDesc = (TypeSystemDescription) tsDescriptor;
      CAS cas = CasCreationUtils.createCas(tsDesc, null, new FsIndexDescription[0]);

      SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
      XCASDeserializer xcasDeserializer = new XCASDeserializer(cas.getTypeSystem());
      parser.parse(xcasFile, xcasDeserializer.getXCASHandler(cas));
View Full Code Here

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

      if (md.getFsIndexCollection() != null)
        fsIndexes.add(md.getFsIndexCollection());
    }

    // merge
    TypeSystemDescription aggTypeDesc = mergeTypeSystems(typeSystems, aResourceManager);
    TypePriorities aggTypePriorities = mergeTypePriorities(typePriorities, aResourceManager);
    FsIndexCollection aggIndexColl = mergeFsIndexes(fsIndexes, aResourceManager);

    return createCas(aggTypeDesc, aggTypePriorities, aggIndexColl.getFsIndexes(),
            aPerformanceTuningSettings, aResourceManager);
View Full Code Here

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

    {
      return createCas(aTypeSystem, aggTypePriorities, aggIndexColl.getFsIndexes(),
              aPerformanceTuningSettings, aResourceManager);
    } else {
      // no type system object specified; merge type system descriptions in metadata
      TypeSystemDescription aggTypeDesc = mergeTypeSystems(typeSystems);
      return createCas(aggTypeDesc, aggTypePriorities, aggIndexColl.getFsIndexes(),
              aPerformanceTuningSettings, aResourceManager);
    }
  }
View Full Code Here

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

   *          the CAS Data from which to extract the type system
   *
   * @return a description of a TypeSystem to which the CAS Data conforms
   */
  public static TypeSystemDescription convertData2TypeSystem(CasData aCasData) {
    TypeSystemDescription result = UIMAFramework.getResourceSpecifierFactory()
            .createTypeSystemDescription();
    Iterator iter = aCasData.getFeatureStructures();
    ArrayList typesArr = new ArrayList();
    while (iter.hasNext()) {
      FeatureStructure casFS = (FeatureStructure) iter.next();
      TypeDescription newType = UIMAFramework.getResourceSpecifierFactory().createTypeDescription();
      newType.setName(casFS.getType());
      newType.setSupertypeName("uima.tcas.annotation");
      newType.setDescription("CasData Type");
      String features[] = casFS.getFeatureNames();
      if (features != null) {
        for (int i = 0; i < features.length; i++) {
          String featName = features[i];
          String rangeName = "";
          String description = "";
          PrimitiveValue pVal = (PrimitiveValue) casFS.getFeatureValue(featName);
          if (pVal.get().getClass().getName().equals("java.lang.String")) {
            System.out.println(" the feature is a String ");
            rangeName = "uima.cas.String";
            description = " featue of the casDataType";
          }
          newType.addFeature(featName, description, rangeName);
        }
      }
      typesArr.add(newType);
    }
    TypeDescription td[] = new TypeDescription[typesArr.size()];
    for (int j = 0; j < typesArr.size(); j++) {
      td[j] = (TypeDescription) typesArr.get(j);
    }
    result.setTypes(td);
    return result;
  }
View Full Code Here

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

   */
  public static TypeSystemDescription mergeTypeSystems(Collection aTypeSystems,
          ResourceManager aResourceManager, Map aOutputMergedTypes)
          throws ResourceInitializationException {
    // create the type system into which we are merging
    TypeSystemDescription result = UIMAFramework.getResourceSpecifierFactory()
            .createTypeSystemDescription();
    // also build a Map from Type names to Types
    Map typeNameMap = new HashMap();

    // Now iterate through all type systems - if a new type is found, add it.
    // If an existing type is found, merge features.
    Iterator it = aTypeSystems.iterator();
    while (it.hasNext()) {
      TypeSystemDescription ts = (TypeSystemDescription) it.next();
      if (ts != null) {
        try {
          ts.resolveImports(aResourceManager);
        } catch (InvalidXMLException e) {
          throw new ResourceInitializationException(e);
        }
        TypeDescription[] types = ts.getTypes();
        if (types != null) {
          for (int i = 0; i < types.length; i++) {
            String typeName = types[i].getName();
            TypeDescription existingType = (TypeDescription) typeNameMap.get(typeName);
            if (existingType == null) {
View Full Code Here

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

    XMLInputSource xmlTypeSystemSource = new XMLInputSource(inTypeSystem, new File(""));

    XMLParser xmlParser = UIMAFramework.getXMLParser();

    TypeSystemDescription typeSystemDesciptor;

    try {
      typeSystemDesciptor = (TypeSystemDescription) xmlParser.parse(xmlTypeSystemSource);

      typeSystemDesciptor.resolveImports();
    } catch (InvalidXMLException e) {

      String message = (e.getMessage() != null ? e.getMessage() : "");

      IStatus s = new Status(IStatus.ERROR, CasEditorPlugin.ID, IStatus.OK, message, e);
View Full Code Here

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

        catch (CoreException e)
        {
            throw new InvocationTargetException(e);
        }
       
        TypeSystemDescription typeSystemDescriptor;
        try
        {
            typeSystemDescriptor = UIMAFramework.getXMLParser()
            .parseTypeSystemDescription(
                    new XMLInputSource(inTypeSystemDescription, new File("")));
           
            typeSystemDescriptor.resolveImports();
        }
        catch (InvalidXMLException e)
        {
            throw new InvocationTargetException(e);
        }
View Full Code Here

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

  {
      XMLInputSource xmlTypeSystemSource = new XMLInputSource(DocumentImportStructureProvider.class
            .getResourceAsStream("ts.xml"), new File(""));
      XMLParser xmlParser = UIMAFramework.getXMLParser();

      TypeSystemDescription typeSystemDesciptor;

      try {
        typeSystemDesciptor = (TypeSystemDescription) xmlParser
                .parse(xmlTypeSystemSource);
      } catch (InvalidXMLException e1) {
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.