Java Code Examples for org.apache.uima.util.CasCreationUtils#mergeTypeSystems()

The following examples show how to use org.apache.uima.util.CasCreationUtils#mergeTypeSystems() . 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: WebAnnoTsv3WriterTestBase.java    From webanno with Apache License 2.0 6 votes vote down vote up
@Test
public void testTwoSentencesWithNoSpaceInBetween() throws Exception
{
    TypeSystemDescription global = TypeSystemDescriptionFactory.createTypeSystemDescription();
    TypeSystemDescription local = TypeSystemDescriptionFactory
            .createTypeSystemDescriptionFromPath(
                    "src/test/resources/desc/type/webannoTestTypes.xml");
   
    TypeSystemDescription merged = CasCreationUtils.mergeTypeSystems(asList(global, local));
    
    JCas jcas = JCasFactory.createJCas(merged);
    
    DocumentMetaData.create(jcas).setDocumentId("doc");
    jcas.setDocumentText("onetwo");
    new Token(jcas, 0, 3).addToIndexes();
    new Sentence(jcas, 0, 3).addToIndexes();
    new Token(jcas, 3, 6).addToIndexes();
    new Sentence(jcas, 3, 6).addToIndexes();
    
    writeAndAssertEquals(jcas);
}
 
Example 2
Source File: ConstraintsGeneratorTest.java    From webanno with Apache License 2.0 6 votes vote down vote up
private JCas makeJCasOneSentence() throws UIMAException
{
    TypeSystemDescription global = TypeSystemDescriptionFactory.createTypeSystemDescription();
    TypeSystemDescription local = TypeSystemDescriptionFactory
            .createTypeSystemDescriptionFromPath(
                    "src/test/resources/desc/types/webannoTestTypes.xml");
   
    TypeSystemDescription merged = CasCreationUtils.mergeTypeSystems(asList(global, local));
    
    JCas jcas = JCasFactory.createJCas(merged);
    
    DocumentMetaData.create(jcas).setDocumentId("doc");
    
    TokenBuilder<Token, Sentence> tb = new TokenBuilder<>(Token.class,
            Sentence.class);
    tb.buildTokens(jcas, "This is a test .");
    
    return jcas;
}
 
Example 3
Source File: CurationTestUtils.java    From webanno with Apache License 2.0 6 votes vote down vote up
public static TypeSystemDescription createMultiLinkWithRoleTestTypeSytem()
    throws Exception
{
    List<TypeSystemDescription> typeSystems = new ArrayList<>();

    TypeSystemDescription tsd = new TypeSystemDescription_impl();

    // Link type
    TypeDescription linkTD = tsd.addType(LINK_TYPE, "", CAS.TYPE_NAME_TOP);
    linkTD.addFeature("role", "", CAS.TYPE_NAME_STRING);
    linkTD.addFeature("target", "", CAS.TYPE_NAME_ANNOTATION);

    // Link host
    TypeDescription hostTD = tsd.addType(HOST_TYPE, "", CAS.TYPE_NAME_ANNOTATION);
    hostTD.addFeature("links", "", CAS.TYPE_NAME_FS_ARRAY, linkTD.getName(), false);

    typeSystems.add(tsd);
    typeSystems.add(TypeSystemDescriptionFactory.createTypeSystemDescription());

    return CasCreationUtils.mergeTypeSystems(typeSystems);
}
 
Example 4
Source File: CurationTestUtils.java    From webanno with Apache License 2.0 6 votes vote down vote up
public static TypeSystemDescription createMultiLinkWithRoleTestTypeSystem(String... aFeatures)
    throws Exception
{
    List<TypeSystemDescription> typeSystems = new ArrayList<>();

    TypeSystemDescription tsd = new TypeSystemDescription_impl();

    // Link type
    TypeDescription linkTD = tsd.addType(LINK_TYPE, "", CAS.TYPE_NAME_TOP);
    linkTD.addFeature("role", "", CAS.TYPE_NAME_STRING);
    linkTD.addFeature("target", "", CAS.TYPE_NAME_ANNOTATION);

    // Link host
    TypeDescription hostTD = tsd.addType(HOST_TYPE, "", CAS.TYPE_NAME_ANNOTATION);
    hostTD.addFeature("links", "", CAS.TYPE_NAME_FS_ARRAY, linkTD.getName(), false);
    for (String feature : aFeatures) {
        hostTD.addFeature(feature, "", CAS.TYPE_NAME_STRING);
    }

    typeSystems.add(tsd);
    typeSystems.add(TypeSystemDescriptionFactory.createTypeSystemDescription());

    return CasCreationUtils.mergeTypeSystems(typeSystems);
}
 
Example 5
Source File: DiffTestUtils.java    From webanno with Apache License 2.0 6 votes vote down vote up
public static TypeSystemDescription createMultiLinkWithRoleTestTypeSytem()
    throws Exception
{
    List<TypeSystemDescription> typeSystems = new ArrayList<>();

    TypeSystemDescription tsd = new TypeSystemDescription_impl();

    // Link type
    TypeDescription linkTD = tsd.addType(LINK_TYPE, "", CAS.TYPE_NAME_TOP);
    linkTD.addFeature("role", "", CAS.TYPE_NAME_STRING);
    linkTD.addFeature("target", "", Token.class.getName());

    // Link host
    TypeDescription hostTD = tsd.addType(HOST_TYPE, "", CAS.TYPE_NAME_ANNOTATION);
    hostTD.addFeature("links", "", CAS.TYPE_NAME_FS_ARRAY, linkTD.getName(), false);

    typeSystems.add(tsd);
    typeSystems.add(TypeSystemDescriptionFactory.createTypeSystemDescription());

    return CasCreationUtils.mergeTypeSystems(typeSystems);
}
 
Example 6
Source File: DiffTestUtils.java    From webanno with Apache License 2.0 6 votes vote down vote up
public static TypeSystemDescription createMultiLinkWithRoleTestTypeSytem(String... aFeatures)
    throws Exception
{
    List<TypeSystemDescription> typeSystems = new ArrayList<>();

    TypeSystemDescription tsd = new TypeSystemDescription_impl();

    // Link type
    TypeDescription linkTD = tsd.addType(LINK_TYPE, "", CAS.TYPE_NAME_TOP);
    linkTD.addFeature("role", "", CAS.TYPE_NAME_STRING);
    linkTD.addFeature("target", "", Token.class.getName());

    // Link host
    TypeDescription hostTD = tsd.addType(HOST_TYPE, "", CAS.TYPE_NAME_ANNOTATION);
    hostTD.addFeature("links", "", CAS.TYPE_NAME_FS_ARRAY, linkTD.getName(), false);
    for (String feature : aFeatures) {
        hostTD.addFeature(feature, "", CAS.TYPE_NAME_STRING);
    }

    typeSystems.add(tsd);
    typeSystems.add(TypeSystemDescriptionFactory.createTypeSystemDescription());

    return CasCreationUtils.mergeTypeSystems(typeSystems);
}
 
Example 7
Source File: AgreementTestUtils.java    From webanno with Apache License 2.0 6 votes vote down vote up
public static TypeSystemDescription createMultiLinkWithRoleTestTypeSytem()
    throws Exception
{
    List<TypeSystemDescription> typeSystems = new ArrayList<>();

    TypeSystemDescription tsd = new TypeSystemDescription_impl();

    // Link type
    TypeDescription linkTD = tsd.addType(LINK_TYPE, "", CAS.TYPE_NAME_TOP);
    linkTD.addFeature("role", "", CAS.TYPE_NAME_STRING);
    linkTD.addFeature("target", "", Token.class.getName());

    // Link host
    TypeDescription hostTD = tsd.addType(HOST_TYPE, "", CAS.TYPE_NAME_ANNOTATION);
    hostTD.addFeature("links", "", CAS.TYPE_NAME_FS_ARRAY, linkTD.getName(), false);

    typeSystems.add(tsd);
    typeSystems.add(TypeSystemDescriptionFactory.createTypeSystemDescription());

    return CasCreationUtils.mergeTypeSystems(typeSystems);
}
 
Example 8
Source File: AgreementTestUtils.java    From webanno with Apache License 2.0 6 votes vote down vote up
public static TypeSystemDescription createMultiLinkWithRoleTestTypeSytem(String... aFeatures)
    throws Exception
{
    List<TypeSystemDescription> typeSystems = new ArrayList<>();

    TypeSystemDescription tsd = new TypeSystemDescription_impl();

    // Link type
    TypeDescription linkTD = tsd.addType(LINK_TYPE, "", CAS.TYPE_NAME_TOP);
    linkTD.addFeature("role", "", CAS.TYPE_NAME_STRING);
    linkTD.addFeature("target", "", Token.class.getName());

    // Link host
    TypeDescription hostTD = tsd.addType(HOST_TYPE, "", CAS.TYPE_NAME_ANNOTATION);
    hostTD.addFeature("links", "", CAS.TYPE_NAME_FS_ARRAY, linkTD.getName(), false);
    for (String feature : aFeatures) {
        hostTD.addFeature(feature, "", CAS.TYPE_NAME_STRING);
    }

    typeSystems.add(tsd);
    typeSystems.add(TypeSystemDescriptionFactory.createTypeSystemDescription());

    return CasCreationUtils.mergeTypeSystems(typeSystems);
}
 
Example 9
Source File: AgreementTestUtils.java    From webanno with Apache License 2.0 6 votes vote down vote up
public static TypeSystemDescription createMultiLinkWithRoleTestTypeSystem(String... aFeatures)
    throws Exception
{
    List<TypeSystemDescription> typeSystems = new ArrayList<>();

    TypeSystemDescription tsd = new TypeSystemDescription_impl();

    // Link type
    TypeDescription linkTD = tsd.addType(LINK_TYPE, "", CAS.TYPE_NAME_TOP);
    linkTD.addFeature("role", "", CAS.TYPE_NAME_STRING);
    linkTD.addFeature("target", "", CAS.TYPE_NAME_ANNOTATION);

    // Link host
    TypeDescription hostTD = tsd.addType(HOST_TYPE, "", CAS.TYPE_NAME_ANNOTATION);
    hostTD.addFeature("links", "", CAS.TYPE_NAME_FS_ARRAY, linkTD.getName(), false);
    for (String feature : aFeatures) {
        hostTD.addFeature(feature, "", CAS.TYPE_NAME_STRING);
    }

    typeSystems.add(tsd);
    typeSystems.add(TypeSystemDescriptionFactory.createTypeSystemDescription());

    return CasCreationUtils.mergeTypeSystems(typeSystems);
}
 
Example 10
Source File: MultiPageEditor.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Sets the merged type system description.
 *
 * @throws ResourceInitializationException the resource initialization exception
 */
public void setMergedTypeSystemDescription() throws ResourceInitializationException {
  mergedTypesAddingFeatures.clear();
  if (isAggregate())
    mergedTypeSystemDescription = mergeDelegateAnalysisEngineTypeSystems(
            (AnalysisEngineDescription) aeDescription.clone(), createResourceManager(),
            mergedTypesAddingFeatures);
  else {
    if (null == typeSystemDescription) {
      mergedTypeSystemDescription = null;
    } else {
      ResourceManager resourceManager = createResourceManager();
      Collection tsdc = new ArrayList(1);
      tsdc.add(typeSystemDescription.clone());
      // System.out.println("mergingTypeSystem 2"); //$NON-NLS-1$
      // long time = System.currentTimeMillis();
      mergedTypeSystemDescription = CasCreationUtils.mergeTypeSystems(tsdc, resourceManager,
              mergedTypesAddingFeatures);
      // System.out.println("Finished mergingTypeSystem 2; time= " + //$NON-NLS-1$
      // (System.currentTimeMillis() - time));
      setImportedTypeSystemDescription();
    }
  }
}
 
Example 11
Source File: WebAnnoTsv3WriterTestBase.java    From webanno with Apache License 2.0 5 votes vote down vote up
private static JCas makeJCas() throws UIMAException
{
    TypeSystemDescription global = TypeSystemDescriptionFactory.createTypeSystemDescription();
    TypeSystemDescription local = TypeSystemDescriptionFactory
            .createTypeSystemDescriptionFromPath(
                    "src/test/resources/desc/type/webannoTestTypes.xml");
   
    TypeSystemDescription merged = CasCreationUtils.mergeTypeSystems(asList(global, local));
    
    JCas jcas = JCasFactory.createJCas(merged);

    DocumentMetaData.create(jcas).setDocumentId("doc");
    
    return jcas;
}
 
