justhalf.nlp.sentenceparser.StanfordSentenceParser Maven / Gradle / Ivy
package justhalf.nlp.sentenceparser;
import java.util.List;
import edu.stanford.nlp.parser.lexparser.LexicalizedParser;
import edu.stanford.nlp.trees.Tree;
/**
* An implementation of {@link SentenceParser} from Stanford CoreNLP
*/
public class StanfordSentenceParser implements SentenceParser {
/** The path to default lexical model for English */
public static final String MODEL_LEXICAL = "edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz";
private LexicalizedParser parser;
public StanfordSentenceParser(){
parser = LexicalizedParser.loadModel(MODEL_LEXICAL);
}
@Override
public Tree parse(String sentence) {
return parser.parse(sentence);
}
@Override
public Tree parse(List sentence) {
return parser.parseStrings(sentence);
}
@Override
public boolean isThreadSafe(){
return true;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy