Class: SiSU_SpellUtility::Spell
- Inherits:
-
Object
- Object
- SiSU_SpellUtility::Spell
- Defined in:
- lib/sisu/utils_spell.rb
Instance Method Summary collapse
- #check ⇒ Object
-
#initialize(input, filesrc, flg) ⇒ Spell
constructor
A new instance of Spell.
Constructor Details
#initialize(input, filesrc, flg) ⇒ Spell
Returns a new instance of Spell.
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/sisu/utils_spell.rb', line 57 def initialize(input,filesrc,flg) @flg=flg @filename, @filetype = /(.+?)(\.\w\w\w0$)/.match(filesrc)[1,2] #.gsub(/\.\w\w\w0$/, "") @input=input @allwords=[] puts @filename @speller='aspell' # 'ispell' @dictionary='british' @lang='en_GB' end |
Instance Method Details
#check ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/sisu/utils_spell.rb', line 67 def check @input.each do |data| data=data.gsub(/(https?|www|ftp|gopher|png|jpg|gif|html|htm)\S+/i,' '). gsub(/( |#{Mx[:nbsp]})/i,' '). gsub(/<\/?(table|tr|td|b|p|href).*?>/i,' '). gsub(/(<==.+|<:\S+>|<!.+?!>|^@\S+?:.+|\{\{\{|~)/,' '). gsub(/(["|<>)(\n'`.;&_-]|\=)/,' '). gsub(/\b(altExternal| target|externalimg| srcimagebext| img|src|toc|pdf| cd|org| helvetica|roman )\b/i,' '). gsub(/EOF/,'') @words=data.scan(/\S+/) @words.each { |y| @allwords << y } end @allwords=@allwords.uniq if @flg =~ /S/ File.open('/home/ralph/spell_error','a+') do |file| #fix file.puts %{\n\n<<#{@filename}>>} end @allwords.each { |y| puts y.inspect; system(%{cat #{y} | /usr/bin/#{@speller} -l -d #{@dictionary} >> ~/spell_error })} else @allwords.each { |y| sp=%x{echo #{y}|#{@speller} -l }; puts sp unless sp.empty?} end end |