pascoale 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/Guardfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +46 -0
- data/Rakefile +1 -0
- data/lib/pascoale/edits.rb +43 -0
- data/lib/pascoale/version.rb +3 -0
- data/lib/pascoale.rb +5 -0
- data/pascoale.gemspec +23 -0
- data/spec/lib/pascoale/edits_spec.rb +29 -0
- data/spec/spec_helper.rb +1 -0
- metadata +106 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3f87f39d24d3b3f69fb4986a5c404b10c09a70ba
|
4
|
+
data.tar.gz: 774b1b69f799b29135d39ebd42dbca289501ee89
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9946235a223bc0ddb21d5f13ade819d839499a576cf350f71592592dc1444108ed2b0ee716a5859f1d6b2cd857ae2eb432bc2f5e6d8016babb22ae34918cafce
|
7
|
+
data.tar.gz: a69644ddfb6c30a31ec4690ec9e32a075727cd7d04db89405e2309eccc095d1ed645b2a50dd031b9fca87cd5c06d74826d010ce46cc8bb47a32169a15148f88a
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Ronie Uliana
|
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,46 @@
|
|
1
|
+
# Pascoale
|
2
|
+
|
3
|
+
Minor utilities for text processing in Brazilian Portuguese.
|
4
|
+
|
5
|
+
I'm going to add new functions as I need them. Currently it has only variations of a word at one and two edit distances.
|
6
|
+
|
7
|
+
The code is kinda slow, but I'm not worried about speed (yet).
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
gem 'pascoale'
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install pascoale
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Variations of a word (typos and misspelling)
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
require 'pascoale'
|
29
|
+
|
30
|
+
edits = Pascoale.Edits.new('você')
|
31
|
+
|
32
|
+
# 1 edit distance
|
33
|
+
puts edits.editions.inspect
|
34
|
+
|
35
|
+
# 2 edits distance
|
36
|
+
puts edits.editions2.inspect # LOTS of output, be aware.
|
37
|
+
```
|
38
|
+
|
39
|
+
|
40
|
+
## Contributing
|
41
|
+
|
42
|
+
1. Fork it ( http://github.com/<my-github-username>/pascoale/fork )
|
43
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
44
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
45
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
46
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,43 @@
|
|
1
|
+
class Pascoale::Edits
|
2
|
+
LETTERS = ' abcdefghijklmnopqrstuvwxyzáéíóúâêôãõç'.scan(/./)
|
3
|
+
|
4
|
+
def initialize(word)
|
5
|
+
@splits = (0..(word.size)).map do |i|
|
6
|
+
[word[0, i].to_s, word[(i)..-1]]
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def deletions
|
11
|
+
@splits.map do |(a, b)|
|
12
|
+
a + b[1..-1] if b.size > 0
|
13
|
+
end.compact
|
14
|
+
end
|
15
|
+
|
16
|
+
def transpositions
|
17
|
+
@splits.map do |(a, b)|
|
18
|
+
a + b[1] + b[0] + b[2..-1] if b.size > 1
|
19
|
+
end.compact
|
20
|
+
end
|
21
|
+
|
22
|
+
def substitutions
|
23
|
+
LETTERS.product(@splits).map do |(letter, (a, b))|
|
24
|
+
(a + letter + b[1..-1]).strip if b.size > 0
|
25
|
+
end.compact
|
26
|
+
end
|
27
|
+
|
28
|
+
def insertions
|
29
|
+
LETTERS.product(@splits).map do |(letter, (a, b))|
|
30
|
+
(a + letter + b).strip
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def editions
|
35
|
+
Set.new(deletions + transpositions + substitutions + insertions)
|
36
|
+
end
|
37
|
+
|
38
|
+
def editions2
|
39
|
+
editions.each_with_object(Set.new) do |it, result|
|
40
|
+
result.merge(self.class.new(it).editions)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/pascoale.rb
ADDED
data/pascoale.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'pascoale/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'pascoale'
|
8
|
+
spec.version = Pascoale::VERSION
|
9
|
+
spec.authors = ['Ronie Uliana']
|
10
|
+
spec.email = ['ronie.uliana@vagas.com.br']
|
11
|
+
spec.summary = %q{Text processing utilities for Brazilian Portuguese}
|
12
|
+
spec.homepage = 'http://github.com/ruliana/pascoale'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
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.5', '>=1.5.1']
|
21
|
+
spec.add_development_dependency 'rake'
|
22
|
+
spec.add_development_dependency 'guard-rspec'
|
23
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Pascoale::Edits do
|
4
|
+
let(:edits) { Pascoale::Edits.new('test') }
|
5
|
+
|
6
|
+
it 'deletes letters' do
|
7
|
+
expect(edits.deletions).to include('est', 'tst', 'tet', 'tes')
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'transpose letters' do
|
11
|
+
expect(edits.transpositions).to include('etst', 'tset', 'tets')
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'substitutes letters' do
|
15
|
+
expect(edits.substitutions).to include('aest', 't st', 'teçt', 'tesz')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'inserts letters' do
|
19
|
+
expect(edits.insertions).to include('t est', 'tesst', 'teste', 'átest')
|
20
|
+
end
|
21
|
+
|
22
|
+
it '1st editions' do
|
23
|
+
expect(edits.editions).to include('est', 'tset', 'teçt', 'átest')
|
24
|
+
end
|
25
|
+
|
26
|
+
it '2nd editions' do
|
27
|
+
expect(edits.editions2).to include('teõstç', 'es', 'tste', 'tessst')
|
28
|
+
end
|
29
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'pascoale'
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pascoale
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ronie Uliana
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-21 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.5'
|
20
|
+
- - '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.5.1
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.5'
|
30
|
+
- - '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.5.1
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rake
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: guard-rspec
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
description:
|
62
|
+
email:
|
63
|
+
- ronie.uliana@vagas.com.br
|
64
|
+
executables: []
|
65
|
+
extensions: []
|
66
|
+
extra_rdoc_files: []
|
67
|
+
files:
|
68
|
+
- .gitignore
|
69
|
+
- Gemfile
|
70
|
+
- Guardfile
|
71
|
+
- LICENSE.txt
|
72
|
+
- README.md
|
73
|
+
- Rakefile
|
74
|
+
- lib/pascoale.rb
|
75
|
+
- lib/pascoale/edits.rb
|
76
|
+
- lib/pascoale/version.rb
|
77
|
+
- pascoale.gemspec
|
78
|
+
- spec/lib/pascoale/edits_spec.rb
|
79
|
+
- spec/spec_helper.rb
|
80
|
+
homepage: http://github.com/ruliana/pascoale
|
81
|
+
licenses:
|
82
|
+
- MIT
|
83
|
+
metadata: {}
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
requirements: []
|
99
|
+
rubyforge_project:
|
100
|
+
rubygems_version: 2.1.11
|
101
|
+
signing_key:
|
102
|
+
specification_version: 4
|
103
|
+
summary: Text processing utilities for Brazilian Portuguese
|
104
|
+
test_files:
|
105
|
+
- spec/lib/pascoale/edits_spec.rb
|
106
|
+
- spec/spec_helper.rb
|