highscore 1.2.0 → 1.2.1
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 +6 -14
- data/History.txt +2 -4
- data/lib/highscore.rb +0 -1
- data/lib/highscore/content.rb +2 -1
- data/lib/highscore/wordlist.rb +14 -11
- data/test/highscore/test_content.rb +0 -2
- data/test/highscore/test_keyword.rb +1 -1
- data/test/highscore/test_multiple_blacklists.rb +2 -4
- data/test/highscore/test_wordlist.rb +14 -3
- data/test/test_highscore.rb +4 -4
- data/version.txt +1 -1
- metadata +27 -41
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
ZGVlOWUwNTgxM2MwMTlkMGMzN2MzYjViYjdhZDkxMjkxYmZiZTNkYTEzOThi
|
10
|
-
Yzg2Y2E4MjdmOGE1NWJhNDMzYjBkZGM4MDMyNzA4ODEwMmFiMTVmYWQyMzk2
|
11
|
-
ODIwOTIwMjRkMzgyN2E1Y2QzNTMxYjFmNzllM2NlOTE2ZjA4ZjM=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NDZlMzFiYjVjYmNiMDcyOGVlZGI1YWZkYmY1YWZhNWI5ZWRmNzgyNWU1NjZi
|
14
|
-
NzJlZDEzZjNmYWJhOGJhMWM3NTE1NDJiNDhlYWI1MTVkNmI1MjNhNzY0OTg0
|
15
|
-
MDhjZGY5MDkxY2FjZWU4NTU1NzcwYzNiNzA4MGVjZDlhMDVmMGI=
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 22d9984fa42f47bf64ceedeb67865d010a372dc5
|
4
|
+
data.tar.gz: 7cba36ed7d9f7baac8f3a58313044936b22caf2d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c9d4835fc043f35deef40d74e6bbb83f59b8acd166daba1ea72073757e1910c436f32be1a6ab6065ee24ba35558a1062371b999781c17edf44b02eb848419965
|
7
|
+
data.tar.gz: 6fa57679daaedc26c9c62361738e5ab9748f86d1e8eeb75a79044b8859b4e3dec0dc14faaaa4ddc167024086d7f047f9349f0de5a6d09232163d21a31289ec67
|
data/History.txt
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
== 1.2.
|
1
|
+
== 1.2.1 / 2016-08-23
|
2
2
|
|
3
|
-
*
|
4
|
-
* bonus words get rated higher than normal words (configurable just like blacklists)
|
5
|
-
* (Thanks to Tim-B for the new features)
|
3
|
+
* removed hard dependency to bloomfilter-rb
|
6
4
|
|
7
5
|
== 1.1.0 / 2013-04-
|
8
6
|
|
data/lib/highscore.rb
CHANGED
data/lib/highscore/content.rb
CHANGED
data/lib/highscore/wordlist.rb
CHANGED
@@ -10,14 +10,14 @@ module Highscore
|
|
10
10
|
# @return Highscore::Wordlist
|
11
11
|
def self.load_file(file_path, use_bloom_filter = true)
|
12
12
|
words = File.read(file_path).split(' ')
|
13
|
-
self.load(words)
|
13
|
+
self.load(words, use_bloom_filter)
|
14
14
|
end
|
15
15
|
|
16
16
|
# load a file or array of words
|
17
17
|
#
|
18
18
|
# @param data String Array
|
19
19
|
# @return Highscore::Wordlist
|
20
|
-
def self.load(data)
|
20
|
+
def self.load(data, use_bloom_filter = true)
|
21
21
|
if data.instance_of?(String)
|
22
22
|
words = data.split(' ')
|
23
23
|
elsif data.instance_of? Array
|
@@ -28,7 +28,7 @@ module Highscore
|
|
28
28
|
|
29
29
|
words.map! {|x| x.gsub(/[\!\.\:\,\;\-\+]/, '') }
|
30
30
|
|
31
|
-
self.new(words)
|
31
|
+
self.new(words, use_bloom_filter)
|
32
32
|
end
|
33
33
|
|
34
34
|
attr_reader :words
|
@@ -37,7 +37,8 @@ module Highscore
|
|
37
37
|
def initialize(words = [], use_bloom_filter = true)
|
38
38
|
@words = words
|
39
39
|
@bloom_filter = nil
|
40
|
-
|
40
|
+
@use_bloom_filter = use_bloom_filter
|
41
|
+
|
41
42
|
init_bloom_filter
|
42
43
|
end
|
43
44
|
|
@@ -80,11 +81,13 @@ module Highscore
|
|
80
81
|
@words << word
|
81
82
|
@bloom_filter << word unless @bloom_filter.nil?
|
82
83
|
end
|
83
|
-
|
84
|
+
|
84
85
|
private
|
85
|
-
|
86
|
+
|
86
87
|
# determine whether bloom filters should be used
|
87
88
|
def use_bloom_filter
|
89
|
+
return false unless @use_bloom_filter
|
90
|
+
|
88
91
|
begin
|
89
92
|
require 'bloomfilter-rb'
|
90
93
|
true
|
@@ -92,15 +95,15 @@ module Highscore
|
|
92
95
|
false
|
93
96
|
end
|
94
97
|
end
|
95
|
-
|
98
|
+
|
96
99
|
# build a bloom filter out of this wordlist to determine faster
|
97
100
|
# if words should be black- or whitelisted
|
98
101
|
#
|
99
102
|
def init_bloom_filter
|
100
103
|
return unless use_bloom_filter
|
101
|
-
|
104
|
+
|
102
105
|
n = length # number of filter elements
|
103
|
-
|
106
|
+
|
104
107
|
if n > 0
|
105
108
|
b = 4 # bits per bucket
|
106
109
|
m = n * b * 10 # number of filter buckets
|
@@ -112,6 +115,6 @@ module Highscore
|
|
112
115
|
each { |w| @bloom_filter.insert(w) }
|
113
116
|
end
|
114
117
|
end
|
115
|
-
|
118
|
+
|
116
119
|
end
|
117
|
-
end
|
120
|
+
end
|
@@ -2,10 +2,8 @@ $:.unshift(File.join(File.dirname(__FILE__), %w{.. .. lib highscore}))
|
|
2
2
|
require "content"
|
3
3
|
require "blacklist"
|
4
4
|
require "whitelist"
|
5
|
-
require "test/unit"
|
6
|
-
require 'rubygems'
|
7
5
|
|
8
|
-
class TestMultipleBlacklists <
|
6
|
+
class TestMultipleBlacklists < Highscore::TestCase
|
9
7
|
def setup
|
10
8
|
@nonsense = "Oui monsieur, je suis un programmer. You OK?"
|
11
9
|
|
@@ -30,7 +28,7 @@ class TestMultipleBlacklists < Test::Unit::TestCase
|
|
30
28
|
end
|
31
29
|
|
32
30
|
def test_bad_wordlist
|
33
|
-
|
31
|
+
assert_raises ArgumentError do
|
34
32
|
@content.add_wordlist 3.14159, "pi"
|
35
33
|
end
|
36
34
|
end
|
@@ -54,12 +54,23 @@ class TestBlacklist < Highscore::TestCase
|
|
54
54
|
assert blacklist.include?("foobar")
|
55
55
|
assert !blacklist.include?("bla")
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
def test_each
|
59
59
|
blacklist = Highscore::Wordlist.load "foo bar baz"
|
60
|
-
|
60
|
+
|
61
61
|
a = []
|
62
62
|
blacklist.each { |x| a << x }
|
63
63
|
assert_equal ['foo', 'bar', 'baz'], a
|
64
64
|
end
|
65
|
-
|
65
|
+
|
66
|
+
def test_use_bloom_filter_flag
|
67
|
+
list = Highscore::Wordlist.load "foo bar baz"
|
68
|
+
assert list.instance_variable_get(:@bloom_filter)
|
69
|
+
|
70
|
+
list = Highscore::Wordlist.load "foo bar baz", true
|
71
|
+
assert list.instance_variable_get(:@bloom_filter)
|
72
|
+
|
73
|
+
list = Highscore::Wordlist.load "foo bar baz", false
|
74
|
+
assert_nil list.instance_variable_get(:@bloom_filter)
|
75
|
+
end
|
76
|
+
end
|
data/test/test_highscore.rb
CHANGED
@@ -8,12 +8,12 @@ rescue LoadError
|
|
8
8
|
end
|
9
9
|
|
10
10
|
require 'highscore'
|
11
|
-
require '
|
11
|
+
require 'minitest/autorun'
|
12
12
|
|
13
13
|
module Highscore
|
14
|
-
class TestCase < Test
|
14
|
+
class TestCase < Minitest::Test
|
15
15
|
def test_version
|
16
|
-
|
16
|
+
assert (not Highscore::VERSION.nil?)
|
17
17
|
end
|
18
18
|
end
|
19
|
-
end
|
19
|
+
end
|
data/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.1
|
metadata
CHANGED
@@ -1,57 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: highscore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dominik Liebler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simplecov
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.6.4
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.6.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: whatlanguage
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 1.0.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 1.0.0
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: bloomfilter-rb
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ! '>='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 2.1.1
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ! '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 2.1.1
|
55
41
|
description: Find and rank keywords in text.
|
56
42
|
email: liebler.dominik@googlemail.com
|
57
43
|
executables:
|
@@ -63,25 +49,25 @@ extra_rdoc_files:
|
|
63
49
|
files:
|
64
50
|
- bin/highscore
|
65
51
|
- lib/blacklist.txt
|
66
|
-
- lib/highscore.rb
|
67
|
-
- lib/highscore/wordlist.rb
|
68
|
-
- lib/highscore/keywords.rb
|
52
|
+
- lib/highscore/blacklist.rb
|
69
53
|
- lib/highscore/bonuslist.rb
|
70
|
-
- lib/highscore/
|
54
|
+
- lib/highscore/content.rb
|
71
55
|
- lib/highscore/keyword.rb
|
56
|
+
- lib/highscore/keywords.rb
|
72
57
|
- lib/highscore/string.rb
|
73
|
-
- lib/highscore/
|
74
|
-
- lib/highscore/
|
58
|
+
- lib/highscore/whitelist.rb
|
59
|
+
- lib/highscore/wordlist.rb
|
60
|
+
- lib/highscore.rb
|
61
|
+
- test/fixtures/blacklist.txt
|
62
|
+
- test/highscore/test_blacklist.rb
|
75
63
|
- test/highscore/test_bonuslist.rb
|
76
|
-
- test/highscore/
|
64
|
+
- test/highscore/test_content.rb
|
77
65
|
- test/highscore/test_keyword.rb
|
66
|
+
- test/highscore/test_keywords.rb
|
67
|
+
- test/highscore/test_multiple_blacklists.rb
|
68
|
+
- test/highscore/test_string.rb
|
78
69
|
- test/highscore/test_whitelist.rb
|
79
70
|
- test/highscore/test_wordlist.rb
|
80
|
-
- test/highscore/test_string.rb
|
81
|
-
- test/highscore/test_content.rb
|
82
|
-
- test/highscore/test_blacklist.rb
|
83
|
-
- test/highscore/test_keywords.rb
|
84
|
-
- test/fixtures/blacklist.txt
|
85
71
|
- test/test_highscore.rb
|
86
72
|
- README.md
|
87
73
|
- History.txt
|
@@ -98,29 +84,29 @@ require_paths:
|
|
98
84
|
- lib
|
99
85
|
required_ruby_version: !ruby/object:Gem::Requirement
|
100
86
|
requirements:
|
101
|
-
- -
|
87
|
+
- - '>='
|
102
88
|
- !ruby/object:Gem::Version
|
103
89
|
version: '0'
|
104
90
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
91
|
requirements:
|
106
|
-
- -
|
92
|
+
- - '>='
|
107
93
|
- !ruby/object:Gem::Version
|
108
94
|
version: '0'
|
109
95
|
requirements: []
|
110
96
|
rubyforge_project: highscore
|
111
|
-
rubygems_version: 2.0.
|
97
|
+
rubygems_version: 2.0.14.1
|
112
98
|
signing_key:
|
113
99
|
specification_version: 3
|
114
100
|
summary: Easily find and rank keywords in long texts.
|
115
101
|
test_files:
|
102
|
+
- test/fixtures/blacklist.txt
|
103
|
+
- test/highscore/test_blacklist.rb
|
116
104
|
- test/highscore/test_bonuslist.rb
|
117
|
-
- test/highscore/
|
105
|
+
- test/highscore/test_content.rb
|
118
106
|
- test/highscore/test_keyword.rb
|
107
|
+
- test/highscore/test_keywords.rb
|
108
|
+
- test/highscore/test_multiple_blacklists.rb
|
109
|
+
- test/highscore/test_string.rb
|
119
110
|
- test/highscore/test_whitelist.rb
|
120
111
|
- test/highscore/test_wordlist.rb
|
121
|
-
- test/highscore/test_string.rb
|
122
|
-
- test/highscore/test_content.rb
|
123
|
-
- test/highscore/test_blacklist.rb
|
124
|
-
- test/highscore/test_keywords.rb
|
125
|
-
- test/fixtures/blacklist.txt
|
126
112
|
- test/test_highscore.rb
|