/*
* 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 java.io.InputStream;
import opennlp.tools.parser.ParserModel;
import opennlp.tools.sentdetect.SentenceModel;
import opennlp.tools.tokenize.TokenizerModel;
/**
*
* @author Marta Rodr�guez
* @author Teresa de Salas
* @author Ana Vargas
*
*/
public class Models {
/**
* Constructor
*/
public Models(){}
/**
* @return tokenizer model
*/
public TokenizerModel tokModel() {
TokenizerModel model = null;
try {
/* Load the tokenization model from file */
InputStream modelIn = this.getClass().getClassLoader().getResourceAsStream("en-token.bin");
model = new TokenizerModel(modelIn);
return model;
}
catch (Exception e) {
e.printStackTrace();
}
return model;
}
/**
*
* @return sentence model
*/
public SentenceModel sentModel(){
/* Load the sentence model from file */
InputStream modelIn = this.getClass().getClassLoader().getResourceAsStream("en-sent.bin");
SentenceModel model= null;
try {
model = new SentenceModel(modelIn);
return model;
} catch (Exception e) {
e.printStackTrace();
}
return model;
}
/**
*
* @return parser model
*/
public ParserModel parsModel(){
/* load the parser model from file */
InputStream modelIn = this.getClass().getClassLoader().getResourceAsStream("en-parser-chunking.bin");
ParserModel model= null;
try {
model = new ParserModel(modelIn);
return model;
} catch (Exception e) {
e.printStackTrace();
}
return model;
}
}