@Override public Set<String> getEngines() throws ChainException { return Collections.singleton(engine.getName()); }
@Override public Set<String> getEngines() throws ChainException { return Collections.singleton(engine.getName()); }
/** * Used in {@link #canEnhance(ContentItem)} to check if a {@link ContentItem} * should be processed based on the language configuration of this engine. * @param engine the {@link EnhancementEngine} calling this method * @param languageConfiguration the language configuration * @param language the language * @param exception <code>false</code> id used in {@link #canEnhance(ContentItem)} * and <code>true</code> when called from {@link #computeEnhancements(ContentItem)} * @return the state * @throws IllegalStateException if exception is <code>true</code> and the * language is not configured as beeing processed. */ public static boolean isLangaugeConfigured(EnhancementEngine engine, LanguageConfiguration languageConfiguration, String language, boolean exception){ boolean state = languageConfiguration.isLanguage(language); if(!state && exception){ throw new IllegalStateException("Language "+language+" is not included " + "by the LanguageConfiguration of this engine (name "+ engine.getName() + "). As this is also checked in canEnhancer this may indicate an Bug in the " + "used EnhancementJobManager!"); } else { return state; } }
/** * Used in {@link #canEnhance(ContentItem)} to check if a {@link ContentItem} * should be processed based on the language configuration of this engine. * @param engine the {@link EnhancementEngine} calling this method * @param languageConfiguration the language configuration * @param language the language * @param exception <code>false</code> id used in {@link #canEnhance(ContentItem)} * and <code>true</code> when called from {@link #computeEnhancements(ContentItem)} * @return the state * @throws IllegalStateException if exception is <code>true</code> and the * language is not configured as beeing processed. */ public static boolean isLangaugeConfigured(EnhancementEngine engine, LanguageConfiguration languageConfiguration, String language, boolean exception){ boolean state = languageConfiguration.isLanguage(language); if(!state && exception){ throw new IllegalStateException("Language "+language+" is not included " + "by the LanguageConfiguration of this engine (name "+ engine.getName() + "). As this is also checked in canEnhancer this may indicate an Bug in the " + "used EnhancementJobManager!"); } else { return state; } }
/** * Getter for the language of the content * @param ci the ContentItem * @param exception <code>false</code> id used in {@link #canEnhance(ContentItem)} * and <code>true</code> when called from {@link #computeEnhancements(ContentItem)} * @return the AnalysedText or <code>null</code> if not found. * @throws IllegalStateException if exception is <code>true</code> and the * language could not be retrieved from the parsed {@link ContentItem}. */ public static String getLanguage(EnhancementEngine engine, ContentItem ci, boolean exception) { String language = EnhancementEngineHelper.getLanguage(ci); if(language != null) { return language; } if(exception){ throw new IllegalStateException("Unable to retrieve the detected language for ContentItem " + ci+". As this is also checked in canEnhancer this may indicate an Bug in the " + "used EnhancementJobManager!"); } else { log.warn("The Enhancement Engine '{} (impl: {})' CAN NOT enhance " + "ContentItem {} because the langauge of " + "this ContentItem is unknown. Users might want to add a " + "Language Identification EnhancementEngine to the current " + "EnhancementChain!", new Object[]{engine.getName(), engine.getClass().getSimpleName(),ci}); return null; } } /**
/** * Getter for the language of the content * @param ci the ContentItem * @param exception <code>false</code> id used in {@link #canEnhance(ContentItem)} * and <code>true</code> when called from {@link #computeEnhancements(ContentItem)} * @return the AnalysedText or <code>null</code> if not found. * @throws IllegalStateException if exception is <code>true</code> and the * language could not be retrieved from the parsed {@link ContentItem}. */ public static String getLanguage(EnhancementEngine engine, ContentItem ci, boolean exception) { String language = EnhancementEngineHelper.getLanguage(ci); if(language != null) { return language; } if(exception){ throw new IllegalStateException("Unable to retrieve the detected language for ContentItem " + ci+". As this is also checked in canEnhancer this may indicate an Bug in the " + "used EnhancementJobManager!"); } else { log.warn("The Enhancement Engine '{} (impl: {})' CAN NOT enhance " + "ContentItem {} because the langauge of " + "this ContentItem is unknown. Users might want to add a " + "Language Identification EnhancementEngine to the current " + "EnhancementChain!", new Object[]{engine.getName(), engine.getClass().getSimpleName(),ci}); return null; } } /**
+ "creates the AnalysedText ContentPart such as the " + "POSTaggingEngine (o.a.stanbol.enhancer.engines.opennlp.pos)!", new Object[]{engine.getName(), engine.getClass().getSimpleName(),ci}); return null;
+ "creates the AnalysedText ContentPart such as the " + "POSTaggingEngine (o.a.stanbol.enhancer.engines.opennlp.pos)!", new Object[]{engine.getName(), engine.getClass().getSimpleName(),ci}); return null;
+ "that supports the conversion of '{}' files to plain text " + "to the current EnhancementChain!", new Object[]{engine.getName(), engine.getClass().getSimpleName(),ci,ci.getMimeType()}); return null;
+ "that supports the conversion of '{}' files to plain text " + "to the current EnhancementChain!", new Object[]{engine.getName(), engine.getClass().getSimpleName(),ci,ci.getMimeType()}); return null;
+ "that supports the conversion of '{}' files to plain text " + "to the current EnhancementChain!", new Object[]{engine.getName(), engine.getClass().getSimpleName(),ci,ci.getMimeType()}); return null;
/** * Creates a {@link Chain} for a single {@link EnhancementEngine} including * optional chain scoped enhancement properties * @param engine the engine * @param enhProps chain scoped enhancement properties or <code>null</code> * if none. * @since 0.12.1 */ public SingleEngineChain(EnhancementEngine engine, Map<String,Object> enhProps){ if(engine == null){ throw new IllegalArgumentException("The parsed EnhancementEngine MUST NOT be NULL!"); } this.engine = engine; this.name = engine.getName()+"Chain"; Graph graph = new IndexedGraph(); writeExecutionNode(graph, createExecutionPlan(graph, name, null), engine.getName(), false, null, enhProps); executionPlan = graph.getImmutableGraph(); }
/** * Creates a {@link Chain} for a single {@link EnhancementEngine} including * optional chain scoped enhancement properties * @param engine the engine * @param enhProps chain scoped enhancement properties or <code>null</code> * if none. * @since 0.12.1 */ public SingleEngineChain(EnhancementEngine engine, Map<String,Object> enhProps){ if(engine == null){ throw new IllegalArgumentException("The parsed EnhancementEngine MUST NOT be NULL!"); } this.engine = engine; this.name = engine.getName()+"Chain"; Graph graph = new IndexedGraph(); writeExecutionNode(graph, createExecutionPlan(graph, name, null), engine.getName(), false, null, enhProps); executionPlan = graph.getImmutableGraph(); }
/** * Create the RDF data for the currently active EnhancementEngines.<p> * Note the the parsed rootUrl MUST already consider offsets configured * for the Stanbol RESTful service. When called from within a * {@link BaseStanbolResource} the following code segment should be used:<p> * <code><pre> * String rootUrl = uriInfo.getBaseUriBuilder().path(getRootUrl()).build().toString(); * </pre></code> * @param activeEngines the active enhancement engines as {@link Entry entries}. * @param graph the RDF graph to add the triples * @param rootUrl the root URL used by the current request * @see EnhancerUtils#buildEnginesMap(EnhancementEngineManager) */ public static void addActiveEngines(Iterable<Entry<ServiceReference,EnhancementEngine>> activeEngines,Graph graph, String rootUrl) { IRI enhancerResource = new IRI(rootUrl+"enhancer"); graph.add(new TripleImpl(enhancerResource, RDF.type, Enhancer.ENHANCER)); for(Entry<ServiceReference,EnhancementEngine> entry : activeEngines){ IRI engineResource = new IRI(rootUrl+"enhancer/engine/"+entry.getValue().getName()); graph.add(new TripleImpl(enhancerResource, Enhancer.HAS_ENGINE, engineResource)); graph.add(new TripleImpl(engineResource, RDF.type, ENHANCEMENT_ENGINE)); graph.add(new TripleImpl(engineResource, RDFS.label, new PlainLiteralImpl(entry.getValue().getName()))); } }
/** * Create the RDF data for the currently active EnhancementEngines.<p> * Note the the parsed rootUrl MUST already consider offsets configured * for the Stanbol RESTful service. When called from within a * {@link BaseStanbolResource} the following code segment should be used:<p> * <code><pre> * String rootUrl = uriInfo.getBaseUriBuilder().path(getRootUrl()).build().toString(); * </pre></code> * @param activeEngines the active enhancement engines as {@link Entry entries}. * @param graph the RDF graph to add the triples * @param rootUrl the root URL used by the current request * @see EnhancerUtils#buildEnginesMap(EnhancementEngineManager) */ public static void addActiveEngines(Iterable<Entry<ServiceReference,EnhancementEngine>> activeEngines,Graph graph, String rootUrl) { IRI enhancerResource = new IRI(rootUrl+"enhancer"); graph.add(new TripleImpl(enhancerResource, RDF.type, Enhancer.ENHANCER)); for(Entry<ServiceReference,EnhancementEngine> entry : activeEngines){ IRI engineResource = new IRI(rootUrl+"enhancer/engine/"+entry.getValue().getName()); graph.add(new TripleImpl(enhancerResource, Enhancer.HAS_ENGINE, engineResource)); graph.add(new TripleImpl(engineResource, RDF.type, ENHANCEMENT_ENGINE)); graph.add(new TripleImpl(engineResource, RDFS.label, new PlainLiteralImpl(entry.getValue().getName()))); } }