highscore 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,8 @@
1
+ == 0.4.2 / 2012-02-07
2
+
3
+ * added a simple example that also shows return values in README.md
4
+ * #7 fixed handling of keywords for Ruby 1.8.7 (thanks to undecided)
5
+
1
6
  == 0.4.1 / 2012-02-06
2
7
 
3
8
  * fixed handling of keywords that are actually Fixnums
data/README.md CHANGED
@@ -6,7 +6,7 @@ Find and rank keywords in long texts.
6
6
  Features
7
7
  --------
8
8
 
9
- * configureable to rank different types of words different (uppercase, long words, etc.)
9
+ * configurable to rank different types of words different (uppercase, long words, etc.)
10
10
  * directly get keywords from String objects
11
11
  * blacklist words via a plain text file, String or an Array of words
12
12
  * merge together Keywords from multiple sources
@@ -26,20 +26,33 @@ end
26
26
  # get all keywords
27
27
  text.keywords.rank => Array
28
28
 
29
- # get the top 50 keywords
29
+ # get only the top 50 keywords
30
30
  text.keywords.top(50).each do |keyword|
31
31
  keyword.text # => keyword text
32
32
  keyword.weight # => rank weight (float)
33
33
  end
34
34
 
35
- # you could simply just use a string
36
- text = "foo bar".keywords(blacklist) do
35
+ # you could just use a string
36
+ keywords = "Foo bar baz".keywords(blacklist) do
37
37
  set :multiplier, 10
38
38
  end
39
-
40
- text.keywords
41
39
  ```
42
40
 
41
+ The result is either a Highscore::Keywords object or an Array (depending on whether it's sorted or not) that you
42
+ can iterate over. Each object in there is a Highscore::Keyword that has methods `text` and `weight`.
43
+
44
+ ```ruby
45
+ keywords = "Foo bar is not bar baz".keywords(Highscore::Blacklist.load(['baz']))
46
+
47
+ keywords.each do |k|
48
+ puts "#{k.text} #{k.weight}"
49
+ end
50
+
51
+ # prints:
52
+ # Foo 3.0
53
+ # bar 2.0
54
+ # not 1.0
55
+ ```
43
56
 
44
57
  Using a custom blacklist to ignore keywords
45
58
  -------------------------------------------
@@ -50,7 +50,7 @@ module Highscore
50
50
  weight *= @emphasis[:long_words]
51
51
  end
52
52
 
53
- if text[0] == text[0].upcase
53
+ if text[0,1] == text[0,1].upcase
54
54
  weight *= @emphasis[:upper_case]
55
55
  end
56
56
 
@@ -60,4 +60,17 @@ class TestBlacklist < Test::Unit::TestCase
60
60
  assert blacklist.include?("foobar")
61
61
  assert !blacklist.include?("bla")
62
62
  end
63
+
64
+ def test_blacklisting_content
65
+ keywords = "Foo bar is not bar baz".keywords(Highscore::Blacklist.load(['baz']))
66
+
67
+ keyword_list = []
68
+ keywords.each do |k|
69
+ keyword_list << k.text
70
+ end
71
+
72
+ expected_keywords = ['Foo', 'bar', 'not']
73
+
74
+ assert_equal expected_keywords, keyword_list
75
+ end
63
76
  end
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.4.2
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.1
4
+ version: 0.4.2
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-06 00:00:00.000000000 Z
12
+ date: 2012-02-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bones
16
- requirement: &70092474871020 !ruby/object:Gem::Requirement
16
+ requirement: &70117716241580 !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: *70092474871020
24
+ version_requirements: *70117716241580
25
25
  description: Find and rank keywords in long texts.
26
26
  email: liebler.dominik@googlemail.com
27
27
  executables: