text_nlp 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +10 -0
- data/.rspec +1 -0
- data/.rvmrc +1 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +18 -0
- data/LICENSE.txt +20 -0
- data/README +1 -0
- data/Rakefile +10 -0
- data/lib/text_nlp.rb +8 -0
- data/lib/text_nlp/normalizer.rb +16 -0
- data/spec/normalizer_spec.rb +17 -0
- data/spec/spec_helper.rb +5 -0
- data/text_nlp.gemspec +13 -0
- metadata +58 -0
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm ruby-1.9.2@text_nlp --create
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
diff-lcs (1.1.2)
|
5
|
+
rspec (2.6.0)
|
6
|
+
rspec-core (~> 2.6.0)
|
7
|
+
rspec-expectations (~> 2.6.0)
|
8
|
+
rspec-mocks (~> 2.6.0)
|
9
|
+
rspec-core (2.6.4)
|
10
|
+
rspec-expectations (2.6.0)
|
11
|
+
diff-lcs (~> 1.1.2)
|
12
|
+
rspec-mocks (2.6.0)
|
13
|
+
|
14
|
+
PLATFORMS
|
15
|
+
ruby
|
16
|
+
|
17
|
+
DEPENDENCIES
|
18
|
+
rspec
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 fonzo14
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
A minimalist Natural Language Processing library.
|
data/Rakefile
ADDED
data/lib/text_nlp.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
class TextNlp
|
4
|
+
class Normalizer
|
5
|
+
def initialize
|
6
|
+
end
|
7
|
+
def normalize(text)
|
8
|
+
text.downcase!
|
9
|
+
text.tr!("éèàçîêô","eeacieo")
|
10
|
+
text.tr!("!',;?.()/\\_|[]{}\"<>:*$%\-"," ")
|
11
|
+
text.gsub!(/\s+/," ")
|
12
|
+
text.strip!
|
13
|
+
text
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe TextNlp::Normalizer do
|
5
|
+
|
6
|
+
it "should normalize text" do
|
7
|
+
n = TextNlp::Normalizer.new
|
8
|
+
n.normalize("pourquoi le 1 se vire").should eq "pourquoi le 1 se vire"
|
9
|
+
n.normalize("TOTO").should eq "toto"
|
10
|
+
n.normalize("TOto").should eq "toto"
|
11
|
+
n.normalize("!'-,;?.()/\_|[]{}\" toto <>:*%$").should eq "toto"
|
12
|
+
n.normalize("éèàçêî").should eq "eeacei"
|
13
|
+
n.normalize("Comment q'ça se fait î pas ?").should eq "comment q ca se fait i pas"
|
14
|
+
n.normalize("pourquoi le 1 se vire").should eq "pourquoi le 1 se vire"
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/text_nlp.gemspec
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'text_nlp'
|
3
|
+
s.version = '0.0.0'
|
4
|
+
s.date = '2011-07-05'
|
5
|
+
s.summary = "A minimalist NLP library"
|
6
|
+
s.description = s.summary
|
7
|
+
s.authors = ["fonzo14"]
|
8
|
+
s.require_paths = ["lib"]
|
9
|
+
s.files = `git ls-files`.split("\n")
|
10
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
11
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
s.homepage = 'http://github.com/fonzo14/text_nlp'
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: text_nlp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- fonzo14
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-07-05 00:00:00.000000000Z
|
13
|
+
dependencies: []
|
14
|
+
description: A minimalist NLP library
|
15
|
+
email:
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- .gitignore
|
21
|
+
- .rspec
|
22
|
+
- .rvmrc
|
23
|
+
- Gemfile
|
24
|
+
- Gemfile.lock
|
25
|
+
- LICENSE.txt
|
26
|
+
- README
|
27
|
+
- Rakefile
|
28
|
+
- lib/text_nlp.rb
|
29
|
+
- lib/text_nlp/normalizer.rb
|
30
|
+
- spec/normalizer_spec.rb
|
31
|
+
- spec/spec_helper.rb
|
32
|
+
- text_nlp-0.0.0.gem
|
33
|
+
- text_nlp.gemspec
|
34
|
+
homepage: http://github.com/fonzo14/text_nlp
|
35
|
+
licenses: []
|
36
|
+
post_install_message:
|
37
|
+
rdoc_options: []
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
48
|
+
requirements:
|
49
|
+
- - ! '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
requirements: []
|
53
|
+
rubyforge_project:
|
54
|
+
rubygems_version: 1.7.2
|
55
|
+
signing_key:
|
56
|
+
specification_version: 3
|
57
|
+
summary: A minimalist NLP library
|
58
|
+
test_files: []
|