本文整理汇总了Java中org.apache.uima.resource.DataResource类的典型用法代码示例。如果您正苦于以下问题:Java DataResource类的具体用法?Java DataResource怎么用?Java DataResource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DataResource类属于org.apache.uima.resource包,在下文中一共展示了DataResource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: load
import org.apache.uima.resource.DataResource; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void load(DataResource dr) throws ResourceInitializationException {
if (this.dict != null) {
throw new IllegalStateException(
"Repeated SharedResourceObjectInvocation#load invocation");
}
URL resUrl = dr.getUrl();
try {
CachedDictionaryDeserializer deser = CachedDictionaryDeserializer.getInstance();
GetDictionaryResult deserResult = deser.getDictionary(resUrl, dr.getInputStream());
this.cacheKey = deserResult.cacheKey;
this.dict = deserResult.dictionary;
} catch (Exception e) {
throw new ResourceInitializationException(e);
}
}
示例2: load
import org.apache.uima.resource.DataResource; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void load(DataResource dr) throws ResourceInitializationException {
ConfigurationParameterInitializer.initialize(this, dr);
try {
dict = DictionaryDeserializer.from(dr.getInputStream(), String.valueOf(dr.getUrl()));
if (wfPredictorClassName != null) {
@SuppressWarnings("unchecked")
Class<? extends WordformPredictor> wfPredictorClass = (Class<? extends WordformPredictor>)
Class.forName(wfPredictorClassName);
WordformPredictor wfPredictor = makePredictor(wfPredictorClass);
((MorphDictionaryImpl) dict).setWfPredictor(wfPredictor);
log.info("{} was set in deserialized MorphDictionary",
wfPredictor.getClass().getSimpleName());
} else {
log.info("A wordform predictor has not been set in deserialized MorphDictionary");
}
} catch (Exception e) {
throw new ResourceInitializationException(e);
}
}
示例3: load
import org.apache.uima.resource.DataResource; //导入依赖的package包/类
@Override
public void load(DataResource aData) throws ResourceInitializationException {
InputStream inputStream = null;
InputStreamReader reader = null;
StringWriter writer = null;
try {
inputStream = aData.getInputStream();
writer = new StringWriter();
reader = new InputStreamReader(inputStream, Charset.forName("UTF-8"));
IOUtils.copy(reader, writer);
// set the adapter
ruleSet = YamlRuleSetIO.fromYaml(writer.toString());
} catch (IOException e) {
LOGGER.error("Could not load the yaml variant rules resource dur to IOException");
throw new ResourceInitializationException(e);
} finally {
IOUtils.closeQuietly(inputStream);
IOUtils.closeQuietly(reader);
IOUtils.closeQuietly(writer);
}
}
示例4: set
import org.apache.uima.resource.DataResource; //导入依赖的package包/类
@Before
public void set() throws Exception {
IndexedCorpus corpus = TermSuiteFactory.createIndexedCorpus(Lang.EN, "");
this.termino = corpus.getTerminology();
DataResource dataReosurce = Mockito.mock(DataResource.class);
Mockito.when(dataReosurce.getInputStream())
.thenReturn(new FileInputStream("src/test/resources/fr/univnantes/termsuite/test/resources/suffix-derivation-exceptions.txt"));
MultimapFlatResource derivationExceptions = new MultimapFlatResource();
derivationExceptions.load(dataReosurce);
populateTermino(new TermFactory(termino));
EngineRunner engine = UnitTests.createEngineRunner(
corpus,
ManualSuffixDerivationDetecter.class,
UnitTests.mockResourceModule().bind(
ResourceType.SUFFIX_DERIVATION_EXCEPTIONS, derivationExceptions));
engine.run();
}
示例5: load
import org.apache.uima.resource.DataResource; //导入依赖的package包/类
public void load(DataResource data) throws ResourceInitializationException {
// InputStream dictStream = null;
try {
Logger logger = new Logger("Dictionary Resource Loader", data.getLogger());
dictLoader = new DictLoader(logger, this, data);
/*
* At least for now, while info from the AnnotatorContext is not available here, must delay
* loading until able to access this info
*
* //open input stream to data dictStream = data.getInputStream ();
*
* dictLoader = new DictLoader (data.getLogger (), this); dictLoader.setDictionary
* (dictStream, NumOfInitialDictEntries);
*/
} catch (Exception e) {
throw new ResourceInitializationException(e);
}
/*
* finally { if (dictStream != null) { try { dictStream.close (); } catch (IOException e) { } } }
*/
}
示例6: DictLoader
import org.apache.uima.resource.DataResource; //导入依赖的package包/类
/**
* Create a dictionary loader.
*
* @param The
* UIMA logger.
*
* @throws Exception
* if XML parser cannot be created.
*/
public DictLoader(Logger log, DictionaryResource dict, DataResource data) throws Exception {
this.setLogger(log);
this.dict = dict;
this.dataResource = data;
// create parser
try {
if (XMLParserName != null) {
parser = XMLReaderFactory.createXMLReader(XMLParserName);
} else {
parser = XMLReaderFactory.createXMLReader();
}
} catch (Exception e) {
log.logError("Unable to instantiate dictionary parser (" + ((XMLParserName==null) ? "default XML parser" : XMLParserName) + ")");
throw (e);
}
parser.setContentHandler(this);
parser.setErrorHandler(this);
}
示例7: load
import org.apache.uima.resource.DataResource; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void load(DataResource dr) throws ResourceInitializationException {
DefaultWordformStore<TagType> ws;
try {
ws = (DefaultWordformStore<TagType>) SerializationUtils.deserialize(
new BufferedInputStream(dr.getInputStream()));
} catch (IOException e) {
throw new ResourceInitializationException(e);
}
this.strKeyMap = ws.strKeyMap;
this.metadataMap = ws.metadataMap;
}
示例8: load
import org.apache.uima.resource.DataResource; //导入依赖的package包/类
@Override
public void load(DataResource aData) throws ResourceInitializationException {
try {
corpusDAO = new XmiFileTreeCorpusDAO(aData.getUri().toString());
} catch (URISyntaxException e) {
e.printStackTrace();
throw new ResourceInitializationException();
}
}
示例9: load
import org.apache.uima.resource.DataResource; //导入依赖的package包/类
@Override
public void load(DataResource dr) throws ResourceInitializationException {
if (model != null) {
throw new IllegalStateException();
}
InputStream is = null;
try {
is = dr.getInputStream();
model = new POSModel(is);
} catch (IOException e) {
throw new IllegalStateException(e);
} finally {
IOUtils.closeQuietly(is);
}
}
示例10: load
import org.apache.uima.resource.DataResource; //导入依赖的package包/类
@Override
public void load(DataResource dr) throws ResourceInitializationException {
try {
gramModel = GramModelDeserializer
.from(dr.getInputStream(), String.valueOf(dr.getUrl()));
} catch (Exception e) {
throw new ResourceInitializationException(e);
}
}
示例11: load
import org.apache.uima.resource.DataResource; //导入依赖的package包/类
@Override
public void load(DataResource data) throws ResourceInitializationException {
try {
this.load(data.getInputStream());
} catch (IOException e) {
throw new ResourceInitializationException(e);
}
}
示例12: load
import org.apache.uima.resource.DataResource; //导入依赖的package包/类
@Override
public void load(DataResource data) throws ResourceInitializationException {
try {
this.load(data.getInputStream());
} catch (Exception e) {
UIMAFramework.getLogger().log(Level.INFO, "Error load SegmentBankResource: " + data.getUri());
throw new ResourceInitializationException(e);
}
}
示例13: getLexer
import org.apache.uima.resource.DataResource; //导入依赖的package包/类
public static Lexer getLexer() throws IOException, FileNotFoundException, ResourceInitializationException,
NoSuchFieldException, IllegalAccessException {
Lexer lexer = new Lexer();
SegmentBankResource segmentBankResource = new SegmentBankResource();
DataResource data = Mockito.mock(DataResource.class);
Mockito.when(data.getInputStream()).thenReturn(new FileInputStream(Tests.FRENCH_BANK.toString()));
segmentBankResource.load(data);
Field typeField = Lexer.class.getDeclaredField("type");
typeField.setAccessible(true);
typeField.set(lexer, "fr.univnantes.termsuite.types.WordAnnotation");
Field bankField = Lexer.class.getDeclaredField("bank");
bankField.setAccessible(true);
bankField.set(lexer, segmentBankResource);
return lexer;
}
示例14: load
import org.apache.uima.resource.DataResource; //导入依赖的package包/类
@Override
public void load(DataResource aData) throws ResourceInitializationException {
try {
regexList = TokensRegex.parseRegexList(aData.getUrl());
} catch (Exception e) {
throw new ResourceInitializationException(e);
}
}
示例15: load
import org.apache.uima.resource.DataResource; //导入依赖的package包/类
@Override
public void load(DataResource aData) throws ResourceInitializationException {
String url = aData.getUri().toString().replaceFirst("file:", "");
if(mateEngine.get() == null) {
mateEngine.set(instanciate(url));
}
}