ruby-spacy 0.1.4 → 0.1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/Gemfile.lock +1 -1
- data/README.md +37 -33
- data/examples/get_started/most_similar.rb +28 -27
- data/examples/japanese/most_similar.rb +28 -27
- data/lib/ruby-spacy.rb +9 -1
- data/lib/ruby-spacy/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fc769c4257e78333c3d6dc114d76b39c31b57365d032d7b741358f34b37099e
|
4
|
+
data.tar.gz: 281a9997a325d16819574c96a0696eeedb59af0709d8f25814e6fa0d39646757
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b387962ee82b60499208225ab7cfca631a55a6eb305212f3b14a2c802f67cfa685b23e762a3877e4ba5ae01308c4909eb26286bcde2fc9683dedeee9059db88
|
7
|
+
data.tar.gz: d94e788a1458f6be22db486e43180f7cbcce516ad053baa8724ce6eacd7869c3123c9f292845fe7e400aa2115786617f5ad69bda5c71b403221c98c084dc9900
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -448,32 +448,36 @@ france = nlp.get_lexeme("France")
|
|
448
448
|
|
449
449
|
query = tokyo.vector - japan.vector + france.vector
|
450
450
|
|
451
|
+
headings = ["rank", "text", "score"]
|
451
452
|
rows = []
|
452
453
|
|
453
|
-
results = nlp.most_similar(query,
|
454
|
-
results.
|
455
|
-
|
454
|
+
results = nlp.most_similar(query, 20)
|
455
|
+
results.each_with_index do |lexeme, i|
|
456
|
+
index = (i + 1).to_s
|
457
|
+
rows << [index, lexeme.text, lexeme.score]
|
456
458
|
end
|
457
459
|
|
458
|
-
headings = ["key", "text", "score"]
|
459
460
|
table = Terminal::Table.new rows: rows, headings: headings
|
460
461
|
puts table
|
461
462
|
```
|
462
463
|
|
463
464
|
Output:
|
464
465
|
|
465
|
-
|
|
466
|
-
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
466
|
+
| rank | text | score |
|
467
|
+
|:-----|:------------|:-------------------|
|
468
|
+
| 1 | FRANCE | 0.8346999883651733 |
|
469
|
+
| 2 | France | 0.8346999883651733 |
|
470
|
+
| 3 | france | 0.8346999883651733 |
|
471
|
+
| 4 | PARIS | 0.7703999876976013 |
|
472
|
+
| 5 | paris | 0.7703999876976013 |
|
473
|
+
| 6 | Paris | 0.7703999876976013 |
|
474
|
+
| 7 | TOULOUSE | 0.6381999850273132 |
|
475
|
+
| 8 | Toulouse | 0.6381999850273132 |
|
476
|
+
| 9 | toulouse | 0.6381999850273132 |
|
477
|
+
| 10 | marseille | 0.6370999813079834 |
|
478
|
+
|
479
|
+
|
480
|
+
|
477
481
|
|
478
482
|
|
479
483
|
### Word vector calculation (Japanese)
|
@@ -494,33 +498,33 @@ france = nlp.get_lexeme("フランス")
|
|
494
498
|
|
495
499
|
query = tokyo.vector - japan.vector + france.vector
|
496
500
|
|
501
|
+
headings = ["rank", "text", "score"]
|
497
502
|
rows = []
|
498
503
|
|
499
|
-
results = nlp.most_similar(query,
|
500
|
-
results.
|
501
|
-
|
504
|
+
results = nlp.most_similar(query, 20)
|
505
|
+
results.each_with_index do |lexeme, i|
|
506
|
+
index = (i + 1).to_s
|
507
|
+
rows << [index, lexeme.text, lexeme.score]
|
502
508
|
end
|
503
509
|
|
504
|
-
headings = ["key", "text", "score"]
|
505
510
|
table = Terminal::Table.new rows: rows, headings: headings
|
506
511
|
puts table
|
507
512
|
```
|
508
513
|
|
509
514
|
Output:
|
510
515
|
|
511
|
-
|
|
512
|
-
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
516
|
+
| rank | text | score |
|
517
|
+
|:-----|:---------------|:-------------------|
|
518
|
+
| 1 | パリ | 0.7376999855041504 |
|
519
|
+
| 2 | フランス | 0.7221999764442444 |
|
520
|
+
| 3 | 東京 | 0.6697999835014343 |
|
521
|
+
| 4 | ストラスブール | 0.631600022315979 |
|
522
|
+
| 5 | リヨン | 0.5939000248908997 |
|
523
|
+
| 6 | Paris | 0.574400007724762 |
|
524
|
+
| 7 | ベルギー | 0.5683000087738037 |
|
525
|
+
| 8 | ニース | 0.5679000020027161 |
|
526
|
+
| 9 | アルザス | 0.5644999742507935 |
|
527
|
+
| 10 | 南仏 | 0.5547999739646912 |
|
524
528
|
|
525
529
|
## Author
|
526
530
|
|
@@ -9,38 +9,39 @@ france = nlp.get_lexeme("France")
|
|
9
9
|
|
10
10
|
query = tokyo.vector - japan.vector + france.vector
|
11
11
|
|
12
|
-
headings = ["
|
12
|
+
headings = ["rank", "text", "score"]
|
13
13
|
rows = []
|
14
14
|
|
15
15
|
results = nlp.most_similar(query, 20)
|
16
|
-
results.
|
17
|
-
|
16
|
+
results.each_with_index do |lexeme, i|
|
17
|
+
index = (i + 1).to_s
|
18
|
+
rows << [index, lexeme.text, lexeme.score]
|
18
19
|
end
|
19
20
|
|
20
21
|
table = Terminal::Table.new rows: rows, headings: headings
|
21
22
|
puts table
|
22
23
|
|
23
|
-
#
|
24
|
-
# |
|
25
|
-
#
|
26
|
-
# |
|
27
|
-
# |
|
28
|
-
# |
|
29
|
-
# |
|
30
|
-
# |
|
31
|
-
# |
|
32
|
-
# |
|
33
|
-
# |
|
34
|
-
# |
|
35
|
-
# |
|
36
|
-
# |
|
37
|
-
# |
|
38
|
-
# |
|
39
|
-
# |
|
40
|
-
# |
|
41
|
-
# |
|
42
|
-
# |
|
43
|
-
# |
|
44
|
-
# |
|
45
|
-
# |
|
46
|
-
#
|
24
|
+
# +------+-------------+--------------------+
|
25
|
+
# | rank | text | score |
|
26
|
+
# +------+-------------+--------------------+
|
27
|
+
# | 1 | FRANCE | 0.8346999883651733 |
|
28
|
+
# | 2 | France | 0.8346999883651733 |
|
29
|
+
# | 3 | france | 0.8346999883651733 |
|
30
|
+
# | 4 | PARIS | 0.7703999876976013 |
|
31
|
+
# | 5 | paris | 0.7703999876976013 |
|
32
|
+
# | 6 | Paris | 0.7703999876976013 |
|
33
|
+
# | 7 | TOULOUSE | 0.6381999850273132 |
|
34
|
+
# | 8 | Toulouse | 0.6381999850273132 |
|
35
|
+
# | 9 | toulouse | 0.6381999850273132 |
|
36
|
+
# | 10 | marseille | 0.6370999813079834 |
|
37
|
+
# | 11 | Marseille | 0.6370999813079834 |
|
38
|
+
# | 12 | MARSEILLE | 0.6370999813079834 |
|
39
|
+
# | 13 | Bordeaux | 0.6096000075340271 |
|
40
|
+
# | 14 | BORDEAUX | 0.6096000075340271 |
|
41
|
+
# | 15 | bordeaux | 0.6096000075340271 |
|
42
|
+
# | 16 | prague | 0.6075000166893005 |
|
43
|
+
# | 17 | PRAGUE | 0.6075000166893005 |
|
44
|
+
# | 18 | Prague | 0.6075000166893005 |
|
45
|
+
# | 19 | SWITZERLAND | 0.6068000197410583 |
|
46
|
+
# | 20 | switzerland | 0.6068000197410583 |
|
47
|
+
# +------+-------------+--------------------+
|
@@ -9,38 +9,39 @@ france = nlp.get_lexeme("フランス")
|
|
9
9
|
|
10
10
|
query = tokyo.vector - japan.vector + france.vector
|
11
11
|
|
12
|
-
headings = ["
|
12
|
+
headings = ["rank", "text", "score"]
|
13
13
|
rows = []
|
14
14
|
|
15
15
|
results = nlp.most_similar(query, 20)
|
16
|
-
results.
|
17
|
-
|
16
|
+
results.each_with_index do |lexeme, i|
|
17
|
+
index = (i + 1).to_s
|
18
|
+
rows << [index, lexeme.text, lexeme.score]
|
18
19
|
end
|
19
20
|
|
20
21
|
table = Terminal::Table.new rows: rows, headings: headings
|
21
22
|
puts table
|
22
23
|
|
23
|
-
#
|
24
|
-
# |
|
25
|
-
#
|
26
|
-
# |
|
27
|
-
# |
|
28
|
-
# |
|
29
|
-
# |
|
30
|
-
# |
|
31
|
-
# |
|
32
|
-
# |
|
33
|
-
# |
|
34
|
-
# |
|
35
|
-
# |
|
36
|
-
# |
|
37
|
-
# |
|
38
|
-
# |
|
39
|
-
# |
|
40
|
-
# |
|
41
|
-
# |
|
42
|
-
# |
|
43
|
-
# |
|
44
|
-
# |
|
45
|
-
# |
|
46
|
-
#
|
24
|
+
# +------+----------------+--------------------+
|
25
|
+
# | rank | text | score |
|
26
|
+
# +------+----------------+--------------------+
|
27
|
+
# | 1 | パリ | 0.7376999855041504 |
|
28
|
+
# | 2 | フランス | 0.7221999764442444 |
|
29
|
+
# | 3 | 東京 | 0.6697999835014343 |
|
30
|
+
# | 4 | ストラスブール | 0.631600022315979 |
|
31
|
+
# | 5 | リヨン | 0.5939000248908997 |
|
32
|
+
# | 6 | Paris | 0.574400007724762 |
|
33
|
+
# | 7 | ベルギー | 0.5683000087738037 |
|
34
|
+
# | 8 | ニース | 0.5679000020027161 |
|
35
|
+
# | 9 | アルザス | 0.5644999742507935 |
|
36
|
+
# | 10 | 南仏 | 0.5547999739646912 |
|
37
|
+
# | 11 | ロンドン | 0.5525000095367432 |
|
38
|
+
# | 12 | モンマルトル | 0.5453000068664551 |
|
39
|
+
# | 13 | ブローニュ | 0.5338000059127808 |
|
40
|
+
# | 14 | トゥールーズ | 0.5275999903678894 |
|
41
|
+
# | 15 | バスティーユ | 0.5213000178337097 |
|
42
|
+
# | 16 | フランス人 | 0.5194000005722046 |
|
43
|
+
# | 17 | ロレーヌ | 0.5148000121116638 |
|
44
|
+
# | 18 | モンパルナス | 0.513700008392334 |
|
45
|
+
# | 19 | 渡仏 | 0.5131000280380249 |
|
46
|
+
# | 20 | イタリア | 0.5127000212669373 |
|
47
|
+
# +------+----------------+--------------------+
|
data/lib/ruby-spacy.rb
CHANGED
@@ -279,7 +279,15 @@ module Spacy
|
|
279
279
|
|
280
280
|
results = []
|
281
281
|
n.times do |i|
|
282
|
-
|
282
|
+
result = {key: keys[i].to_i,
|
283
|
+
text: texts[i],
|
284
|
+
best_row: best_rows[i],
|
285
|
+
score: scores[i]
|
286
|
+
}
|
287
|
+
result.each_key do |key|
|
288
|
+
result.define_singleton_method(key){ result[key] }
|
289
|
+
end
|
290
|
+
results << result
|
283
291
|
end
|
284
292
|
results
|
285
293
|
end
|
data/lib/ruby-spacy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-spacy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.4
|
4
|
+
version: 0.1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoichiro Hasebe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pycall
|
@@ -150,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
150
|
- !ruby/object:Gem::Version
|
151
151
|
version: '0'
|
152
152
|
requirements: []
|
153
|
-
rubygems_version: 3.2.
|
153
|
+
rubygems_version: 3.2.3
|
154
154
|
signing_key:
|
155
155
|
specification_version: 4
|
156
156
|
summary: A wrapper module for using spaCy natural language processing library from
|