cld2-small 1.0.4 → 2.0.0
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 +4 -4
- data/LICENSE +203 -0
- data/README.md +43 -0
- data/ext/cld/cld2/internal/cld2_generated_cjk_compatible.o +0 -0
- data/ext/cld/cld2/internal/cld2_generated_deltaoctachrome.o +0 -0
- data/ext/cld/cld2/internal/cld2_generated_distinctoctachrome.o +0 -0
- data/ext/cld/cld2/internal/cld2_generated_quadchrome_2.o +0 -0
- data/ext/cld/cld2/internal/cld_generated_cjk_delta_bi_4.o +0 -0
- data/ext/cld/cld2/internal/cld_generated_cjk_uni_prop_80.o +0 -0
- data/ext/cld/cld2/internal/cld_generated_score_quad_octa_2.o +0 -0
- data/ext/cld/cld2/internal/cldutil.o +0 -0
- data/ext/cld/cld2/internal/cldutil_shared.o +0 -0
- data/ext/cld/cld2/internal/compact_lang_det.o +0 -0
- data/ext/cld/cld2/internal/compact_lang_det_hint_code.o +0 -0
- data/ext/cld/cld2/internal/compact_lang_det_impl.o +0 -0
- data/ext/cld/cld2/internal/debug.o +0 -0
- data/ext/cld/cld2/internal/fixunicodevalue.o +0 -0
- data/ext/cld/cld2/internal/generated_distinct_bi_0.o +0 -0
- data/ext/cld/cld2/internal/generated_entities.o +0 -0
- data/ext/cld/cld2/internal/generated_language.o +0 -0
- data/ext/cld/cld2/internal/generated_ulscript.o +0 -0
- data/ext/cld/cld2/internal/getonescriptspan.o +0 -0
- data/ext/cld/cld2/internal/lang_script.o +0 -0
- data/ext/cld/cld2/internal/offsetmap.o +0 -0
- data/ext/cld/cld2/internal/scoreonescriptspan.o +0 -0
- data/ext/cld/cld2/internal/tote.o +0 -0
- data/ext/cld/cld2/internal/utf8statetable.o +0 -0
- data/ext/cld/extconf.rb +13 -9
- data/ext/cld/thunk.cc +3 -3
- data/lib/cld/version.rb +1 -1
- data/lib/cld.rb +11 -1
- data/spec/cld_spec.rb +74 -0
- data/spec/spec_helper.rb +7 -0
- metadata +47 -16
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f88610ddab27246200e533e2a863ecfa32adbf0542490bfbe42deb1f54653b7a
|
|
4
|
+
data.tar.gz: fbecb14a1eac61c643a6bf8c347005d5dabed88e83a301e12708ec056336ddd0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3dd02811b0fe15197f8640019ce5235c2531d8af0a48a97cf944fb27d30797813ca91ca4ee2e80e703b8d197e2e3d5f180f45733e6d39139a830c15ea2bc95f9
|
|
7
|
+
data.tar.gz: ff09ffa0689e7e9ee426f0a383cc82b238d5f891ed0f81d1478720b9ea24ae6f4a469bb1bab43255e610847348f07416a2f3dbc07f072c0c0861ef40fc0c16ed
|
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,43 @@
|
|
|
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
|
+
```ruby
|
|
14
|
+
CLD.detect_language("Working as expected")
|
|
15
|
+
# => {:name => "ENGLISH", :code => "en", :reliable => true}
|
|
16
|
+
|
|
17
|
+
CLD.detect_language("plus ça change, plus c'est la même chose")
|
|
18
|
+
# => {:name => "FRENCH", :code => "fr", :reliable => true}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
Add this line to your application's Gemfile:
|
|
24
|
+
|
|
25
|
+
```ruby
|
|
26
|
+
gem 'cld2-small', require 'cld'
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
And then execute:
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
$ bundle
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Thanks
|
|
36
|
+
|
|
37
|
+
Thanks to the Chrome authors, and to Mike McCandless for writing a Python version.
|
|
38
|
+
|
|
39
|
+
Thanks to Jason Toy for the original cld v1.0 ruby port.
|
|
40
|
+
|
|
41
|
+
Thanks to BanjoInc for cld v2.0 ruby port.
|
|
42
|
+
|
|
43
|
+
Licensed the same as CLD2Owners.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/ext/cld/extconf.rb
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
require 'mkmf'
|
|
2
2
|
|
|
3
|
-
#
|
|
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
|
-
|
|
35
|
+
# Create makefile with the correct target
|
|
36
|
+
create_makefile('cld/libcld2')
|
|
34
37
|
end
|
|
35
38
|
|
|
36
|
-
#
|
|
37
|
-
open('Makefile', 'a') do |f|
|
|
38
|
-
f.write
|
|
39
|
+
# Add clean target
|
|
40
|
+
File.open('Makefile', 'a') do |f|
|
|
41
|
+
f.write <<-EOF
|
|
39
42
|
|
|
40
|
-
|
|
41
|
-
|
|
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
|
|
data/lib/cld/version.rb
CHANGED
data/lib/cld.rb
CHANGED
|
@@ -11,7 +11,17 @@ module CLD
|
|
|
11
11
|
FFI::Platform::LIBSUFFIX
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
|
|
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
|
+
]
|
|
20
|
+
|
|
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
|
|
15
25
|
|
|
16
26
|
def self.detect_language(text, is_plain_text=true)
|
|
17
27
|
result = detect_language_ext(text.to_s, is_plain_text)
|
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
|
data/spec/spec_helper.rb
ADDED
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:
|
|
4
|
+
version: 2.0.0
|
|
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:
|
|
13
|
+
date: 2025-03-10 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.
|
|
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.
|
|
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:
|
|
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:
|
|
43
|
-
description: Compact Language
|
|
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
|
|
@@ -71,39 +74,51 @@ files:
|
|
|
71
74
|
- ext/cld/cld2/internal/cld2_dynamic_data_loader.h
|
|
72
75
|
- ext/cld/cld2/internal/cld2_dynamic_data_tool.cc
|
|
73
76
|
- ext/cld/cld2/internal/cld2_generated_cjk_compatible.cc
|
|
77
|
+
- ext/cld/cld2/internal/cld2_generated_cjk_compatible.o
|
|
74
78
|
- ext/cld/cld2/internal/cld2_generated_deltaocta0122.cc
|
|
75
79
|
- ext/cld/cld2/internal/cld2_generated_deltaocta0527.cc
|
|
76
80
|
- ext/cld/cld2/internal/cld2_generated_deltaoctachrome.cc
|
|
81
|
+
- ext/cld/cld2/internal/cld2_generated_deltaoctachrome.o
|
|
77
82
|
- ext/cld/cld2/internal/cld2_generated_distinctocta0122.cc
|
|
78
83
|
- ext/cld/cld2/internal/cld2_generated_distinctocta0527.cc
|
|
79
84
|
- ext/cld/cld2/internal/cld2_generated_distinctoctachrome.cc
|
|
85
|
+
- ext/cld/cld2/internal/cld2_generated_distinctoctachrome.o
|
|
80
86
|
- ext/cld/cld2/internal/cld2_generated_octa2_dummy.cc
|
|
81
87
|
- ext/cld/cld2/internal/cld2_generated_quad0122.cc
|
|
82
88
|
- ext/cld/cld2/internal/cld2_generated_quad0720.cc
|
|
83
89
|
- ext/cld/cld2/internal/cld2_generated_quadchrome_16.cc
|
|
84
90
|
- ext/cld/cld2/internal/cld2_generated_quadchrome_2.cc
|
|
91
|
+
- ext/cld/cld2/internal/cld2_generated_quadchrome_2.o
|
|
85
92
|
- ext/cld/cld2/internal/cld2_unittest.cc
|
|
86
93
|
- ext/cld/cld2/internal/cld2_unittest_full.cc
|
|
87
94
|
- ext/cld/cld2/internal/cld2tablesummary.h
|
|
88
95
|
- ext/cld/cld2/internal/cld_generated_cjk_delta_bi_32.cc
|
|
89
96
|
- ext/cld/cld2/internal/cld_generated_cjk_delta_bi_4.cc
|
|
97
|
+
- ext/cld/cld2/internal/cld_generated_cjk_delta_bi_4.o
|
|
90
98
|
- ext/cld/cld2/internal/cld_generated_cjk_uni_prop_80.cc
|
|
99
|
+
- ext/cld/cld2/internal/cld_generated_cjk_uni_prop_80.o
|
|
91
100
|
- ext/cld/cld2/internal/cld_generated_score_quad_octa_0122.cc
|
|
92
101
|
- ext/cld/cld2/internal/cld_generated_score_quad_octa_0122_2.cc
|
|
93
102
|
- ext/cld/cld2/internal/cld_generated_score_quad_octa_1024_256.cc
|
|
94
103
|
- ext/cld/cld2/internal/cld_generated_score_quad_octa_2.cc
|
|
104
|
+
- ext/cld/cld2/internal/cld_generated_score_quad_octa_2.o
|
|
95
105
|
- ext/cld/cld2/internal/cldutil.cc
|
|
96
106
|
- ext/cld/cld2/internal/cldutil.h
|
|
107
|
+
- ext/cld/cld2/internal/cldutil.o
|
|
97
108
|
- ext/cld/cld2/internal/cldutil_offline.cc
|
|
98
109
|
- ext/cld/cld2/internal/cldutil_offline.h
|
|
99
110
|
- ext/cld/cld2/internal/cldutil_shared.cc
|
|
100
111
|
- ext/cld/cld2/internal/cldutil_shared.h
|
|
112
|
+
- ext/cld/cld2/internal/cldutil_shared.o
|
|
101
113
|
- ext/cld/cld2/internal/clean.sh
|
|
102
114
|
- ext/cld/cld2/internal/compact_lang_det.cc
|
|
115
|
+
- ext/cld/cld2/internal/compact_lang_det.o
|
|
103
116
|
- ext/cld/cld2/internal/compact_lang_det_hint_code.cc
|
|
104
117
|
- ext/cld/cld2/internal/compact_lang_det_hint_code.h
|
|
118
|
+
- ext/cld/cld2/internal/compact_lang_det_hint_code.o
|
|
105
119
|
- ext/cld/cld2/internal/compact_lang_det_impl.cc
|
|
106
120
|
- ext/cld/cld2/internal/compact_lang_det_impl.h
|
|
121
|
+
- ext/cld/cld2/internal/compact_lang_det_impl.o
|
|
107
122
|
- ext/cld/cld2/internal/compact_lang_det_test.cc
|
|
108
123
|
- ext/cld/cld2/internal/compile.sh
|
|
109
124
|
- ext/cld/cld2/internal/compile_and_test_all.sh
|
|
@@ -112,31 +127,42 @@ files:
|
|
|
112
127
|
- ext/cld/cld2/internal/compile_libs.sh
|
|
113
128
|
- ext/cld/cld2/internal/debug.cc
|
|
114
129
|
- ext/cld/cld2/internal/debug.h
|
|
130
|
+
- ext/cld/cld2/internal/debug.o
|
|
115
131
|
- ext/cld/cld2/internal/debug_empty.cc
|
|
116
132
|
- ext/cld/cld2/internal/fixunicodevalue.cc
|
|
117
133
|
- ext/cld/cld2/internal/fixunicodevalue.h
|
|
134
|
+
- ext/cld/cld2/internal/fixunicodevalue.o
|
|
118
135
|
- ext/cld/cld2/internal/generated_distinct_bi_0.cc
|
|
136
|
+
- ext/cld/cld2/internal/generated_distinct_bi_0.o
|
|
119
137
|
- ext/cld/cld2/internal/generated_entities.cc
|
|
138
|
+
- ext/cld/cld2/internal/generated_entities.o
|
|
120
139
|
- ext/cld/cld2/internal/generated_language.cc
|
|
121
140
|
- ext/cld/cld2/internal/generated_language.h
|
|
141
|
+
- ext/cld/cld2/internal/generated_language.o
|
|
122
142
|
- ext/cld/cld2/internal/generated_ulscript.cc
|
|
123
143
|
- ext/cld/cld2/internal/generated_ulscript.h
|
|
144
|
+
- ext/cld/cld2/internal/generated_ulscript.o
|
|
124
145
|
- ext/cld/cld2/internal/getonescriptspan.cc
|
|
125
146
|
- ext/cld/cld2/internal/getonescriptspan.h
|
|
147
|
+
- ext/cld/cld2/internal/getonescriptspan.o
|
|
126
148
|
- ext/cld/cld2/internal/integral_types.h
|
|
127
149
|
- ext/cld/cld2/internal/lang_script.cc
|
|
128
150
|
- ext/cld/cld2/internal/lang_script.h
|
|
151
|
+
- ext/cld/cld2/internal/lang_script.o
|
|
129
152
|
- ext/cld/cld2/internal/langspan.h
|
|
130
153
|
- ext/cld/cld2/internal/offsetmap.cc
|
|
131
154
|
- ext/cld/cld2/internal/offsetmap.h
|
|
155
|
+
- ext/cld/cld2/internal/offsetmap.o
|
|
132
156
|
- ext/cld/cld2/internal/port.h
|
|
133
157
|
- ext/cld/cld2/internal/scoreonescriptspan.cc
|
|
134
158
|
- ext/cld/cld2/internal/scoreonescriptspan.h
|
|
159
|
+
- ext/cld/cld2/internal/scoreonescriptspan.o
|
|
135
160
|
- ext/cld/cld2/internal/scoreutf8text.cc
|
|
136
161
|
- ext/cld/cld2/internal/stringpiece.h
|
|
137
162
|
- ext/cld/cld2/internal/test_shuffle_1000_48_666.utf8.gz
|
|
138
163
|
- ext/cld/cld2/internal/tote.cc
|
|
139
164
|
- ext/cld/cld2/internal/tote.h
|
|
165
|
+
- ext/cld/cld2/internal/tote.o
|
|
140
166
|
- ext/cld/cld2/internal/unittest_data.h
|
|
141
167
|
- ext/cld/cld2/internal/utf8acceptinterchange.h
|
|
142
168
|
- ext/cld/cld2/internal/utf8prop_lettermarkscriptnum.h
|
|
@@ -144,20 +170,24 @@ files:
|
|
|
144
170
|
- ext/cld/cld2/internal/utf8scannot_lettermarkspecial.h
|
|
145
171
|
- ext/cld/cld2/internal/utf8statetable.cc
|
|
146
172
|
- ext/cld/cld2/internal/utf8statetable.h
|
|
173
|
+
- ext/cld/cld2/internal/utf8statetable.o
|
|
147
174
|
- ext/cld/cld2/public/compact_lang_det.h
|
|
148
175
|
- ext/cld/cld2/public/encodings.h
|
|
149
176
|
- ext/cld/extconf.rb
|
|
150
177
|
- ext/cld/thunk.cc
|
|
151
178
|
- lib/cld.rb
|
|
152
179
|
- lib/cld/version.rb
|
|
180
|
+
- spec/cld_spec.rb
|
|
181
|
+
- spec/spec_helper.rb
|
|
153
182
|
homepage: https://github.com/justjuned/cld2-small
|
|
154
183
|
licenses:
|
|
155
184
|
- Apache-2.0
|
|
156
185
|
metadata: {}
|
|
157
|
-
post_install_message:
|
|
186
|
+
post_install_message:
|
|
158
187
|
rdoc_options: []
|
|
159
188
|
require_paths:
|
|
160
189
|
- lib
|
|
190
|
+
- ext
|
|
161
191
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
162
192
|
requirements:
|
|
163
193
|
- - ">="
|
|
@@ -169,9 +199,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
169
199
|
- !ruby/object:Gem::Version
|
|
170
200
|
version: '0'
|
|
171
201
|
requirements: []
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
signing_key:
|
|
202
|
+
rubygems_version: 3.4.19
|
|
203
|
+
signing_key:
|
|
175
204
|
specification_version: 4
|
|
176
|
-
summary: Compact Language
|
|
177
|
-
test_files:
|
|
205
|
+
summary: Language detection for Ruby using Compact Language Detection 2.0
|
|
206
|
+
test_files:
|
|
207
|
+
- spec/cld_spec.rb
|
|
208
|
+
- spec/spec_helper.rb
|