當前位置: 首頁>>代碼示例>>Java>>正文


Java SentenceDetectorME.sentPosDetect方法代碼示例

本文整理匯總了Java中opennlp.tools.sentdetect.SentenceDetectorME.sentPosDetect方法的典型用法代碼示例。如果您正苦於以下問題:Java SentenceDetectorME.sentPosDetect方法的具體用法?Java SentenceDetectorME.sentPosDetect怎麽用?Java SentenceDetectorME.sentPosDetect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在opennlp.tools.sentdetect.SentenceDetectorME的用法示例。


在下文中一共展示了SentenceDetectorME.sentPosDetect方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import opennlp.tools.sentdetect.SentenceDetectorME; //導入方法依賴的package包/類
public static void main(String[] strings) throws Exception {
    String text = "“But I don’t want to go among mad people,” Alice remarked. " +
            "“Oh, you can’t help that,” said the Cat: “we’re all mad here. I’m mad. You’re mad.” " +
            "“How do you know I’m mad?” said Alice. " +
            "“You must be,” said the Cat, “or you wouldn’t have come here.”";

    try (InputStream modelIn = new FileInputStream(NATURAL_LANGUAGE_PROCESSING_SRC_MAIN_RESOURCES_EN_SENT_BIN)) {
        SentenceModel model = new SentenceModel(modelIn);
        SentenceDetectorME sentenceDetector = new SentenceDetectorME(model);
        String sentences[] = sentenceDetector.sentDetect(text);
        Span sentences2[] = sentenceDetector.sentPosDetect(text);
        for (String sentence : sentences) {
            System.out.println(sentence);
        }
        System.out.println(Arrays.deepToString(sentences2));
    }
}
 
開發者ID:Vedenin,項目名稱:java_in_examples,代碼行數:18,代碼來源:OpenNLPSentenceDetectionTest.java

示例2: apply

import opennlp.tools.sentdetect.SentenceDetectorME; //導入方法依賴的package包/類
@Override
public void apply(Document doc) {
    SentenceDetectorME detector = new SentenceDetectorME(model);
    Span[] spans = detector.sentPosDetect(doc.text());

    for(int i = 0; i < spans.length; i++) {
        int start = spans[i].getStart();
        int end = spans[i].getEnd();
        new Sentence(doc).setRange(start, end);
    }
}
 
開發者ID:marcusklang,項目名稱:langforia,代碼行數:12,代碼來源:OpenNlpSentenceSplitter.java

示例3: testOpenNLPPosition

import opennlp.tools.sentdetect.SentenceDetectorME; //導入方法依賴的package包/類
private static Span[] testOpenNLPPosition(String text) throws Exception {
    try (InputStream modelIn = new FileInputStream(RESOURCES_EN_SENT_BIN)) {
        SentenceModel model = new SentenceModel(modelIn);
        SentenceDetectorME sentenceDetector = new SentenceDetectorME(model);
        return sentenceDetector.sentPosDetect(text);
    }
}
 
開發者ID:Vedenin,項目名稱:java_in_examples,代碼行數:8,代碼來源:SentenceDetectors.java


注:本文中的opennlp.tools.sentdetect.SentenceDetectorME.sentPosDetect方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。