public static TypeSystemDescription getInternalTypeSystem() { return createTypeSystemDescription( "de/tudarmstadt/ukp/clarin/webanno/api/type/webanno-internal"); }
public void initTypeSystem(String... descriptorNames) { try { compiler.addClassPath(); boolean nameIsPath = false; for (int i = 0; i < descriptorNames.length; i++) { if (descriptorNames[i].endsWith(".xml")) { nameIsPath = true; descriptorNames[i] = new File(descriptorNames[i]).getAbsolutePath(); } } if (nameIsPath) { typeSystemDescription = TypeSystemDescriptionFactory.createTypeSystemDescriptionFromPath(descriptorNames); } else { typeSystemDescription = TypeSystemDescriptionFactory.createTypeSystemDescription(descriptorNames); } JCas jCas = CasCreationUtils.createCas(typeSystemDescription, null, null).getJCas(); customTypes = new HashSet<>(); } catch (Exception e) { e.printStackTrace(); System.exit(1); } }
public static CollectionReader getCollectionReader(List<File> items) throws ResourceInitializationException { String[] paths = new String[items.size()]; for (int i = 0; i < paths.length; ++i) { paths[i] = items.get(i).getPath(); } return CollectionReaderFactory.createReader( XMIReader.class, TypeSystemDescriptionFactory.createTypeSystemDescriptionFromPath(), XMIReader.PARAM_FILES, paths); }
/** * Creates a {@link TypeSystemDescription} from all type descriptions that can be found via the * default import pattern or via the {@code META-INF/org.apache.uima.fit/types.txt} files in the * classpath. * * @return the auto-scanned type system. * @throws ResourceInitializationException * if the collected type system descriptions cannot be merged. */ public static TypeSystemDescription createTypeSystemDescription() throws ResourceInitializationException { List<TypeSystemDescription> tsdList = new ArrayList<TypeSystemDescription>(); for (String location : scanTypeDescriptors()) { try { XMLInputSource xmlInputType1 = new XMLInputSource(location); tsdList.add(getXMLParser().parseTypeSystemDescription(xmlInputType1)); LogFactory.getLog(TypeSystemDescription.class).debug( "Detected type system at [" + location + "]"); } catch (IOException e) { throw new ResourceInitializationException(e); } catch (InvalidXMLException e) { LogFactory.getLog(TypeSystemDescription.class).warn( "[" + location + "] is not a type file. Ignoring.", e); } } ResourceManager resMgr = ResourceManagerFactory.newResourceManager(); return mergeTypeSystems(tsdList, resMgr); }
/** * Creates a new JCas from type system descriptor files. No auto-detection for type priorities, or * indexes is performed. * * @param typeSystemDescriptorPaths * paths to type system descriptor files * @return a new JCas * @throws UIMAException * if the JCas could not be initialized */ public static JCas createJCasFromPath(String... typeSystemDescriptorPaths) throws UIMAException { return createJCas(createTypeSystemDescriptionFromPath(typeSystemDescriptorPaths)); }
/** Return the singleton TypeSystemDescription instance */ public static TypeSystemDescription getTypeSystemDescriptionInstance() throws ResourceInitializationException { if (tsd == null) { tsd = TypeSystemDescriptionFactory.createTypeSystemDescription(); } return tsd; } }
private TypeSystem createTypeSystem() throws IOException, UIMAException { TypeSystemDescription tsDesc = null; if (typeSystemDescPaths != null && typeSystemDescPaths.length > 0) { tsDesc = createTypeSystemDescriptionFromPath(typeSystemDescPaths); } if (typeSystemDescNames != null && typeSystemDescNames.length > 0) { TypeSystemDescription tsDescFromNames = createTypeSystemDescription( typeSystemDescNames); if (tsDesc != null) { tsDesc = mergeTypeSystems(asList(tsDesc, tsDescFromNames)); } else { tsDesc = tsDescFromNames; } } if (tsDesc == null) { throw new IllegalStateException( "Type system description paths or names were not specified!"); } CAS dumbCas = CasCreationUtils.createCas(tsDesc, null, null); TypeSystem typeSystem = dumbCas.getTypeSystem(); // printAllTypes(); return typeSystem; }
public static CollectionReader getCollectionReader(List<File> items) throws ResourceInitializationException { String[] paths = new String[items.size()]; for (int i = 0; i < paths.length; ++i) { paths[i] = items.get(i).getPath(); } return CollectionReaderFactory.createReader( XMIReader.class, TypeSystemDescriptionFactory.createTypeSystemDescriptionFromPath(), XMIReader.PARAM_FILES, paths); }
@Override public TypeSystemDescription getTypeSystem() throws ResourceInitializationException { return createTypeSystemDescription(); } }
typeSystemDescription = TypeSystemDescriptionFactory.createTypeSystemDescription(); TypeSystemDescriptionFactory.createTypeSystemDescriptionFromPath(), XMIReader.PARAM_FILES, paths);
@Override public CollectionReader getCollectionReader(List<File> items) throws ResourceInitializationException { String[] paths = new String[items.size()]; for (int i = 0; i < paths.length; ++i) { paths[i] = items.get(i).getPath(); } return CollectionReaderFactory.createReader( XMIReader.class, TypeSystemDescriptionFactory.createTypeSystemDescriptionFromPath(), XMIReader.PARAM_FILES, paths); }
/** Return the singleton TypeSystemDescription instance */ public static TypeSystemDescription getTypeSystemDescriptionInstance() throws ResourceInitializationException { if (tsd == null) { tsd = TypeSystemDescriptionFactory.createTypeSystemDescription(); } return tsd; } }
typeSystemDescription = TypeSystemDescriptionFactory.createTypeSystemDescription(); TypeSystemDescriptionFactory.createTypeSystemDescriptionFromPath(), XMIReader.PARAM_FILES, paths);
@Override public CollectionReader getCollectionReader(List<File> items) throws ResourceInitializationException { String[] paths = new String[items.size()]; for (int i = 0; i < paths.length; ++i) { paths[i] = items.get(i).getPath(); } return CollectionReaderFactory.createReader( XMIReader.class, TypeSystemDescriptionFactory.createTypeSystemDescriptionFromPath(), XMIReader.PARAM_FILES, paths); }
public static TypeSystemDescription getInternalTypeSystem() { return createTypeSystemDescription( "de/tudarmstadt/ukp/clarin/webanno/api/type/webanno-internal"); }
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; }
public static void main(String[] args) throws CmdLineException, UIMAException, IOException { Options options = new Options(); CmdLineParser parser = new CmdLineParser(options); parser.parseArgument(args); List<File> paths = new ArrayList<>(); for(String dataDirname : options.dataDirectories.split(":")){ File dataDir = new File(dataDirname.trim()); File[] domainFiles = dataDir.listFiles(new java.io.FileFilter() { @Override public boolean accept(File pathname) { return pathname.getName().endsWith(".xmi"); } }); paths.addAll(Arrays.asList(domainFiles)); } CollectionReaderDescription reader = CollectionReaderFactory.createReaderDescription( XMIReader.class, TypeSystemDescriptionFactory.createTypeSystemDescriptionFromPath(), XMIReader.PARAM_FILES, paths); AnalysisEngineDescription aed = getPipeline(options, options.dataDirectories); SimplePipeline.runPipeline(reader, aed); }
/** New instance */ public OwlSchemaFactory(String namespace, TypeSystem typeSystem, List<String> ignoreProperties) throws ResourceInitializationException { this.namespace = namespace; this.typeSystem = typeSystem; this.ignoreProperties = ignoreProperties; descriptions = TypeSystemDescriptionFactory.createTypeSystemDescription(); }
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; } }
parser.parseArgument(args); TypeSystemDescription typeSystem = TypeSystemDescriptionFactory.createTypeSystemDescriptionFromPath("../../../ctakes-type-system/src/main/resources/org/apache/ctakes/typesystem/types/TypeSystem.xml");