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


Java Blob类代码示例

本文整理汇总了Java中org.apache.stanbol.enhancer.servicesapi.Blob的典型用法代码示例。如果您正苦于以下问题:Java Blob类的具体用法?Java Blob怎么用?Java Blob使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Blob类属于org.apache.stanbol.enhancer.servicesapi包,在下文中一共展示了Blob类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testDefaultEnhancements

import org.apache.stanbol.enhancer.servicesapi.Blob; //导入依赖的package包/类
@Test 
public void testDefaultEnhancements() throws EngineException, IOException, ParseException {
	
    //engine = new SpeechToTextEngine(ciFactory, MP);
    
    log.info(">>> Default Model Sphinix Testing WAV  <<<");
    ContentItem ci = createContentItem("temp.wav", "audio/wav1");
    assertFalse(engine.canEnhance(ci) == CANNOT_ENHANCE);
    //System.out.println("##################################################"+ci.getMetadata());
    System.out.println("##### Engine open ");
    engine.computeEnhancements(ci);
    System.out.println("##### Engine Close");
    Entry<UriRef,Blob> contentPart = ContentItemHelper.getBlob(ci, singleton("text/plain"));
    //	String text = ContentItemHelper.getText(contentPart.getValue());
    //System.out.println("##################################################"+ci.getMetadata());
    
    assertNotNull(contentPart);
    Blob plainTextBlob = contentPart.getValue();
    //log.info("Recongised String: {}",ContentItemHelper.getText(plainTextBlob));
    assertNotNull(plainTextBlob);        
}
 
开发者ID:sumansaurabh,项目名称:SpeechToTextEngine,代码行数:22,代码来源:SpeechToTextEngineTest.java

示例2: testCustomEnhancements

import org.apache.stanbol.enhancer.servicesapi.Blob; //导入依赖的package包/类
@Test 
   public void testCustomEnhancements() throws EngineException, IOException, ParseException {
       //engine = new SpeechToTextEngine(ciFactory, MP);
       log.info(">>> Custom Model Sphinix Testing WAV  <<<");
       ContentItem ci = createContentItem("temp.wav", "audio/wav");
       assertFalse(engine.canEnhance(ci) == CANNOT_ENHANCE);
       //engine.config.setCustomLangModel("en-us.lm.dmp");
       //engine.config.setCustomDictModel("en-cmu.dict");
       String acousticResource[]={"feat.params", "mdef", "means", "mixture_weights", "noisedict", "transition_matrices", "variances","feature_transform"};
	for(String resourceName: acousticResource) {
		//engine.config.setCustomAcousticModel(resourceName);
	}
//	SphinxConfig.CUSTOM_MODEL_AVAILABLE=true;
       //System.out.println("##################################################"+ci.getMetadata());
       engine.computeEnhancements(ci);
       Entry<UriRef,Blob> contentPart = ContentItemHelper.getBlob(ci, singleton("text/plain"));
       //	String text = ContentItemHelper.getText(contentPart.getValue());
       //System.out.println("##################################################"+ci.getMetadata());
       assertNotNull(contentPart);
       Blob plainTextBlob = contentPart.getValue();
       assertNotNull(plainTextBlob);        
   }
 
开发者ID:sumansaurabh,项目名称:SpeechToTextEngine,代码行数:23,代码来源:SpeechToTextEngineTest.java

示例3: getInputText

import org.apache.stanbol.enhancer.servicesapi.Blob; //导入依赖的package包/类
/**
 * Extracts text from the content item.
 *
 * @param ci
 * @return
 * @throws IOException
 */
public static String getInputText(ContentItem ci) throws IOException {
    Map.Entry<UriRef, Blob> contentPart = ContentItemHelper.getBlob(ci, SUPPORTED_MIMTYPES);
    if (contentPart == null) {
        throw new IllegalStateException("No ContentPart with Mimetype '" + TEXT_PLAIN_MIMETYPE
                + "' found for ContentItem "
                + ci.getUri() + ": This is also checked in the canEnhance method! -> This "
                + "indicated an Bug in the implementation of the " + "EnhancementJobManager!");
    }

    final String text = ContentItemHelper.getText(contentPart.getValue());
    if (text.trim().length() == 0) {
        throw new IllegalArgumentException(
                "No text contained in ContentPart {" + contentPart.getKey() +
                "} of ContentItem {" +
                ci.getUri() + "}"
        );
    }
    return text;
}
 
开发者ID:michelemostarda,项目名称:machinelinking-stanbol-enhancement-engine,代码行数:27,代码来源:Util.java

示例4: testAnalysis

import org.apache.stanbol.enhancer.servicesapi.Blob; //导入依赖的package包/类
@Test
   public void testAnalysis() throws IOException {
       long sum = 0;
       long min = Long.MAX_VALUE;
       long max = 0;
       for(Entry<String,Blob> example : examples.entrySet()){
           long start = System.currentTimeMillis();
           AnalysedText at = analyzer.analyse("en",example.getValue());
           long dur = System.currentTimeMillis() - start;
           if(dur < min){
               min = dur;
           }
           if(dur > max){
               max = dur;
           }
           sum = sum + dur;
           log.info(" > completed {} in {}ms", example.getKey(), dur);
           validateAnalysedText(at.getSpan(), at);
           sentimentAnalysisTest( at);
       }
       log.info(" completed {} tests in {}sec (avg: {}ms, min: {}ms, max: {}ms)",new Object[]{
               examples.size(),Math.round(sum/100d)/10f, Math.round(sum*10/(double)examples.size())/10f, min, max});
}
 
开发者ID:westei,项目名称:stanbol-stanfordnlp,代码行数:24,代码来源:TestStanfordNlpAnalyser.java

示例5: readFrom

import org.apache.stanbol.enhancer.servicesapi.Blob; //导入依赖的package包/类
@Override
public Blob readFrom(Class<Blob> type, Type genericType, Annotation[] annotations, MediaType mediaType,
        MultivaluedMap<String,String> httpHeaders, InputStream entityStream) throws IOException,
        WebApplicationException {
    ContentItemFactory cif = getContentItemFactory();
    return cif.createBlob(new StreamSource(entityStream,mediaType.toString()));
}
 
开发者ID:westei,项目名称:stanbol-talismane,代码行数:8,代码来源:BlobReader.java

示例6: testAnalysis

import org.apache.stanbol.enhancer.servicesapi.Blob; //导入依赖的package包/类
@Test
   public void testAnalysis() throws IOException {
       for(Entry<String,Blob> example : examples.entrySet()){
           AnalysedText at = analyzer.analyse(example.getValue());
           validateAnalysedText(at.getSpan(), at);
       }
}
 
开发者ID:westei,项目名称:stanbol-talismane,代码行数:8,代码来源:TestTalismaneAnalyser.java

示例7: testConcurrentAnalyses

import org.apache.stanbol.enhancer.servicesapi.Blob; //导入依赖的package包/类
@Test
public void testConcurrentAnalyses() throws IOException, InterruptedException, ExecutionException{
    //warm up
    log.info("Start concurrent analyses test");
    log.info("  ... warm up");
    for(Entry<String,Blob> example : examples.entrySet()){
        analyzer.analyse(example.getValue());
    }

    //performance test
    long start = System.currentTimeMillis();
    int concurrentRequests = 3;
    ExecutorService executor = Executors.newFixedThreadPool(concurrentRequests);
    int iterations = 100;
    log.info("  ... start test with {} iterations", iterations);
    List<Future<?>> tasks = new ArrayList<Future<?>>(iterations);
    long[] times = new long[iterations];
    Iterator<Blob> texts = examples.values().iterator();
    for(int i=0; i < iterations;i++){
        if(!texts.hasNext()){
            texts = examples.values().iterator();
        }
        tasks.add(executor.submit(new AnalyzerRequest(i, times, analyzer, texts.next())));
    }
    for(Future<?> task : tasks){ //wait for completion of all tasks
        task.get();
    }
    long duration = System.currentTimeMillis()-start;
    log.info("Processed {} texts",iterations);
    log.info("  > time       : {}ms",duration);
    log.info("  > average    : {}ms",(duration)/(double)iterations);
    long sumTime = 0;
    for(int i=0;i<times.length;i++){
        sumTime = sumTime+times[i];
    }
    log.info("  > processing : {}ms",sumTime);
    float concurrency = sumTime/(float)duration;
    log.info("  > concurrency: {} / {}%",concurrency, concurrency*100/concurrentRequests);
}
 
开发者ID:westei,项目名称:stanbol-talismane,代码行数:40,代码来源:TestTalismaneAnalyser.java

示例8: prepareContentItem

import org.apache.stanbol.enhancer.servicesapi.Blob; //导入依赖的package包/类
private ContentItem prepareContentItem(String text) throws IOException {
    final ContentItem ci = ciFactory.createContentItem(new StringSource(text));
    assertNotNull(ci);
    Entry<UriRef, Blob> textContentPart = ContentItemHelper.getBlob(
            ci, Collections.singleton("text/plain")
    );
    assertNotNull(textContentPart);
    return ci;
}
 
开发者ID:michelemostarda,项目名称:machinelinking-stanbol-enhancement-engine,代码行数:10,代码来源:MLAnnotateEnhancementEngineTest.java

示例9: testFrAnalysis

import org.apache.stanbol.enhancer.servicesapi.Blob; //导入依赖的package包/类
@Test
public void testFrAnalysis() throws IOException {
    log.info("init French Analyzer Pipeline");
    StanfordNlpAnalyzer analyzer = new StanfordNlpAnalyzer(executorService, null);
    LangPipeline pipeline = new LangPipeline(FR_TEST_CONFIG);
    analyzer.setPipeline(pipeline.getLanguage(), pipeline);
    log.info(" ... initialised");
    for(Entry<String,Blob> example : frExamples.entrySet()){
        AnalysedText at = analyzer.analyse("fr",example.getValue());
        validateAnalysedText(at.getSpan(), at, tagSetRegistry.getPosTagSet("fr"));
    }
}
 
开发者ID:westei,项目名称:stanbol-stanfordnlp,代码行数:13,代码来源:TestNonEnglishConfig.java

