use of edu.illinois.cs.cogcomp.thrift.curator.Curator in project cogcomp-nlp by CogComp.
the class CuratorClient method addRecordViewFromCurator.
/**
* Does the network call to the Curator and fetches a record that has a particular view.
*
* @param text The raw text (this will be used if {@link #respectTokenization} is false.
* @param sentences The list of tokenized sentences (will be {@code null} if
* {@link #respectTokenization} is true.
* @param viewName The view to get (according to the Curator lingo.)
* @return A {@link edu.illinois.cs.cogcomp.thrift.curator.Record} with the requested view
*/
private Record addRecordViewFromCurator(String text, List<String> sentences, String viewName) throws ServiceUnavailableException, AnnotationFailedException, TException, SocketException {
viewName = convertCuratorViewName(viewName);
TTransport transport = new TSocket(this.curatorHost, this.curatorPort);
logger.debug("Calling curator on host '" + curatorHost + "', port '" + curatorPort + "' for view '" + viewName + "'...");
try {
((TSocket) transport).getSocket().setReuseAddress(true);
} catch (SocketException e) {
logger.error("Unable to setReuseAddress!", e);
throw e;
}
transport = new TFramedTransport(transport);
TProtocol protocol = new TBinaryProtocol(transport);
transport.open();
Curator.Client client = new Curator.Client(protocol);
Record newRecord;
if (respectTokenization) {
newRecord = client.wsprovide(viewName, sentences, forceUpdate);
} else {
newRecord = client.provide(viewName, text, forceUpdate);
}
transport.close();
return newRecord;
}
Aggregations