text_parser 0.1.8 → 0.1.9
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 +17 -0
- data/.travis.yml +6 -0
- data/.yardoc/checksums +2 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +68 -0
- data/Rakefile +4 -1
- data/doc/_index.html +0 -3
- data/lib/text_parser/version.rb +3 -0
- data/lib/text_parser.rb +3 -1
- data/text_parser.gemspec +19 -10
- metadata +59 -30
- data/README.rdoc +0 -33
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/.yardoc/checksums
ADDED
Binary file
|
data/.yardoc/proxy_types
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Fred
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# TextParser
|
2
|
+
|
3
|
+
Using method parse in the String object you can parse any text.
|
4
|
+
|
5
|
+

|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'text_parser'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install text_parser
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
"Simple, simple test".parse
|
24
|
+
# => [{:word => "simple", :hits => 2}, {:word => "test", :hits => 1}]
|
25
|
+
|
26
|
+
---
|
27
|
+
|
28
|
+
my_text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque pretium consectetur."
|
29
|
+
my_text.parse(:dictionary => ["dolor", "consectetur"])
|
30
|
+
# => [{:word => "consectetur", :hits => 2}, {:word => "dolor", :hits => 1}]
|
31
|
+
|
32
|
+
---
|
33
|
+
|
34
|
+
my_text.parse(:dictionary => ["dolor", "consectetur"], :order => :word, :order_direction => :desc)
|
35
|
+
# => [{:word => "dolor", :hits => 1}, {:word => "consectetur", :hits => 2}]
|
36
|
+
|
37
|
+
---
|
38
|
+
|
39
|
+
"Lorem ipsum dolor sit amet".parse(:negative_dictionary => ["ipsum", "dolor", "sit"])
|
40
|
+
# => [{:word => "loren", :hits => 1}, {:word => "amet", :hits => 1}]
|
41
|
+
|
42
|
+
---
|
43
|
+
|
44
|
+
"My test!".parse(:minimum_length => 3)
|
45
|
+
# => [{:word => "test", :hits => 1}]
|
46
|
+
|
47
|
+
---
|
48
|
+
|
49
|
+
### Arguments (Hash)
|
50
|
+
|
51
|
+
| Key | Type | Default value |
|
52
|
+
| ------------------------------- | ------ | ------------- |
|
53
|
+
| :dictionary | Array | nil |
|
54
|
+
| :order (:word, :hits) | Symbol | :word |
|
55
|
+
| :order_direction (:asc, :desc) | Symbol | :asc |
|
56
|
+
| :negative_dictionary | Array | nil |
|
57
|
+
| :minimum_length | int | nil |
|
58
|
+
|
59
|
+
Try it online at the [site example](http://textparser.heroku.com "Title").
|
60
|
+
|
61
|
+
## Contributing
|
62
|
+
|
63
|
+
1. Fork it
|
64
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
65
|
+
3. Run the tests
|
66
|
+
4. Commit your changes (`git commit -am 'Add some feature'`)
|
67
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
68
|
+
6. Create new Pull Request
|
data/Rakefile
CHANGED
data/doc/_index.html
CHANGED
data/lib/text_parser.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
+
require "text_parser/version"
|
3
|
+
|
2
4
|
module TextParser
|
3
5
|
# Returns a parsed text with the words and its occurrences.
|
4
6
|
# @param [Hash] [args]
|
@@ -30,4 +32,4 @@ end
|
|
30
32
|
# Includes module TextParser in the String object
|
31
33
|
class String
|
32
34
|
include TextParser
|
33
|
-
end
|
35
|
+
end
|
data/text_parser.gemspec
CHANGED
@@ -1,10 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'text_parser/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "text_parser"
|
8
|
+
gem.version = TextParser::VERSION
|
9
|
+
gem.authors = ["Frederico de Paula"]
|
10
|
+
gem.email = ["fpaula@gmail.com"]
|
11
|
+
gem.description = %q{Includes a parse method on String object}
|
12
|
+
gem.summary = %q{Using method parse in the String object you can parse any text.}
|
13
|
+
gem.homepage = "http://textparser.heroku.com"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
end
|
metadata
CHANGED
@@ -1,27 +1,45 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: text_parser
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 9
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 9
|
10
|
+
version: 0.1.9
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Frederico de Paula
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
17
|
+
|
18
|
+
date: 2012-10-23 00:00:00 Z
|
13
19
|
dependencies: []
|
14
|
-
|
15
|
-
|
20
|
+
|
21
|
+
description: Includes a parse method on String object
|
22
|
+
email:
|
23
|
+
- fpaula@gmail.com
|
16
24
|
executables: []
|
25
|
+
|
17
26
|
extensions: []
|
27
|
+
|
18
28
|
extra_rdoc_files: []
|
19
|
-
|
20
|
-
|
21
|
-
-
|
22
|
-
-
|
29
|
+
|
30
|
+
files:
|
31
|
+
- .gitignore
|
32
|
+
- .travis.yml
|
33
|
+
- .yardoc/checksums
|
34
|
+
- .yardoc/objects/root.dat
|
35
|
+
- .yardoc/proxy_types
|
36
|
+
- Gemfile
|
37
|
+
- LICENSE.txt
|
38
|
+
- README.md
|
23
39
|
- Rakefile
|
24
|
-
-
|
40
|
+
- doc/String.html
|
41
|
+
- doc/TextParser.html
|
42
|
+
- doc/TextParser/Version.html
|
25
43
|
- doc/_index.html
|
26
44
|
- doc/class_list.html
|
27
45
|
- doc/css/common.css
|
@@ -35,32 +53,43 @@ files:
|
|
35
53
|
- doc/js/full_list.js
|
36
54
|
- doc/js/jquery.js
|
37
55
|
- doc/method_list.html
|
38
|
-
- doc/String.html
|
39
|
-
- doc/TextParser/Version.html
|
40
|
-
- doc/TextParser.html
|
41
56
|
- doc/top-level-namespace.html
|
42
|
-
|
57
|
+
- lib/text_parser.rb
|
58
|
+
- lib/text_parser/version.rb
|
59
|
+
- test/text_parser_test.rb
|
60
|
+
- text_parser.gemspec
|
61
|
+
homepage: http://textparser.heroku.com
|
43
62
|
licenses: []
|
63
|
+
|
44
64
|
post_install_message:
|
45
65
|
rdoc_options: []
|
46
|
-
|
66
|
+
|
67
|
+
require_paths:
|
47
68
|
- lib
|
48
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
70
|
none: false
|
50
|
-
requirements:
|
51
|
-
- -
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
|
54
|
-
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
hash: 3
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
version: "0"
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
79
|
none: false
|
56
|
-
requirements:
|
57
|
-
- -
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
hash: 3
|
84
|
+
segments:
|
85
|
+
- 0
|
86
|
+
version: "0"
|
60
87
|
requirements: []
|
88
|
+
|
61
89
|
rubyforge_project:
|
62
|
-
rubygems_version: 1.8.
|
90
|
+
rubygems_version: 1.8.24
|
63
91
|
signing_key:
|
64
92
|
specification_version: 3
|
65
|
-
summary:
|
66
|
-
test_files:
|
93
|
+
summary: Using method parse in the String object you can parse any text.
|
94
|
+
test_files:
|
95
|
+
- test/text_parser_test.rb
|
data/README.rdoc
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
=Arguments (Hash)
|
2
|
-
+---------------------------------+--------+---------------+
|
3
|
-
| Key | Type | Default value |
|
4
|
-
+---------------------------------+--------+---------------+
|
5
|
-
| :dictionary | Array | nil |
|
6
|
-
| :order (:word | :hits) | Symbol | :word |
|
7
|
-
| :order_direction (:asc | :desc) | Symbol | :asc |
|
8
|
-
| :negative_dictionary | Array | nil |
|
9
|
-
+---------------------------------+--------+---------------+
|
10
|
-
|
11
|
-
|
12
|
-
=Usage
|
13
|
-
|
14
|
-
"Simple, simple test".parse
|
15
|
-
# => [{:word => "simple", :hits => 2}, {:word => "test", :hits => 1}]
|
16
|
-
|
17
|
-
------------------------------------------------------------------------------------------------------------
|
18
|
-
|
19
|
-
my_text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque pretium consectetur."
|
20
|
-
my_text.parse(:dictionary => ["dolor", "consectetur"])
|
21
|
-
# => [{:word => "consectetur", :hits => 2}, {:word => "dolor", :hits => 1}]
|
22
|
-
|
23
|
-
------------------------------------------------------------------------------------------------------------
|
24
|
-
|
25
|
-
my_text.parse(:dictionary => ["dolor", "consectetur"], :order => :word, :order_direction => :desc)
|
26
|
-
# => [{:word => "dolor", :hits => 1}, {:word => "consectetur", :hits => 2}]
|
27
|
-
|
28
|
-
------------------------------------------------------------------------------------------------------------
|
29
|
-
|
30
|
-
"Lorem ipsum dolor sit amet".parse(:negative_dictionary => ["ipsum", "dolor", "sit"])
|
31
|
-
# => [{:word => "loren", :hits => 1}, {:word => "amet", :hits => 1}]
|
32
|
-
|
33
|
-
|