示例10: testArAnalysis

import org.apache.stanbol.enhancer.servicesapi.Blob; //导入依赖的package包/类
@Test
public void testArAnalysis() throws IOException {
    log.info("init Arabic Analyzer Pipeline");
    StanfordNlpAnalyzer analyzer = new StanfordNlpAnalyzer(executorService, null);
    LangPipeline pipeline = new LangPipeline(AR_TEST_CONFIG);
    analyzer.setPipeline(pipeline.getLanguage(), pipeline);
    log.info(" ... initialised");
    for(Entry<String,Blob> example : arExamples.entrySet()){
        AnalysedText at = analyzer.analyse("ar",example.getValue());
        validateAnalysedText(at.getSpan(), at, tagSetRegistry.getPosTagSet("ar"));
    }
}
 
开发者ID:westei,项目名称:stanbol-stanfordnlp,代码行数:13,代码来源:TestNonEnglishConfig.java

示例11: testZhAnalysis

import org.apache.stanbol.enhancer.servicesapi.Blob; //导入依赖的package包/类
@Test
public void testZhAnalysis() throws IOException {
    log.info("init Chinese Analyzer Pipeline");
    StanfordNlpAnalyzer analyzer = new StanfordNlpAnalyzer(executorService, null);
    LangPipeline pipeline = new LangPipeline(ZH_TEST_CONFIG);
    analyzer.setPipeline(pipeline.getLanguage(), pipeline);
    log.info(" ... initialised");
    for(Entry<String,Blob> example : zhExamples.entrySet()){
        AnalysedText at = analyzer.analyse("zh",example.getValue());
        validateAnalysedText(at.getSpan(), at, tagSetRegistry.getPosTagSet("zh"));
    }
}
 
开发者ID:westei,项目名称:stanbol-stanfordnlp,代码行数:13,代码来源:TestNonEnglishConfig.java

示例12: testConcurrentAnalyses

import org.apache.stanbol.enhancer.servicesapi.Blob; //导入依赖的package包/类
@Test
public void testConcurrentAnalyses() throws IOException, InterruptedException, ExecutionException{
    //warm up
    log.info("Start concurrent analyses test (iterating over {} test documents)", examples.size());
    log.info("  ... warm up");
    for(Entry<String,Blob> example : examples.entrySet()){
        analyzer.analyse("en",example.getValue());
    }

    //performance test
    long start = System.currentTimeMillis();
    int concurrentRequests = ANALYZER_THREADS;
    ExecutorService executor = Executors.newFixedThreadPool(concurrentRequests);
    int iterations = 100;
    log.info("  ... start test with {} iterations", iterations);
    List<Future<?>> tasks = new ArrayList<Future<?>>(iterations);
    long[] times = new long[iterations];
    Iterator<Blob> texts = examples.values().iterator();
    for(int i=0; i < iterations;i++){
        if(!texts.hasNext()){
            texts = examples.values().iterator();
        }
        tasks.add(executor.submit(new AnalyzerRequest(i, times, analyzer, texts.next())));
    }
    for(Future<?> task : tasks){ //wait for completion of all tasks
        task.get();
    }
    long duration = System.currentTimeMillis()-start;
    log.info("Processed {} texts",iterations);
    log.info("  > time       : {}ms",duration);
    log.info("  > average    : {}ms",(duration)/(double)iterations);
    long sumTime = 0;
    for(int i=0;i<times.length;i++){
        sumTime = sumTime+times[i];
    }
    log.info("  > processing : {}ms",sumTime);
    float concurrency = sumTime/(float)duration;
    log.info("  > concurrency: {} / {}%",concurrency, concurrency*100/concurrentRequests);
    log.info(analyzer.getPipeline("en").timingInformation());
}
 
开发者ID:westei,项目名称:stanbol-stanfordnlp,代码行数:41,代码来源:TestStanfordNlpAnalyser.java

示例13: isReadable

import org.apache.stanbol.enhancer.servicesapi.Blob; //导入依赖的package包/类
@Override
public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
    return type.isAssignableFrom(Blob.class);
}
 
开发者ID:westei,项目名称:stanbol-talismane,代码行数:5,代码来源:BlobReader.java

示例14: AnalyzerRequest

import org.apache.stanbol.enhancer.servicesapi.Blob; //导入依赖的package包/类
private AnalyzerRequest(int index, long[] times, TalismaneAnalyzer ta, Blob blob){
    this.index = index;
    this.times = times;
    this.blob = blob;
    this.ta = ta;
}
 
开发者ID:westei,项目名称:stanbol-talismane,代码行数:7,代码来源:TestTalismaneAnalyser.java

示例15: AnalyzerRequest

import org.apache.stanbol.enhancer.servicesapi.Blob; //导入依赖的package包/类
private AnalyzerRequest(int index, long[] times, StanfordNlpAnalyzer ta, Blob blob){
    this.index = index;
    this.times = times;
    this.blob = blob;
    this.ta = ta;
}
 
开发者ID:westei,项目名称:stanbol-stanfordnlp,代码行数:7,代码来源:TestNonEnglishConfig.java


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