Using the Trained model

We can then use the model, as illustrated in the following code sequence. This is based on the techniques illustrated in the Using the SentenceDetectorME class section:

try (InputStream is = new FileInputStream( 
        new File(getModelDir(), "modelFile"))) { 
    SentenceModel model = new SentenceModel(is); 
    SentenceDetectorME detector = new 
SentenceDetectorME(model); String sentences[] = detector.sentDetect(paragraph); for (String sentence : sentences) { System.out.println(sentence); } } catch (FileNotFoundException ex) { // Handle exception } catch (IOException ex) { // Handle exception }

The output is as follows:

    When determining the end of sentences we need to consider several factors.
    Sentences may end with exclamation marks! Or possibly questions marks?
    Within sentences we may find numbers like 3.14159,
    abbreviations such as found in Mr.
    Smith, and possibly ellipses either within a sentence ..., or at the end of a sentence...
  

This model did not process the last sentence very well, which reflects a mismatch between the sample text and the text the model is used against. Using relevant training data is important. Otherwise, downstream tasks based on this output will suffer.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset