highscore 0.4.0 → 0.4.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.
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
1
  # general
2
2
  .DS_Store
3
+ *.gemspec
3
4
 
4
5
  # RubyMine
5
6
  .idea
@@ -8,4 +9,4 @@
8
9
  announcement.txt
9
10
  coverage
10
11
  doc
11
- pkg
12
+ pkg
@@ -1,3 +1,8 @@
1
+ == 0.4.1 / 2012-02-06
2
+
3
+ * fixed handling of keywords that are actually Fixnums
4
+ * fixed a typo in the README (thanks to snyff)
5
+
1
6
  == 0.4.0 / 2012-02-04
2
7
 
3
8
  * monkey-patched String to have a keywords method on it that takes the same arguments as Highscore::Content.new
data/README.md CHANGED
@@ -14,61 +14,59 @@ Features
14
14
  Examples
15
15
  --------
16
16
 
17
- text = Highscore::Content.new "foo bar"
18
- text.configure.do
19
- set :multiplier, 2
20
- set :upper_case, 3
21
- set :long_words, 2
22
- set :long_words_threshold, 15
23
- end
17
+ ```ruby
18
+ text = Highscore::Content.new "foo bar"
19
+ text.configure do
20
+ set :multiplier, 2
21
+ set :upper_case, 3
22
+ set :long_words, 2
23
+ set :long_words_threshold, 15
24
+ end
24
25
 
25
- # get all keywords
26
- text.keywords.rank => Array
26
+ # get all keywords
27
+ text.keywords.rank => Array
27
28
 
28
- # get the top 50 keywords
29
- text.keywords.top(50).each do |keyword|
30
- keyword.text # => keyword text
31
- keyword.weight # => rank weight (float)
32
- end
29
+ # get the top 50 keywords
30
+ text.keywords.top(50).each do |keyword|
31
+ keyword.text # => keyword text
32
+ keyword.weight # => rank weight (float)
33
+ end
33
34
 
34
- # you could simply just use a string
35
- text = "foo bar".keywords(blacklist) do
36
- set :multiplier, 10
37
- end
35
+ # you could simply just use a string
36
+ text = "foo bar".keywords(blacklist) do
37
+ set :multiplier, 10
38
+ end
38
39
 
39
- text.keywords
40
+ text.keywords
41
+ ```
40
42
 
41
43
 
42
44
  Using a custom blacklist to ignore keywords
43
45
  -------------------------------------------
44
46
 
45
- # setting single words
46
- blacklist = Highscore::Blacklist.new
47
- blacklist << 'foo'
47
+ ```ruby
48
+ # setting single words
49
+ blacklist = Highscore::Blacklist.new
50
+ blacklist << 'foo'
48
51
 
49
- # load a string/array
50
- blacklist = Highscore::Blacklist.load "a string"
51
- blacklist = Highscore::Blacklist.load %w{an array}
52
+ # load a string/array
53
+ blacklist = Highscore::Blacklist.load "a string"
54
+ blacklist = Highscore::Blacklist.load %w{an array}
52
55
 
53
- # loading from a file (separated by whitespace)
54
- blacklist = Highscore::Blacklist.load_file "blacklist.txt"
56
+ # loading from a file (separated by whitespace)
57
+ blacklist = Highscore::Blacklist.load_file "blacklist.txt"
55
58
 
56
- # loading the default blacklist (falls back automatically if not explicit given)
57
- blacklist = Highscore::Blacklist.load_default_file
59
+ # loading the default blacklist (falls back automatically if not explicit given)
60
+ blacklist = Highscore::Blacklist.load_default_file
58
61
 
59
- # inject the blacklist into the content class
60
- content = Highscore::Content.new "a string", blacklist
61
-
62
-
63
- Requirements
64
- ------------
65
-
66
- (none)
62
+ # inject the blacklist into the content class
63
+ content = Highscore::Content.new "a string", blacklist
64
+ ```
67
65
 
68
66
  Install
