From 6bd77e1c0f6c1d1818c5673cb5d4e1eb1c3af12d Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 18 Aug 2011 23:16:25 -0400 Subject: v3: concordance, i18n, start adding alternative language alphabets * Danish, Norwegian, Swedish --- lib/sisu/v3/concordance.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'lib/sisu/v3/concordance.rb') diff --git a/lib/sisu/v3/concordance.rb b/lib/sisu/v3/concordance.rb index 2c1c9ddf..f8118cd0 100644 --- a/lib/sisu/v3/concordance.rb +++ b/lib/sisu/v3/concordance.rb @@ -173,6 +173,8 @@ WOK end end class Words + require_relative 'i18n' # i18n.rb + include SiSU_i18n require_relative 'defaults' # defaults.rb include SiSU_Viz require_relative 'html_format' # html_format.rb @@ -198,7 +200,9 @@ WOK @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 - @rgx_scanlist=%r{#{Mx[:fa_italics_o]}[a-zA-Z0-9"\s]{2,12}#{Mx[:fa_italics_c]}|#{Mx[:fa_bold_o]}[a-zA-Z0-9"\s]{2,12}#{Mx[:fa_bold_c]}|(?:https?|file)://\S+|<\S+?>|\w+|[a-zA-Z]+}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::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error end end @@ -244,6 +248,11 @@ WOK line.obj.gsub!(/#{@rxp_excluded1}/,' ') line.obj=line.obj.split(@rgx_splitlist).join(' ') #%take in word or other match for word in line.obj.scan(@rgx_scanlist) #%take in word or other match + if word =~ /^([#{@alphlst[:l]}])/ + firstletter=$1 + flu=firstletter.tr(@alphlst[:l],@alphlst[:u]) + word.gsub!(/^#{firstletter}/,flu ) + end word.gsub!(/#{Mx[:lnk_o]}|#{Mx[:lnk_c]}|#{Mx[:url_o]}|#{Mx[:url_c]}/,'') word.gsub!(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,'') word.gsub!(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,'') @@ -310,8 +319,8 @@ WOK head.gsub!(/#{Xx[:html_relative2]}/m,@file.path_rel_links.html_seg_2) head.gsub!(/#{Xx[:html_relative1]}/m,@file.path_rel_links.html_seg_1) @file_concordance << head - alph=%W[A B C D E F G H I J K L M N O P Q R S T U V W X Y Z] @file_concordance << '

' + alph=@alph[:u] alph.each {|x| @file_concordance << %{#{x}, }} @file_concordance << '

' letter=alph.shift -- cgit v1.2.3