seasy 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +0 -5
- data/LICENSE.txt +1 -1
- data/README.md +46 -0
- data/VERSION +1 -1
- data/lib/seasy/fragmentizer.rb +5 -4
- data/lib/seasy/index.rb +0 -3
- data/seasy.gemspec +5 -5
- data/spec/fragmentizer_spec.rb +21 -8
- metadata +6 -6
- data/README.rdoc +0 -19
data/Gemfile
CHANGED
@@ -1,10 +1,5 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
|
-
# Add dependencies required to use your gem here.
|
3
|
-
# Example:
|
4
|
-
# gem "activesupport", ">= 2.3.5"
|
5
2
|
|
6
|
-
# Add dependencies to develop your gem here.
|
7
|
-
# Include everything needed to run rake, tests, features, etc.
|
8
3
|
group :development do
|
9
4
|
gem "rspec", ">= 2.5.0"
|
10
5
|
gem "bundler", "~> 1.0.0"
|
data/LICENSE.txt
CHANGED
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
seasy
|
2
|
+
=====
|
3
|
+
|
4
|
+
Seasy is a library that makes search easy.
|
5
|
+
|
6
|
+
|
7
|
+
Usage
|
8
|
+
-----
|
9
|
+
|
10
|
+
# updating the index
|
11
|
+
index = Index::default
|
12
|
+
index.add 'Fredrik Rubenssons blog', 'http://www.highlevelbits.com'
|
13
|
+
|
14
|
+
# searching the index
|
15
|
+
index.search "Ruben" # will return {'http://www.highlevelbits.com' => 1}
|
16
|
+
|
17
|
+
|
18
|
+
Configuration
|
19
|
+
-------------
|
20
|
+
|
21
|
+
Seasy got a built-in memory storage that is used default. If you need to do something else it can be configured:
|
22
|
+
|
23
|
+
include Seasy
|
24
|
+
configure do |config|
|
25
|
+
config.storage = YourOwnFancyStorage
|
26
|
+
end
|
27
|
+
|
28
|
+
A storage needs to answer to the following methods.
|
29
|
+
|
30
|
+
* an empty constructor
|
31
|
+
* a save method with three arguments: a target, a string that will be indexed and a options hash
|
32
|
+
* a search method that accepts a query string
|
33
|
+
* a remove method that accepts a source that is to be removed (see below for source and target definitions)
|
34
|
+
* a clear method for test purposes
|
35
|
+
|
36
|
+
If several indices will be used the storage needs to support a name= method that sets the name of the index. There will be one or moer instances of the storage per index.
|
37
|
+
|
38
|
+
The storage also needs to understand the difference between targets and sources. A target is where you want to end when doing a search. A source is the item that contains the text that leads to the source. (Example ffrom whan I needed it: you have a database of persons with payments and want to search for persons based on details in the payments but when a payment is removed those search items should be removed but not the persons own search items.) To enable this the save method accepts source in the options hash and the remove method should remove all items matching the argument source.
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
Copyright
|
43
|
+
---------
|
44
|
+
|
45
|
+
Copyright (c) 2011-2012 Fredrik Rubensson. See LICENSE.txt for further details.
|
46
|
+
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.8
|
data/lib/seasy/fragmentizer.rb
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
class Fragmentizer
|
2
2
|
def fragmentize str, weights = Hash.new( 0 )
|
3
|
+
str = str.downcase
|
3
4
|
split = str.split
|
4
|
-
|
5
|
-
if split.size > 1
|
5
|
+
|
6
|
+
if split.size > 1
|
6
7
|
split.each do |one|
|
7
8
|
fragmentize one, weights
|
8
9
|
end
|
9
10
|
weights
|
10
11
|
else
|
11
12
|
length = str.length
|
12
|
-
|
13
|
+
|
13
14
|
# loop over all possible intervals
|
14
15
|
(1..length).each do |interval|
|
15
16
|
fragmentize_in_interval str, interval, weights
|
@@ -18,7 +19,7 @@ class Fragmentizer
|
|
18
19
|
weights
|
19
20
|
end
|
20
21
|
end
|
21
|
-
|
22
|
+
|
22
23
|
def fragmentize_in_interval str, interval, weights
|
23
24
|
length = str.length
|
24
25
|
(0..length-interval).each do |i|
|
data/lib/seasy/index.rb
CHANGED
data/seasy.gemspec
CHANGED
@@ -5,16 +5,16 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "seasy"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.8"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Fredrik Rubensson"]
|
12
|
-
s.date = "
|
12
|
+
s.date = "2012-10-30"
|
13
13
|
s.description = "An easy to use search index (requiring no external servers) with a pluggable design for index storage."
|
14
14
|
s.email = "fredrik@eldfluga.se"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE.txt",
|
17
|
-
"README.
|
17
|
+
"README.md"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".document",
|
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
|
|
22
22
|
"Gemfile",
|
23
23
|
"Gemfile.lock",
|
24
24
|
"LICENSE.txt",
|
25
|
-
"README.
|
25
|
+
"README.md",
|
26
26
|
"Rakefile",
|
27
27
|
"VERSION",
|
28
28
|
"lib/seasy.rb",
|
@@ -35,7 +35,7 @@ Gem::Specification.new do |s|
|
|
35
35
|
s.homepage = "http://github.com/froderik/seasy"
|
36
36
|
s.licenses = ["MIT"]
|
37
37
|
s.require_paths = ["lib"]
|
38
|
-
s.rubygems_version = "1.8.
|
38
|
+
s.rubygems_version = "1.8.24"
|
39
39
|
s.summary = "server less search"
|
40
40
|
|
41
41
|
if s.respond_to? :specification_version then
|
data/spec/fragmentizer_spec.rb
CHANGED
@@ -26,20 +26,33 @@ describe Fragmentizer do
|
|
26
26
|
result["ab"].should == 2
|
27
27
|
result["bc"].should == 1
|
28
28
|
result["ca"].should == 1
|
29
|
-
result["abc"].should == 1
|
30
|
-
result["abca"].should == 1
|
31
|
-
result["abcab"].should == 1
|
32
|
-
result["bca"].should == 1
|
33
|
-
result["bcab"].should == 1
|
34
|
-
result["cab"].should == 1
|
29
|
+
result["abc"].should == 1
|
30
|
+
result["abca"].should == 1
|
31
|
+
result["abcab"].should == 1
|
32
|
+
result["bca"].should == 1
|
33
|
+
result["bcab"].should == 1
|
34
|
+
result["cab"].should == 1
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should downcase" do
|
38
|
+
f = Fragmentizer.new
|
39
|
+
result = f.fragmentize( "Abab" )
|
40
|
+
result.size.should == 7
|
41
|
+
result['a'].should == 2
|
42
|
+
result['b'].should == 2
|
43
|
+
result['ab'].should == 2
|
44
|
+
result['ba'].should == 1
|
45
|
+
result['bab'].should == 1
|
46
|
+
result['aba'].should == 1
|
47
|
+
result['abab'].should == 1
|
35
48
|
end
|
36
|
-
|
49
|
+
|
37
50
|
it "should count conecutive singularities" do
|
38
51
|
f = subject
|
39
52
|
result = f.fragmentize "fluffluff"
|
40
53
|
result["f"].should == 5
|
41
54
|
end
|
42
|
-
|
55
|
+
|
43
56
|
it "should split a string into parts on whitespace" do
|
44
57
|
f = Fragmentizer.new
|
45
58
|
result = f.fragmentize( "ab c" )
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: seasy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.8
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Fredrik Rubensson
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date:
|
13
|
+
date: 2012-10-30 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
@@ -64,14 +64,14 @@ extensions: []
|
|
64
64
|
|
65
65
|
extra_rdoc_files:
|
66
66
|
- LICENSE.txt
|
67
|
-
- README.
|
67
|
+
- README.md
|
68
68
|
files:
|
69
69
|
- .document
|
70
70
|
- .rvmrc
|
71
71
|
- Gemfile
|
72
72
|
- Gemfile.lock
|
73
73
|
- LICENSE.txt
|
74
|
-
- README.
|
74
|
+
- README.md
|
75
75
|
- Rakefile
|
76
76
|
- VERSION
|
77
77
|
- lib/seasy.rb
|
@@ -93,7 +93,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
hash:
|
96
|
+
hash: -1654166568412522441
|
97
97
|
segments:
|
98
98
|
- 0
|
99
99
|
version: "0"
|
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
106
|
requirements: []
|
107
107
|
|
108
108
|
rubyforge_project:
|
109
|
-
rubygems_version: 1.8.
|
109
|
+
rubygems_version: 1.8.24
|
110
110
|
signing_key:
|
111
111
|
specification_version: 3
|
112
112
|
summary: server less search
|
data/README.rdoc
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
= seasy
|
2
|
-
|
3
|
-
Description goes here.
|
4
|
-
|
5
|
-
== Contributing to seasy
|
6
|
-
|
7
|
-
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
-
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
-
* Fork the project
|
10
|
-
* Start a feature/bugfix branch
|
11
|
-
* Commit and push until you are happy with your contribution
|
12
|
-
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
-
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
-
|
15
|
-
== Copyright
|
16
|
-
|
17
|
-
Copyright (c) 2011 Fredrik Rubensson. See LICENSE.txt for
|
18
|
-
further details.
|
19
|
-
|