Class: SiSU_Concordance::Source::Words

Inherits:
Object
  • Object
show all
Includes:
SiSU_HTML_Format, SiSU_Screen, SiSU_i18n
Defined in:
lib/sisu/html_concordance.rb

Constant Summary collapse

@@dp =
nil

Instance Method Summary collapse

Constructor Details

#initialize(particulars) ⇒ Words

Returns a new instance of Words.



205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# File 'lib/sisu/html_concordance.rb', line 205

def initialize(particulars)
  @particulars=particulars
  begin
    @env,@md,@ao_array=particulars.env,particulars.md,particulars.ao_array
    @file=SiSU_Env::FileOp.new(@md)
    @freq=Hash.new(0)
    @dp=@@dp ||=SiSU_Env::InfoEnv.new.digest.pattern
    @rxp_lv1=/^#{Mx[:lv_o]}1:/ #fix @rxp_lv #  Mx[:lv_o]
    @rxp_lv2=/^#{Mx[:lv_o]}2:/ #fix @rxp_lv #  Mx[:lv_o]
    @rxp_lv3=/^#{Mx[:lv_o]}3:/ #fix @rxp_lv #  Mx[:lv_o]
    @rxp_title=Regexp.new("^#{Mx[:meta_o]}title#{Mx[:meta_c]}\s*(.+?)\s*$")
    @rxp_t1=Regexp.new('^T1')
    @rxp_t2=Regexp.new('^T2')
    @rxp_t3=Regexp.new('^T3')
    @rxp_excluded1=/#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/
    @rxp_excluded0=/^(?:#{Mx[:fa_bold_o]}|#{Mx[:fa_italics_o]})?(?:to\d+|\d+| |#{Mx[:br_endnotes]}|EOF|#{Mx[:br_eof]}|thumb_\S+|snap_\S+|_+|-+|[(]?(?:ii+|iv|vi+|ix|xi+|xiv|xv|xvi+|xix|xx)[).]?|\S+?_\S+|[\d_]+\w\S+|[\w\d]{1,2}|\d{1,3}\w?|#{@dp}|[0-9a-f]{16,64}|\d{2,3}x\d{2,3}|\S{0,2}sha\d|\S{0,3}\d{4}w\d\d|\b\w\d+|\d_all\b|e\.?g\.?)(?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})?$/mi #this regex causes and cures a stack dump in ruby 1.9 !!!
    @rgx_splitlist=%r{[—.,;:#{Mx[:nbsp]}-]}mi
    @alph=SiSU_i18n::Alphabet.new(@md.opt.lng).hash_arrays
    @alphlst=SiSU_i18n::Alphabet.new(@md.opt.lng).hash_strings
    @rgx_scanlist=%r{#{Mx[:fa_italics_o]}[#{@alphlst[:l]}#{@alphlst[:u]}0-9"\s]{2,12}#{Mx[:fa_italics_c]}|#{Mx[:fa_bold_o]}[#{@alphlst[:l]}#{@alphlst[:u]}0-9"\s]{2,12}#{Mx[:fa_bold_c]}|(?:https?|file)://\S+|<\S+?>|[#{@alphlst[:l]}#{@alphlst[:u]}]+|\w+}mi
  rescue
    SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do
      __LINE__.to_s + ':' + __FILE__
    end
  end
end

Instance Method Details

#songsheetObject



231
232
233
234
235
236
237
238
239
240
241
242
243
244
# File 'lib/sisu/html_concordance.rb', line 231

def songsheet
  begin
    FileUtils::mkdir_p(@file.output_path.html_concordance.dir) \
      unless FileTest.directory?(@file.output_path.html_concordance.dir)
    @file_concordance=File.open(@file.place_file.html_concordance.dir,'w')
    map_para
  rescue
    SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do
      __LINE__.to_s + ':' + __FILE__
    end
  ensure
    @file_concordance.close
  end
end