lexical_units 0.0.6 → 0.0.7
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/lexical_units/version.rb +1 -1
- data/lib/lexical_units/words.rb +2 -1
- data/lib/lexical_units/words_without_digits.rb +16 -0
- data/lib/lexical_units.rb +1 -0
- data/spec/lexical_units/words_spec.rb +11 -0
- data/spec/lexical_units/words_without_digits_spec.rb +16 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0900a1a365540816cacaf4ea41ae0ce6d70a37f
|
4
|
+
data.tar.gz: 77c84fbc21845351e53eb83fd912afc389700e34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ccaaba2910f859a987252cb9dfe38b0812462657077382fcb377e4c05d59259df9b565d56977e3699d0c6427b12da8e9d3bf1390948bd1e10fcb5cd9ca05639
|
7
|
+
data.tar.gz: 2a3bec215bdf473fe76287090aafe31f25d75ca481c0515c5c90011cd81444a9e957b32b3cfdd1a61a86046b89884a53549da05fc264534badbe652034c54ac9
|
data/CHANGELOG.md
CHANGED
data/lib/lexical_units/words.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module LexicalUnits
|
3
|
+
# Split text into words without digits
|
4
|
+
#
|
5
|
+
# self.words("Lorem 0 ipsum") #=> ["Lorem", "ipsum"]
|
6
|
+
# self.words("Lorem ipsum 100") #=> ["Lorem", "ipsum"]
|
7
|
+
def self.words_without_digits(text)
|
8
|
+
LexicalUnits::words(text).delete_if { |word| numeric?(word) }
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
def self.numeric?(value)
|
13
|
+
return true if value =~ /^\d+$/
|
14
|
+
true if Float(value) rescue false
|
15
|
+
end
|
16
|
+
end
|
data/lib/lexical_units.rb
CHANGED
@@ -88,5 +88,16 @@ describe LexicalUnits do
|
|
88
88
|
subject.words(text).should eq(@array)
|
89
89
|
end
|
90
90
|
|
91
|
+
it "splits text with equals sign into words" do
|
92
|
+
text = "Lorem ipsum=dolor sit amet"
|
93
|
+
|
94
|
+
subject.words(text).should eq(@array)
|
95
|
+
end
|
96
|
+
|
97
|
+
it "splits text with typewriter double quotes into words" do
|
98
|
+
text = %Q(Lorem"ipsum dolor"sit amet)
|
99
|
+
|
100
|
+
subject.words(text).should eq(@array)
|
101
|
+
end
|
91
102
|
end
|
92
103
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe LexicalUnits do
|
5
|
+
context ".words_without_digits" do
|
6
|
+
[
|
7
|
+
{text: "Lorem ipsum 12345", array: %w(Lorem ipsum)},
|
8
|
+
{text: "dolor 98765 sit amet.", array: %w(dolor sit amet)}
|
9
|
+
].each do |hash|
|
10
|
+
text, array = hash.values
|
11
|
+
it "splits text into words without digits" do
|
12
|
+
subject.words_without_digits(text).should eq(array)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lexical_units
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aleksander Malaszkiewicz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -63,10 +63,12 @@ files:
|
|
63
63
|
- lib/lexical_units/syllables.rb
|
64
64
|
- lib/lexical_units/version.rb
|
65
65
|
- lib/lexical_units/words.rb
|
66
|
+
- lib/lexical_units/words_without_digits.rb
|
66
67
|
- spec/lexical_units/sentences_spec.rb
|
67
68
|
- spec/lexical_units/string_spec.rb
|
68
69
|
- spec/lexical_units/syllables_spec.rb
|
69
70
|
- spec/lexical_units/words_spec.rb
|
71
|
+
- spec/lexical_units/words_without_digits_spec.rb
|
70
72
|
- spec/spec_helper.rb
|
71
73
|
homepage: ''
|
72
74
|
licenses:
|
@@ -97,4 +99,5 @@ test_files:
|
|
97
99
|
- spec/lexical_units/string_spec.rb
|
98
100
|
- spec/lexical_units/syllables_spec.rb
|
99
101
|
- spec/lexical_units/words_spec.rb
|
102
|
+
- spec/lexical_units/words_without_digits_spec.rb
|
100
103
|
- spec/spec_helper.rb
|