/** * @throws EngineException */ private void checkRESTfulNlpAnalysisService() throws EngineException { if(!initRESTfulNlpAnalysisService()){ throw new EngineException("The configured RESTful NLP Analysis Service is " + "currently not available (url: '"+analysisServiceUrl+"')"); } } /**
/** * Retrieves the configured {@link Site} which holds the NER properties. * * @return * @throws EngineException */ private Site getReferencedSite() throws EngineException { Site site = null; if (referencedSiteID != null) { // lookup the referenced site site = siteManager.getSite(referencedSiteID); // ensure that it is present if (site == null) { String msg = String .format("Unable to enhance because Referenced Site %s is currently not active!", referencedSiteID); throw new EngineException(msg); } } return site; } }
model = readModel(in, "application/rdf+xml"); } catch (UnsupportedEncodingException e) { throw new EngineException(e.getMessage(), e); } catch (IOException e) { throw new EngineException(e.getMessage(), e);
model = openNLP.getModel(TokenizerModel.class, modelName, null); } catch (Exception e) { throw new EngineException("Error while loading the configured OpenNLP " + "TokenizerModel '"+modelName+"' ("+getClass().getSimpleName()+" | name=" + getName() + ")!",e); throw new EngineException("The configured OpenNLP TokenizerModel '" + modelName +" is not available' ("+getClass().getSimpleName() + " | name=" + getName() + ")!");
public static String getPlainContent(ContentItem ci) throws EngineException { Entry<IRI, 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!"); } try { return ContentItemHelper.getText(contentPart.getValue()); } catch (IOException e) { throw new EngineException("Unable to read plain text content form" + "contentpart "+contentPart.getKey()+" of ContentItem " + ci.getUri()); } } /**
private void addLemmatizationEnhancement(ContentItem ci, String text, String language, Graph g) throws EngineException { Language lang = new Language(language); // clerezza language for PlainLiterals String lemmatizedContents; try { lemmatizedContents = this.client.lemmatizeContents(text, language); } catch (IOException e) { throw new EngineException("Error while calling the CELI Lemmatizer" + " service (configured URL: " + serviceURL + ")!", e); } catch (SOAPException e) { throw new EngineException("Error wile encoding/decoding the request/" + "response to the CELI lemmatizer service!", e); } // get a write lock before writing the enhancements ci.getLock().writeLock().lock(); try { IRI textEnhancement = EnhancementEngineHelper.createTextEnhancement(ci, this); g.add(new TripleImpl(textEnhancement, CeliLemmatizerEnhancementEngine.hasLemmaForm, new PlainLiteralImpl(lemmatizedContents, lang))); } finally { ci.getLock().writeLock().unlock(); } }
} catch (ResourceInitializationException ex) { logger.error("Error initializing UIMA AE", ex); throw new EngineException("Error initializing UIMA AE", ex); } catch (AnalysisEngineProcessException ex) { logger.error("Error running UIMA AE", ex); throw new EngineException("Error running UIMA AE", ex);
log.trace(" enhance ci {}",ci.getUri()); if(isOfflineMode() && !entitySearcher.supportsOfflineMode()){ throw new EngineException(this,ci,"Offline mode is not supported by the used EntitySearcher!",null); } catch (EntitySearcherException e) { log.error("Unable to link Entities with "+entityLinker,e); throw new EngineException(this, ci, "Unable to link Entities with "+entityLinker, e);
log.trace(" enhance ci {}",ci.getUri()); if(isOfflineMode() && !entitySearcher.supportsOfflineMode()){ throw new EngineException(this,ci,"Offline mode is not supported by the used EntitySearcher!",null); } catch (EntitySearcherException e) { log.error("Unable to link Entities with "+entityLinker,e); throw new EngineException(this, ci, "Unable to link Entities with "+entityLinker, e);
throw new EngineException(this, ci, "No LabelTokenizer available!",null); } catch (EntitySearcherException e) { log.error("Unable to link Entities with "+entityLinker,e); throw new EngineException(this, ci, "Unable to link Entities with "+entityLinker, e);
searchStrings, state.getSentence().getLanguage(),config.getDefaultLanguage()); } catch (RuntimeException e) { throw new EngineException(e.getMessage(),e);
results.addAll(zemanta.enhance(text)); } catch (IOException e) { throw new EngineException("Unable to get Enhancement from remote Zemanta Service",e);
@Override public void computeEnhancements(ContentItem ci) throws EngineException { InputStream in = ci.getBlob().getStream(); XMPPacketScanner scanner = new XMPPacketScanner(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { scanner.parse(in, baos); } catch (IOException e) { throw new EngineException(e); } byte[] bytes = baos.toByteArray(); if (bytes.length > 0) { Graph model = new IndexedGraph(); parser.parse(model, new ByteArrayInputStream(bytes), "application/rdf+xml"); GraphNode gn = new GraphNode( new IRI("http://relative-uri.fake/"), model); gn.replaceWith(ci.getUri()); ci.getLock().writeLock().lock(); try { LOG.info("Model: {}",model); ci.getMetadata().addAll(model); } finally { ci.getLock().writeLock().unlock(); } } }
@Override public void computeEnhancements(ContentItem ci) throws EngineException { HtmlExtractor extractor = new HtmlExtractor(htmlExtractorRegistry, htmlParser); Graph model = new SimpleGraph(); ci.getLock().readLock().lock(); try { extractor.extract(ci.getUri().getUnicodeString(), ci.getStream(),null, ci.getMimeType(), model); } catch (ExtractorException e) { throw new EngineException("Error while processing ContentItem " + ci.getUri()+" with HtmlExtractor",e); } finally { ci.getLock().readLock().unlock(); } ClerezzaRDFUtils.urifyBlankNodes(model); // make the model single rooted if (singleRootRdf) { ClerezzaRDFUtils.makeConnected(model,ci.getUri(),new IRI(NIE_NS+"contains")); } //add the extracted triples to the metadata of the ContentItem ci.getLock().writeLock().lock(); try { LOG.info("Model: {}",model); ci.getMetadata().addAll(model); model = null; } finally { ci.getLock().writeLock().unlock(); } }
throw new EngineException("Error while calling the CELI language" +" identifier service (configured URL: " +serviceURL+")!",e); } catch (SOAPException e) { throw new EngineException("Error wile encoding/decoding the request/" +"response to the CELI language identifier service!",e);
+"CharSequenceReader of AnalyzedText for ContentItem %s",ci.getUri()); log.error(message,e); throw new EngineException(this, ci, message, e);
@Override public void computeEnhancements(ContentItem ci) throws EngineException { HtmlExtractor extractor = new HtmlExtractor(htmlExtractorRegistry, htmlParser); Graph model = new SimpleGraph(); ci.getLock().readLock().lock(); try { extractor.extract(ci.getUri().getUnicodeString(), ci.getStream(),null, ci.getMimeType(), model); } catch (ExtractorException e) { throw new EngineException("Error while processing ContentItem " + ci.getUri()+" with HtmlExtractor",e); } finally { ci.getLock().readLock().unlock(); } ClerezzaRDFUtils.urifyBlankNodes(model); // make the model single rooted if (singleRootRdf) { ClerezzaRDFUtils.makeConnected(model,ci.getUri(),new IRI(NIE_NS+"contains")); } //add the extracted triples to the metadata of the ContentItem ci.getLock().writeLock().lock(); try { LOG.info("Model: {}",model); ci.getMetadata().addAll(model); model = null; } finally { ci.getLock().writeLock().unlock(); } }
Exception e = pae.getException(); if(e instanceof ClientProtocolException) { throw new EngineException(this, ci, "Exception while executing Request " + "on RESTful Language Identification Service at "+serviceUrl, e); } else if(e instanceof IOException) { throw new EngineException(this, ci, "Exception while executing Request " + "on RESTful Language Identification Service at "+serviceUrl, e); } else {
terms = this.client.performMorfologicalAnalysis(text, language); } catch (IOException e) { throw new EngineException("Error while calling the CELI Lemmatizer" + " service (configured URL: " + serviceURL + ")!", e); } catch (SOAPException e) { throw new EngineException("Error wile encoding/decoding the request/" + "response to the CELI lemmatizer service!", e);
throw new EngineException("Error while calling the CELI NER (Named Entity Recognition)" +" service (configured URL: " +serviceURL+")!",e); } catch (SOAPException e) { throw new EngineException("Error wile encoding/decoding the request/" +"response to the CELI NER (Named Entity Recognition) service!",e);