lexical_units 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f525e4f5314f36a83f70fe377e9fab926bc837ff
4
+ data.tar.gz: 166743d0dd6094a56146f2c0de941e573c151505
5
+ SHA512:
6
+ metadata.gz: 2005b725f605df1857f138d24d7febb224c887dfb5ba00626a735eba275a4073a68fb823ba12023699aad1ebbb8ce8452838d6bcb37521c03c277dd0eebb0f61
7
+ data.tar.gz: 9bffe65d097bd7580044f8f6cd8469663b29fb18f08b8a6da19f70afc7173afa61ba79aa5c6524bcf2d263df6b9d44b59acc1d050c7efe29fc9965d3aba74f06
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ lexical_units
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.0.0
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - jruby-head
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :development, :test do
4
+ gem 'coveralls', require: false
5
+ gem 'rspec'
6
+ gem 'guard'
7
+ gem 'guard-bundler'
8
+ gem 'guard-rspec'
9
+ end
10
+
11
+ # Specify your gem's dependencies in lexical_units.gemspec
12
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,13 @@
1
+ guard 'bundler' do
2
+ watch('Gemfile')
3
+ watch(/^.+\.gemspec/)
4
+ end
5
+
6
+ guard :rspec do
7
+ watch(%r{^spec/.+_spec\.rb$})
8
+ watch(%r{^lib/(.+)\.rb$}) do |array|
9
+ name = array.last
10
+ "spec/#{name}_spec.rb"
11
+ end
12
+ watch('spec/spec_helper.rb') { "spec" }
13
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Fractal Soft
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,31 @@
1
+ # LexicalUnits [![Gem Version](https://badge.fury.io/rb/lexical_units.png)](http://badge.fury.io/rb/lexical_units) [![Build Status](https://travis-ci.org/fractalsoft/lexical_units.png)](https://travis-ci.org/fractalsoft/lexical_units) [![Dependency Status](https://gemnasium.com/fractalsoft/lexical_units.png)](https://gemnasium.com/fractalsoft/lexical_units) [![Coverage Status](https://coveralls.io/repos/fractalsoft/lexical_units/badge.png)](https://coveralls.io/r/fractalsoft/lexical_units)
2
+
3
+ Lexical unit is a single word, a part of a word, or a chain of words that forms the basic elements of a language's lexicon.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'lexical_units'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install lexical_units
18
+
19
+ ## Usage
20
+
21
+ ```ruby
22
+ LexicalUnits::words(text)
23
+ ```
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'lexical_units/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "lexical_units"
8
+ spec.version = LexicalUnits::VERSION
9
+ spec.authors = ["Aleksander Malaszkiewicz"]
10
+ spec.email = ["info@fractalsoft.org"]
11
+ spec.summary = %q{Split text into lexical units}
12
+ spec.homepage = ""
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.3"
21
+ spec.add_development_dependency "rake"
22
+ end
@@ -0,0 +1,3 @@
1
+ module LexicalUnits
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,23 @@
1
+ module LexicalUnits
2
+ # Split text into words
3
+ #
4
+ # self.words("Lorem ipsum dolor sit") #=> ["Lorem", "ipsum", "dolor", "sit"]
5
+ # self.words("Lorem, ipsum. Dolor?") #=> ["Lorem", "ipsum", "Dolor"]
6
+ def self.words(text)
7
+ regexp = Regexp.new("[#{LexicalUnits::separators}]")
8
+ text.gsub(regexp, " ").split(" ")
9
+ end
10
+
11
+ private
12
+ def self.separators
13
+ [
14
+ '\,', '\:', '\;',
15
+ '\.', '\?', '\!',
16
+ '\-', '\/',
17
+ '\(', '\)',
18
+ '\[', '\]',
19
+ '\>', '\<',
20
+ '\{', '\}'
21
+ ].join
22
+ end
23
+ end
@@ -0,0 +1,5 @@
1
+ require "lexical_units/words"
2
+ require "lexical_units/version"
3
+
4
+ module LexicalUnits
5
+ end
@@ -0,0 +1,77 @@
1
+ require 'spec_helper'
2
+
3
+ describe LexicalUnits do
4
+ context ".words" do
5
+ let(:klass) { LexicalUnits }
6
+
7
+ it "splits text with whitespaces into words" do
8
+ text = "Lorem ipsum dolor sit amet"
9
+ array = %w(Lorem ipsum dolor sit amet)
10
+
11
+ klass::words(text).should eq(array)
12
+ end
13
+
14
+ it "splits text with comma, colon and semicolon into words" do
15
+ text = "Lorem ipsum,dolor:sit;amet"
16
+ array = %w(Lorem ipsum dolor sit amet)
17
+
18
+ klass::words(text).should eq(array)
19
+ end
20
+
21
+ it "splits text with dot, question mark and exclamation mark into words" do
22
+ text = "Lorem ipsum.dolor?sit!amet"
23
+ array = %w(Lorem ipsum dolor sit amet)
24
+
25
+ klass::words(text).should eq(array)
26
+ end
27
+
28
+ it "splits other text with whitespaces, comma and dot into words" do
29
+ text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
30
+ array = %w(Lorem ipsum dolor sit amet consectetur adipiscing elit)
31
+
32
+ klass::words(text).should eq(array)
33
+ end
34
+
35
+ it "splits text with hyphen into words" do
36
+ text = "Lorem ipsum dolor-sit amet"
37
+ array = %w(Lorem ipsum dolor sit amet)
38
+
39
+ klass::words(text).should eq(array)
40
+ end
41
+
42
+ it "splits text with slash into words" do
43
+ text = "Lorem ipsum dolor sit/amet"
44
+ array = %w(Lorem ipsum dolor sit amet)
45
+
46
+ klass::words(text).should eq(array)
47
+ end
48
+
49
+ it "splits text with round brackets into words" do
50
+ text = "Lorem ipsum(dolor sit)amet"
51
+ array = %w(Lorem ipsum dolor sit amet)
52
+
53
+ klass::words(text).should eq(array)
54
+ end
55
+
56
+ it "splits text with square brackets into words" do
57
+ text = "Lorem ipsum dolor[sit]amet"
58
+ array = %w(Lorem ipsum dolor sit amet)
59
+
60
+ klass::words(text).should eq(array)
61
+ end
62
+
63
+ it "splits text with pointy brackets into words" do
64
+ text = "Lorem<ipsum dolor sit>amet"
65
+ array = %w(Lorem ipsum dolor sit amet)
66
+
67
+ klass::words(text).should eq(array)
68
+ end
69
+
70
+ it "splits text with braces into words" do
71
+ text = "Lorem ipsum{dolor}sit amet"
72
+ array = %w(Lorem ipsum dolor sit amet)
73
+
74
+ klass::words(text).should eq(array)
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,9 @@
1
+ require 'lexical_units'
2
+ require 'coveralls'
3
+ Coveralls.wear!
4
+
5
+ RSpec.configure do |config|
6
+ config.treat_symbols_as_metadata_keys_with_true_values = true
7
+ config.run_all_when_everything_filtered = true
8
+ config.filter_run :focus
9
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lexical_units
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Aleksander Malaszkiewicz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-07-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description:
42
+ email:
43
+ - info@fractalsoft.org
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - .rspec
50
+ - .ruby-gemset
51
+ - .ruby-version
52
+ - .travis.yml
53
+ - Gemfile
54
+ - Guardfile
55
+ - LICENSE.txt
56
+ - README.md
57
+ - Rakefile
58
+ - lexical_units.gemspec
59
+ - lib/lexical_units.rb
60
+ - lib/lexical_units/version.rb
61
+ - lib/lexical_units/words.rb
62
+ - spec/lexical_units/words_spec.rb
63
+ - spec/spec_helper.rb
64
+ homepage: ''
65
+ licenses:
66
+ - MIT
67
+ metadata: {}
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubyforge_project:
84
+ rubygems_version: 2.0.3
85
+ signing_key:
86
+ specification_version: 4
87
+ summary: Split text into lexical units
88
+ test_files:
89
+ - spec/lexical_units/words_spec.rb
90
+ - spec/spec_helper.rb