Examples of UIMAExecutor


Examples of org.apache.clerezza.uima.utils.UIMAExecutor

  public Graph extractPersons(@FormParam("uri") String uriString) {
    if (uriString == null || uriString.length() == 0)
      throw new WebApplicationException(Response.status(
              Response.Status.BAD_REQUEST).entity(new StringBuilder("No URI specified").toString()).build());

    UIMAExecutor executor = UIMAExecutorFactory.getInstance().createUIMAExecutor();
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put(OUTPUTGRAPH, uriString);
    try {
      URL url = URI.create(uriString).toURL();
      String text = IOUtils.toString(url.openConnection().getInputStream());
      executor.analyzeDocument(text, new XMLInputSource(getClass().getResource(PATH)), parameters);
    } catch (Exception e) {
      throw new WebApplicationException(Response.status(
              Response.Status.INTERNAL_SERVER_ERROR).entity(new StringBuilder("Failed UIMA execution on URI ").
              append(uriString).append(" due to \n").append(e.getLocalizedMessage()).toString()).build());
    }
View Full Code Here

Examples of org.apache.clerezza.uima.utils.UIMAExecutor

  public Graph tagUri(@QueryParam("uri") String uri, @QueryParam("key") String key) {
    if (uri == null || uri.length() == 0)
      throw new WebApplicationException(Response.status(
              Response.Status.BAD_REQUEST).entity(new StringBuilder("No URI specified").toString()).build());

    UIMAExecutor executor = UIMAExecutorFactory.getInstance().createUIMAExecutor();
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put(OUTPUTGRAPH, uri);
    parameters.put(ALCHEMYKEY, key);
    try {
      executor.analyzeDocument(uri, new XMLInputSource(getClass().getResource(PATH)), parameters);
    } catch (Exception e) {
      throw new WebApplicationException(Response.status(
              Response.Status.INTERNAL_SERVER_ERROR).entity(new StringBuilder("Failed UIMA execution on URI ").
              append(uri).append(" due to \n").append(e.getLocalizedMessage()).toString()).build());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.