69
67
  -------
70
68
 
71
- * sudo gem install highscore
69
+ * `[sudo] gem install highscore`
72
70
 
73
71
  Author
74
72
  ------
@@ -44,6 +44,7 @@ module Highscore
44
44
 
45
45
  Keywords.find_keywords(@content, @blacklist).each do |text|
46
46
  weight = @emphasis[:multiplier]
47
+ text = text.to_s
47
48
 
48
49
  if text.length >= @emphasis[:long_words_threshold]
49
50
  weight *= @emphasis[:long_words]
@@ -10,7 +10,7 @@ module Highscore
10
10
 
11
11
  # find keywords in a piece of content
12
12
  def self.find_keywords content, blacklist
13
- keywords = content.scan(/\w+/)
13
+ keywords = content.to_s.scan(/\w+/)
14
14
  keywords.delete_if do |x|
15
15
  x.match(/^[\d]+(\.[\d]+){0,1}$/) or x.length <= 2
16
16
  end
@@ -22,4 +22,12 @@ class TestContent < Test::Unit::TestCase
22
22
  content = Highscore::Content.new content
23
23
  assert_equal 2, content.keywords.length
24
24
  end
25
+
26
+ # https://github.com/domnikl/highscore/issues/7
27
+ def test_keywords_fixnum
28
+ content = '522 abc 232'
29
+
30
+ content = Highscore::Content.new content
31
+ assert_equal 1, content.keywords.length
32
+ end
25
33
  end
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.4.1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: highscore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-05 00:00:00.000000000 Z
12
+ date: 2012-02-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bones
16
- requirement: &70220913110960 !ruby/object:Gem::Requirement
16
+ requirement: &70092474871020 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 3.7.3
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70220913110960
24
+ version_requirements: *70092474871020
25
25
  description: Find and rank keywords in long texts.
26
26
  email: liebler.dominik@googlemail.com
27
27
  executables:
@@ -38,7 +38,6 @@ files:
38
38
  - README.md
39
39
  - Rakefile
40
40
  - bin/highscore
41
- - highscore.gemspec
42
41
  - lib/blacklist.txt
43
42
  - lib/highscore.rb
44
43
  - lib/highscore/blacklist.rb
@@ -1,34 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- Gem::Specification.new do |s|
4
- s.name = "highscore"
5
- s.version = "0.3.0"
6
-
7
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Dominik Liebler"]
9
- s.date = "2012-01-21"
10
- s.description = "Rank keywords in long texts."
11
- s.email = "liebler.dominik@googlemail.com"
12
- s.executables = ["highscore"]
13
- s.extra_rdoc_files = ["History.txt", "bin/highscore"]
14
- s.files = [".gitignore", "History.txt", "README.md", "Rakefile", "bin/highscore", "lib/highscore.rb", "lib/highscore/content.rb", "lib/highscore/keyword.rb", "lib/highscore/keywords.rb", "test/highscore/test_content.rb", "test/highscore/test_keyword.rb", "test/highscore/test_keywords.rb", "test/test_highscore.rb", "version.txt"]
15
- s.homepage = "http://thewebdev.de"
16
- s.rdoc_options = ["--main", "README.md"]
17
- s.require_paths = ["lib"]
18
- s.rubyforge_project = "highscore"
19
- s.rubygems_version = "1.8.11"
20
- s.summary = "Rank keywords in long texts."
21
- s.test_files = ["test/highscore/test_content.rb", "test/highscore/test_keyword.rb", "test/highscore/test_keywords.rb", "test/test_highscore.rb"]
22
-
23
- if s.respond_to? :specification_version then
24
- s.specification_version = 3
25
-
26
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
27
- s.add_development_dependency(%q<bones>, [">= 3.7.3"])
28
- else
29
- s.add_dependency(%q<bones>, [">= 3.7.3"])
30
- end
31
- else
32
- s.add_dependency(%q<bones>, [">= 3.7.3"])
33
- end
34
- end