Class: Opener::LanguageIdentifier::Detector
- Inherits:
-
Object
- Object
- Opener::LanguageIdentifier::Detector
- Includes:
- Singleton
- Defined in:
- lib/opener/language_identifier/detector.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #detect(input) ⇒ Object
-
#initialize(options = {}) ⇒ Detector
constructor
A new instance of Detector.
- #probabilities(input) ⇒ Object
- #profiles_path ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Detector
Returns a new instance of Detector.
12 13 14 15 16 |
# File 'lib/opener/language_identifier/detector.rb', line 12 def initialize(={}) @options = @detector = CybozuDetector.new(profiles_path) @semaphore = Mutex.new end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/opener/language_identifier/detector.rb', line 8 def @options end |
Instance Method Details
#detect(input) ⇒ Object
18 19 20 21 22 |
# File 'lib/opener/language_identifier/detector.rb', line 18 def detect(input) @semaphore.synchronize do @detector.detect(input) end end |
#probabilities(input) ⇒ Object
24 25 26 27 28 |
# File 'lib/opener/language_identifier/detector.rb', line 24 def probabilities(input) @semaphore.synchronize do result = @detector.detect_langs(input) end end |
#profiles_path ⇒ Object
30 31 32 33 |
# File 'lib/opener/language_identifier/detector.rb', line 30 def profiles_path default_path = File.("../../../../core/target/classes/profiles", __FILE__) .fetch(:profiles_path, default_path) end |