lingua_rs 0.4.4 → 0.4.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 +4 -4
- data/README.md +12 -23
- data/lib/lingua/version.rb +1 -1
- metadata +2 -3
- data/ext/lingua/Cargo.lock +0 -289
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 953c59791dc0b1234e1264f3e75881319edfd752a537a3bb0fd02c9830cb63ea
|
|
4
|
+
data.tar.gz: 6cf3ce511f0026deb1090c531771a843bb15e0fc4c7637e974f1d50b65330106
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 067a63ee83c014a358fa48f0df452c626123d8039862cb9dac57b4e733fb379fc6af97102613bd8c664b3762105123223a488b962896bfc419195d237ff6135f
|
|
7
|
+
data.tar.gz: 4336e0b72d1dff76ddf28d2721025b4a36a4f6dd031252a09bdfa1eb10fdfc6982dcbc1bbd01d223a84e0f5256c06a98190c4c47a0f154ba06696e4a60abfce7
|
data/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[](https://rubygems.org/gems/lingua_rs)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Native Ruby bindings for the [Lingua](https://github.com/pemistahl/lingua-rs) Rust library, bringing highly accurate language detection for short text and mixed-language text, with confidence scores and ISO 639-1/639-3 language codes.
|
|
9
9
|
|
|
10
10
|
## Installation
|
|
11
11
|
|
|
@@ -25,12 +25,7 @@ Then run `bundle install`.
|
|
|
25
25
|
|
|
26
26
|
### Build requirements
|
|
27
27
|
|
|
28
|
-
A Rust toolchain is required to compile the native extension.
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
export LIBCLANG_PATH=/usr/lib/llvm21/lib
|
|
32
|
-
export PATH=/usr/lib/llvm21/bin:$PATH
|
|
33
|
-
```
|
|
28
|
+
A Rust toolchain is required to compile the native extension.
|
|
34
29
|
|
|
35
30
|
## Usage
|
|
36
31
|
|
|
@@ -148,6 +143,12 @@ Lingua::Language['fra'] # => #<Lingua::Language French>
|
|
|
148
143
|
Lingua::Language['xxx'] # => nil
|
|
149
144
|
```
|
|
150
145
|
|
|
146
|
+
| Method | Return type | Description |
|
|
147
|
+
|---|---|---|
|
|
148
|
+
| `Lingua::Language.all` | `Array<Lingua::Language>` | All supported languages |
|
|
149
|
+
| `Lingua::Language.names` | `Array<String>` | All language names (e.g. `'French'`) |
|
|
150
|
+
| `Lingua::Language.iso_codes` | `Array<String>` | All ISO 639-1 codes (e.g. `'fr'`) |
|
|
151
|
+
|
|
151
152
|
| Method | Return type | Example |
|
|
152
153
|
|---|---|---|
|
|
153
154
|
| `name` | `String` | `'French'` |
|
|
@@ -157,19 +158,11 @@ Lingua::Language['xxx'] # => nil
|
|
|
157
158
|
| `to_iso` | `String` | `'fr'` (alias for `to_iso6391`) |
|
|
158
159
|
| `to_iso6391` | `String` | `'fr'` |
|
|
159
160
|
| `to_iso6393` | `String` | `'fra'` |
|
|
160
|
-
|
|
|
161
|
+
| `<name>?` | `Boolean` | Dynamic predicate for any language (`french?`, `fr?`, `fra?`) |
|
|
161
162
|
| `inspect` | `String` | `'#<Lingua::Language French>'` |
|
|
162
163
|
| `==` | `Boolean` | Compare two languages |
|
|
163
164
|
| `hash` | `Integer` | Hash value (usable as Hash key) |
|
|
164
165
|
|
|
165
|
-
Class methods:
|
|
166
|
-
|
|
167
|
-
| Method | Return type | Description |
|
|
168
|
-
|---|---|---|
|
|
169
|
-
| `Lingua::Language.all` | `Array<Lingua::Language>` | All supported languages |
|
|
170
|
-
| `Lingua::Language.names` | `Array<String>` | All language names (e.g. `'French'`) |
|
|
171
|
-
| `Lingua::Language.iso_codes` | `Array<String>` | All ISO 639-1 codes (e.g. `'fr'`) |
|
|
172
|
-
|
|
173
166
|
### `Lingua::ConfidenceResult` methods
|
|
174
167
|
|
|
175
168
|
Returned by `confidence_values`.
|
|
@@ -200,14 +193,10 @@ Returned by `detect_multiple`.
|
|
|
200
193
|
`Lingua::UnknownLanguageError` (subclass of `ArgumentError`) is raised when an unrecognized language name or code is passed:
|
|
201
194
|
|
|
202
195
|
```ruby
|
|
203
|
-
Lingua.detect('Hello', languages: %w[en zzzz])
|
|
204
|
-
# => Lingua::UnknownLanguageError: unknown language: "zzzz"
|
|
205
|
-
|
|
206
|
-
# Can also be rescued as ArgumentError
|
|
207
196
|
begin
|
|
208
|
-
Lingua.detect('Hello', languages: %w[zzzz])
|
|
209
|
-
rescue
|
|
210
|
-
puts e.message
|
|
197
|
+
Lingua.detect('Hello', languages: %w[en zzzz])
|
|
198
|
+
rescue Lingua::UnknownLanguageError => e
|
|
199
|
+
puts e.message # => unknown language: "zzzz"
|
|
211
200
|
end
|
|
212
201
|
```
|
|
213
202
|
|
data/lib/lingua/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lingua_rs
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sébastien Vrillaud
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-04-
|
|
10
|
+
date: 2026-04-08 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: rb_sys
|
|
@@ -50,7 +50,6 @@ files:
|
|
|
50
50
|
- LICENSE.txt
|
|
51
51
|
- README.md
|
|
52
52
|
- Rakefile
|
|
53
|
-
- ext/lingua/Cargo.lock
|
|
54
53
|
- ext/lingua/Cargo.toml
|
|
55
54
|
- ext/lingua/extconf.rb
|
|
56
55
|
- ext/lingua/src/confidence_result.rs
|
data/ext/lingua/Cargo.lock
DELETED
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
# This file is automatically @generated by Cargo.
|
|
2
|
-
# It is not intended for manual editing.
|
|
3
|
-
version = 4
|
|
4
|
-
|
|
5
|
-
[[package]]
|
|
6
|
-
name = "aho-corasick"
|
|
7
|
-
version = "1.1.4"
|
|
8
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
-
checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301"
|
|
10
|
-
dependencies = [
|
|
11
|
-
"memchr",
|
|
12
|
-
]
|
|
13
|
-
|
|
14
|
-
[[package]]
|
|
15
|
-
name = "bindgen"
|
|
16
|
-
version = "0.69.5"
|
|
17
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
18
|
-
checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088"
|
|
19
|
-
dependencies = [
|
|
20
|
-
"bitflags",
|
|
21
|
-
"cexpr",
|
|
22
|
-
"clang-sys",
|
|
23
|
-
"itertools",
|
|
24
|
-
"lazy_static",
|
|
25
|
-
"lazycell",
|
|
26
|
-
"proc-macro2",
|
|
27
|
-
"quote",
|
|
28
|
-
"regex",
|
|
29
|
-
"rustc-hash",
|
|
30
|
-
"shlex",
|
|
31
|
-
"syn",
|
|
32
|
-
]
|
|
33
|
-
|
|
34
|
-
[[package]]
|
|
35
|
-
name = "bitflags"
|
|
36
|
-
version = "2.11.0"
|
|
37
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
38
|
-
checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af"
|
|
39
|
-
|
|
40
|
-
[[package]]
|
|
41
|
-
name = "cexpr"
|
|
42
|
-
version = "0.6.0"
|
|
43
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
44
|
-
checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
|
|
45
|
-
dependencies = [
|
|
46
|
-
"nom",
|
|
47
|
-
]
|
|
48
|
-
|
|
49
|
-
[[package]]
|
|
50
|
-
name = "cfg-if"
|
|
51
|
-
version = "1.0.4"
|
|
52
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
53
|
-
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
|
54
|
-
|
|
55
|
-
[[package]]
|
|
56
|
-
name = "clang-sys"
|
|
57
|
-
version = "1.8.1"
|
|
58
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
59
|
-
checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4"
|
|
60
|
-
dependencies = [
|
|
61
|
-
"glob",
|
|
62
|
-
"libc",
|
|
63
|
-
"libloading",
|
|
64
|
-
]
|
|
65
|
-
|
|
66
|
-
[[package]]
|
|
67
|
-
name = "either"
|
|
68
|
-
version = "1.15.0"
|
|
69
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
70
|
-
checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
|
|
71
|
-
|
|
72
|
-
[[package]]
|
|
73
|
-
name = "glob"
|
|
74
|
-
version = "0.3.3"
|
|
75
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
76
|
-
checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280"
|
|
77
|
-
|
|
78
|
-
[[package]]
|
|
79
|
-
name = "itertools"
|
|
80
|
-
version = "0.12.1"
|
|
81
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
82
|
-
checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569"
|
|
83
|
-
dependencies = [
|
|
84
|
-
"either",
|
|
85
|
-
]
|
|
86
|
-
|
|
87
|
-
[[package]]
|
|
88
|
-
name = "lazy_static"
|
|
89
|
-
version = "1.5.0"
|
|
90
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
91
|
-
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
|
92
|
-
|
|
93
|
-
[[package]]
|
|
94
|
-
name = "lazycell"
|
|
95
|
-
version = "1.3.0"
|
|
96
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
97
|
-
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
|
98
|
-
|
|
99
|
-
[[package]]
|
|
100
|
-
name = "libc"
|
|
101
|
-
version = "0.2.183"
|
|
102
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
103
|
-
checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d"
|
|
104
|
-
|
|
105
|
-
[[package]]
|
|
106
|
-
name = "libloading"
|
|
107
|
-
version = "0.8.9"
|
|
108
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
109
|
-
checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55"
|
|
110
|
-
dependencies = [
|
|
111
|
-
"cfg-if",
|
|
112
|
-
"windows-link",
|
|
113
|
-
]
|
|
114
|
-
|
|
115
|
-
[[package]]
|
|
116
|
-
name = "lingua"
|
|
117
|
-
version = "0.1.0"
|
|
118
|
-
dependencies = [
|
|
119
|
-
"magnus",
|
|
120
|
-
]
|
|
121
|
-
|
|
122
|
-
[[package]]
|
|
123
|
-
name = "magnus"
|
|
124
|
-
version = "0.8.2"
|
|
125
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
126
|
-
checksum = "3b36a5b126bbe97eb0d02d07acfeb327036c6319fd816139a49824a83b7f9012"
|
|
127
|
-
dependencies = [
|
|
128
|
-
"magnus-macros",
|
|
129
|
-
"rb-sys",
|
|
130
|
-
"rb-sys-env",
|
|
131
|
-
"seq-macro",
|
|
132
|
-
]
|
|
133
|
-
|
|
134
|
-
[[package]]
|
|
135
|
-
name = "magnus-macros"
|
|
136
|
-
version = "0.8.0"
|
|
137
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
138
|
-
checksum = "47607461fd8e1513cb4f2076c197d8092d921a1ea75bd08af97398f593751892"
|
|
139
|
-
dependencies = [
|
|
140
|
-
"proc-macro2",
|
|
141
|
-
"quote",
|
|
142
|
-
"syn",
|
|
143
|
-
]
|
|
144
|
-
|
|
145
|
-
[[package]]
|
|
146
|
-
name = "memchr"
|
|
147
|
-
version = "2.8.0"
|
|
148
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
149
|
-
checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
|
|
150
|
-
|
|
151
|
-
[[package]]
|
|
152
|
-
name = "minimal-lexical"
|
|
153
|
-
version = "0.2.1"
|
|
154
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
155
|
-
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
|
156
|
-
|
|
157
|
-
[[package]]
|
|
158
|
-
name = "nom"
|
|
159
|
-
version = "7.1.3"
|
|
160
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
161
|
-
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
|
|
162
|
-
dependencies = [
|
|
163
|
-
"memchr",
|
|
164
|
-
"minimal-lexical",
|
|
165
|
-
]
|
|
166
|
-
|
|
167
|
-
[[package]]
|
|
168
|
-
name = "proc-macro2"
|
|
169
|
-
version = "1.0.106"
|
|
170
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
171
|
-
checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
|
|
172
|
-
dependencies = [
|
|
173
|
-
"unicode-ident",
|
|
174
|
-
]
|
|
175
|
-
|
|
176
|
-
[[package]]
|
|
177
|
-
name = "quote"
|
|
178
|
-
version = "1.0.45"
|
|
179
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
180
|
-
checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924"
|
|
181
|
-
dependencies = [
|
|
182
|
-
"proc-macro2",
|
|
183
|
-
]
|
|
184
|
-
|
|
185
|
-
[[package]]
|
|
186
|
-
name = "rb-sys"
|
|
187
|
-
version = "0.9.124"
|
|
188
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
189
|
-
checksum = "c85c4188462601e2aa1469def389c17228566f82ea72f137ed096f21591bc489"
|
|
190
|
-
dependencies = [
|
|
191
|
-
"rb-sys-build",
|
|
192
|
-
]
|
|
193
|
-
|
|
194
|
-
[[package]]
|
|
195
|
-
name = "rb-sys-build"
|
|
196
|
-
version = "0.9.124"
|
|
197
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
198
|
-
checksum = "568068db4102230882e6d4ae8de6632e224ca75fe5970f6e026a04e91ed635d3"
|
|
199
|
-
dependencies = [
|
|
200
|
-
"bindgen",
|
|
201
|
-
"lazy_static",
|
|
202
|
-
"proc-macro2",
|
|
203
|
-
"quote",
|
|
204
|
-
"regex",
|
|
205
|
-
"shell-words",
|
|
206
|
-
"syn",
|
|
207
|
-
]
|
|
208
|
-
|
|
209
|
-
[[package]]
|
|
210
|
-
name = "rb-sys-env"
|
|
211
|
-
version = "0.2.3"
|
|
212
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
213
|
-
checksum = "cca7ad6a7e21e72151d56fe2495a259b5670e204c3adac41ee7ef676ea08117a"
|
|
214
|
-
|
|
215
|
-
[[package]]
|
|
216
|
-
name = "regex"
|
|
217
|
-
version = "1.12.3"
|
|
218
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
219
|
-
checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276"
|
|
220
|
-
dependencies = [
|
|
221
|
-
"aho-corasick",
|
|
222
|
-
"memchr",
|
|
223
|
-
"regex-automata",
|
|
224
|
-
"regex-syntax",
|
|
225
|
-
]
|
|
226
|
-
|
|
227
|
-
[[package]]
|
|
228
|
-
name = "regex-automata"
|
|
229
|
-
version = "0.4.14"
|
|
230
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
231
|
-
checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f"
|
|
232
|
-
dependencies = [
|
|
233
|
-
"aho-corasick",
|
|
234
|
-
"memchr",
|
|
235
|
-
"regex-syntax",
|
|
236
|
-
]
|
|
237
|
-
|
|
238
|
-
[[package]]
|
|
239
|
-
name = "regex-syntax"
|
|
240
|
-
version = "0.8.10"
|
|
241
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
242
|
-
checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a"
|
|
243
|
-
|
|
244
|
-
[[package]]
|
|
245
|
-
name = "rustc-hash"
|
|
246
|
-
version = "1.1.0"
|
|
247
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
248
|
-
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
|
249
|
-
|
|
250
|
-
[[package]]
|
|
251
|
-
name = "seq-macro"
|
|
252
|
-
version = "0.3.6"
|
|
253
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
254
|
-
checksum = "1bc711410fbe7399f390ca1c3b60ad0f53f80e95c5eb935e52268a0e2cd49acc"
|
|
255
|
-
|
|
256
|
-
[[package]]
|
|
257
|
-
name = "shell-words"
|
|
258
|
-
version = "1.1.1"
|
|
259
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
260
|
-
checksum = "dc6fe69c597f9c37bfeeeeeb33da3530379845f10be461a66d16d03eca2ded77"
|
|
261
|
-
|
|
262
|
-
[[package]]
|
|
263
|
-
name = "shlex"
|
|
264
|
-
version = "1.3.0"
|
|
265
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
266
|
-
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
|
267
|
-
|
|
268
|
-
[[package]]
|
|
269
|
-
name = "syn"
|
|
270
|
-
version = "2.0.117"
|
|
271
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
272
|
-
checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"
|
|
273
|
-
dependencies = [
|
|
274
|
-
"proc-macro2",
|
|
275
|
-
"quote",
|
|
276
|
-
"unicode-ident",
|
|
277
|
-
]
|
|
278
|
-
|
|
279
|
-
[[package]]
|
|
280
|
-
name = "unicode-ident"
|
|
281
|
-
version = "1.0.24"
|
|
282
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
283
|
-
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
|
284
|
-
|
|
285
|
-
[[package]]
|
|
286
|
-
name = "windows-link"
|
|
287
|
-
version = "0.2.1"
|
|
288
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
289
|
-
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|