Example 12
Source File: Tsv3XSerializerTest.java    From webanno with Apache License 2.0 5 votes vote down vote up
private JCas makeJCasOneSentence(String aText) throws UIMAException
{
    TypeSystemDescription global = TypeSystemDescriptionFactory.createTypeSystemDescription();
    TypeSystemDescription local = TypeSystemDescriptionFactory
            .createTypeSystemDescriptionFromPath(
                    "src/test/resources/desc/type/webannoTestTypes.xml");
   
    TypeSystemDescription merged = CasCreationUtils.mergeTypeSystems(asList(global, local));
    
    JCas jcas = JCasFactory.createJCas(merged);
    
    DocumentMetaData.create(jcas).setDocumentId("doc");
    
    TokenBuilder<Token, Sentence> tb = new TokenBuilder<>(Token.class,
            Sentence.class);
    tb.buildTokens(jcas, aText);
    
    // Remove the sentences generated by the token builder which treats the line break as a
    // sentence break
    for (Sentence s : select(jcas, Sentence.class)) {
        s.removeFromIndexes();
    }
    
    // Add a new sentence covering the whole text
    new Sentence(jcas, 0, jcas.getDocumentText().length()).addToIndexes();
    
    return jcas;
}
 
Example 13
Source File: CasDefinition.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
public CasDefinition(Collection<? extends ProcessingResourceMetaData> aMetaDataToMerge, ResourceManager aResourceManager)
        throws ResourceInitializationException {
  // extract TypeSystems, TypePriorities, and FsIndexes from metadata
  List<TypeSystemDescription> typeSystems = new ArrayList<>();
  List<TypePriorities> typePrioritiesList = new ArrayList<>();
  List<FsIndexCollection> fsIndexes = new ArrayList<>();
  Iterator<? extends ProcessingResourceMetaData> it = aMetaDataToMerge.iterator();
  while (it.hasNext()) {
    ProcessingResourceMetaData md = it.next();
    if (md.getTypeSystem() != null)
      typeSystems.add(md.getTypeSystem());
    if (md.getTypePriorities() != null)
      typePrioritiesList.add(md.getTypePriorities());
    if (md.getFsIndexCollection() != null)
      fsIndexes.add(md.getFsIndexCollection());
  }

  // merge TypePriorities and FsIndexes
  TypePriorities aggTypePriorities = CasCreationUtils.mergeTypePriorities(typePrioritiesList,
          aResourceManager);
  FsIndexCollection aggIndexColl = CasCreationUtils.mergeFsIndexes(fsIndexes, aResourceManager);
  TypeSystemDescription aggTypeDesc = CasCreationUtils.mergeTypeSystems(typeSystems,
          aResourceManager);

  this.typeSystemDescription = aggTypeDesc;
  this.typePriorities = aggTypePriorities;
  this.fsIndexDescriptions = aggIndexColl.getFsIndexes();
  this.resourceManager = aResourceManager;
}
 
Example 14
Source File: Jg.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Merge type system imports.
 *
 * @param tsd the tsd
 * @return the type system description
 * @throws ResourceInitializationException the resource initialization exception
 */
private TypeSystemDescription mergeTypeSystemImports(TypeSystemDescription tsd)
        throws ResourceInitializationException {
  Collection<TypeSystemDescription> tsdc = new ArrayList<>(1);
  tsdc.add((TypeSystemDescription) tsd.clone());
  mergedTypesAddingFeatures.clear();
  TypeSystemDescription mergedTsd = CasCreationUtils.mergeTypeSystems(tsdc,
          createResourceManager(), mergedTypesAddingFeatures);
  return mergedTsd;
}
 
Example 15
Source File: MultiPageEditor.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the cas.
 *
 * @param aAeDescription the a ae description
 * @param aPerformanceTuningSettings the a performance tuning settings
 * @param aResourceManager the a resource manager
 * @return the cas
 * @throws ResourceInitializationException the resource initialization exception
 */
public CAS createCas(AnalysisEngineDescription aAeDescription,
        Properties aPerformanceTuningSettings, ResourceManager aResourceManager)
        throws ResourceInitializationException {
  
  getMergeInput(aAeDescription, aResourceManager);

  // merge
  TypeSystemDescription aggTypeDesc = CasCreationUtils.mergeTypeSystems(typeSystemsToMerge, aResourceManager);
  TypePriorities aggTypePriorities = CasCreationUtils.mergeTypePriorities(typePrioritiesToMerge, aResourceManager);
  FsIndexCollection aggIndexColl = CasCreationUtils.mergeFsIndexes(fsIndexesToMerge, aResourceManager);

  return CasCreationUtils.createCas(aggTypeDesc, aggTypePriorities, aggIndexColl.getFsIndexes(),
          aPerformanceTuningSettings, aResourceManager);
}
 
Example 16
Source File: AggregateAnalysisEngine_impl.java    From uima-uimaj with Apache License 2.0 4 votes vote down vote up
/**
 * Does processing using the delegate AnalysisEngine metadata once it becomes available.
 * <p>
 * Specifically, sets this aggregate AE's Type System, Type Priorities, and FS Index Descriptions
 * equal to the result of merging the information from its delegate AEs.
 * 
 * @throws ResourceInitializationException
 *           if an error occurs
 */
protected void processDelegateAnalysisEngineMetaData() throws ResourceInitializationException {
  // set this aggregate AnalysisEngine's TypeSystem, TypePriorities, and FS
  // Index Descriptions to the result of merging the information from all
  // delegate AEs. (The aggregate AE may specify its own indexes or type
  // priorities but NOT its own types.)

  // first, create Collections of TypeSystems, TypePriorities, and Index Descriptions
  List<TypeSystemDescription> typeSystems = new ArrayList<>();
  List<TypePriorities> typePriorities = new ArrayList<>();
  List<FsIndexCollection> fsIndexCollections = new ArrayList<>();

  TypePriorities thisAEsTypePriorities = getAnalysisEngineMetaData().getTypePriorities();
  if (thisAEsTypePriorities != null) {
    typePriorities.add(thisAEsTypePriorities);
  }
  FsIndexCollection thisAEsIndexes = getAnalysisEngineMetaData().getFsIndexCollection();
  if (thisAEsIndexes != null) {
    fsIndexCollections.add(thisAEsIndexes);
  }

  // iterate over metadata for all components
  Iterator<ProcessingResourceMetaData> metadataIterator = _getComponentMetaData().values().iterator();
  while (metadataIterator.hasNext()) {
    ProcessingResourceMetaData md = metadataIterator.next();
    if (md.getTypeSystem() != null)
      typeSystems.add(md.getTypeSystem());
    if (md.getTypePriorities() != null)
      typePriorities.add(md.getTypePriorities());
    if (md.getFsIndexCollection() != null)
      fsIndexCollections.add(md.getFsIndexCollection());
  }

  // now do merge
  TypeSystemDescription aggTypeDesc = CasCreationUtils.mergeTypeSystems(typeSystems,
          getResourceManager());
  TypePriorities aggTypePriorities = CasCreationUtils.mergeTypePriorities(typePriorities,
          getResourceManager());
  FsIndexCollection aggIndexColl = CasCreationUtils.mergeFsIndexes(fsIndexCollections,
          getResourceManager());

  // assign results of merge to this aggregate AE's metadata
  AnalysisEngineMetaData aggregateMD = this.getAnalysisEngineMetaData();
  aggregateMD.setTypeSystem(aggTypeDesc);
  aggregateMD.setTypePriorities(aggTypePriorities);
  aggregateMD.setFsIndexCollection(aggIndexColl);

  // check for inconsistent operationalProperties between aggregate and delegates
  validateOperationalProperties();
}
 
Example 17
Source File: CasDiffTest.java    From webanno with Apache License 2.0 4 votes vote down vote up
@Test
    public void relationStackedSpansTest()
        throws Exception
    {
        TypeSystemDescription global = TypeSystemDescriptionFactory.createTypeSystemDescription();
        TypeSystemDescription local = TypeSystemDescriptionFactory
                .createTypeSystemDescriptionFromPath(
                        "src/test/resources/desc/type/webannoTestTypes.xml");
       
        TypeSystemDescription merged = CasCreationUtils.mergeTypeSystems(asList(global, local));

        TokenBuilder<Token, Sentence> tb = new TokenBuilder<>(Token.class,
                Sentence.class);
        
        JCas jcasA = JCasFactory.createJCas(merged);
        {
            CAS casA = jcasA.getCas();
            tb.buildTokens(jcasA, "This is a test .");
            
            List<Token> tokensA = new ArrayList<>(select(jcasA, Token.class));
            Token t1A = tokensA.get(0);
            Token t2A = tokensA.get(tokensA.size() - 1);
            
            NamedEntity govA = new NamedEntity(jcasA, t1A.getBegin(), t1A.getEnd());
            govA.addToIndexes();
            // Here we add a stacked named entity!
            new NamedEntity(jcasA, t1A.getBegin(), t1A.getEnd()).addToIndexes();
            
            NamedEntity depA =  new NamedEntity(jcasA, t2A.getBegin(), t2A.getEnd());
            depA.addToIndexes();
    
            Type relationTypeA = casA.getTypeSystem().getType("webanno.custom.Relation");
            AnnotationFS fs1A = casA.createAnnotation(relationTypeA, depA.getBegin(),
                    depA.getEnd());
            FSUtil.setFeature(fs1A, "Governor", govA);
            FSUtil.setFeature(fs1A, "Dependent", depA);
            FSUtil.setFeature(fs1A, "value", "REL");
            casA.addFsToIndexes(fs1A);
        }

        JCas jcasB = JCasFactory.createJCas(merged);
        {
            CAS casB = jcasB.getCas();
            tb.buildTokens(jcasB, "This is a test .");
            
            List<Token> tokensB = new ArrayList<>(select(jcasB, Token.class));
            Token t1B = tokensB.get(0);
            Token t2B = tokensB.get(tokensB.size() - 1);
            
            NamedEntity govB = new NamedEntity(jcasB, t1B.getBegin(), t1B.getEnd());
            govB.addToIndexes();
            NamedEntity depB =  new NamedEntity(jcasB, t2B.getBegin(), t2B.getEnd());
            depB.addToIndexes();
    
            Type relationTypeB = casB.getTypeSystem().getType("webanno.custom.Relation");
            AnnotationFS fs1B = casB.createAnnotation(relationTypeB, depB.getBegin(),
                    depB.getEnd());
            FSUtil.setFeature(fs1B, "Governor", govB);
            FSUtil.setFeature(fs1B, "Dependent", depB);
            FSUtil.setFeature(fs1B, "value", "REL");
            casB.addFsToIndexes(fs1B);
        }

        Map<String, List<CAS>> casByUser = new LinkedHashMap<>();
        casByUser.put("user1", asList(jcasA.getCas()));
        casByUser.put("user2", asList(jcasB.getCas()));

        List<? extends DiffAdapter> diffAdapters = asList(new RelationDiffAdapter(
                "webanno.custom.Relation", WebAnnoConst.FEAT_REL_TARGET,
                WebAnnoConst.FEAT_REL_SOURCE, "value"));

        CasDiff diff = doDiff(diffAdapters, LINK_TARGET_AS_LABEL, casByUser);
        DiffResult result = diff.toResult();
        
        // result.print(System.out);
        
        assertEquals(1, result.size());
        assertEquals(0, result.getDifferingConfigurationSets().size());
        assertEquals(0, result.getIncompleteConfigurationSets().size());
        
        // Todo: Agreement has moved to separate project - should create agreement test there
//        CodingAgreementResult agreement = AgreementUtils.getCohenKappaAgreement(diff,
//                "webanno.custom.Relation", "value", casByUser);
//
//        // Asserts
//        System.out.printf("Agreement: %s%n", agreement.toString());
//        AgreementUtils.dumpAgreementStudy(System.out, agreement);
//
//        assertEquals(1, agreement.getPluralitySets().size());
    }
 
