Text Processing

Ruby

and

Hal Fulton

13 August 2018

austin.rb

What is text processing?

  • analyze word frequencies, letter frequencies, sentence length

  • translation, grammar checking, spell checking

  • transformation or substitution of text

  • formatting text

  • creating a concordance, index, TOC

  • and so on

Things you should know about...

  • read, readlines, each_line

  • write method

  • Array: join, grep

  • String: split, scan, sub, gsub, capitalization

  • I18N issues

  • Regexp: capturing, classes, etc.

  • appending onto a string

  • other performance issues

  • Enumerable and so on

And it doesn't hurt to know...

  • ARGF
  • File.basename and so on
  • ANSI escape sequences?
  • print, puts, printf, and \r
  • send and eval 

Some simple examples

 

  • grep in Ruby (forrestgrep.rb)
  • wc in Ruby (wcfields.rb)
  • HMTL (Hal's Mangled Text Language)
  • A cautionary tale: appendage.rb

And now... a look at

Livetext

https://github.com/Hal9000/livetext
Made with Slides.com