
lv.semti.morphology.webservice.NormalizePhraseResource Maven / Gradle / Ivy
/*******************************************************************************
* Copyright 2012, 2013, 2014 Institute of Mathematics and Computer Science, University of Latvia
* Author: Pēteris Paikens
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*******************************************************************************/
package lv.semti.morphology.webservice;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.Map;
import lv.semti.morphology.analyzer.Analyzer;
import org.json.simple.JSONObject;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;
import lv.lumii.expressions.Expression;
public class NormalizePhraseResource extends ServerResource {
@Get
public String retrieve() {
getResponse().setAccessControlAllowOrigin("*");
String query = (String) getRequest().getAttributes().get("phrase");
try {
query = URLDecoder.decode(query, "UTF8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
String category = getQuery().getValues("category");
Analyzer analyzer = MorphoServer.getAnalyzer();
analyzer.enableGuessing = true;
analyzer.enableVocative = true;
analyzer.guessVerbs = false;
analyzer.guessParticiples = false;
analyzer.guessAdjectives = false;
analyzer.guessInflexibleNouns = true;
analyzer.enableAllGuesses = true;
Expression e = new Expression(query, category, false);
String pamatforma = e.normalize();
analyzer.defaultSettings();
return pamatforma;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy