Package translator

Source Code of translator.Translator

package translator;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.List;
import java.util.Set;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.stream.XMLStreamException;

import lexicon.jaxb.Lexicon;

public class Translator {


  static String inputString;
  static String outputString;
  static List<String> inputWords;
  Set<ElementaryTree> sourceTrees;
  public Translator(String inputString)
  {
    this.inputString=inputString;
  }
 
  public String translate(String inputString)
  throws FileNotFoundException, XMLStreamException, JAXBException{
   
    List<String> inputWords= (List<String>)getInputWords();
   
    for (int i=0 ; i< inputWords.size();i++)
    {
      sourceTrees.add(buildTree(inputWords.get(i)));

    }
    return outputString ;
  }
  public  List<String> getInputWords (){
   
    TokenizerForms tok =new TokenizerForms(inputString);
   
    return (List<String>) (tok.WordsForm());
    

  }


  public static ElementaryTree buildTree(String word) throws
  FileNotFoundException, XMLStreamException, JAXBException,java.lang.NullPointerException{
   
    JAXBContext jc = JAXBContext.newInstance(Lexicon.class)
    Unmarshaller u = jc.createUnmarshaller();
    Lexicon lex =(Lexicon) (u.unmarshal(new File("binding\\En-Fr.xml")));
    System.out.println(lex.getTgt_language());
    System.out.println( "D�but: " );
    System.out.println(lex.getEntryCount());
    System.out.println(lex.getEntry(1).getSource().getForm());
   
    for (int i = 0; i < lex.getEntryCount(); i++) {
     
      if(lex.getEntry(i).getSource().getForm().equals("John"))
      {
        System.out.println(lex.getEntry(i).getSource().getLexicalisation().getTree_id());
      }
     
    }
          
    return null;
  }

  }
TOP

Related Classes of translator.Translator

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.