lingua-ruby 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Cargo.lock +1494 -0
- data/Cargo.toml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +40 -0
- data/ext/lingua/Cargo.toml +14 -0
- data/ext/lingua/extconf.rb +6 -0
- data/ext/lingua/src/lib.rs +24 -0
- data/lib/lingua/lingua.so +0 -0
- data/lib/lingua/version.rb +5 -0
- data/lib/lingua-ruby.rb +1 -0
- data/lib/lingua.rb +9 -0
- metadata +85 -0
data/Cargo.toml
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2023 Followers Tracker
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
## Lingua Ruby
|
2
|
+
|
3
|
+
**lingua-ruby** is the Ruby gem wrapper for the powerful [Lingua](https://github.com/pemistahl/lingua-rs) Rust library.
|
4
|
+
|
5
|
+
#### Requirements
|
6
|
+
|
7
|
+
- clang
|
8
|
+
- ruby >= 3.0
|
9
|
+
- rubygems >= 3.3.11
|
10
|
+
|
11
|
+
#### Installation
|
12
|
+
|
13
|
+
```
|
14
|
+
gem "lingua-ruby"
|
15
|
+
```
|
16
|
+
|
17
|
+
#### Usage
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
Lingua.detect_language "how are you?" # => "english"
|
21
|
+
|
22
|
+
```
|
23
|
+
|
24
|
+
#### Development
|
25
|
+
|
26
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
27
|
+
|
28
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
29
|
+
|
30
|
+
#### Contributing
|
31
|
+
|
32
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/followerstracker/lingua-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/followerstracker/lingua-ruby/blob/master/CODE_OF_CONDUCT.md).
|
33
|
+
|
34
|
+
#### License
|
35
|
+
|
36
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
37
|
+
|
38
|
+
#### Code of Conduct
|
39
|
+
|
40
|
+
Everyone interacting in the Lingua project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/followerstracker/lingua-ruby/blob/master/CODE_OF_CONDUCT.md).
|
@@ -0,0 +1,14 @@
|
|
1
|
+
[package]
|
2
|
+
name = "lingua"
|
3
|
+
version = "0.1.0"
|
4
|
+
edition = "2021"
|
5
|
+
authors = ["Followers Tracker <support@followerstracker.com>"]
|
6
|
+
license = "MIT"
|
7
|
+
publish = false
|
8
|
+
|
9
|
+
[lib]
|
10
|
+
crate-type = ["cdylib"]
|
11
|
+
|
12
|
+
[dependencies]
|
13
|
+
lingua = { version = "1.4.0" }
|
14
|
+
magnus = { version = "0.4" }
|
@@ -0,0 +1,24 @@
|
|
1
|
+
use magnus::{define_module, function, prelude::*, Error};
|
2
|
+
use lingua::{Language, LanguageDetector, LanguageDetectorBuilder};
|
3
|
+
use std::iter::FromIterator;
|
4
|
+
|
5
|
+
fn detect_language(text: String) -> String {
|
6
|
+
let languages = Language::all();
|
7
|
+
let language_vec = Vec::from_iter(languages.into_iter());
|
8
|
+
|
9
|
+
let detector: LanguageDetector = LanguageDetectorBuilder::from_languages(&language_vec).build();
|
10
|
+
|
11
|
+
if let Some(detected_language) = detector.detect_language_of(&text) {
|
12
|
+
detected_language.to_string()
|
13
|
+
} else {
|
14
|
+
"Unknown".to_string()
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
|
19
|
+
#[magnus::init]
|
20
|
+
fn init() -> Result<(), Error> {
|
21
|
+
let module = define_module("Lingua")?;
|
22
|
+
module.define_singleton_method("detect_language", function!(detect_language, 1))?;
|
23
|
+
Ok(())
|
24
|
+
}
|
Binary file
|
data/lib/lingua-ruby.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require_relative "lingua"
|
data/lib/lingua.rb
ADDED
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lingua-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Followers Tracker
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-05-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rb_sys
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.10'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.10'
|
41
|
+
description: Ruby (Rust) gem wrapper around Lingua library.
|
42
|
+
email:
|
43
|
+
- support@followerstracker.com
|
44
|
+
executables: []
|
45
|
+
extensions:
|
46
|
+
- ext/lingua/extconf.rb
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- CHANGELOG.md
|
50
|
+
- CODE_OF_CONDUCT.md
|
51
|
+
- Cargo.lock
|
52
|
+
- Cargo.toml
|
53
|
+
- LICENSE.txt
|
54
|
+
- README.md
|
55
|
+
- ext/lingua/Cargo.toml
|
56
|
+
- ext/lingua/extconf.rb
|
57
|
+
- ext/lingua/src/lib.rs
|
58
|
+
- lib/lingua-ruby.rb
|
59
|
+
- lib/lingua.rb
|
60
|
+
- lib/lingua/lingua.so
|
61
|
+
- lib/lingua/version.rb
|
62
|
+
homepage: https://github.com/followerstracker/lingua-ruby
|
63
|
+
licenses:
|
64
|
+
- MIT
|
65
|
+
metadata: {}
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 3.0.0
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 3.3.11
|
80
|
+
requirements: []
|
81
|
+
rubygems_version: 3.4.12
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: Ruby (Rust) gem wrapper around Lingua library.
|
85
|
+
test_files: []
|