/*
Copyright 2009
Ubiquitous Knowledge Processing (UKP) Lab
Technische Universitaet Darmstadt
All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package org.uimafit.factory;
import static org.apache.uima.UIMAFramework.getResourceSpecifierFactory;
import static org.uimafit.factory.ConfigurationParameterFactory.canParameterBeSet;
import static org.uimafit.factory.ConfigurationParameterFactory.createConfigurationData;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.commons.lang.ArrayUtils;
import org.apache.uima.analysis_engine.AnalysisEngineDescription;
import org.apache.uima.collection.CollectionReaderDescription;
import org.apache.uima.resource.ConfigurableDataResourceSpecifier;
import org.apache.uima.resource.CustomResourceSpecifier;
import org.apache.uima.resource.DataResource;
import org.apache.uima.resource.ExternalResourceDependency;
import org.apache.uima.resource.ExternalResourceDescription;
import org.apache.uima.resource.FileResourceSpecifier;
import org.apache.uima.resource.Parameter;
import org.apache.uima.resource.ParameterizedDataResource;
import org.apache.uima.resource.Resource;
import org.apache.uima.resource.ResourceCreationSpecifier;
import org.apache.uima.resource.ResourceManager;
import org.apache.uima.resource.ResourceSpecifier;
import org.apache.uima.resource.SharedResourceObject;
import org.apache.uima.resource.impl.ConfigurableDataResourceSpecifier_impl;
import org.apache.uima.resource.impl.ExternalResourceDependency_impl;
import org.apache.uima.resource.impl.ExternalResourceDescription_impl;
import org.apache.uima.resource.impl.FileResourceSpecifier_impl;
import org.apache.uima.resource.impl.Parameter_impl;
import org.apache.uima.resource.metadata.ExternalResourceBinding;
import org.apache.uima.resource.metadata.ResourceManagerConfiguration;
import org.apache.uima.resource.metadata.impl.ExternalResourceBinding_impl;
import org.apache.uima.resource.metadata.impl.ResourceManagerConfiguration_impl;
import org.apache.uima.resource.metadata.impl.ResourceMetaData_impl;
import org.apache.uima.util.InvalidXMLException;
import org.uimafit.descriptor.ExternalResource;
import org.uimafit.factory.ConfigurationParameterFactory.ConfigurationData;
import org.uimafit.util.ExtendedExternalResourceDescription_impl;
/**
* Helper methods for external resources.
*
* @author Richard Eckart de Castilho
*/
public final class ExternalResourceFactory {
public static final String PARAM_RESOURCE_NAME = "__UIMAFIT_RESOURCE_NAME__";
/**
* Used to separate resource name from key for nested resource.
*/
public static final String PREFIX_SEPARATOR = "##";
/**
* Counter used to create unique resource names.
*/
private final static AtomicLong DISAMBIGUATOR = new AtomicLong();
private ExternalResourceFactory() {
// This class is not meant to be instantiated
}
/**
* Create an external resource description for a custom resource. This is intended to
* be used together with ....
*
* @param aInterface
* the interface the resource should implement.
* @param aParams
* parameters passed to the resource when it is created.
* @return the description.
* @see CustomResourceSpecifier
*/
public static ExternalResourceDescription createExternalResourceDescription(
Class<? extends Resource> aInterface, Object... aParams) {
return createExternalResourceDescription(uniqueResourceKey(aInterface.getName()), aInterface, aParams);
}
/**
* Create an external resource description for a custom resource.
*
* @param aName
* the name of the resource (the key).
* @param aInterface
* the interface the resource should implement.
* @param aParams
* parameters passed to the resource when it is created.
* @return the description.
* @see CustomResourceSpecifier
*/
public static ExternalResourceDescription createExternalResourceDescription(final String aName,
Class<? extends Resource> aInterface, Object... aParams) {
ConfigurationParameterFactory.ensureParametersComeInPairs(aParams);
// Extract ExternalResourceDescriptions from configurationData
List<ExternalResourceBinding> bindings = new ArrayList<ExternalResourceBinding>();
List<ExternalResourceDescription> descs = new ArrayList<ExternalResourceDescription>();
for (Entry<String, ExternalResourceDescription> res : extractExternalResourceParameters(
aParams).entrySet()) {
bindings.add(createExternalResourceBinding(res.getKey(), res.getValue()));
descs.add(res.getValue());
}
List<Parameter> params = new ArrayList<Parameter>();
if (aParams != null) {
for (int i = 0; i < aParams.length / 2; i++) {
if (aParams[i * 2 + 1] instanceof ExternalResourceDescription) {
continue;
}
Parameter param = new Parameter_impl();
param.setName((String) aParams[i * 2]);
param.setValue((String) aParams[i * 2 + 1]);
params.add(param);
}
}
CustomResourceSpecifier spec = getResourceSpecifierFactory().createCustomResourceSpecifier();
spec.setResourceClassName(aInterface.getName());
spec.setParameters(params.toArray(new Parameter[params.size()]));
ExtendedExternalResourceDescription_impl extRes = new ExtendedExternalResourceDescription_impl();
extRes.setName(aName);
extRes.setResourceSpecifier(spec);
extRes.setExternalResourceBindings(bindings);
extRes.setExternalResources(descs);
return extRes;
}
/**
* Create an external resource description for a {@link SharedResourceObject}.
*
* @param aInterface
* the interface the resource should implement.
* @param aUrl
* the URL from which the resource is initialized.
* @param aParams
* parameters passed to the resource when it is created.
* @return the description.
* @see ConfigurableDataResourceSpecifier
* @see SharedResourceObject
*/
public static ExternalResourceDescription createExternalResourceDescription(
Class<? extends SharedResourceObject> aInterface, String aUrl, Object... aParams) {
return createExternalResourceDescription(uniqueResourceKey(aInterface.getName()),
aInterface, aUrl, aParams);
}
/**
* Create an external resource description for a {@link SharedResourceObject}.
*
* @param aInterface
* the interface the resource should implement.
* @param aUrl
* the URL from which the resource is initialized.
* @param aParams
* parameters passed to the resource when it is created.
* @return the description.
* @see ConfigurableDataResourceSpecifier
* @see SharedResourceObject
*/
public static ExternalResourceDescription createExternalResourceDescription(
Class<? extends SharedResourceObject> aInterface, URL aUrl, Object... aParams) {
return createExternalResourceDescription(uniqueResourceKey(aInterface.getName()),
aInterface, aUrl.toString(), aParams);
}
/**
* Create an external resource description for a {@link SharedResourceObject}.
*
* @param aInterface
* the interface the resource should implement.
* @param aFile
* the file from which the resource is initialized.
* @param aParams
* parameters passed to the resource when it is created.
* @return the
没有合适的资源?快使用搜索试试~ 我知道了~
Java的UIMA注解类 uimaFIT.7z
共269个文件
java:196个
xml:30个
wiki:17个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 127 浏览量
2022-07-06
10:31:35
上传
评论
收藏 4.64MB 7Z 举报
温馨提示
Java的UIMA注解类 uimaFIT.7z
资源推荐
资源详情
资源评论
收起资源包目录
Java的UIMA注解类 uimaFIT.7z (269个子文件)
CHANGES 11KB
CHANGES 39B
.DS_Store 6KB
test.xmi.dump 1KB
JCasBuilderTest.dump 1KB
1.html 127B
4.1.1.html 119B
2.1.html 110B
3.html 22B
2.2.html 0B
ExternalResourceFactory.java 36KB
CasUtil.java 30KB
AnalysisEngineFactory.java 28KB
JCasUtil.java 23KB
ConfigurationParameterFactory.java 22KB
AnalysisEngineFactoryTest.java 21KB
JCasUtilTest.java 21KB
ConfigurationParameterInitializerTest.java 20KB
FSCollectionFactory.java 20KB
ConfigurationParameterInitializer.java 17KB
CollectionReaderFactory.java 14KB
AnalysisEngineFactoryExternalResourceTest.java 14KB
ExternalResourceFactoryTest.java 14KB
ParameterizedAE.java 11KB
ExternalResourceInitializer.java 11KB
LoggingTest.java 10KB
FsIndexFactory.java 10KB
TokenBuilder.java 9KB
ExtendedLogger.java 9KB
TypeSystemDescriptionFactory.java 9KB
CASDumpWriter.java 9KB
AggregateBuilderTest.java 9KB
AggregateBuilder.java 8KB
TokenBuilderTest.java 8KB
SimplePipeline.java 8KB
AggregateWithReaderTest.java 8KB
ConfigurationParameterFactoryTest.java 8KB
FSCollectionFactoryTest.java 7KB
SimpleNamedResourceManager.java 7KB
CpeBuilder.java 7KB
ResourceCreationSpecifierFactory.java 7KB
UimaMeetingAnnotator.java 7KB
ViewCreatorAnnotatorTest.java 6KB
CasUtilTest.java 6KB
XWriterTest.java 6KB
ExternalResourceExample.java 6KB
JCasFactory.java 6KB
ContainmentIndex.java 6KB
XmiTest.java 6KB
XWriter.java 5KB
SpringContextResourceManager.java 5KB
RunExperiment.java 5KB
InitializableFactoryTest.java 5KB
FsIndexFactoryTest.java 5KB
UimaFactoryInjectionTest.java 5KB
FlowControllerFactory.java 5KB
Meeting_Type.java 5KB
Meeting.java 5KB
ConfigurationParameter.java 4KB
CollectionReaderFactoryTest.java 4KB
RoomNumberAnnotator1Test.java 4KB
UimaAcronymAnnotator.java 4KB
JCasIterable.java 4KB
SingleFileXReader.java 4KB
SingleFileXReaderTest.java 4KB
CpePipeline.java 4KB
JCasGenPomFriendly.java 3KB
ReflectionUtil.java 3KB
ViewTextCopierAnnotatorTest.java 3KB
FlowControllerFactoryExternalResourceTest.java 3KB
JCasBuilder.java 3KB
RoomNumberAnnotator.java 3KB
CapabilityFactory.java 3KB
Evaluator.java 3KB
OperationalProperties.java 3KB
SpringContextResourceManagerTest.java 3KB
SimplePipelineTest.java 3KB
CollectionReaderFactoryExternalResourceTest.java 3KB
GoldTagger.java 3KB
DisableLoggingTest.java 3KB
ViewCreatorAnnotator.java 3KB
ExamplesTestBase.java 3KB
DateTimeAnnotation_Type.java 3KB
RoomNumberAnnotator.java 3KB
ComponentTestBase.java 3KB
ViewTextCopierAnnotator.java 3KB
JCasCollectionReader_ImplBase.java 3KB
ExternalResourceConfiguratorTest.java 3KB
Initializable.java 3KB
ReversableTestFlowController.java 3KB
UimaAcronym_Type.java 3KB
LocaleUtil.java 3KB
SofaCapability.java 3KB
LicenseTest.java 3KB
UimaContextFactoryTest.java 3KB
RoomNumber_Type.java 3KB
SofaMappingFactory.java 3KB
LicenseTest.java 3KB
ContainmentIndexTest.java 3KB
LicenseTest.java 3KB
共 269 条
- 1
- 2
- 3
资源评论
BryanDing
- 粉丝: 299
- 资源: 5584
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功