highscore 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ODQ1NGUyMjdjNGUzNjdlYTA4MjFlYjViMmY0NzM1MjBhMTU2ODlhOQ==
5
- data.tar.gz: !binary |-
6
- MTVmNzMyOTVhZjFkNjBhMTFjODc5NWM2MzdlN2E1NTljYzNjY2ExMw==
7
- !binary "U0hBNTEy":
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
@@ -1,8 +1,6 @@
1
- == 1.2.0 / 2013-12-06
1
+ == 1.2.1 / 2016-08-23
2
2
 
3
- * configurable minimum word length
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
 
@@ -24,4 +24,3 @@ module Highscore
24
24
  end
25
25
 
26
26
  Highscore.load_modules
27
-
@@ -105,7 +105,8 @@ module Highscore
105
105
  #
106
106
  # @return Symbol
107
107
  def language
108
- @content.language
108
+ wl = WhatLanguage.new(:all)
109
+ wl.language(@content)
109
110
  end
110
111
 
111
112
  private
@@ -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
@@ -1,8 +1,6 @@
1
1
  # encoding: utf-8
2
2
  $:.unshift(File.join(File.dirname(__FILE__), %w{.. .. lib highscore}))
3
3
  require "content"
4
- require "test/unit"
5
- require 'rubygems'
6
4
 
7
5
  class TestContent < Highscore::TestCase
8
6
  def setup
@@ -8,7 +8,7 @@ class TestKeyword < Highscore::TestCase
8
8
  def test_init
9
9
 
10
10
  # don't allow 'empty' keywords
11
- assert_raise(ArgumentError) do
11
+ assert_raises(ArgumentError) do
12
12
  Highscore::Keyword.new
13
13
  end
14
14
  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 < Test::Unit::TestCase
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
- assert_raise ArgumentError do
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
- end
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
@@ -8,12 +8,12 @@ rescue LoadError
8
8
  end
9
9
 
10
10
  require 'highscore'
11
- require 'test/unit'
11
+ require 'minitest/autorun'
12
12
 
13
13
  module Highscore
14
- class TestCase < Test::Unit::TestCase
14
+ class TestCase < Minitest::Test
15
15
  def test_version
16
- assert_not_nil Highscore::VERSION
16
+ assert (not Highscore::VERSION.nil?)
17
17
  end
18
18
  end
19
- end
19
+ end
@@ -1 +1 @@
1
- 1.2.0
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.0
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: 2013-12-06 00:00:00.000000000 Z
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/whitelist.rb
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/content.rb
74
- - lib/highscore/blacklist.rb
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/test_multiple_blacklists.rb
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.3
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/test_multiple_blacklists.rb
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