All Downloads are FREE. Search and download functionalities are using the official Maven repository.

lv.semti.morphology.webservice.DomainNameResource Maven / Gradle / Ivy

Go to download

Webservice API for Tēzaurs.lv and other ailab.lv Latvian computational linguistic tools

There is a newer version: 2.5.7
Show newest version
package lv.semti.morphology.webservice;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.List;

import lv.ailab.domainnames.AlternativeBuilder;

import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;

public class DomainNameResource extends ServerResource{


	@Get("json")
	public String retrieve() throws Exception {
		getResponse().setAccessControlAllowOrigin("*");
		String query = (String) getRequest().getAttributes().get("domainname");
		try {
			query = URLDecoder.decode(query, "UTF8");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}

		Integer limit = null;
		try {
			String limit_str= getQuery().getValues("limit");
			System.out.println("limits");
			System.out.println(limit_str);
			if (limit_str != null)
				limit = Integer.parseInt(limit_str);
		} catch (Exception e) {
			limit = null;
		}
		
		List alternatives = MorphoServer.alternatives.buildAlternatives(query, limit);

		return AlternativeBuilder.resultToJson(alternatives);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy