Example usage for edu.stanford.nlp.time TimeAnnotator TimeAnnotator

List of usage examples for edu.stanford.nlp.time TimeAnnotator TimeAnnotator

Introduction

In this page you can find the example usage for edu.stanford.nlp.time TimeAnnotator TimeAnnotator.

Prototype

public TimeAnnotator(String name, Properties props) 

Source Link

Usage

From source file:StanfordCoreNLPXMLServer.java

License:Open Source License

public static void main(String args[]) throws Exception {
    // use port if given
    try {/*from   ww w  .jav a 2s.  c om*/
        port = Integer.parseInt(args[0]);
    } catch (Exception e) {
        // silently keep port at 8080
    }

    // initialize the Stanford Core NLP
    java.util.Properties props = new java.util.Properties();
    props.setProperty("sutime.markTimeRanges", "true");
    props.setProperty("sutime.includeRange", "true");

    TimeAnnotator sutime = new TimeAnnotator("sutime", props);

    pipeline = new StanfordCoreNLP(props);

    pipeline.addAnnotator(sutime);

    // start the server
    Container container = new StanfordCoreNLPXMLServer();
    Server server = new ContainerServer(container);
    Connection connection = new SocketConnection(server);
    SocketAddress address = new InetSocketAddress(port);
    connection.connect(address);

    log.info("Initialized server at port " + port + ".");
}

From source file:com.epictodo.controller.nlp.NLPLoadEngine.java

License:Open Source License

public NLPLoadEngine() {
    this.mute();/* w  ww.  j  a  v  a 2  s.co  m*/
    Properties _properties = new Properties();
    _properties.put("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref, sentiment");

    try {
        CLASSIFIER = CRFClassifier.getClassifierNoExceptions(CLASSIFIER_MODEL);
        LEXICAL_PARSER = LexicalizedParser.loadModel(ENGLISHPCFG_MODEL);
        _pipeline = new StanfordCoreNLP(_properties, true);
        _pipeline.addAnnotator(new TimeAnnotator("sutime", _properties));

        _logger.log(Level.INFO, "Successfully loaded models.");
    } catch (RuntimeException ex) {
        _logger.log(Level.SEVERE, "Error loading models.");
        throw ex;
    }
}