lingua_rs 0.4.1 → 0.4.2
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 +7 -3
- data/ext/lingua/src/detector.rs +12 -0
- data/lib/lingua/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 10f60785757487a1928e8d35dff0a23a5b10143f69cd4c147fe4da13b7362e31
|
|
4
|
+
data.tar.gz: 587f8b61751bee91d89df4fa2c278163cdd48c601536292f56ed35f4807044fd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '03383e1fa0da8d3131f2e8d724b5818697bcddae9604d33a3cfafe7b73b48d32468f2817eaa5b1606f726b47a326b7f2c48f46ef5b3361a605b4f7a7c3b20cc2'
|
|
7
|
+
data.tar.gz: e347f5ef0485bda583d4df5cfa116699b496184554a2d367615ff3e538e8a8a76769aca20c74a2f67f7fe2caf870d6184d28733e1d040f84d2ca5be8c21ecaf6
|
data/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# LinguaRs
|
|
2
2
|
|
|
3
3
|
[](https://github.com/kochka/lingua_rs/actions/workflows/ci.yml)
|
|
4
|
-
[](https://rubygems.org/gems/lingua_rs)
|
|
6
|
-
[](https://rubygems.org/gems/lingua_rs)
|
|
5
|
+
[](https://rubygems.org/gems/lingua_rs)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
7
|
|
|
8
8
|
A Ruby gem wrapping the [Lingua](https://github.com/pemistahl/lingua-rs) Rust library for language detection.
|
|
9
9
|
|
|
@@ -249,6 +249,10 @@ LINGUA_LANGUAGES=east_asia,english bundle install
|
|
|
249
249
|
|
|
250
250
|
Language and bundle names must match the Cargo features defined by this gem (lowercase, e.g. `french`, `english`, `german`, `core`, `europe_common`).
|
|
251
251
|
|
|
252
|
+
Supported languages (from [Lingua Rust's official list](https://github.com/pemistahl/lingua-rs?tab=readme-ov-file#3-which-languages-are-supported)):
|
|
253
|
+
|
|
254
|
+
`afrikaans`, `albanian`, `arabic`, `armenian`, `azerbaijani`, `basque`, `belarusian`, `bengali`, `bokmal`, `bosnian`, `bulgarian`, `catalan`, `chinese`, `croatian`, `czech`, `danish`, `dutch`, `english`, `esperanto`, `estonian`, `finnish`, `french`, `ganda`, `georgian`, `german`, `greek`, `gujarati`, `hebrew`, `hindi`, `hungarian`, `icelandic`, `indonesian`, `irish`, `italian`, `japanese`, `kazakh`, `korean`, `latin`, `latvian`, `lithuanian`, `macedonian`, `malay`, `maori`, `marathi`, `mongolian`, `nynorsk`, `persian`, `polish`, `portuguese`, `punjabi`, `romanian`, `russian`, `serbian`, `shona`, `slovak`, `slovene`, `somali`, `sotho`, `spanish`, `swahili`, `swedish`, `tagalog`, `tamil`, `telugu`, `thai`, `tsonga`, `tswana`, `turkish`, `ukrainian`, `urdu`, `vietnamese`, `welsh`, `xhosa`, `yoruba`, `zulu`
|
|
255
|
+
|
|
252
256
|
## Development
|
|
253
257
|
|
|
254
258
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake compile` to build the native extension and `rake test` to run the tests.
|
data/ext/lingua/src/detector.rs
CHANGED
|
@@ -122,6 +122,12 @@ pub fn build_detector_from_options(
|
|
|
122
122
|
})?;
|
|
123
123
|
languages.push(lang);
|
|
124
124
|
}
|
|
125
|
+
if languages.is_empty() {
|
|
126
|
+
return Err(magnus::Error::new(
|
|
127
|
+
ruby.exception_arg_error(),
|
|
128
|
+
"languages must contain at least 1 language",
|
|
129
|
+
));
|
|
130
|
+
}
|
|
125
131
|
LanguageDetectorBuilder::from_languages(&languages)
|
|
126
132
|
} else {
|
|
127
133
|
LanguageDetectorBuilder::from_all_languages()
|
|
@@ -129,6 +135,12 @@ pub fn build_detector_from_options(
|
|
|
129
135
|
|
|
130
136
|
if let Some(opts) = options {
|
|
131
137
|
if let Some(dist) = fetch_option::<f64>(ruby, opts, "minimum_relative_distance") {
|
|
138
|
+
if !(0.0..=0.99).contains(&dist) {
|
|
139
|
+
return Err(magnus::Error::new(
|
|
140
|
+
ruby.exception_arg_error(),
|
|
141
|
+
"minimum_relative_distance must be between 0.0 and 0.99",
|
|
142
|
+
));
|
|
143
|
+
}
|
|
132
144
|
builder.with_minimum_relative_distance(dist);
|
|
133
145
|
}
|
|
134
146
|
if fetch_option::<bool>(ruby, opts, "is_every_language_model_preloaded").unwrap_or(false) {
|
data/lib/lingua/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sébastien Vrillaud
|
|
@@ -37,8 +37,9 @@ dependencies:
|
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
39
|
version: 1.3.0
|
|
40
|
-
description: Native Ruby bindings for the Lingua Rust library
|
|
41
|
-
|
|
40
|
+
description: Native Ruby bindings for the Lingua Rust library, bringing highly accurate
|
|
41
|
+
language detection for short text and mixed-language text to Ruby, with confidence
|
|
42
|
+
scores and ISO 639-1/639-3 language codes.
|
|
42
43
|
email:
|
|
43
44
|
- kochka@gmail.com
|
|
44
45
|
executables: []
|
|
@@ -86,5 +87,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
86
87
|
requirements: []
|
|
87
88
|
rubygems_version: 3.6.9
|
|
88
89
|
specification_version: 4
|
|
89
|
-
summary:
|
|
90
|
+
summary: High-accuracy language detection for Ruby, powered by Lingua (Rust).
|
|
90
91
|
test_files: []
|