aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v3/epub_concordance.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v3/epub_concordance.rb')
-rw-r--r--lib/sisu/v3/epub_concordance.rb93
1 files changed, 50 insertions, 43 deletions
diff --git a/lib/sisu/v3/epub_concordance.rb b/lib/sisu/v3/epub_concordance.rb
index c2a289a2..e2e5bb5c 100644
--- a/lib/sisu/v3/epub_concordance.rb
+++ b/lib/sisu/v3/epub_concordance.rb
@@ -69,7 +69,7 @@ module SiSU_EPUB_Concordance
class Source
def initialize(opt)
@opt=opt
- @particulars=SiSU_Particulars::Combined_singleton.instance.get_all(opt)
+ @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt)
end
def read
begin
@@ -85,21 +85,21 @@ module SiSU_EPUB_Concordance
SiSU_Screen::Ansi.new(@md.opt.cmd,"wc (word count) is off, concordance will be processed for all files including those over the max set size of: #{wordmax} words").warn unless @md.opt.cmd =~/q/
SiSU_EPUB_Concordance::Source::Words.new(@particulars).songsheet
end
- rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error
+ rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error
ensure
end
end
private
- class Doc_title
+ class DocTitle
include SiSU_Viz
#revisit, both requires (html & shared_xml) needed for stand alone operation (sisu -w [filename])
require_relative 'epub' # epub.rb
def initialize(particulars)
@particulars,@md=particulars,particulars.md
- @data=SiSU_EPUB::Source::XHtml_environment.new(particulars).tuned_file_instructions
- @vz=SiSU_Env::Get_init.instance.skin
+ @data=SiSU_EPUB::Source::XHTML_Environment.new(particulars).tuned_file_instructions
+ @vz=SiSU_Env::GetInit.instance.skin
txt_path=%{#{@md.dir_out}}
- SiSU_Env::Info_skin.new(@md).select
+ SiSU_Env::InfoSkin.new(@md).select
@fnb=@md.fnb
@lex_button=%{<a href="http://www.jus.uio.no/sisu/" target="_top"><img border="0" height="44" width="144" valign="center" src="../_sisu/image/sisu.png" alt="SiSU home --&gt;"></a>}
@doc_details =<<WOK
@@ -107,8 +107,8 @@ module SiSU_EPUB_Concordance
WOK
end
def create
- @css=SiSU_Env::CSS_stylesheet.new(@particulars.md)
- format_head_toc=SiSU_EPUB_Format::Head_toc.new(@md)
+ @css=SiSU_Env::CSS_Stylesheet.new(@particulars.md)
+ format_head_toc=SiSU_EPUB_Format::HeadToc.new(@md)
dochead=format_head_toc.head
<<WOK
#{dochead}
@@ -151,7 +151,7 @@ WOK
def initialize(particulars)
@particulars=particulars
begin
- @vz=SiSU_Env::Get_init.instance.skin
+ @vz=SiSU_Env::GetInit.instance.skin
@env,@md,@dal_array=particulars.env,particulars.md,particulars.dal_array
@path="#{@env.processing_path.epub}"
@freq=Hash.new(0)
@@ -167,14 +167,18 @@ WOK
@rxp_excluded0=/^(?:#{Mx[:fa_bold_o]}|#{Mx[:fa_italics_o]})?(?:to\d+|\d+|&nbsp;|#{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?|[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]}|#{Mx[:url_o]}https?://\S+?#{Mx[:url_c]}|file://\S+|<\S+?>|\w+|[a-zA-Z]+}mi
- rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error
+ rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error
end
end
def songsheet
begin
+ #fix to use
+ p __LINE__.to_s + ':' + __FILE__
+ p "#{@path}/content/#{@md.fn[:epub_concord]}"
+ p "#{@md.file.output_path.epub.dir}/#{@md.file.base_filename.epub}"
@file_concordance=File.open("#{@path}/content/#{@md.fn[:epub_concord]}",'w')
map_para
- rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error
+ rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error
ensure
@file_concordance.close
end
@@ -202,7 +206,10 @@ WOK
@word_map={}
@dal_array.each do |line|
if defined? line.ocn
- if line.is =~/heading/ and line.ln==4; @seg=line.name
+ if (line.is ==:heading \
+ || line.is ==:heading_insert) \
+ && line.ln==4
+ @seg=line.name
end
if line.ocn.to_s =~/\d+/; toy=line.ocn.to_s
end
@@ -210,46 +217,46 @@ WOK
and toy !~/^0$/
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
- 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]}/,'')
- word.gsub!(/#{Mx[:gl_o]}#[a-z]+#{Mx[:gl_c]}/,'')
- word.gsub!(/#{Mx[:gl_o]}#[0-9]+#{Mx[:gl_c]}/,'')
- word.gsub!(/^\S$/,'')
+ word=word.gsub(/#{Mx[:lnk_o]}|#{Mx[:lnk_c]}|#{Mx[:url_o]}|#{Mx[:url_c]}/,'').
+ gsub(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,'').
+ gsub(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,'').
+ gsub(/#{Mx[:gl_o]}#[a-z]+#{Mx[:gl_c]}/,'').
+ gsub(/#{Mx[:gl_o]}#[0-9]+#{Mx[:gl_c]}/,'').
+ gsub(/^\S$/,'')
word=nil if word.empty?
word=nil if word =~@rxp_excluded0 #watch
word=nil if word =~@rxp_excluded1 #watch
word=nil if word =~/^\S$/
if word
- word.gsub!(/#{Mx[:br_nl]}|#{Mx[:br_line]}/,' ')
- word.gsub!(/#{Mx[:fa_o]}[a-z]{1,7}#{Mx[:fa_o_c]}|#{Mx[:fa_c_o]}[a-z]{1,7}#{Mx[:fa_c]}/,'')
- word.gsub!(/#{Mx[:mk_o]}(?:[0-9a-f]{32}:[0-9a-f]{32}|[0-9a-f]{64}:[0-9a-f]{64})#{Mx[:mk_c]}/,'')
- word.gsub!(/#{Mx[:mk_o]}(?:[0-9a-f]{32}|[0-9a-f]{64})#{Mx[:mk_c]}/,'')
- word.gsub!(/#{Mx[:en_a_o]}(?:\d|[*+])*|#{Mx[:en_b_o]}(?:\d|[*+])*|#{Mx[:en_a_c]}|#{Mx[:en_b_c]}/mi,'')
- word.gsub!(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,''); word.gsub!(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,'')
- word.gsub!(/<\/?\S+?>/,'')
- word.gsub!(/^\@+/,'')
- word.strip!
- word.gsub!(/#{Mx[:tc_p]}.+/,'')
- word.gsub!(/[\.,;:"]$/,'')
- word.gsub!(/["]/,'')
- word.gsub!(/^\s*[\(]/,'')
- word.gsub!(/[\(]\s*$/,'')
- word.gsub!(/^(?:See|e\.?g\.?).+/,'')
- word.gsub!(/^\s*[.,;:]\s*/,'')
- word.strip!
- word.gsub!(/^\(?[a-zA-Z]\)$/,'')
- word.gsub!(/^\d+(st|nd|rd|th)$/,'')
- word.gsub!(/^(\d+\.?)+$/, '')
- word.gsub!(/#{Mx[:mk_o]}|#{Mx[:mk_c]}/,'')
- word.gsub!(/:name#\S+/,'')
- word.gsub!(/^\S$/,'')
+ word=word.gsub(/#{Mx[:br_nl]}|#{Mx[:br_line]}/,' ').
+ gsub(/#{Mx[:fa_o]}[a-z]{1,7}#{Mx[:fa_o_c]}|#{Mx[:fa_c_o]}[a-z]{1,7}#{Mx[:fa_c]}/,'').
+ gsub(/#{Mx[:mk_o]}(?:[0-9a-f]{32}:[0-9a-f]{32}|[0-9a-f]{64}:[0-9a-f]{64})#{Mx[:mk_c]}/,'').
+ gsub(/#{Mx[:mk_o]}(?:[0-9a-f]{32}|[0-9a-f]{64})#{Mx[:mk_c]}/,'').
+ gsub(/#{Mx[:en_a_o]}(?:\d|[*+])*|#{Mx[:en_b_o]}(?:\d|[*+])*|#{Mx[:en_a_c]}|#{Mx[:en_b_c]}/mi,'').
+ gsub(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,'').gsub(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,'').
+ gsub(/<\/?\S+?>/,'').
+ gsub(/^\@+/,'').
+ strip.
+ gsub(/#{Mx[:tc_p]}.+/,'').
+ gsub(/[\.,;:"]$/,'').
+ gsub(/["]/,'').
+ gsub(/^\s*[\(]/,'').
+ gsub(/[\(]\s*$/,'').
+ gsub(/^(?:See|e\.?g\.?).+/,'').
+ gsub(/^\s*[.,;:]\s*/,'').
+ strip.
+ gsub(/^\(?[a-zA-Z]\)$/,'').
+ gsub(/^\d+(st|nd|rd|th)$/,'').
+ gsub(/^(\d+\.?)+$/, '').
+ gsub(/#{Mx[:mk_o]}|#{Mx[:mk_c]}/,'').
+ gsub(/:name#\S+/,'').
+ gsub(/^\S$/,'')
word=nil if word =~/^\S$/
word=nil if word =~/^\s*$/ #watch
if word
unless word =~/[A-Z][A-Z]/ \
or word =~/\w+\s\w+/
- word.capitalize!
+ word=word.capitalize
end
@freq[word] +=1
@word_map[word] ||= []
@@ -272,7 +279,7 @@ WOK
end
scr='<font size="1" color="#777777" face=times new roman><img border="0" height="15" width="15" src="../_sisu/image/b_doc.png" alt="Full Text">&nbsp;scroll:&nbsp;</font><font size="1" color="#222222" face=times new roman>doc#&nbsp;</font> '
seg=''
- @file_concordance << SiSU_EPUB_Concordance::Source::Doc_title.new(@particulars).create
+ @file_concordance << SiSU_EPUB_Concordance::Source::DocTitle.new(@particulars).create
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 << '<p>'
alph.each {|x| @file_concordance << %{<a href="##{x}">#{x}</a>,&nbsp;}}