// Path: poli-libras-core/src/br/usp/libras/translator/Translator.java
// public class Translator {
// 
//     private SyntacticTranformer transformer = new SynTransfPortLibras();
//     private Contextualiser context;
//     private boolean verbose = false;
// 
//     public Translator() 
//     {
//     	context = new Contextualiser();
//     }
//     
//     public Translator(SignDictionary dic) {
//         context = new Contextualiser(dic);
//     }
// 
//     public void setVerbose() {
//         verbose = true;
//     }
// 
//     public List<Sign> translate(String text) {
// 
//         List<TokenMorph >tokens = transformer.transform(text);
//     
//         if (verbose) {
//             System.out.println("Transformer");
//             for (TokenMorph tokenMorph : tokens) {
//                 System.out.println(tokenMorph);
//             }
//         }
// 
//         List<Sign> signs = context.contextualise(tokens);
// 
//         return signs;
//     }
// }


import java.io.IOException;
import java.io.StringWriter;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.bind.JAXBException;
import br.usp.libras.sign.Sign;
import br.usp.libras.translator.Translator;
import br.usp.libras.xml.XMLWriter;
package br.usp.polilibras.web;




/**
 * Utiliza a API tradutor para traduzir a frase fornecida pelo usuário Devolve a sequência de sinais para a view
 */
@WebServlet("/translator")
public class TranslatorServ extends HttpServlet {
    private static final long serialVersionUID = 1L;

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
            IOException {

        String text = request.getParameter("texto");
        System.out.println("Entrada: " + text);

        if (text == null) {
        	System.err.println("Invalid received text null");
        	return;
        }

        List<Sign> signs = translate(text);

        for (Sign sign : signs) {
            System.out.println(sign.getName());
        }

        String xml = signsToXml(signs);
        
        response.setHeader("signsXmlString", xml);
    }

	private List<Sign> translate(String text) {
// Path: poli-libras-core/src/br/usp/libras/translator/Translator.java
// public class Translator {
// 
//     private SyntacticTranformer transformer = new SynTransfPortLibras();
//     private Contextualiser context;
//     private boolean verbose = false;
// 
//     public Translator() 
//     {
//     	context = new Contextualiser();
//     }
//     
//     public Translator(SignDictionary dic) {
//         context = new Contextualiser(dic);
//     }
// 
//     public void setVerbose() {
//         verbose = true;
//     }
// 
//     public List<Sign> translate(String text) {
// 
//         List<TokenMorph >tokens = transformer.transform(text);
//     
//         if (verbose) {
//             System.out.println("Transformer");
//             for (TokenMorph tokenMorph : tokens) {
//                 System.out.println(tokenMorph);
//             }
//         }
// 
//         List<Sign> signs = context.contextualise(tokens);
// 
//         return signs;
//     }
// }


// Path: poli-libras-web/src/br/usp/polilibras/web/TranslatorServ.java
import java.io.IOException;
import java.io.StringWriter;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.bind.JAXBException;
import br.usp.libras.sign.Sign;
import br.usp.libras.translator.Translator;
import br.usp.libras.xml.XMLWriter;

package br.usp.polilibras.web;




/**
 * Utiliza a API tradutor para traduzir a frase fornecida pelo usuário Devolve a sequência de sinais para a view
 */
@WebServlet("/translator")
public class TranslatorServ extends HttpServlet {
    private static final long serialVersionUID = 1L;

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
            IOException {

        String text = request.getParameter("texto");
        System.out.println("Entrada: " + text);

        if (text == null) {
        	System.err.println("Invalid received text null");
        	return;
        }

        List<Sign> signs = translate(text);

        for (Sign sign : signs) {
            System.out.println(sign.getName());
        }

        String xml = signsToXml(signs);
        
        response.setHeader("signsXmlString", xml);
    }

	private List<Sign> translate(String text) {
		Translator translator = new Translator();