Example 18
Source File: WebAnnoTsv3XReaderWriterRoundTripTest.java    From webanno with Apache License 2.0 4 votes vote down vote up
@Test
public void runTest() throws Exception
{
    TypeSystemDescription global = TypeSystemDescriptionFactory.createTypeSystemDescription();
    TypeSystemDescription local;
    if (new File(referenceFolder, "typesystem.xml").exists()) {
        local = TypeSystemDescriptionFactory.createTypeSystemDescriptionFromPath(
                new File(referenceFolder, "typesystem.xml").toString());
    }
    else {
        local = TypeSystemDescriptionFactory.createTypeSystemDescriptionFromPath(
                "src/test/resources/desc/type/webannoTestTypes.xml");
    }
   
    TypeSystemDescription merged = CasCreationUtils.mergeTypeSystems(asList(global, local));
    
    String targetFolder = "target/test-output/WebAnnoTsv3XReaderWriterRoundTripTest/"
            + referenceFolder.getName();
    
    CollectionReaderDescription reader = createReaderDescription(WebannoTsv3XReader.class,
            merged,
            WebannoTsv3XReader.PARAM_SOURCE_LOCATION, referenceFolder,
            WebannoTsv3XReader.PARAM_PATTERNS, "reference.tsv");
    
    AnalysisEngineDescription checker = createEngineDescription(
            DKProCoreConventionsChecker.class);
    
    AnalysisEngineDescription tsvWriter = createEngineDescription(WebannoTsv3XWriter.class,
            merged,
            WebannoTsv3XWriter.PARAM_TARGET_LOCATION, targetFolder,
            WebannoTsv3XWriter.PARAM_STRIP_EXTENSION, true,
            WebannoTsv3XWriter.PARAM_OVERWRITE, true);

    AnalysisEngineDescription xmiWriter = createEngineDescription(XmiWriter.class,
            merged,
            XmiWriter.PARAM_TARGET_LOCATION, targetFolder,
            XmiWriter.PARAM_STRIP_EXTENSION, true,
            XmiWriter.PARAM_OVERWRITE, true);

    SimplePipeline.runPipeline(reader, checker, tsvWriter, xmiWriter);
    
    String referenceTsv = FileUtils.readFileToString(new File(referenceFolder, "reference.tsv"),
            "UTF-8");

    String actualTsv = FileUtils.readFileToString(new File(targetFolder, "reference.tsv"),
            "UTF-8");

    //
    // The XMI files here are not compared semantically but using their serialization which
    // is subject to minor variations depending e.g. on the order in which annotation are
    // created in the CAS. Thus, this code is commented out and should only be used on a
    // case-by-case base to compare XMIs during development.
    //
    // String referenceXmi = FileUtils.readFileToString(new File(referenceFolder,
    // "reference.xmi"),
    // "UTF-8");
    //
    // String actualXmi = FileUtils.readFileToString(new File(targetFolder, "reference.xmi"),
    // "UTF-8");

    assumeFalse("This test is known to fail.", isKnownToFail(referenceFolder.getName()));
    assertEquals(referenceTsv, actualTsv);
    // assertEquals(referenceXmi, actualXmi);
}
 
Example 19
Source File: MultiPageEditor.java    From uima-uimaj with Apache License 2.0 3 votes vote down vote up
/**
 * Merge delegate analysis engine type systems.
 *
 * @param aAeDescription the a ae description
 * @param aResourceManager the a resource manager
 * @param aOutputMergedTypes the a output merged types
 * @return the type system description
 * @throws ResourceInitializationException the resource initialization exception
 */
private TypeSystemDescription mergeDelegateAnalysisEngineTypeSystems(
        AnalysisEngineDescription aAeDescription, ResourceManager aResourceManager,
        Map aOutputMergedTypes) throws ResourceInitializationException {
  
  getMergeInput(aAeDescription, aResourceManager);
  return CasCreationUtils.mergeTypeSystems(typeSystemsToMerge, aResourceManager, aOutputMergedTypes);
}