rnlp 0.0.2.a

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.
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .rvmrc
6
+ coverage
7
+ InstalledFiles
8
+ lib/bundler/man
9
+ pkg
10
+ rdoc
11
+ spec/reports
12
+ test/tmp
13
+ test/version_tmp
14
+ tmp
15
+
16
+ # YARD artifacts
17
+ .yardoc
18
+ _yardoc
19
+ doc/
data/.irbrc ADDED
@@ -0,0 +1,2 @@
1
+ require 'rspec/core/rake_task'
2
+ require File.expand_path('../spec/spec_helper', __FILE__)
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.9.3"
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+
3
+ gemspec
@@ -0,0 +1,36 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rnlp (0.0.1.a)
5
+ contracts (>= 0.1.2)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ coderay (1.0.8)
11
+ contracts (0.1.2)
12
+ diff-lcs (1.1.3)
13
+ method_source (0.8.1)
14
+ pry (0.9.10)
15
+ coderay (~> 1.0.5)
16
+ method_source (~> 0.8)
17
+ slop (~> 3.3.1)
18
+ rake (0.9.2.2)
19
+ rspec (2.11.0)
20
+ rspec-core (~> 2.11.0)
21
+ rspec-expectations (~> 2.11.0)
22
+ rspec-mocks (~> 2.11.0)
23
+ rspec-core (2.11.1)
24
+ rspec-expectations (2.11.3)
25
+ diff-lcs (~> 1.1.3)
26
+ rspec-mocks (2.11.3)
27
+ slop (3.3.3)
28
+
29
+ PLATFORMS
30
+ ruby
31
+
32
+ DEPENDENCIES
33
+ pry (>= 0.9.10)
34
+ rake (>= 0.9.2.2)
35
+ rnlp!
36
+ rspec (>= 2.11.0)
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Robert Moszczynski
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.
@@ -0,0 +1,37 @@
1
+ # Ruby Natural Language Processing Library
2
+
3
+ RNLP is strongly influenced by [NLTK](http://nltk.org). It is not yet ready for use!
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'rnlp'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install rnlp
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Links
24
+ * [nltk.org](http://nltk.org)
25
+ * [N-gram Wikipedia](http://en.wikipedia.org/wiki/N-gram)
26
+ * [Google Books Ngram Viewer](http://books.google.com/ngrams)
27
+
28
+ ## Contributing
29
+
30
+ 1. Fork it
31
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
32
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
33
+ 4. Push to the branch (`git push origin my-new-feature`)
34
+ 5. Create new Pull Request
35
+
36
+
37
+ [![Build Status](https://travis-ci.org/rmoszczynski/rnlp.png)](https://travis-ci.org/rmoszczynski/rnlp)
@@ -0,0 +1,5 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+ task :default => :spec
@@ -0,0 +1,7 @@
1
+ require 'contracts'
2
+
3
+ require "rnlp/version"
4
+ require "rnlp/util"
5
+
6
+ module RNLP
7
+ end
@@ -0,0 +1,13 @@
1
+ module RNLP
2
+ module Util
3
+ include Contracts
4
+
5
+ Contract Array, And[Num, Pos], Or[nil, Bool], Or[nil, Bool], Or[nil, Any] => ArrayOf[Array]
6
+ def self.ingrams(array, n, pad_left = false, pad_right = false, pad_symbol = nil)
7
+ array = Array.new(n-1) { pad_symbol } + array if pad_left
8
+ array = array + Array.new(n-1) { pad_symbol } if pad_right
9
+
10
+ (0..(array.size-n)).map { |i| array[i..(i+n-1)] }
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ module RNLP
2
+ VERSION = "0.0.2.a"
3
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rnlp/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "rnlp"
8
+ gem.version = RNLP::VERSION
9
+ gem.authors = ["Robert Moszczynski"]
10
+ gem.email = ["robert@moszczynski.de"]
11
+ gem.description = %q{Ruby Natural Language Processing Library}
12
+ gem.summary = %q{RNLP is strongly influenced by NLTK. It is not yet ready for use!}
13
+ gem.homepage = "https://github.com/rmoszczynski/rnlp"
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
+ gem.required_ruby_version = '>= 1.9.2'
20
+
21
+ gem.add_development_dependency 'rake', '>= 0.9.2.2'
22
+ gem.add_development_dependency 'rspec', '>= 2.11.0'
23
+ gem.add_development_dependency 'pry', '>= 0.9.10'
24
+
25
+ gem.add_dependency 'contracts', '>= 0.1.2'
26
+ end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+
3
+ describe RNLP::Util do
4
+ describe ".ingram" do
5
+ describe "should keep the contract" do
6
+ describe "if nil parameter used for" do
7
+ it "array should raise RuntimeError" do
8
+ expect {
9
+ RNLP::Util.ingrams(nil, 1)
10
+ }.to raise_error RuntimeError
11
+ end
12
+
13
+ it "n should raise RuntimeError" do
14
+ expect {
15
+ RNLP::Util.ingrams([], nil)
16
+ }.to raise_error RuntimeError
17
+ end
18
+ end
19
+
20
+ it "if n = 0 should raise RuntimeError" do
21
+ expect {
22
+ RNLP::Util.ingrams([], 0)
23
+ }.to raise_error RuntimeError
24
+ end
25
+
26
+ it "if n = -1 should raise RuntimeError" do
27
+ expect {
28
+ RNLP::Util.ingrams([], -1)
29
+ }.to raise_error RuntimeError
30
+ end
31
+ end
32
+
33
+ describe "should return unigrams" do
34
+ it "for empty array" do
35
+ RNLP::Util.ingrams([], 1).should be_empty
36
+ end
37
+
38
+ it "for 1 element in array" do
39
+ RNLP::Util.ingrams(['a'], 1).should == [['a']]
40
+ end
41
+
42
+ it "for 2 elements in array" do
43
+ RNLP::Util.ingrams(['a', 'b'], 1).should == [['a'], ['b']]
44
+ end
45
+
46
+ it "for 3 elements in array" do
47
+ RNLP::Util.ingrams(['a', 'b', 'c'], 1).should == [['a'], ['b'], ['c']]
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,7 @@
1
+ require 'rnlp'
2
+
3
+ RSpec.configure do |config|
4
+ config.color_enabled = true
5
+ config.tty = true
6
+ config.formatter = :documentation # :progress, :html, :textmate, :documentation
7
+ end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rnlp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2.a
5
+ prerelease: 6
6
+ platform: ruby
7
+ authors:
8
+ - Robert Moszczynski
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.9.2.2
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.9.2.2
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 2.11.0
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 2.11.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: pry
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 0.9.10
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.9.10
62
+ - !ruby/object:Gem::Dependency
63
+ name: contracts
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: 0.1.2
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 0.1.2
78
+ description: Ruby Natural Language Processing Library
79
+ email:
80
+ - robert@moszczynski.de
81
+ executables: []
82
+ extensions: []
83
+ extra_rdoc_files: []
84
+ files:
85
+ - .gitignore
86
+ - .irbrc
87
+ - .travis.yml
88
+ - Gemfile
89
+ - Gemfile.lock
90
+ - LICENSE.txt
91
+ - README.md
92
+ - Rakefile
93
+ - lib/rnlp.rb
94
+ - lib/rnlp/util.rb
95
+ - lib/rnlp/version.rb
96
+ - rnlp.gemspec
97
+ - spec/lib/util_spec.rb
98
+ - spec/spec_helper.rb
99
+ homepage: https://github.com/rmoszczynski/rnlp
100
+ licenses: []
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: 1.9.2
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ! '>'
115
+ - !ruby/object:Gem::Version
116
+ version: 1.3.1
117
+ requirements: []
118
+ rubyforge_project:
119
+ rubygems_version: 1.8.24
120
+ signing_key:
121
+ specification_version: 3
122
+ summary: RNLP is strongly influenced by NLTK. It is not yet ready for use!
123
+ test_files:
124
+ - spec/lib/util_spec.rb
125
+ - spec/spec_helper.rb