Sha256: a249cf115dd8190652c836779d7a8cb3b3cfe0b4ead6584708fbbe4a9764a15f
Contents?: true
Size: 1.87 KB
Versions: 11
Compression:
Stored size: 1.87 KB
Contents
module WordCountAnalyzer class Analyzer attr_reader :text, :tgr def initialize(text:) @text = text @tgr = EngTagger.new end def analyze analysis = {} analysis['ellipsis'] = WordCountAnalyzer::Ellipsis.new(string: text).occurences contraction_count = 0 hyphenated_word_count = 0 WordCountAnalyzer::Xhtml.new(string: text).replace.split(/\s+/).each_with_index do |token, index| contraction_count += 1 if WordCountAnalyzer::Contraction.new(token: token, following_token: text.split(/\s+/)[index + 1], tgr: tgr, hyphen: 'single').contraction? hyphenated_word_count += 1 if WordCountAnalyzer::HyphenatedWord.new(token: token).hyphenated_word? end analysis['hyperlink'] = WordCountAnalyzer::Hyperlink.new(string: text).occurences analysis['contraction'] = contraction_count analysis['hyphenated_word'] = hyphenated_word_count analysis['date'] = WordCountAnalyzer::Date.new(string: text).occurences analysis['number'] = WordCountAnalyzer::Number.new(string: text).occurences analysis['numbered_list'] = WordCountAnalyzer::NumberedList.new(string: text).occurences analysis['xhtml'] = WordCountAnalyzer::Xhtml.new(string: text).occurences analysis['forward_slash'] = WordCountAnalyzer::Slash.new(string: text).forward_slash_occurences analysis['backslash'] = WordCountAnalyzer::Slash.new(string: text).backslash_occurences analysis['dotted_line'] = WordCountAnalyzer::Punctuation.new(string: text).dotted_line_ocurrances analysis['dashed_line'] = WordCountAnalyzer::Punctuation.new(string: text).dashed_line_ocurrances analysis['underscore'] = WordCountAnalyzer::Punctuation.new(string: text).underscore_ocurrances analysis['stray_punctuation'] = WordCountAnalyzer::Punctuation.new(string: text).stray_punctuation_occurences analysis end end end
Version data entries
11 entries across 11 versions & 1 rubygems