that_language-client 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +115 -12
- data/lib/that_language/client/config.rb +1 -1
- data/lib/that_language/client/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ede343e2d2d2065c8eec215ad7434eed345c0fce
|
4
|
+
data.tar.gz: 725f13a0d292bcc889ee3bddf8951f47385f64bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49442abaaeae4c90371c03ffd294cb7fe8ea75306328d25714bceb56474c79eb3918e4aa6de71967719ef8e3e28e72b56ccc26867ba8dce359b672b6cbed3548
|
7
|
+
data.tar.gz: b0cac92492926a67f690af4479716852de3dd0fb4517b18f4996b27074d6be86c3fbd5da9359b481f9365752d95d04c346245c1aa00ef1ab24036a535a6c0c3b
|
data/README.md
CHANGED
@@ -1,15 +1,11 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/detect_language/client`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
1
|
+
# ThatLanguage::Client
|
6
2
|
|
7
3
|
## Installation
|
8
4
|
|
9
5
|
Add this line to your application's Gemfile:
|
10
6
|
|
11
7
|
```ruby
|
12
|
-
gem '
|
8
|
+
gem 'that_language-client'
|
13
9
|
```
|
14
10
|
|
15
11
|
And then execute:
|
@@ -18,21 +14,128 @@ And then execute:
|
|
18
14
|
|
19
15
|
Or install it yourself as:
|
20
16
|
|
21
|
-
$ gem install
|
17
|
+
$ gem install that_language-client
|
18
|
+
|
19
|
+
## Examples
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
text = "This is just a random english sentence."
|
23
|
+
|
24
|
+
## == Language
|
25
|
+
|
26
|
+
ThatLanguage.language(text)
|
27
|
+
# => "English"
|
28
|
+
|
29
|
+
|
30
|
+
## == LanguageCode
|
31
|
+
|
32
|
+
ThatLanguage.language_code(text)
|
33
|
+
# => "en"
|
34
|
+
|
35
|
+
|
36
|
+
## == Detect
|
37
|
+
|
38
|
+
detect = ThatLanguage.detect(text)
|
39
|
+
# => #<ThatLanguage::Client::DetectQuery:...
|
40
|
+
|
41
|
+
detect.language
|
42
|
+
# => "English"
|
43
|
+
|
44
|
+
detect.language_code
|
45
|
+
# => "en"
|
46
|
+
|
47
|
+
detect.confidence
|
48
|
+
# => 0.5631093821386951
|
49
|
+
|
50
|
+
detect.to_h
|
51
|
+
# => {"language"=>"English", "language_code"=>"en", "confidence"=>0.5631093821386951}
|
22
52
|
|
23
|
-
## Usage
|
24
53
|
|
25
|
-
|
54
|
+
## == Details
|
55
|
+
|
56
|
+
details = ThatLanguage.details(text)
|
57
|
+
# => #<ThatLanguage::Client::DetailsQuery:...
|
58
|
+
|
59
|
+
winner = details.winner
|
60
|
+
# => OpenStruct
|
61
|
+
|
62
|
+
winner.language
|
63
|
+
# => "English"
|
64
|
+
|
65
|
+
winner.language_code
|
66
|
+
# => "en"
|
67
|
+
|
68
|
+
winner.confidence
|
69
|
+
# => 0.5631093821386951
|
70
|
+
|
71
|
+
winner.value
|
72
|
+
# => 3.9417656749708656
|
73
|
+
|
74
|
+
winner.hit_ratio
|
75
|
+
# => 0.8571428571428571
|
76
|
+
|
77
|
+
winner.hit_count
|
78
|
+
# => 6
|
79
|
+
|
80
|
+
winner.words_count
|
81
|
+
# => 7
|
82
|
+
|
83
|
+
results = details.results
|
84
|
+
# => [#<OpenStruct, #<OpenStruct, ...]
|
85
|
+
|
86
|
+
details.to_h
|
87
|
+
# =>
|
88
|
+
# {
|
89
|
+
# "results" => [
|
90
|
+
# {
|
91
|
+
# "language"=>"English",
|
92
|
+
# "language_code"=>"en",
|
93
|
+
# "confidence"=>0.5631093821386951,
|
94
|
+
# "value"=>3.9417656749708656,
|
95
|
+
# "hit_ratio"=>0.8571428571428571,
|
96
|
+
# "hit_count"=>6,
|
97
|
+
# "words_count"=>7
|
98
|
+
# },
|
99
|
+
# {
|
100
|
+
# "language"=>"Sundanese",
|
101
|
+
# "language_code"=>"su",
|
102
|
+
# "confidence"=>0.26101716738575337,
|
103
|
+
# "value"=>1.8271201717002734,
|
104
|
+
# "hit_ratio"=>0.7142857142857143,
|
105
|
+
# "hit_count"=>5,
|
106
|
+
# "words_count"=>7
|
107
|
+
# },
|
108
|
+
# # ...
|
109
|
+
# ]
|
110
|
+
# }
|
111
|
+
```
|
112
|
+
|
113
|
+
## Configure
|
114
|
+
|
115
|
+
Configure the host to use:
|
116
|
+
|
117
|
+
```ruby
|
118
|
+
ThatLanguage::Client.configure do |config|
|
119
|
+
config.host = "my-custom-that-language-api.com"
|
120
|
+
end
|
121
|
+
```
|
26
122
|
|
27
123
|
## Development
|
28
124
|
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies.
|
125
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
126
|
+
Then, run `rake rspec` to run the tests.
|
127
|
+
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
128
|
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`.
|
129
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
130
|
+
To release a new version, update the version number in `version.rb`, and then run
|
131
|
+
`bundle exec rake release`, which will create a git tag for the version,
|
132
|
+
push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
133
|
|
33
134
|
## Contributing
|
34
135
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
136
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Deradon/that_language-client.
|
137
|
+
This project is intended to be a safe, welcoming space for collaboration,
|
138
|
+
and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
139
|
|
37
140
|
|
38
141
|
## License
|