gnfinder 0.15.4.1 → 0.15.5
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/CHANGELOG.md +4 -0
- data/README.md +22 -25
- data/lib/gnfinder/client.rb +15 -6
- data/lib/gnfinder/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbac598ce79e8e9db5ad0fd4f24b5004b2cf4f91d3f5fae0ece871b525d1f488
|
4
|
+
data.tar.gz: 36abaa471d385f27ae6bfa32f6f960bb7bc3a1b258b0b2a5402826e41d629d6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e6a3e825edfaa873e0d178a7323d7a9b6124292e940e504834b48d8127e18ae08298044458b15fc1125abf9b98afcd1faa292eadfb6edf64f80d6b3d89d43d7
|
7
|
+
data.tar.gz: 68e7871b2ce105ca751c63b391ca7477a33ce965c88d6ef87235635fd8aebbfba18e856c549d0e0a26d2a4228f0a0bf46ab8cce58892c677824273f6c1f9d259
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# gnfinder
|
2
2
|
|
3
|
-
Ruby gem to access functionality of [
|
3
|
+
Ruby gem to access functionality of [GNfinder] project written in Go. This gem
|
4
4
|
allows to perform fast and accurate scientific name finding in UTF-8 encoded
|
5
5
|
plain texts for Ruby-based projects.
|
6
6
|
|
7
|
-
- [
|
7
|
+
- [GNfinder](#gnfinder)
|
8
8
|
- [Requirements](#requirements)
|
9
9
|
- [Installation](#installation)
|
10
10
|
- [Usage](#usage)
|
@@ -19,12 +19,12 @@ plain texts for Ruby-based projects.
|
|
19
19
|
|
20
20
|
## Requirements
|
21
21
|
|
22
|
-
This gem uses
|
23
|
-
to run it in [
|
22
|
+
This gem uses REST API to access a running [GNfinder] server. You can find how
|
23
|
+
to run it in [GNfinder] README file.
|
24
24
|
|
25
25
|
## Installation
|
26
26
|
|
27
|
-
To use the gem from Ruby proect install it using Gemfile, or manually:
|
27
|
+
To use the gem from a Ruby proect install it using Gemfile, or manually:
|
28
28
|
|
29
29
|
```bash
|
30
30
|
gem install gnfinder
|
@@ -32,10 +32,10 @@ gem install gnfinder
|
|
32
32
|
|
33
33
|
## Usage
|
34
34
|
|
35
|
-
The purpose of this gem is to access [
|
35
|
+
The purpose of this gem is to access [GNfinder] functionality from Ruby
|
36
36
|
applications. If you need to find names using other languages, use the
|
37
37
|
[source code][client] of this gem for reference. For other usages read
|
38
|
-
the original Go-lang [
|
38
|
+
the original Go-lang [GNfinder] README file.
|
39
39
|
|
40
40
|
First you need to create a instance of a `gnfinder` client
|
41
41
|
|
@@ -63,7 +63,7 @@ gf = Gnfinder::Client.new(host = '0.0.0.0', port = 8000)
|
|
63
63
|
|
64
64
|
### Finding names in a text using default settings
|
65
65
|
|
66
|
-
You can find format of returning result in [
|
66
|
+
You can find format of returning result in [GNfinder API docs]
|
67
67
|
|
68
68
|
```ruby
|
69
69
|
txt = File.read('utf8-text-with-names.txt')
|
@@ -73,6 +73,18 @@ puts res.names[0].value
|
|
73
73
|
puts res.names[0].odds
|
74
74
|
```
|
75
75
|
|
76
|
+
### Finding names by a URL
|
77
|
+
|
78
|
+
If you need to find names in an HTML page, or a PDF document available on
|
79
|
+
Internet, use `find_url` method.
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
url = 'https://en.wikipedia.org/wiki/Monochamus_galloprovincialis'
|
83
|
+
res = gf.find_url(url)
|
84
|
+
puts res.names[0].value
|
85
|
+
puts res.names[0].odds
|
86
|
+
```
|
87
|
+
|
76
88
|
Returned result will have the following methods for each name:
|
77
89
|
|
78
90
|
* value: name-string cleaned up for verification.
|
@@ -173,21 +185,6 @@ res = gf.find_names(txt, language: 'eng', sources: [1, 4, 179])
|
|
173
185
|
|
174
186
|
## Development
|
175
187
|
|
176
|
-
This gem uses gRPC to access [gnfinder] server. gRPC in turn depends on a
|
177
|
-
protobuf library. If you need to compile Ruby programs with protobuf you need
|
178
|
-
to install [Go] language and download [gnfinder] project.
|
179
|
-
|
180
|
-
```bash
|
181
|
-
go get github.com/gnames/gnfinder
|
182
|
-
```
|
183
|
-
Then you need to run bundle from the root of the project and generate
|
184
|
-
grpc files:
|
185
|
-
|
186
|
-
```bash
|
187
|
-
bundle
|
188
|
-
rake grpc
|
189
|
-
```
|
190
|
-
|
191
188
|
If you get an error, you might need to set a ``GOPATH`` environment variable.
|
192
189
|
|
193
190
|
After starting the server with default host and port (localhost:8778) you will
|
@@ -208,10 +205,10 @@ To run tests without rubocop
|
|
208
205
|
bundle exec rspec
|
209
206
|
```
|
210
207
|
|
211
|
-
[
|
208
|
+
[GNfinder]: https://github.com/gnames/gnfinder
|
212
209
|
[gnfinder recent release]: https://github.com/gnames/gnfinder/releases
|
213
210
|
[Go]: https://golang.org/doc/install
|
214
211
|
[client]: https://github.com/GlobalNamesArchitecture/gnfinder/blob/master/lib/gnfinder/client.rb
|
215
212
|
[data-source list]: http://index.globalnames.org/datasource
|
216
|
-
[proto file]: https://github.com/GlobalNamesArchitecture/gnfinder/blob/master/lib/protob_pb.rb
|
217
213
|
[tests]: https://github.com/GlobalNamesArchitecture/gnfinder/blob/master/spec/lib/client_spec.rb
|
214
|
+
[GNfinder API docs]: https://apidoc.globalnames.org/gnfinder
|
data/lib/gnfinder/client.rb
CHANGED
@@ -21,13 +21,24 @@ module Gnfinder
|
|
21
21
|
@site['/ping'].get.body
|
22
22
|
end
|
23
23
|
|
24
|
-
|
24
|
+
def find_url(url, opts = {})
|
25
|
+
return to_open_struct({ "names": [] }) if url.to_s.strip == ''
|
26
|
+
|
27
|
+
params = { url: url }
|
28
|
+
find(params, opts)
|
29
|
+
end
|
30
|
+
|
25
31
|
def find_names(text, opts = {})
|
26
|
-
if text.to_s.strip == ''
|
27
|
-
return to_open_struct({ "names": [] })
|
28
|
-
end
|
32
|
+
return to_open_struct({ "names": [] }) if text.to_s.strip == ''
|
29
33
|
|
30
34
|
params = { text: text }
|
35
|
+
find(params, opts)
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
# rubocop:disable all
|
41
|
+
def find(params, opts = {})
|
31
42
|
params[:noBayes] = true if opts[:no_bayes]
|
32
43
|
params[:oddsDetails] = true if opts[:odds_details]
|
33
44
|
params[:language] = opts[:language] if opts[:language].to_s.strip != ''
|
@@ -54,8 +65,6 @@ module Gnfinder
|
|
54
65
|
end
|
55
66
|
# rubocop:enable all
|
56
67
|
|
57
|
-
private
|
58
|
-
|
59
68
|
def to_open_struct(obj)
|
60
69
|
case obj
|
61
70
|
when Hash
|
data/lib/gnfinder/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gnfinder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.15.
|
4
|
+
version: 0.15.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Mozzherin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|