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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bd0dba860ee235a6acfc46afb3ba851ec08303df9499f403e47624c74b9396e7
4
- data.tar.gz: b3d9faca1f0f12fb7abee0643b94f1f494ef02e6b4f2c92846fa88e94d503904
3
+ metadata.gz: 10f60785757487a1928e8d35dff0a23a5b10143f69cd4c147fe4da13b7362e31
4
+ data.tar.gz: 587f8b61751bee91d89df4fa2c278163cdd48c601536292f56ed35f4807044fd
5
5
  SHA512:
6
- metadata.gz: 2cae21715d81d650c71df5d55b18fb7b09eb86bcfe1356e5ace3b526a48e9ff31be39d852ee43abe342dffed711c7ea08ad3a9342702960b04a864a674df6068
7
- data.tar.gz: 221eb0c62f4b7158d5c95b4d7c28490a2bcabc3f4cffe64914bea62c413c0d35fc8ceab1a6b6dc81a4750e75f8d7deac522bab1d0aa97b5c02cfd7d49e9eab40
6
+ metadata.gz: '03383e1fa0da8d3131f2e8d724b5818697bcddae9604d33a3cfafe7b73b48d32468f2817eaa5b1606f726b47a326b7f2c48f46ef5b3361a605b4f7a7c3b20cc2'
7
+ data.tar.gz: e347f5ef0485bda583d4df5cfa116699b496184554a2d367615ff3e538e8a8a76769aca20c74a2f67f7fe2caf870d6184d28733e1d040f84d2ca5be8c21ecaf6
data/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # LinguaRs
2
2
 
3
3
  [![CI](https://github.com/kochka/lingua_rs/actions/workflows/ci.yml/badge.svg)](https://github.com/kochka/lingua_rs/actions/workflows/ci.yml)
4
- [![Gem Version](https://badge.fury.io/rb/lingua_rs.svg)](https://badge.fury.io/rb/lingua_rs)
5
- [![Downloads](https://img.shields.io/gem/dt/lingua_rs)](https://rubygems.org/gems/lingua_rs)
6
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
4
+ [![Gem Version](https://img.shields.io/gem/v/lingua_rs?color=cc342d)](https://rubygems.org/gems/lingua_rs)
5
+ [![Downloads](https://img.shields.io/gem/dt/lingua_rs?color=0969da)](https://rubygems.org/gems/lingua_rs)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-6e7781.svg)](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.
@@ -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) {
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lingua
4
- VERSION = '0.4.1'
4
+ VERSION = '0.4.2'
5
5
  end
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.1
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. Detects languages with
41
- confidence scores, ISO 639-1/639-3 support, and configurable accuracy modes.
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: Fast language detection for Ruby, powered by Lingua (Rust).
90
+ summary: High-accuracy language detection for Ruby, powered by Lingua (Rust).
90
91
  test_files: []