what_you_say 0.4.3-aarch64-linux → 0.6.3-aarch64-linux

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1dcf93fdbe33c1db914d347f5ecbae3d6612bae29ca08bdb121859b53eea396b
4
- data.tar.gz: e8ff2e085f1ac6eb827f3ac8545145611a214e4039cf62dc8a2a8545b2ede2e1
3
+ metadata.gz: 743fbcc489197473a37400682f68adea1d4f348e9f95266a257cf0105ce0c9fd
4
+ data.tar.gz: b3c9e24fc23aa570fe0fe967f0dfe13faf7548241f0454b2cdd1bdfbce132d62
5
5
  SHA512:
6
- metadata.gz: c852c49a95a46554b3ff03864a9f0f7fd2f0acaeae25fb17693eb80a0010feba6e94d8c29bab753ff16751b0ed7207a25d3c25c23d7c821910cff1e0f76ed406
7
- data.tar.gz: ef8cbd28e6ecaf9b42c51357208ea29224eccc31f1d2ffe46ea6d117ded1fb5bcd82f75ea0b9c185ad482ab31a6ad6e3d848bb27fa5a1f2e2796d43c91516dc2
6
+ metadata.gz: b226c425f55de262c5e45b728179aef7ad966863a46561964f6d03986980eef9d1eedd6e32d8cfbcea51406527dd61392a7d0b4edec3784fc66e9f0b89e2ab6b
7
+ data.tar.gz: fcb513e094dee4203ae96ff2ff45ecd16c0b4413199cb4baca9ef2d5f7da583cf9f8491b471d2460d1f528eb6a88b063591026a1ee83fe0f00728d411d7c6c04
data/README.md CHANGED
@@ -1,14 +1,12 @@
1
1
  # WhatYouSay
2
2
 
3
- Quick and easy natural language detection wrapping the [Whatlang Rust crate](https://github.com/greyblake/whatlang-rs). Instantly identify the source language of a piece of text.
3
+ Quick and easy natural language detection wrapping the [lingua-rs Rust crate](https://github.com/pemistahl/lingua-rs). Instantly identify the source language of a piece of text.
4
4
 
5
5
  ![What you say!!](https://user-images.githubusercontent.com/64050/224237944-ceb2570c-d544-474a-8c91-41433efdee43.png)
6
6
 
7
- - Supports [69 languages](https://github.com/greyblake/whatlang-rs/blob/master/SUPPORTED_LANGUAGES.md) (nice!)
7
+ - Supports [75+ languages](https://github.com/pemistahl/lingua-rs/tree/main#3-which-languages-are-supported)
8
8
  - Core library is written in Rust; this is a Ruby wrapper to it
9
9
  - Lightweight, fast, and simple
10
- - Recognizes not only a language, but also a script (Latin, Cyrillic, etc)
11
- - Provides reliability information
12
10
 
13
11
  ## Installation
14
12
 
@@ -22,25 +20,52 @@ If bundler is not being used to manage dependencies, install the gem by executin
22
20
 
23
21
  ## Usage
24
22
 
25
- The method to call is `_?`. Why? Because. Pass in the text whose language you want to detect:
23
+ The method to call is `detect_language`.
24
+
25
+ Pass in the text whose language you want to detect:
26
26
 
27
27
  ```ruby
28
28
  require "what_you_say"
29
29
 
30
30
  text = "Ĉu vi ne volas eklerni Esperanton? Bonvolu! Estas unu de la plej bonaj aferoj!"
31
31
 
32
- result = WhatYouSay._?(text)
32
+ result = WhatYouSay.new.detect_language(text)
33
33
 
34
- assert_equal("epo", result.code)
35
- assert_equal("esperanto", result.eng_name)
34
+ assert_equal("epo", result.lang.code)
35
+ assert_equal("Esperanto", result.lang.eng_name)
36
36
  ```
37
37
 
38
38
  You also have to opportunity to `inspect` some output:
39
39
 
40
40
  ```ruby
41
41
  text = "Եվ ահա ես ստանում եմ մի զանգ պատահական տղայից"
42
- WhatYouSay._?(text).inspect
43
- #=> #<WhatYouSay::Lang code="hye" eng_name="Armenian">
42
+ WhatYouSay.new.detect_language(text).inspect
43
+ #=> #<WhatYouSay::Lang code="hye" eng_name="armenian">
44
+ ```
45
+
46
+ Not everything in life is perfect, and neither is this lib. Sometimes language detection will be wildly mistaken. You
47
+ can attempt to correct this by passing in an `allowlist` of supported languages:
48
+
49
+ ```ruby
50
+ text = "สวัสดี Rágis hello"
51
+ result = WhatYouSay.new.detect_language(text)
52
+
53
+ assert_equal("spanish", result.eng_name)
54
+
55
+ result = WhatYouSay.new(allowlist: ["English", "Thai"]).detect_language(text)
56
+
57
+ assert_equal("eng", result.code)
58
+ ```
59
+
60
+ If a language truly cannot be detected, the `Unknown` language type is returned:
61
+
62
+ ```ruby
63
+ text = "日本語"
64
+
65
+ result = WhatYouSay.new(allowlist: ["English", "Thai"]).detect_language(text)
66
+
67
+ assert_equal("???", result.code)
68
+ assert_equal("unknown", result.eng_name)
44
69
  ```
45
70
 
46
71
  ## Development
Binary file
Binary file
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module WhatYouSay
3
+ class WhatYouSay
4
4
  class Lang
5
5
  end
6
6
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module WhatYouSay
4
- VERSION = "0.4.3"
3
+ class WhatYouSay
4
+ VERSION = "0.6.3"
5
5
  end
data/lib/what_you_say.rb CHANGED
@@ -9,13 +9,11 @@ if ENV.fetch("DEBUG", false)
9
9
  require "debug"
10
10
  end
11
11
 
12
- module WhatYouSay
13
- class << self
14
- def _?(text)
15
- raise TypeError, "text must be a String; got a #{text.class}!" unless text.is_a?(String)
16
- raise TypeError, "text must be UTF-8 encoded; got #{text.encoding}!" unless text.encoding.name == "UTF-8"
12
+ class WhatYouSay
13
+ def detect_language(text)
14
+ raise TypeError, "text must be a String; got a #{text.class}!" unless text.is_a?(String)
15
+ raise TypeError, "text must be UTF-8 encoded; got #{text.encoding}!" unless text.encoding.name == "UTF-8"
17
16
 
18
- detect(text, options: {})
19
- end
17
+ detect_text(text)
20
18
  end
21
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: what_you_say
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.6.3
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - Garen J. Torikian
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-11 00:00:00.000000000 Z
11
+ date: 2023-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -38,8 +38,8 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.2'
41
- description: Natural language detectio with a focus on simplicity and performance.
42
- Currently wraps the whatlang Rust crate.
41
+ description: Natural language detection with a focus on simplicity and performance.
42
+ Currently wraps the lingua-rs Rust crate.
43
43
  email:
44
44
  - gjtorikian@users.noreply.github.com
45
45
  executables: []