aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v3/dal_idx.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2012-10-01 16:12:14 -0400
committerRalph Amissah <ralph@amissah.com>2012-10-01 16:12:14 -0400
commit52e870e3e04b3848d024e144ffb2a7f26b078cb3 (patch)
treee33e864b661903a4eb59c399ff160a53d4824028 /lib/sisu/v3/dal_idx.rb
parentv3: some fixes, cleaning, removing (diff)
v3: dal, sysenv, file processing, split objects; remove ref to old ruby
* markup file processing, change to sourcefile readlines & split of sourcefile array * removal of RUBY_VERSION references to older versions of ruby
Diffstat (limited to 'lib/sisu/v3/dal_idx.rb')
-rw-r--r--lib/sisu/v3/dal_idx.rb63
1 files changed, 35 insertions, 28 deletions
diff --git a/lib/sisu/v3/dal_idx.rb b/lib/sisu/v3/dal_idx.rb
index a90217c4..db4ba9c1 100644
--- a/lib/sisu/v3/dal_idx.rb
+++ b/lib/sisu/v3/dal_idx.rb
@@ -117,35 +117,42 @@ module SiSU_DAL_BookIndex
def construct_book_index(idx_array)
the_idx={}
idx_array.each do |idx|
- idx_lst=idx[:rough_idx].scan(/[^|:]+/)
- idx_lst[0]=idx_lst[0].strip
- if idx_lst[0] =~/.+?\+\d+/
- use,plus=/(.+?)\+(\d+)/.match(idx_lst[0])[1,2]
- else use=idx_lst[0]
- end
- use=use[0].chr.capitalize + use[1,use.length]
- the_idx[use]={} unless the_idx[use] and defined? the_idx[use]
- idx_lst.each do |i|
- i=i.strip
- i,r=/(.+?)\+(\d+)/.match(i)[1,2] if i =~/.+?\+\d+/
- x=if idx_lst.length==1 or idx_lst[0].gsub(/\+\d+/,'')==i
- the_idx[use]['term_node_lev1']=[] unless the_idx[use]['term_node_lev1'] and defined? the_idx[use]['term_node_lev1']
- x=if r
- the_idx[use]['term_node_lev1'] << { ocn: idx[:ocn], range: "#{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}", seg: idx[:seg] }
- "#{i} #{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}"
- else
- the_idx[use]['term_node_lev1'] << { ocn: idx[:ocn], seg: idx[:seg] }
- "#{i} #{idx[:ocn]}"
- end
- else
- the_idx[use]['term_node_lev2']={} unless the_idx[use]['term_node_lev2'] and defined? the_idx[use]['term_node_lev2']
- the_idx[use]['term_node_lev2'][i]=[] unless the_idx[use]['term_node_lev2'][i] and defined? the_idx[use]['term_node_lev2'][i]
- x=if r
- the_idx[use]['term_node_lev2'][i] << { ocn: idx[:ocn], range: "#{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}", seg: idx[:seg] }
- "#{idx_lst[0]}:#{i} #{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}"
+ if idx[:rough_idx] =~/[|]/ \
+ && idx[:rough_idx] !~/[:]/
+ if @md.opt.cmd =~/[MVv]/
+ p 'book index error? --> ' + idx[:rough_idx]
+ end
+ else
+ idx_lst=idx[:rough_idx].scan(/[^|:]+/)
+ idx_lst[0]=idx_lst[0].strip
+ if idx_lst[0] =~/.+?\+\d+/
+ use,plus=/(.+?)\+(\d+)/.match(idx_lst[0])[1,2]
+ else use=idx_lst[0]
+ end
+ use=use[0].chr.capitalize + use[1,use.length]
+ the_idx[use]={} unless the_idx[use] and defined? the_idx[use]
+ idx_lst.each do |i|
+ i=i.strip
+ i,r=/(.+?)\+(\d+)/.match(i)[1,2] if i =~/.+?\+\d+/
+ x=if idx_lst.length==1 or idx_lst[0].gsub(/\+\d+/,'')==i
+ the_idx[use]['term_node_lev1']=[] unless the_idx[use]['term_node_lev1'] and defined? the_idx[use]['term_node_lev1']
+ x=if r
+ the_idx[use]['term_node_lev1'] << { ocn: idx[:ocn], range: "#{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}", seg: idx[:seg] }
+ "#{i} #{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}"
+ else
+ the_idx[use]['term_node_lev1'] << { ocn: idx[:ocn], seg: idx[:seg] }
+ "#{i} #{idx[:ocn]}"
+ end
else
- the_idx[use]['term_node_lev2'][i] << { ocn: idx[:ocn], seg: idx[:seg] }
- "#{idx_lst[0]}:#{i} #{idx[:ocn]}"
+ the_idx[use]['term_node_lev2']={} unless the_idx[use]['term_node_lev2'] and defined? the_idx[use]['term_node_lev2']
+ the_idx[use]['term_node_lev2'][i]=[] unless the_idx[use]['term_node_lev2'][i] and defined? the_idx[use]['term_node_lev2'][i]
+ x=if r
+ the_idx[use]['term_node_lev2'][i] << { ocn: idx[:ocn], range: "#{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}", seg: idx[:seg] }
+ "#{idx_lst[0]}:#{i} #{idx[:ocn]}-#{idx[:ocn].to_i+r.to_i}"
+ else
+ the_idx[use]['term_node_lev2'][i] << { ocn: idx[:ocn], seg: idx[:seg] }
+ "#{idx_lst[0]}:#{i} #{idx[:ocn]}"
+ end
end
end
end