Class: OpenNlp::Categorizer

Inherits:
Tool
  • Object
show all
Defined in:
lib/open_nlp/categorizer.rb

Instance Attribute Summary

Attributes inherited from Tool

#j_instance

Instance Method Summary collapse

Methods inherited from Tool

#initialize

Methods included from JavaClass

included

Constructor Details

This class inherits a constructor from OpenNlp::Tool

Instance Method Details

#categorize(str) ⇒ String

Categorizes a string passed as parameter to one of the categories

Parameters:

  • str (String)

    string to be categorized

Returns:

  • (String)

    category



9
10
11
12
13
14
# File 'lib/open_nlp/categorizer.rb', line 9

def categorize(str)
  fail ArgumentError, 'str param must be a String' unless str.is_a?(String)

  outcomes = j_instance.categorize(str)
  j_instance.getBestCategory(outcomes)
end