numerouno 0.0.1 → 0.1.0
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.
- data/History.txt +6 -0
- data/README.rdoc +1 -2
- data/lib/numerouno/parser.rb +12 -3
- data/lib/numerouno-parsing.rb +1 -1
- metadata +2 -2
data/History.txt
CHANGED
data/README.rdoc
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
= Numerouno
|
2
2
|
|
3
3
|
* http://github.com/brentsnook/numerouno
|
4
|
+
* http://groups.google.com/group/numerouno-number-parsing
|
4
5
|
|
5
6
|
English natural language parser for numbers.
|
6
7
|
|
@@ -12,8 +13,6 @@ Recognises numbers in the trillions.
|
|
12
13
|
|
13
14
|
== Installation
|
14
15
|
|
15
|
-
Whoah, hang on there. Not up on Rubyforge yet but hopefully soon. When it is:
|
16
|
-
|
17
16
|
sudo gem install numerouno
|
18
17
|
|
19
18
|
=== Building the Gem yourself
|
data/lib/numerouno/parser.rb
CHANGED
@@ -5,13 +5,22 @@ module Numerouno
|
|
5
5
|
extend SearchMethods
|
6
6
|
|
7
7
|
def self.number_from string
|
8
|
+
parse_literal_within(string) || parse_phrase_within(string)
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def self.parse_literal_within string
|
14
|
+
number = string.to_i
|
15
|
+
number if number != 0 or string.start_with?(0.to_s)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.parse_phrase_within string
|
8
19
|
numbers = numbers_within string
|
9
20
|
numbers.empty? ? raise(NoNumberFoundError, "No number found in string: #{string}") :
|
10
21
|
total(numbers)
|
11
22
|
end
|
12
|
-
|
13
|
-
private
|
14
|
-
|
23
|
+
|
15
24
|
def self.total numbers
|
16
25
|
[10, 100, 1000, 1000000, 1000000000, 1000000000000].each do |power|
|
17
26
|
combine(numbers).of_power(power).apply!
|
data/lib/numerouno-parsing.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: numerouno
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brent Snook
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-06-07 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|