Module: Piola::Splitting
- Defined in:
- lib/piola/splitting.rb
Instance Method Summary collapse
-
#string_to_important_parragraph_arr ⇒ Object
Converts a string into a parragaph array with only important sentences.
-
#string_to_parragraph_arr ⇒ Object
Converts a string into a parragraph array.
-
#to_arr(options = {}) ⇒ Object
Converts a string into a word array without extra spaces, etc.
Instance Method Details
#string_to_important_parragraph_arr ⇒ Object
Converts a string into a parragaph array with only important sentences
37 38 39 40 41 42 43 |
# File 'lib/piola/splitting.rb', line 37 def string_to_important_parragraph_arr arr = self.string_to_parragraph_arr arr.map do |part| part if part.count_words >= 5 && !part.html_leftover? end.compact.uniq end |
#string_to_parragraph_arr ⇒ Object
Converts a string into a parragraph array
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/piola/splitting.rb', line 21 def string_to_parragraph_arr str = self str = str.strip str = str.gsub(',', ' ') str = str.gsub('.', ' ') str = str.gsub(/ +/, ' ') str = str.strip str = str.gsub("\r", "\n") arr = str.split("\n") arr.map do |part| part.strip if part.strip.present? end.compact end |
#to_arr(options = {}) ⇒ Object
Converts a string into a word array without extra spaces, etc
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/piola/splitting.rb', line 8 def to_arr( = {}) str = self str = str.strip str = str.gsub(',', ' ') str = str.gsub('.', ' ') str = str.gsub(/ +/, ' ') arr = str.split(' ') arr = arr.compact arr = arr.uniq unless [:non_unique] arr end |