Search in sources :

Example 11 with TextInput

use of org.opensextant.data.TextInput in project Xponents by OpenSextant.

the class TaggerResource method processGet.

/**
	 * HTTP GET -- vanilla. Do not use in production, unless you have really small data packages.
	 * This is useful for testing. Partial contract:
	 * 
	 * miscellany: 'cmd' = 'ping' |... other commands.
	 * processing: 'docid' = ?, 'text' = ?
	 * 
	 * @param params
	 *            the params
	 * @return the representation
	 */
@Get("application/json;charset=utf-8")
public Representation processGet(Representation params) {
    Form inputs = getRequest().getResourceRef().getQueryAsForm();
    String cmd = inputs.getFirstValue("cmd");
    if ("ping".equalsIgnoreCase(cmd)) {
        return ping();
    } else if ("stop".equalsIgnoreCase(cmd)) {
        info("Stopping Xponents Xlayer Service Requested by CLIENT=" + getRequest().getClientInfo().getAddress());
        stop();
    }
    String input = inputs.getFirstValue("text");
    String docid = inputs.getFirstValue("docid");
    String lang = inputs.getFirstValue("lang");
    TextInput item = new TextInput(docid, input);
    item.langid = lang;
    RequestParameters job = fromRequest(inputs);
    return process(item, job);
}
Also used : Form(org.restlet.data.Form) TextInput(org.opensextant.data.TextInput) Get(org.restlet.resource.Get)

Aggregations

TextInput (org.opensextant.data.TextInput)11 IOException (java.io.IOException)8 ConfigException (org.opensextant.ConfigException)8 TextMatch (org.opensextant.extraction.TextMatch)4 JSONObject (net.sf.json.JSONObject)3 ExtractionException (org.opensextant.extraction.ExtractionException)3 ParseException (java.text.ParseException)2 HashSet (java.util.HashSet)2 Text (org.apache.hadoop.io.Text)2 ExtractionResult (org.opensextant.extraction.ExtractionResult)2 ProcessingException (org.opensextant.processing.ProcessingException)2 File (java.io.File)1 SolrServerException (org.apache.solr.client.solrj.SolrServerException)1 JSONObject (org.json.JSONObject)1 Form (org.restlet.data.Form)1 Get (org.restlet.resource.Get)1 Post (org.restlet.resource.Post)1