Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Sentence detection with OpenNLP and jRuby
# By Oto Brglez - <>
# Read:
require 'bundler/setup'
require 'ruby-debug'
require 'pp'
# Java & jRuby
require 'java'
Dir["apache-opennlp/lib/*"].each { |jar| require jar }
# OpenNLP
include_class ""
include_class ""
include_class ""
stream ="apache-opennlp/nlp-models/en-sent.bin")
model =
detector =
sentences = detector.sentDetect("Today is a nice day. I love the day. My name is Oto and I'm from Maribor.")
sentences.each do |s|
puts s
rescue Exception => e
puts e.message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment