Package opennlp.tools.sentdetect

Examples of opennlp.tools.sentdetect.SentenceDetector.sentDetect()


    SentenceModel model = new SentenceModel(modelStream);
    SentenceDetector detector = //<co id="openSentDetect.co.detect"/>
      new SentenceDetectorME(model);
    String testString = "This is a sentence. It has fruits, vegetables," +
      " etc. but does not have meat. Mr. Smith went to Washington.";
    String[] result = detector.sentDetect(testString); //<co id="openSentDetect.co.run"/>
    for (int i = 0; i < result.length; i++) {
      System.out.println("Sentence: " + result[i]);
    }
    /*<calloutlist>
        <callout arearefs="openSentDetect.co.detect"><para>Create the <command>SentenceDetector</command> with the en-sent.bin model</para></callout>
View Full Code Here


        String[] lines = content.split("\n");
        List<String> results = new ArrayList<String>();
        SentenceDetector detector = getSentenceDetector();
        for (String line : lines) {
            line = line.trim();
            for (String sent : detector.sentDetect(line)) {
                if (!sent.trim().equals("")) {
                    results.add(sent);
                }
            }
        }
View Full Code Here

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.