Sha256: 9b7858cf5bf5489d6a9a4bbede9957552487d7b72b2d7c8a172a8f2e1dfffbf3
Contents?: true
Size: 1020 Bytes
Versions: 1
Compression:
Stored size: 1020 Bytes
Contents
require 'singleton' import 'org.vicomtech.opennlp.LanguageDetection.CybozuDetector' module Opener class LanguageIdentifier ## # Singleton class wrapped around the Cybozu detector. The Cybozu code uses # the factory pattern and stores a bunch of things on class level. As such # the Cybozu code is *not* thread-safe. # class Detector attr_reader :options include Singleton def initialize(options={}) @options = options @detector = CybozuDetector.new(profiles_path) @semaphore = Mutex.new end def detect(input) @semaphore.synchronize do @detector.detect(input) end end def probabilities(input) @semaphore.synchronize do result = @detector.detect_langs(input) end end def profiles_path default_path = File.expand_path("../../../../core/target/classes/profiles", __FILE__) options.fetch(:profiles_path, default_path) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
opener-language-identifier-4.1.0 | lib/opener/language_identifier/detector.rb |