当前位置: 首页>>代码示例>>Java>>正文


Java DataResource类代码示例

本文整理汇总了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);
    }
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:20,代码来源:CachedSerializedDictionaryResource.java

示例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);
    }
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:24,代码来源:ConfigurableSerializedDictionaryResource.java

示例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);
	}
}
 
开发者ID:termsuite,项目名称:termsuite-core,代码行数:24,代码来源:YamlRuleSetResource.java

示例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();
}
 
开发者ID:termsuite,项目名称:termsuite-core,代码行数:19,代码来源:ManualSuffixDerivationDetecterSpec.java

示例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) { } } }
   */
}
 
开发者ID:NUNLP,项目名称:uima-components,代码行数:23,代码来源:DictionaryResource_impl.java

示例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);

}
 
开发者ID:NUNLP,项目名称:uima-components,代码行数:30,代码来源:DictionaryResource_impl.java

示例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;
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:14,代码来源:SharedDefaultWordformStore.java

示例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();
    }
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:10,代码来源:XmiFileTreeCorpusDAOResource.java

示例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);
    }
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:16,代码来源:DefaultPOSModelHolder.java

示例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);
    }
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:10,代码来源:GramModelResource.java

示例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);
	}
}
 
开发者ID:nantesnlp,项目名称:uima-chinese-segmenter,代码行数:9,代码来源:ChineseSegmentResource.java

示例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);
	}
}
 
开发者ID:nantesnlp,项目名称:uima-tokenizer,代码行数:10,代码来源:SegmentBankResource.java

示例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;
}
 
开发者ID:nantesnlp,项目名称:uima-tokenizer,代码行数:16,代码来源:Tests.java

示例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);
	}
}
 
开发者ID:nantesnlp,项目名称:uima-tokens-regex,代码行数:9,代码来源:RegexListResource.java

示例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));
	}
}
 
开发者ID:termsuite,项目名称:termsuite-core,代码行数:8,代码来源:MateModel.java


注:本文中的org.apache.uima.resource.DataResource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。