cld2-small 1.0.4 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a0331cd31bbebffe75382c1ddbed32777319a3960252a7fd8a73f0c085dfce65
4
- data.tar.gz: 3d531ad57c29c481bdfcdb7e5b94246c026c5fce89866ad62b9ffee8ebba5165
3
+ metadata.gz: 6f10fe04b1de4166a0dabfbae2294879bc24e749312461fa882fc2f0de8176a1
4
+ data.tar.gz: 9de3c4cecb30494f28924e98c76303192ebbee33105b778b3d606a390a4a2f69
5
5
  SHA512:
6
- metadata.gz: eb38c6eaf8b930d41505f4b4aac2096f999bd4f89f27a14a20c4480104469a4652e411d8727a8ae7af2f1c3bd09cecfbde784c70280559759b123efd25c4e619
7
- data.tar.gz: b163cc1162d5b2183b6f00863ee7e1a6afb05f1c4b4a6d4c2a3511d7719357881f4dd6587ac366f2f9f693e75bd9759ed3cf014002b69db2d2dfcf24273d8fe0
6
+ metadata.gz: '00418d5b352b925de52c3e82c4ec7651f5089a15612b8a0a2a43c76b709efae082c219c0e4513714cd0b4de7dba83fd215a769d3d67cf0995c7e0893588a5eaf'
7
+ data.tar.gz: '078fd9c608432d46f03adc3592438e16f54dcd7a9118129cc6af12cd2344ff010862a7bb799262e434d475a5a7f342da34609413277c5db93433dc41fb116b0e'
data/LICENSE ADDED
@@ -0,0 +1,203 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
203
+
data/README.md ADDED
@@ -0,0 +1,82 @@
1
+ # Compact Language Detection 2.0(Updated to latest CLD2 source code)
2
+
3
+ Based on Jason Toy's CLD v1.0.
4
+
5
+ Based on BanjoInc's CLD v2.0.
6
+
7
+ Blazing-fast language detection for Ruby provided using Compact Language Detector v2.0
8
+
9
+ ### NOTE: Using smaller verison of CLD2 currently.
10
+
11
+ ## How to Use
12
+
13
+ The `detect_language` method returns a hash with the language name, code, and reliability.
14
+
15
+ ```ruby
16
+ CLD.detect_language("Working as expected")
17
+ # => {:name => "ENGLISH", :code => "en", :reliable => true}
18
+
19
+ CLD.detect_language("plus ça change, plus c'est la même chose")
20
+ # => {:name => "FRENCH", :code => "fr", :reliable => true}
21
+ ```
22
+
23
+ **Options**
24
+
25
+ You can pass an options hash as the second argument to `detect_language`:
26
+
27
+ ```ruby
28
+ CLD.detect_language(text, options = {})
29
+ ```
30
+
31
+ Available options:
32
+
33
+ * `:is_plain_text` (Boolean, default: `true`): Set to `false` if the input text is HTML. CLD2 will then try to skip HTML tags.
34
+ * `:best_effort` (Boolean, default: `false`): If `true`, CLD2 will give its best-effort answer, even on short or ambiguous text, instead of potentially returning "Unknown".
35
+ * `:tld_hint` (String, default: `nil`): A Top-Level Domain hint (e.g., `"id"`, `"us"`) to boost detection accuracy for languages associated with that TLD.
36
+ * `:content_language_hint` (String, default: `nil`): An HTTP Content-Language header style hint (e.g., `"en,fr"`) to boost detection for the specified languages.
37
+ * `:score_as_quads` (Boolean, default: `false`): Forces CLD2 to use quadgram-based scoring for certain languages that are normally detected by script alone. This can be a refinement for more meaningful text detection in those languages but depends on CLD2's internal data tables.
38
+
39
+ **Examples with Options:**
40
+
41
+ ```ruby
42
+ # Using best_effort for short text
43
+ CLD.detect_language("test", best_effort: true)
44
+ # => Might return a language like {:name => "ENGLISH", :code => "en", :reliable => false}
45
+ # instead of "Unknown"
46
+
47
+ # Providing a TLD hint
48
+ CLD.detect_language("Ini adalah teks dalam bahasa Indonesia", tld_hint: "id")
49
+ # => {:name => "INDONESIAN", :code => "id", :reliable => true}
50
+
51
+ # Providing a content language hint
52
+ CLD.detect_language("Ceci est un texte en français.", content_language_hint: "fr,en")
53
+ # => {:name => "FRENCH", :code => "fr", :reliable => true}
54
+
55
+ # Using score_as_quads (example, effect depends on text and CLD2 tables)
56
+ CLD.detect_language("Ελληνικό κείμενο", score_as_quads: true)
57
+ # => May provide a more refined result for Greek
58
+ ```
59
+
60
+ ## Installation
61
+
62
+ Add this line to your application's Gemfile:
63
+
64
+ ```ruby
65
+ gem 'cld2-small', require 'cld'
66
+ ```
67
+
68
+ And then execute:
69
+
70
+ ```sh
71
+ $ bundle
72
+ ```
73
+
74
+ ## Thanks
75
+
76
+ Thanks to the Chrome authors, and to Mike McCandless for writing a Python version.
77
+
78
+ Thanks to Jason Toy for the original cld v1.0 ruby port.
79
+
80
+ Thanks to BanjoInc for cld v2.0 ruby port.
81
+
82
+ Licensed the same as CLD2Owners.
data/ext/cld/extconf.rb CHANGED
@@ -1,6 +1,10 @@
1
1
  require 'mkmf'
