summaryrefslogtreecommitdiff
path: root/derivation_to_json/rules.rb
blob: b0d267b8410e418a016b3396b44175adbb154aff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env ruby

require 'zipf'

src = ['Synergistische', 'pharmazeutische Zusammensetzung enthaltend', 'ein Peptid', 'mit 2 bis 5', 'Aminosaeuren']
target = ["A", "synergistic", "pharmaceutical composition containing", "a peptide", "with 2 to 5", "amino acis"]
align = [[1], [2], [0,3], [4], [5]]


def single_nt a
  r = []
  r << a
  max_sz = a.size-2
  if max_sz<0
    return r
  end
  a.each_index { |i|
    b = Array.new a
    b[i] = "[X]"
    r << b
    c = Array.new b
    (1).upto(a.size-(i+1)) { |k|
      c = Array.new c
      c.delete_at(i+1)
      break if c.size<2
      r << c
    }
  }

  return r
end

src.each_with_index { |i,j|
  src[j..src.size-1].each_with_index { |k,l|
    sub = src[j..(j+l)]
    r = single_nt sub
    r.each { |i|
      puts i.to_s
    }
  }
}