Module: TWFilter::Evidence
- Defined in:
- lib/twfilter/evidence.rb,
sig/twfilter.rbs
Class Method Summary collapse
- .count(text) ⇒ ::Integer
- .hits(text) ⇒ ::Array[::String]
- .markers(text) ⇒ ::Array[::String]
- .per_100(text) ⇒ ::Float
- .reset! ⇒ Object
- .terms ⇒ ::Array[::String]
Class Method Details
.count(text) ⇒ ::Integer
6 |
# File 'lib/twfilter/evidence.rb', line 6 def count(text) = terms.sum { |term| text.scan(term).length } |
.hits(text) ⇒ ::Array[::String]
13 |
# File 'lib/twfilter/evidence.rb', line 13 def hits(text) = terms.select { |term| text.include?(term) } |
.markers(text) ⇒ ::Array[::String]
15 |
# File 'lib/twfilter/evidence.rb', line 15 def markers(text) = Tables.rows("taiwan_markers.txt").select { |term| text.include?(term) } |
.per_100(text) ⇒ ::Float
8 9 10 11 |
# File 'lib/twfilter/evidence.rb', line 8 def per_100(text) han = Han.count(text) han.zero? ? 0.0 : count(text) * 100.0 / han end |
.reset! ⇒ Object
17 |
# File 'lib/twfilter/evidence.rb', line 17 def reset! = @terms = nil |