epitome 0.3.0 → 0.3.1
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/README.md +5 -1
- data/lib/epitome/corpus.rb +8 -2
- data/lib/epitome/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aad2c8fc4a5e37379b2aea76c4ff18becf88de2e
|
4
|
+
data.tar.gz: 07a84242a19c4c9fa268c6fad11ff393be31bee3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0df6dd77b55f5f2a523fad554178ba59794e89c2976692141989955e84bde13c34ac8b6f1f29351e510a342da39ecedb425f9d0c3e3ba5ed71a81c195ce93d33
|
7
|
+
data.tar.gz: 9ab51cfde82db95f0043bd16744f7eaf9b884c0d6414a546db223fd6ecc4f41bf71d4e7145e9cf17462ffd87952af7c66abd59a5fad578a9727f8f092361d411
|
data/README.md
CHANGED
@@ -39,7 +39,11 @@ Finally, output the summary
|
|
39
39
|
@corpus.summary(length=3)
|
40
40
|
```
|
41
41
|
|
42
|
-
|
42
|
+
By default, this output a nice, short string. If you want an array containing each individual sentence,
|
43
|
+
you can pass the argument:
|
44
|
+
```ruby
|
45
|
+
@corpus.summary(:array)
|
46
|
+
```
|
43
47
|
|
44
48
|
## Options
|
45
49
|
### Summary options
|
data/lib/epitome/corpus.rb
CHANGED
@@ -28,7 +28,7 @@ module Epitome
|
|
28
28
|
|
29
29
|
end
|
30
30
|
|
31
|
-
def summary(summary_length, threshold=0.2)
|
31
|
+
def summary(summary_length, threshold=0.2, output=:string)
|
32
32
|
s = @clean_corpus.values.flatten
|
33
33
|
# n is the number of sentences in the total corpus
|
34
34
|
n = @clean_corpus.values.flatten.size
|
@@ -58,7 +58,13 @@ module Epitome
|
|
58
58
|
# Ugly sleight of hand to return a text based on results
|
59
59
|
# <Array>Results => <Hash>Results => <String>ResultsText
|
60
60
|
h = Hash[@sentences.zip(results)]
|
61
|
-
|
61
|
+
if output == :array
|
62
|
+
return h.sort_by {|k, v| v}.reverse.first(summary_length).to_h.keys
|
63
|
+
elsif output == :string
|
64
|
+
return h.sort_by {|k, v| v}.reverse.first(summary_length).to_h.keys.join(" ")
|
65
|
+
else
|
66
|
+
return "No return format specified."
|
67
|
+
end
|
62
68
|
end
|
63
69
|
|
64
70
|
private
|
data/lib/epitome/version.rb
CHANGED