Sha256: d20785129af42bc25865ec30befe1d14aec76bcbde4f541b8d024f1dcf86458a

Contents?: true

Size: 566 Bytes

Versions: 2

Compression:

Stored size: 566 Bytes

Contents

require "cld/version"
require "ffi"

module CLD
  extend FFI::Library
  ffi_lib "#{File.expand_path("../../", __FILE__)}/ext/cld/lib/libcld2.so"

  def self.detect_language(text, is_plain_text=true)
    result = detect_language_ext(text.to_s, is_plain_text)
    Hash[ result.members.map {|member| [member.to_sym, result[member]]} ]
  end

  private

  class ReturnValue < FFI::Struct
    layout :name, :string, :code, :string, :reliable, :bool
  end
  
  attach_function "detect_language_ext", "detectLanguageThunkInt", [:buffer_in, :bool], ReturnValue.by_value
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cld2-1.0.1 lib/cld.rb
cld2-1.0.0 lib/cld.rb