0

openNlp SentenceDetectorME の文末セパレータを変更したいと思います。私はopennlp 1.5.3を使用しています。通常版は「.」で区切られたフレーズしか検出しないので、「;」、「!」などの別の文区切りを追加するのが目的です。および '?' で、char 配列 eos[] を SentenceDetectorFactory に渡します。.train メソッド SentenceDetectorME を使用する必要があると読みましたが、静的であり、トレーニング モデルが必要であるため、方法がわかりません。助言がありますか?

私のコード:

import java.io.*;
import opennlp.tools.sentdetect.*;

public class SenTest {

public static void main(String[] args) throws IOException {

    String paragraph = "12oz bottle poured into a tulip. Pleasing aromas of citrus rind, lemongrass, peaches, and toasted caramel are picked up from the start. After it settles a bit, more of a fresh baked bread crust and tangerine comes through, and even later, the bread crust turns more towards a blackened pizza crust. It pours a slightly hazy copper-orange color with a creamy white head that retains well; it leaves a thick puffy ring with a creamy island and a decent, messy lace along the glass. Great balance between medium high levels of sweet and bitter. The texture is creamy on the palate with a body towards the higher end of medium. The carbonation is a touch effervescent or fizzy, but overall, soft. There’s a very pronounced grapefruit tartness up front, but it mellows quickly after the first few sips. It finishes with a zesty combination of lemongrass, caramel, and stonefruit. The aftertaste is primarily sweet, overripe tangerines and it’s peel with a tart grapefruit bitter lingering in the mouth. Overall very refreshing, straddles the line between IPA and APA.";
    char eos[] = {';', '.', '!', '?' };
    int counter = 0;
    // always start with a model, a model is learned from training data

    InputStream is = new FileInputStream( System.getProperty( "user.dir" ) + "/lib/en-sent.bin" );
    SentenceModel model = new SentenceModel( is );
    SentenceDetectorME sdetector = new SentenceDetectorME( model );


    String sentences[] = sdetector.sentDetect( paragraph );

    for ( String s : sentences ) {

        counter++;
        System.out.println( "Frase numero " + counter + ": " + s );
    }
    is.close();
}

}

4

1 に答える 1