sentence_extractor 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sentence_extractor/extractor.rb +1 -1
- data/lib/sentence_extractor/version.rb +1 -1
- data/sentence_extractor.gemspec +1 -0
- data/spec/extractor_spec.rb +29 -0
- metadata +24 -9
@@ -45,7 +45,7 @@ module SentenceExtractor
|
|
45
45
|
while match != nil
|
46
46
|
sentence_end_point = remaining_text =~ /#{@reg_exp}/ # check for sentences
|
47
47
|
if sentence_end_point
|
48
|
-
sentences << remaining_text[0..sentence_end_point] # add new sentence to array
|
48
|
+
sentences << remaining_text[0..sentence_end_point].strip # add new sentence to array
|
49
49
|
remaining_text = remaining_text[sentence_end_point+1..remaining_text.size] # set the rest of the text to be processed.
|
50
50
|
else
|
51
51
|
match = nil
|
data/sentence_extractor.gemspec
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'lib/sentence_extractor.rb'
|
2
|
+
|
3
|
+
describe SentenceExtractor::Extractor do
|
4
|
+
it "Sould find a sentence with a full stop" do
|
5
|
+
sen_exc = SentenceExtractor::Extractor.new
|
6
|
+
sen_exc.extract_sentences("Hello.").should eql(["Hello."])
|
7
|
+
end
|
8
|
+
|
9
|
+
it "Sould find a sentence with a exclamation mark" do
|
10
|
+
sen_exc = SentenceExtractor::Extractor.new
|
11
|
+
sen_exc.extract_sentences("Hello!").should eql(["Hello!"])
|
12
|
+
end
|
13
|
+
|
14
|
+
it "Sould find a sentence with a question mark" do
|
15
|
+
sen_exc = SentenceExtractor::Extractor.new
|
16
|
+
sen_exc.extract_sentences("Hello?").should eql(["Hello?"])
|
17
|
+
end
|
18
|
+
|
19
|
+
it "Should not find anything" do
|
20
|
+
sen_exc = SentenceExtractor::Extractor.new
|
21
|
+
sen_exc.extract_sentences("Hello").should eql([])
|
22
|
+
end
|
23
|
+
|
24
|
+
it "Should find three sentences with no leading or trailing spaces" do
|
25
|
+
sen_exc = SentenceExtractor::Extractor.new
|
26
|
+
sen_exc.extract_sentences("Hello. How are you? Good thanks! ").should eql(["Hello.", "How are you?", "Good thanks!"])
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sentence_extractor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Seb Glazebrook
|
@@ -15,9 +15,23 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-03-
|
19
|
-
dependencies:
|
20
|
-
|
18
|
+
date: 2012-03-23 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rspec
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 15
|
29
|
+
segments:
|
30
|
+
- 2
|
31
|
+
- 6
|
32
|
+
version: "2.6"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
21
35
|
description: This gem takes takes a bunch of text and returns the sentences found based on language specific rules. E.g. start and end delimiters etc.
|
22
36
|
email:
|
23
37
|
- me@sebglazebrook.com
|
@@ -38,6 +52,7 @@ files:
|
|
38
52
|
- lib/sentence_extractor/extractor.rb
|
39
53
|
- lib/sentence_extractor/version.rb
|
40
54
|
- sentence_extractor.gemspec
|
55
|
+
- spec/extractor_spec.rb
|
41
56
|
homepage: ""
|
42
57
|
licenses: []
|
43
58
|
|
@@ -71,5 +86,5 @@ rubygems_version: 1.8.9
|
|
71
86
|
signing_key:
|
72
87
|
specification_version: 3
|
73
88
|
summary: Give it some text and it will return an array of sentences.
|
74
|
-
test_files:
|
75
|
-
|
89
|
+
test_files:
|
90
|
+
- spec/extractor_spec.rb
|