comparison software/mpdl-services/mpiwg-mpdl-lt-web/src/de/mpg/mpiwg/berlin/mpdl/servlets/lt/GetLemmas.java @ 21:4ea0f81a5d08

little corrections
author Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de>
date Wed, 14 Dec 2011 12:49:06 +0100
parents 4a3641ae14d2
children
comparison
equal deleted inserted replaced
20:7d6d969b10cf 21:4ea0f81a5d08
15 import de.mpg.mpiwg.berlin.mpdl.exception.ApplicationException; 15 import de.mpg.mpiwg.berlin.mpdl.exception.ApplicationException;
16 import de.mpg.mpiwg.berlin.mpdl.lt.dict.db.LexHandler; 16 import de.mpg.mpiwg.berlin.mpdl.lt.dict.db.LexHandler;
17 import de.mpg.mpiwg.berlin.mpdl.lt.general.Language; 17 import de.mpg.mpiwg.berlin.mpdl.lt.general.Language;
18 import de.mpg.mpiwg.berlin.mpdl.lt.morph.app.Form; 18 import de.mpg.mpiwg.berlin.mpdl.lt.morph.app.Form;
19 import de.mpg.mpiwg.berlin.mpdl.lt.morph.app.Lemma; 19 import de.mpg.mpiwg.berlin.mpdl.lt.morph.app.Lemma;
20 import de.mpg.mpiwg.berlin.mpdl.lt.text.norm.Normalizer;
20 21
21 public class GetLemmas extends HttpServlet { 22 public class GetLemmas extends HttpServlet {
22 private static final long serialVersionUID = 1L; 23 private static final long serialVersionUID = 1L;
23 private LexHandler lexHandler; 24 private LexHandler lexHandler;
24 25
53 outputFormat = "xml"; 54 outputFormat = "xml";
54 if (outputType == null || ! (outputType.equals("compact") || outputType.equals("full"))) 55 if (outputType == null || ! (outputType.equals("compact") || outputType.equals("full")))
55 outputType = "compact"; 56 outputType = "compact";
56 if (normalization == null || ! (normalization.equals("none") || normalization.equals("reg") || normalization.equals("reg norm"))) 57 if (normalization == null || ! (normalization.equals("none") || normalization.equals("reg") || normalization.equals("reg norm")))
57 normalization = "norm"; 58 normalization = "norm";
59 int normalizationType = Normalizer.DICTIONARY;
60 if (normalization != null && normalization.equals("none"))
61 normalizationType = Normalizer.NONE;
58 62
59 String xmlQueryString = "<query><name>" + query + "</name>" + "<language>" + language + "</language>" + "<inputType>" + inputType + "</inputType>" + 63 String xmlQueryString = "<query><name>" + query + "</name>" + "<language>" + language + "</language>" + "<inputType>" + inputType + "</inputType>" +
60 "<outputFormat>" + outputFormat + "</outputFormat>" + "<outputType>" + outputType + "</outputType>" + "<normalization>" + normalization + "</normalization>" + "</query>"; 64 "<outputFormat>" + outputFormat + "</outputFormat>" + "<outputType>" + outputType + "</outputType>" + "<normalization>" + normalization + "</normalization>" + "</query>";
61 try { 65 try {
62 if (outputFormat.equals("xml")) 66 if (outputFormat.equals("xml"))
69 if (query == null || query.isEmpty()) { 73 if (query == null || query.isEmpty()) {
70 out.print("request parameter query is empty. Please specify a query."); 74 out.print("request parameter query is empty. Please specify a query.");
71 out.close(); 75 out.close();
72 return; 76 return;
73 } 77 }
74 ArrayList<Lemma> lemmas = lexHandler.getLemmas(query, inputType, language, normalization); 78 ArrayList<Lemma> lemmas = lexHandler.getLemmas(query, inputType, language, normalizationType);
75 String baseUrl = getBaseUrl(request); 79 String baseUrl = getBaseUrl(request);
76 Date end = new Date(); 80 Date end = new Date();
77 String elapsedTime = String.valueOf(end.getTime() - begin.getTime()); 81 String elapsedTime = String.valueOf(end.getTime() - begin.getTime());
78 String result = ""; 82 String result = "";
79 if (outputFormat == null || outputFormat.equals("xml")) 83 if (outputFormat == null || outputFormat.equals("xml"))