2
2
 
3
- # HACK: mkmf doesn't support multiple subdirs for the same library
3
+ # Add include paths
4
+ $INCFLAGS = "-I$(srcdir) -I$(srcdir)/cld2 #{$INCFLAGS}"
5
+ $CXXFLAGS += " -std=c++98"
6
+
7
+ # List object files
4
8
  $objs = ["cld2/internal/cldutil.o",
5
9
  "cld2/internal/cldutil_shared.o",
6
10
  "cld2/internal/compact_lang_det.o",
@@ -27,16 +31,16 @@ $objs = ["cld2/internal/cldutil.o",
27
31
  "cld2/internal/cld_generated_score_quad_octa_2.o",
28
32
  "thunk.o"]
29
33
 
30
- $CXXFLAGS +=" -std=c++98"
31
-
32
34
  if have_library('stdc++')
33
- create_makefile('libcld2')
35
+ # Create makefile with the correct target
36
+ create_makefile('cld/libcld2')
34
37
  end
35
38
 
36
- # to clean up object files under internal subdirectory.
37
- open('Makefile', 'a') do |f|
38
- f.write <<EOS
39
+ # Add clean target
40
+ File.open('Makefile', 'a') do |f|
41
+ f.write <<-EOF
39
42
 
40
- CLEANOBJS := $(CLEANOBJS) cld2/internal/*.#{CONFIG["OBJEXT"]}
41
- EOS
43
+ clean-local:
44
+ \t$(Q)rm -f $(CLEANOBJS) cld2/internal/*.#{CONFIG["OBJEXT"]}
45
+ EOF
42
46
  end
data/ext/cld/thunk.cc CHANGED
@@ -1,8 +1,8 @@
1
1
  #include <stdio.h>
2
2
  #include <string.h>
3
- #include "cld2/internal/lang_script.h"
4
- #include "cld2/public/compact_lang_det.h"
5
- #include "cld2/public/encodings.h"
3
+ #include "./cld2/internal/lang_script.h"
4
+ #include "./cld2/public/compact_lang_det.h"
5
+ #include "./cld2/public/encodings.h"
6
6
 
7
7
  using namespace CLD2;
8
8
 
@@ -13,28 +13,43 @@ typedef struct {
13
13
  } RESULT;
14
14
 
15
15
  extern "C" {
16
- RESULT detectLanguageThunkInt(const char * src, bool is_plain_text) {
16
+ RESULT detectLanguageThunkInt(const char * src,
17
+ bool is_plain_text,
18
+ bool best_effort,
19
+ const char* tld_hint_param,
20
+ const char* content_lang_hint_param,
21
+ bool score_as_quads_param) {
17
22
  bool is_reliable;
18
23
  Language plus_one = UNKNOWN_LANGUAGE;
19
- const char* tld_hint = NULL;
20
- int encoding_hint = UNKNOWN_ENCODING;
21
- Language language_hint = UNKNOWN_LANGUAGE;
24
+ int encoding_hint_val = UNKNOWN_ENCODING;
25
+ Language language_hint_val = UNKNOWN_LANGUAGE;
26
+
27
+ CLDHints cld_hints = {content_lang_hint_param, tld_hint_param, encoding_hint_val, language_hint_val};
28
+
29
+ int flags = 0;
30
+ if (best_effort) {
31
+ flags |= kCLDFlagBestEffort;
32
+ }
33
+ if (score_as_quads_param) {
34
+ flags |= kCLDFlagScoreAsQuads;
35
+ }
22
36
 
23
37
  double normalized_score3[3];
24
38
  Language language3[3];
25
39
  int percent3[3];
26
40
  int text_bytes;
41
+ ResultChunkVector resultchunkvector;
27
42
 
28
43
  Language lang;
29
44
  lang = ExtDetectLanguageSummary(src,
30
45
  strlen(src),
31
46
  is_plain_text,
32
- tld_hint,
33
- encoding_hint,
34
- language_hint,
47
+ &cld_hints,
48
+ flags,
35
49
  language3,
36
50
  percent3,
37
51
  normalized_score3,
52
+ &resultchunkvector,
38
53
  &text_bytes,
39
54
  &is_reliable);
40
55
 
data/lib/cld/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module CLD
2
- VERSION = "1.0.4"
2
+ VERSION = "2.0.5"
3
3
  end
data/lib/cld.rb CHANGED
@@ -1,4 +1,4 @@
1
- require "cld/version"
1
+ require_relative "cld/version"
2
2
  require "ffi"
3
3
 
4
4
  module CLD
@@ -11,10 +11,31 @@ module CLD
11
11
  FFI::Platform::LIBSUFFIX
12
12
  end
13
13
 
14
- ffi_lib File.join(File.expand_path(File.dirname(__FILE__)), '..', 'ext', 'cld', 'libcld2.' + suffix)
14
+ # Look in multiple possible locations
15
+ possible_paths = [
16
+ File.expand_path("../cld/libcld2.#{suffix}", __FILE__),
17
+ File.expand_path("../../ext/cld/libcld2.#{suffix}", __FILE__),
18
+ File.join(File.expand_path("../../ext/cld", __FILE__), "libcld2.#{suffix}")
19
+ ]
15
20
 
16
- def self.detect_language(text, is_plain_text=true)
17
- result = detect_language_ext(text.to_s, is_plain_text)
21
+ lib_path = possible_paths.find { |path| File.exist?(path) }
22
+ raise LoadError, "Could not find libcld2.#{suffix} in #{possible_paths.join(', ')}" unless lib_path
23
+
24
+ ffi_lib lib_path
25
+
26
+ def self.detect_language(text, options = {})
27
+ is_plain_text = options.fetch(:is_plain_text, true)
28
+ best_effort = options.fetch(:best_effort, false)
29
+ tld_hint = options.fetch(:tld_hint, nil)
30
+ content_language_hint = options.fetch(:content_language_hint, nil)
31
+ score_as_quads = options.fetch(:score_as_quads, false)
32
+
33
+ result = detect_language_ext(text.to_s,
34
+ is_plain_text,
35
+ best_effort,
36
+ tld_hint,
37
+ content_language_hint,
38
+ score_as_quads)
18
39
  Hash[ result.members.map {|member| [member.to_sym, result[member]]} ]
19
40
  end
20
41
 
@@ -24,5 +45,7 @@ module CLD
24
45
  layout :name, :string, :code, :string, :reliable, :bool
25
46
  end
26
47
 
27
- attach_function "detect_language_ext", "detectLanguageThunkInt", [:buffer_in, :bool], ReturnValue.by_value
48
+ attach_function "detect_language_ext", "detectLanguageThunkInt",
49
+ [:buffer_in, :bool, :bool, :string, :string, :bool],
50
+ ReturnValue.by_value
28
51
  end
data/spec/cld_spec.rb ADDED
@@ -0,0 +1,74 @@
1
+ # encoding: UTF-8
2
+ require "spec_helper"
3
+
4
+ describe CLD do
5
+
6
+ context "English text" do
7
+ subject { CLD.detect_language("This is a test") }
8
+
9
+ it { expect(subject[:name]).to eq("ENGLISH") }
10
+ it { expect(subject[:code]).to eq("en") }
11
+ it { expect(subject[:reliable]).to be true }
12
+ end
13
+
14
+ context "French text" do
15
+ subject { CLD.detect_language("plus ça change, plus c'est la même chose") }
16
+
17
+ it { expect(subject[:name]).to eq("FRENCH") }
18
+ it { expect(subject[:code]).to eq("fr") }
19
+ it { expect(subject[:reliable]).to be true }
20
+ end
21
+
22
+ context "Italian text" do
23
+ subject { CLD.detect_language("sono tutti pazzi qui") }
24
+
25
+ it { expect(subject[:name]).to eq("ITALIAN") }
26
+ it { expect(subject[:code]).to eq("it") }
27
+ it { expect(subject[:reliable]).to be true }
28
+ end
29
+
30
+ context "French in HTML - using CLD html " do
31
+ subject { CLD.detect_language("<html><head><body><script>A large amount of english in the script which should be ignored if using html in detect_language.</script><p>plus ça change, plus c'est la même chose</p></body></html>", false) }
32
+
33
+ it { expect(subject[:name]).to eq("FRENCH") }
34
+ it { expect(subject[:code]).to eq("fr") }
35
+ end
36
+
37
+ context "French in HTML - using CLD text " do
38
+ subject { CLD.detect_language("<html><head><body><script>A large amount of english in the script which should be ignored if using html in detect_language.</script><p>plus ça change, plus c'est la même chose</p></body></html>", true) }
39
+
40
+ it { expect(subject[:name]).to eq("ENGLISH") }
41
+ it { expect(subject[:code]).to eq("en") }
42
+ end
43
+
44
+ context "Simplified Chinese text" do
45
+ subject { CLD.detect_language("你好吗箭体") }
46
+
47
+ it { expect(subject[:name]).to eq("Chinese") }
48
+ it { expect(subject[:code]).to eq("zh") }
49
+ end
50
+
51
+ context "Traditional Chinese text" do
52
+ subject { CLD.detect_language("你好嗎繁體") }
53
+
54
+ it { expect(subject[:name]).to eq("ChineseT") }
55
+ it { expect(subject[:code]).to eq("zh-Hant") }
56
+ end
57
+
58
+ context "Unknown text" do
59
+ subject { CLD.detect_language("") }
60
+
61
+ it { expect(subject[:name]).to eq("Unknown") }
62
+ it { expect(subject[:code]).to eq("un") }
63
+ it { expect(subject[:reliable]).to_not be true }
64
+ end
65
+
66
+ context "nil for text" do
67
+ subject { CLD.detect_language(nil) }
68
+
69
+ it { expect(subject[:name]).to eq("Unknown") }
70
+ it { expect(subject[:code]).to eq("un") }
71
+ it { expect(subject[:reliable]).to_not be true }
72
+ end
73
+
74
+ end
@@ -0,0 +1,7 @@
1
+ require "rubygems"
2
+ require "bundler/setup"
3
+ Bundler.require(:default)
4
+ require File.dirname(__FILE__) + '/../lib/cld.rb'
5
+
6
+ RSpec.configure do |config|
7
+ end
metadata CHANGED
@@ -1,46 +1,47 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cld2-small
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alessandro Dal Grande
8
8
  - Jason Toy
9
9
  - Juned Shaikh
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-04-30 00:00:00.000000000 Z
13
+ date: 2025-05-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ffi
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - '='
19
+ - - "~>"
20
20
  - !ruby/object:Gem::Version
21
- version: 1.12.0
21
+ version: 1.17.1
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - '='
26
+ - - "~>"
27
27
  - !ruby/object:Gem::Version
28
- version: 1.12.0
28
+ version: 1.17.1
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: rspec
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
33
  - - "~>"
34
34
  - !ruby/object:Gem::Version
35
- version: 2.14.1
35
+ version: '3.10'
36
36
  type: :development
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - "~>"
41
41
  - !ruby/object:Gem::Version
42
- version: 2.14.1
43
- description: Compact Language Detection2.0 for Ruby
42
+ version: '3.10'
43
+ description: A Ruby gem for Compact Language Detection 2.0, providing language detection
44
+ capabilities.
44
45
  email:
45
46
  - juned1234all@gmail.com
46
47
  executables: []
@@ -48,6 +49,8 @@ extensions:
48
49
  - ext/cld/extconf.rb
49
50
  extra_rdoc_files: []
50
51
  files:
52
+ - LICENSE
53
+ - README.md
51
54
  - ext/cld/cld2/LICENSE
52
55
  - ext/cld/cld2/README.md
53
56
  - ext/cld/cld2/docs/CLD2UnitTestFullOutput.html
@@ -150,14 +153,17 @@ files:
150
153
  - ext/cld/thunk.cc
151
154
  - lib/cld.rb
152
155
  - lib/cld/version.rb
156
+ - spec/cld_spec.rb
157
+ - spec/spec_helper.rb
153
158
  homepage: https://github.com/justjuned/cld2-small
154
159
  licenses:
155
160
  - Apache-2.0
156
161
  metadata: {}
157
- post_install_message:
162
+ post_install_message:
158
163
  rdoc_options: []
159
164
  require_paths:
160
165
  - lib
166
+ - ext
161
167
  required_ruby_version: !ruby/object:Gem::Requirement
162
168
  requirements:
163
169
  - - ">="
@@ -169,9 +175,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
175
  - !ruby/object:Gem::Version
170
176
  version: '0'
171
177
  requirements: []
172
- rubyforge_project:
173
- rubygems_version: 2.7.9
174
- signing_key:
178
+ rubygems_version: 3.4.19
179
+ signing_key:
175
180
  specification_version: 4
176
- summary: Compact Language Detection2.0 for Ruby
177
- test_files: []
181
+ summary: Language detection for Ruby using Compact Language Detection 2.0
182
+ test_files:
183
+ - spec/cld_spec.rb
184
+ - spec/spec_helper.rb