rundown 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -2
- data/lib/rundown/processor.rb +5 -1
- data/lib/rundown/processors/phone.rb +6 -6
- data/lib/rundown/version.rb +1 -1
- data/spec/rundown_spec.rb +2 -3
- metadata +3 -3
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Rundown
|
2
2
|
=======
|
3
3
|
|
4
|
-
[![Gem Version](https://badge.fury.io/rb/rundown.png)](http://badge.fury.io/rb/rundown) [![Build Status](https://travis-ci.org/modsognir/rundown.png)](https://travis-ci.org/modsognir/rundown) [![Code Climate](https://codeclimate.com/github/modsognir/rundown.png)](https://codeclimate.com/github/modsognir/rundown) [![Coverage Status](https://coveralls.io/repos/modsognir/rundown/badge.png)](https://coveralls.io/r/modsognir/rundown)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/rundown.png)](http://badge.fury.io/rb/rundown) [![Build Status](https://travis-ci.org/modsognir/rundown.png)](https://travis-ci.org/modsognir/rundown) [![Code Climate](https://codeclimate.com/github/modsognir/rundown.png)](https://codeclimate.com/github/modsognir/rundown) [![Coverage Status](https://coveralls.io/repos/modsognir/rundown/badge.png)](https://coveralls.io/r/modsognir/rundown) [![Dependency Status](https://gemnasium.com/modsognir/rundown.png)](https://gemnasium.com/modsognir/rundown)
|
5
5
|
|
6
6
|
Rundown is a simple Natural Language Processor built with Ruby, inspired by [Knwl.js](https://github.com/loadfive/Knwl.js). Rundown scans through text, user data, or just about anything for likely data of interest, phone numbers, dates, locations, emails, times, as well as likelyhood of spam and overall emotion.
|
7
7
|
|
@@ -22,7 +22,7 @@ Or install it yourself as:
|
|
22
22
|
## Usage
|
23
23
|
|
24
24
|
rd = Rundown.parse("I'll see you on the 18th, give me a ring on 07912 345 678. - Jerertt, me@example.com")
|
25
|
-
|
25
|
+
|
26
26
|
rd.emails
|
27
27
|
=> ["me@example.com"]
|
28
28
|
|
@@ -50,3 +50,7 @@ Or install it yourself as:
|
|
50
50
|
###Licence
|
51
51
|
|
52
52
|
Project released under an MIT license.
|
53
|
+
|
54
|
+
|
55
|
+
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/modsognir/rundown/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
|
56
|
+
|
data/lib/rundown/processor.rb
CHANGED
@@ -2,7 +2,7 @@ module Rundown
|
|
2
2
|
class Processor
|
3
3
|
attr_accessor :words
|
4
4
|
|
5
|
-
PUNCTUATION = /[\s`!()\[\]{}
|
5
|
+
PUNCTUATION = /[\s`!()\[\]{}\-;:'".,<>?]/
|
6
6
|
|
7
7
|
def initialize(words)
|
8
8
|
@words = words.to_s.split(/\s/)
|
@@ -13,5 +13,9 @@ module Rundown
|
|
13
13
|
def strip_punctuation(word)
|
14
14
|
word.gsub(/^#{PUNCTUATION}/, '').gsub(/#{PUNCTUATION}$/, '')
|
15
15
|
end
|
16
|
+
|
17
|
+
def remove_punctuation(word)
|
18
|
+
word.gsub(/#{PUNCTUATION}/, '')
|
19
|
+
end
|
16
20
|
end
|
17
21
|
end
|
@@ -1,19 +1,19 @@
|
|
1
1
|
module Rundown
|
2
2
|
module Processors
|
3
3
|
class Phone < Rundown::Processor
|
4
|
-
attr_accessor :
|
4
|
+
attr_accessor :formatter, :text
|
5
5
|
|
6
|
-
def initialize(words,
|
6
|
+
def initialize(words, formatter=Phony)
|
7
7
|
@text = words
|
8
|
-
@
|
8
|
+
@formatter = formatter
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
12
|
-
|
11
|
+
def format(number)
|
12
|
+
number.start_with?('0') ? number : formatter.formatted(number)
|
13
13
|
end
|
14
14
|
|
15
15
|
def process
|
16
|
-
text.scan(
|
16
|
+
remove_punctuation(text).scan(/\d{7,13}/).map {|number| format(number) }
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
data/lib/rundown/version.rb
CHANGED
data/spec/rundown_spec.rb
CHANGED
@@ -19,7 +19,7 @@ David (david32@gmail.com)"
|
|
19
19
|
end
|
20
20
|
|
21
21
|
describe 'phones' do
|
22
|
-
it {
|
22
|
+
it { expect(Rundown::Processors::Phone.new(subject).process).to eql ["+1 212 323 1239"]}
|
23
23
|
end
|
24
24
|
|
25
25
|
describe 'sentiment' do
|
@@ -42,8 +42,7 @@ David (david32@gmail.com)"
|
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'extracts phone numbers' do
|
45
|
-
|
46
|
-
expect(subject.phones).to eql(["07912 345 678"])
|
45
|
+
expect(subject.phones).to eql(["07912345678"])
|
47
46
|
end
|
48
47
|
|
49
48
|
it 'extracts sentiment' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rundown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -156,7 +156,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
156
156
|
version: '0'
|
157
157
|
segments:
|
158
158
|
- 0
|
159
|
-
hash:
|
159
|
+
hash: -2020343493529302066
|
160
160
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
161
|
none: false
|
162
162
|
requirements:
|
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
165
|
version: '0'
|
166
166
|
segments:
|
167
167
|
- 0
|
168
|
-
hash:
|
168
|
+
hash: -2020343493529302066
|
169
169
|
requirements: []
|
170
170
|
rubyforge_project:
|
171
171
|
rubygems_version: 1.8.25
|