aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v3/dal_idx.rb
diff options
context:
space:
mode:
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