Word index links are to html versions of the text the segmented version followed by the scroll (single document) version.
[For segmented text references [T1], [T2] or [T3] appearing without a link, indicates that the word appears in a title (or subtitle) of the text (that is identifiable by the appended object citation number).]
(The word listing/index is Case sensitive: Capitalized words appear before lower case)
word (number of occurences)
linked references to word within document
[if number of occurences exceed number of references - word occurs more than once in at least one reference. Footnote/endnotes are either assigned to the paragraph from which they are referenced or ignored, so it is relevant to check the footnotes referenced from within a paragraph as well.]
(After the page is fully loaded) you can jump directly to a word by appending a hash (#) and the word to the url for this text, (do not forget that words are case sensitive, and may be listed twice (starting with and without an upper case letter)), #your_word # [ http://[web host]/#{@fnb}/concordance.html#your_word ]
WOK end end class Word @@word_previous='' def initialize(word,freq) @word,@freq=word,freq end def html w=if @word.capitalize==@@word_previous %{\n#@word
(#@freq)
\n\t} else n=@word.strip.gsub(/\s+/,'_') #also need to convert extended character set to html %{\n
(#@freq)
\n\t }
end
@@word_previous=@word.capitalize
w
end
end
class Words
require "#{SiSU_lib}/defaults"
include SiSU_Viz
require "#{SiSU_lib}/html_format"
include SiSU_HTML_Format
require "#{SiSU_lib}/sysenv"
include SiSU_Screen
@@dp=nil
def initialize(particulars)
@particulars=particulars
begin
@vz=SiSU_Env::Get_init.instance.skin
@env,@md,@dal_array=particulars.env,particulars.md,particulars.dal_array
@path="#{@env.path.output}/#{@md.fnb}"
@freq=Hash.new(0)
@dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern
@rxp_to=Regexp.new("#{Mx[:id_o]}~(\\d+);(?:[oh]|[0-6]:)\\d+;\\w\\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}|#{Mx[:id_o]}\S+?#{Mx[:id_c]}$")
@rxp_lv1=/^#{Mx[:lv_o]}1:/
@rxp_lv2=/^#{Mx[:lv_o]}2:/
@rxp_lv3=/^#{Mx[:lv_o]}3:/
@rxp_seg=/^#{Mx[:lv_o]}4:(\S+?)#{Mx[:lv_c]}/
@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=/(?:https?|file|ftp):\/\/\S+/
@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[:id_o]}\S+?#{Mx[:id_c]}}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+|#{Mx[:gr_o]}code#{Mx[:gr_o]}.+?#{Mx[:gr_o]}code-end#{Mx[:gr_o]}|<\S+?>|\w+|[a-zA-Z]+}mi
rescue; SiSU_Errors::Info_error.new($!,$@,@md.cmd,@md.fns).error
end
end
def songsheet
begin
mkdir_p(@path) unless FileTest.directory?(@path)
@file_concordance=File.open("#@path/#{@md.fn[:concordance]}",'w')
map_para
rescue; SiSU_Errors::Info_error.new($!,$@,@md.cmd,@md.fns).error
ensure
@file_concordance.close
end
end
protected
def location_scroll(wordlocation,show)
@wordlocation=wordlocation
%{#@wordlocation; }
end
def location_seg(wordlocation,show)
@wordlocation,@show=wordlocation,show
@sfx='.html' #used for hardlinks, previous setting @sfx='', web server takes care of suffix
@word_location_seg=wordlocation.gsub(/(.+?)\#(\d+)/,"#{@md.fnl[:pre]}\\1#{@md.fnl[:mid]}#@sfx#{@md.fnl[:post]}#\\2") unless wordlocation.nil?
case @wordlocation
when @rxp_t1
%{[H]#@show, }
when @rxp_t2
%{[H]#@show, }
when @rxp_t3
%{[H]#@show, }
else %{#@show, }
end
end
def map_para
@seg,toy=nil,nil
@word_map={}
@dal_array.each do |line|
if line !~/#{Mx[:id_o]}~(\d+);[um]\d+;\w\d+#{Mx[:id_c]}#{Mx[:id_o]}#@dp:#@dp#{Mx[:id_c]}$/ #lines to ignore: # are added but not part of authors substantive text; 0 are mostly machine generated
if line =~@rxp_seg; @seg=line[@rxp_seg,1]
end
if line =~@rxp_to; toy=line[@rxp_to,1]
end
if toy =~/\d+/ \
and toy !~/^0$/
line=line.split(@rgx_splitlist).join(' ') #%take in word or other match
for word in line.scan(@rgx_scanlist) #%take in word or other match
#word.gsub!(@rxp_clean,'')
word.gsub!(/#{Mx[:lnk_o]}|#{Mx[:lnk_c]}(?:http)?/,'')
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=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[:lv_o]}\d:\S*?#{Mx[:lv_c]}/,'')
word.gsub!(/#{Mx[:pa_o]}:i\d#{Mx[:pa_c]}/,'')
word.gsub!(/#{Mx[:id_o]}~\d+;\S+?#{Mx[:id_c]}/,'')
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!(/#{Mx[:fa_o]}\S+?#{Mx[:fa_c]}/,'') #watch
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=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!
end
#word.downcase! if word =~lesser
#word.capitalize! if word =~greater
@freq[word] +=1
@word_map[word] ||= []
if line !~@rxp_lv1 \
and line !~@rxp_lv2 \
and line !~@rxp_lv3
@word_map[word] << location_seg("#@seg\##{toy}",toy)
else
@word_map[word] << case line
when @rxp_lv1; location_seg('T1',toy)
when @rxp_lv2; location_seg('T2',toy)
when @rxp_lv3; location_seg('T3',toy)
end
end
end
end
end
end
end
end
scr=' scroll: doc# '
seg=''
@file_concordance << SiSU_Concordance::Source::Doc_title.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 << '
' alph.each {|x| @file_concordance << %{#{x}, }} @file_concordance << '
' letter=alph.shift @file_concordance << %{\n} for word in @freq.keys.sort! {|a,b| a.downcase<=>b.downcase} f=/^(\S)/.match(word)[1] if letter < f.upcase while letter < f.upcase if alph.length > 0 letter=alph.shift @file_concordance << %{\n} else break end end end keyword=SiSU_Concordance::Source::Word.new(word,@freq[word]).html if keyword !~ @rxp_excluded0 if @word_map[word][0] =~ /\d+/ wm=[] @file_concordance << %{#{keyword}#{seg}#{@word_map[word].uniq.compact.join}} end @file_concordance << '' end # special cases endnotes and header levels 1 - 3 end credits=@vz.credits_sisu @file_concordance << %{