bm25f 0.1.0 → 0.2.0
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/test/test_bm25f.rb +23 -0
- metadata +16 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2649ac16a2f5adeb5815b2f472e62f98aec6b05af882648e4d128051c5fb90e0
|
4
|
+
data.tar.gz: e70ee90881438943874b4ae5e4852a6e7d44eda53f0315af35ea85565a2cde70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f7a68810a77daa256eb3e3177748e6b22f53cf3dfd2e68c68e82c4b7c143cdc60ac38c0e519e6f4b3c90725123c62f2b5e852898230c5e9812ca181e3efa577
|
7
|
+
data.tar.gz: 6690099e9435eebc6676d7bbd0d5530218e2d360a2ca8fb3e5156faf74b426364765eab60bdab5bb2caa85deadb69bb22b951a987d9904eaf1cb75bbb1b31520
|
data/test/test_bm25f.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'bm25f'
|
3
|
+
|
4
|
+
class BM25FTest < Minitest::Test
|
5
|
+
def setup
|
6
|
+
@bm25f = BM25F.new
|
7
|
+
@documents = [
|
8
|
+
{ title: 'hello world', content: 'foo bar baz' },
|
9
|
+
{ title: 'foo bar', content: 'goodbye, world!' }
|
10
|
+
]
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_score
|
14
|
+
@bm25f.fit @documents
|
15
|
+
scores = @bm25f.score 'hello world foo bar baz'
|
16
|
+
|
17
|
+
# Sort
|
18
|
+
scores = scores.to_a.sort_by { |_, v| v.to_i }
|
19
|
+
|
20
|
+
# Checks if the most matching element is the first element
|
21
|
+
assert scores.last[0].zero?
|
22
|
+
end
|
23
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bm25f
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- catflip
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
description: A fast implementation of the BM25F ranking algorithm for information
|
28
42
|
retrieval systems, written in Ruby.
|
29
43
|
email:
|
@@ -32,6 +46,7 @@ extensions: []
|
|
32
46
|
extra_rdoc_files: []
|
33
47
|
files:
|
34
48
|
- lib/bm25f.rb
|
49
|
+
- test/test_bm25f.rb
|
35
50
|
homepage: https://github.com/catflip/bm25f-ruby
|
36
51
|
licenses:
|
37
52
|
- AGPL-3.0
|