lib/open-nlp/bindings.rb in open-nlp-0.1.0 vs lib/open-nlp/bindings.rb in open-nlp-0.1.1

- old
+ new

@@ -8,14 +8,10 @@ # ############################ # require 'bind-it' extend BindIt::Binding - # The path in which to look for JAR files, with - # a trailing slash (default is gem's bin folder). - self.jar_path = File.dirname(__FILE__) + '/../../bin/' - # Load the JVM with a minimum heap size of 512MB, # and a maximum heap size of 1024MB. self.jvm_args = ['-Xms512M', '-Xmx1024M'] # Turn logging off by default. @@ -32,10 +28,11 @@ # Default namespace. self.default_namespace = 'opennlp.tools' # Default classes. self.default_classes = [ + # OpenNLP classes. ['AbstractBottomUpParser', 'opennlp.tools.parser'], ['DocumentCategorizerME', 'opennlp.tools.doccat'], ['ChunkerME', 'opennlp.tools.chunker'], ['DictionaryDetokenizer', 'opennlp.tools.tokenize'], ['NameFinderME', 'opennlp.tools.namefind'], @@ -44,27 +41,24 @@ ['ParserFactory', 'opennlp.tools.parser'], ['POSTaggerME', 'opennlp.tools.postag'], ['SentenceDetectorME', 'opennlp.tools.sentdetect'], ['SimpleTokenizer', 'opennlp.tools.tokenize'], ['Span', 'opennlp.tools.util'], - ['TokenizerME', 'opennlp.tools.tokenize'] + ['TokenizerME', 'opennlp.tools.tokenize'], + + # Generic Java classes. + ['FileInputStream', 'java.io'], + ['String', 'java.lang'], + ['ArrayList', 'java.util'] ] # Add in Rjb workarounds. unless RUBY_PLATFORM =~ /java/ self.default_jars << 'utils.jar' self.default_classes << ['Utils', ''] end - - # Make the bindings. - self.bind - # Load utility classes. - self.load_class('FileInputStream', 'java.io') - self.load_class('String', 'java.lang') - self.load_class('ArrayList', 'java.util') - # ############################ # # OpenNLP bindings proper # # ############################ # class <<self @@ -76,14 +70,22 @@ attr_accessor :model_path # Store the language currently being used. attr_accessor :language end + def self.default_path + File.dirname(__FILE__) + '/../../bin/' + end + # The loaded models. self.models = {} # The names of loaded models. self.model_files = {} + + # The path in which to look for JAR files, with + # a trailing slash (default is gem's bin folder). + self.jar_path = self.default_path # The path to the main folder containing the folders # with the individual models inside. By default, this # is the same as the JAR path. self.model_path = self.jar_path