/** * This method fires off a request to the server. Upon returning, it calls the provided * callback method. * * @param annotations The input annotations to process * @param numThreads The number of threads to run on. IGNORED in this class. * @param callback A function to be called when an annotation finishes. */ @Override public void annotate(final Iterable<Annotation> annotations, int numThreads, final Consumer<Annotation> callback){ for (Annotation annotation : annotations) { annotate(annotation, callback); } }
@Override public void annotate(Annotation annotation) { client.annotate(annotation); }
/** * Runs the entire pipeline on the content of the given text passed in. * @param text The text to process * @return An Annotation object containing the output of all annotators */ public Annotation process(String text) { Annotation annotation = new Annotation(text); annotate(annotation); return annotation; }
/** * {@inheritDoc} * * This method creates an async call to the server, and blocks until the server * has finished annotating the object. */ @Override public void annotate(Annotation annotation) { final Lock lock = new ReentrantLock(); final Condition annotationDone = lock.newCondition(); annotate(Collections.singleton(annotation), 1, (Annotation annInput) -> { try { lock.lock(); annotationDone.signal(); } finally { lock.unlock(); } }); try { lock.lock(); annotationDone.await(); // Only wait for one callback to complete; only annotating one document } catch (InterruptedException e) { log.info("Interrupt while waiting for annotation to return"); } finally { lock.unlock(); } }
@Override public void annotate(Annotation annotation) { client.annotate(annotation); }
/** * This method fires off a request to the server. Upon returning, it calls the provided * callback method. * * @param annotations The input annotations to process * @param numThreads The number of threads to run on. IGNORED in this class. * @param callback A function to be called when an annotation finishes. */ @Override public void annotate(final Iterable<Annotation> annotations, int numThreads, final Consumer<Annotation> callback){ for (Annotation annotation : annotations) { annotate(annotation, callback); } }
/** * Runs the entire pipeline on the content of the given text passed in. * @param text The text to process * @return An Annotation object containing the output of all annotators */ public Annotation process(String text) { Annotation annotation = new Annotation(text); annotate(annotation); return annotation; }
/** * {@inheritDoc} * * This method creates an async call to the server, and blocks until the server * has finished annotating the object. */ @Override public void annotate(Annotation annotation) { final Lock lock = new ReentrantLock(); final Condition annotationDone = lock.newCondition(); annotate(Collections.singleton(annotation), 1, (Annotation annInput) -> { try { lock.lock(); annotationDone.signal(); } finally { lock.unlock(); } }); try { lock.lock(); annotationDone.await(); // Only wait for one callback to complete; only annotating one document } catch (InterruptedException e) { log.info("Interrupt while waiting for annotation to return"); } finally { lock.unlock(); } }