/** * Creates a TypeSystemDescription from descriptor names. * * @param descriptorNames * The fully qualified, Java-style, dotted descriptor names. * @return A TypeSystemDescription that includes the types from all of the specified files. */ public static TypeSystemDescription createTypeSystemDescription(String... descriptorNames) { TypeSystemDescription typeSystem = new TypeSystemDescription_impl(); List<Import> imports = new ArrayList<Import>(); for (String descriptorName : descriptorNames) { Import imp = new Import_impl(); imp.setName(descriptorName); imports.add(imp); } Import[] importArray = new Import[imports.size()]; typeSystem.setImports(imports.toArray(importArray)); return typeSystem; }
public synchronized void resolveImports(Collection<String> aAlreadyImportedTypeSystemURLs, ResourceManager aResourceManager) throws InvalidXMLException { List<TypeDescription> importedTypes = null; if (getImports().length != 0) { if (getSourceUrl() != null) { aAlreadyImportedTypeSystemURLs.add(getSourceUrl().toString()); Import[] imports = getImports(); for (int i = 0; i < imports.length; i++) { ((Import_impl) imports[i]).setSourceUrlIfNull(this.getSourceUrl()); aAlreadyImportedTypeSystemURLs.add(url.toString()); try { resolveImport(url, aAlreadyImportedTypeSystemURLs, importedTypes, aResourceManager); } catch (IOException e) { throw new InvalidXMLException(InvalidXMLException.IMPORT_FAILED_COULD_NOT_READ_FROM_URL, TypeDescription[] existingTypes = this.getTypes(); if (existingTypes == null) { this.setTypes(existingTypes = TypeDescription.EMPTY_TYPE_DESCRIPTIONS); newTypes[existingTypes.length + i] = importedTypes.get(i); this.setTypes(newTypes); this.setImports(Import.EMPTY_IMPORTS);
public synchronized void resolveImports(ResourceManager aResourceManager) throws InvalidXMLException { resolveImports((getImports().length == 0) ? null : new TreeSet<String>(), aResourceManager); }
/** * @see TypeSystemDescription#addType(String, String, String) */ public TypeDescription addType(String aTypeName, String aDescription, String aSupertypeName) { // create new type description TypeDescription newType = new TypeDescription_impl(aTypeName, aDescription, aSupertypeName); // add to array TypeDescription[] types = getTypes(); if (types == null) { setTypes(new TypeDescription[] { newType }); } else { TypeDescription[] newArray = new TypeDescription[types.length + 1]; System.arraycopy(types, 0, newArray, 0, types.length); newArray[types.length] = newType; setTypes(newArray); } return newType; }
/** * @see TypeSystemDescription#resolveImports() */ // allow these calls to be done multiple times on this same object, in different threads public synchronized void resolveImports() throws InvalidXMLException { if (getImports().length == 0) { resolveImports(null, null); } else { resolveImports(new TreeSet<String>(), UIMAFramework.newDefaultResourceManager()); } }
/** * Creates a TypeSystemDescription from a descriptor file * * @param descriptorURIs * The descriptor file paths. * @return A TypeSystemDescription that includes the types from all of the specified files. */ public static TypeSystemDescription createTypeSystemDescriptionFromPath(String... descriptorURIs) { TypeSystemDescription typeSystem = new TypeSystemDescription_impl(); List<Import> imports = new ArrayList<Import>(); for (String descriptorURI : descriptorURIs) { Import imp = new Import_impl(); imp.setLocation(descriptorURI); imports.add(imp); } Import[] importArray = new Import[imports.size()]; typeSystem.setImports(imports.toArray(importArray)); return typeSystem; }
@Override public TypeSystemDescription getProjectTypes(Project aProject) { // Create a new type system from scratch TypeSystemDescription tsd = new TypeSystemDescription_impl(); for (AnnotationLayer type : listAnnotationLayer(aProject)) { if (type.isBuiltIn()) { continue; } LayerSupport<?> layerSupport = layerSupportRegistry.getLayerSupport(type); layerSupport.generateTypes(tsd, type); } return tsd; }
@Override public TypeSystemDescription getProjectTypes(Project aProject) { // Create a new type system from scratch TypeSystemDescription tsd = new TypeSystemDescription_impl(); for (AnnotationLayer type : listAnnotationLayer(aProject)) { if (type.isBuiltIn()) { continue; } LayerSupport<?> layerSupport = layerSupportRegistry.getLayerSupport(type); layerSupport.generateTypes(tsd, type); } return tsd; }
@Override public boolean initialize(ResourceSpecifier aSpecifier, Map<String, Object> aAdditionalParams) throws ResourceInitializationException { if (!super.initialize(aSpecifier, aAdditionalParams)) return false; TypeSystemDescription typeSystem = new TypeSystemDescription_impl(); AutoAdapters adapters = injector.getInstance(AutoAdapters.class); adapters.addToTypeSystem(typeSystem); AnalysisEngineMetaData_impl md = new AnalysisEngineMetaData_impl(); md.setTypeSystem(typeSystem); getCasManager().addMetaData(md); return true; }
} else if(selected.getName().endsWith(".xmi")){ try { TypeSystemDescription tsd = new TypeSystemDescription_impl(); CAS dummyCas = CasCreationUtils.createCas(tsd, null, null); XmiCasDeserializer.deserialize(new FileInputStream(selected), dummyCas, true);
TypeSystemDescription typeSystem = new TypeSystemDescription_impl(); List<Import> imports = new ArrayList<Import>(); boolean contextDelta = false;
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); }
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); }
try { CAS cas = null; cas = CasCreationUtils.createCas(new TypeSystemDescription_impl(), null, null); cas.setDocumentLanguage("en"); if (inf != null) {
public static TypeSystemDescription createCustomTypeSystem(String aType, String aTypeName, List<String> aFeatures, String aAttacheType) throws Exception { TypeSystemDescription type = new TypeSystemDescription_impl(); if (aType.equals(SPAN_TYPE)) { TypeDescription td = type.addType(aTypeName, "", CAS.TYPE_NAME_ANNOTATION); for (String feature : aFeatures) { td.addFeature(feature, "", CAS.TYPE_NAME_STRING); } } else if (aType.equals(RELATION_TYPE)) { TypeDescription td = type.addType(aTypeName, "", CAS.TYPE_NAME_ANNOTATION); td.addFeature(WebAnnoConst.FEAT_REL_TARGET, "", aAttacheType); td.addFeature(WebAnnoConst.FEAT_REL_SOURCE, "", aAttacheType); for (String feature : aFeatures) { td.addFeature(feature, "", "uima.cas.String"); } } return type; }
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); }
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); }
public static TypeSystemDescription createCustomTypeSystem(String aType, String aTypeName, List<String> aFeatures, String aAttacheType) throws Exception { TypeSystemDescription type = new TypeSystemDescription_impl(); if (aType.equals(SPAN_TYPE)) { TypeDescription td = type.addType(aTypeName, "", CAS.TYPE_NAME_ANNOTATION); for (String feature : aFeatures) { td.addFeature(feature, "", CAS.TYPE_NAME_STRING); } } else if (aType.equals(RELATION_TYPE)) { TypeDescription td = type.addType(aTypeName, "", CAS.TYPE_NAME_ANNOTATION); td.addFeature(WebAnnoConst.FEAT_REL_TARGET, "", aAttacheType); td.addFeature(WebAnnoConst.FEAT_REL_SOURCE, "", aAttacheType); for (String feature : aFeatures) { td.addFeature(feature, "", "uima.cas.String"); } } return type; }