Package functionality

Source Code of functionality.Parsing

/*
*    Copyright (C) 2012  Marta Rodr�guez, Teresa de Salas, Ana Vargas
*
*    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 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
*   http://www.gnu.org/licenses/.
*/

package functionality;

import opennlp.tools.cmdline.parser.ParserTool;
import opennlp.tools.parser.Parse;
import opennlp.tools.parser.Parser;
import opennlp.tools.parser.ParserFactory;
import opennlp.tools.parser.ParserModel;

/**
*
* @author Marta Rodr�guez
* @author Teresa de Salas
* @author Ana Vargas
*
*/
public class Parsing {
 
  /**
   * sentence to parse
   */
  private String sentence;
 
  /**
   * Constructor
   * @param sentence
   */
  public Parsing (String sentence){
    this.sentence = sentence;
  }
 
  /**
   *
   * @param model
   * @return the parse sentence
   */
  public String getParsing(ParserModel model){
   
    String par = null;
    Parser parser = ParserFactory.create(model);
    Parse topParses[] = ParserTool.parseLine(sentence, parser, 1);

    StringBuffer buffer = new StringBuffer();
    topParses[0].show(buffer);
    par = buffer.toString();
    return par;
  }
}
TOP

Related Classes of functionality.Parsing

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.