-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplit_by_disposition_test.rb
More file actions
78 lines (69 loc) · 2.29 KB
/
Copy pathsplit_by_disposition_test.rb
File metadata and controls
78 lines (69 loc) · 2.29 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
HAS_DISPOSITION_IRI = "http://purl.obolibrary.org/obo/RO_0000091"
def split_by_disposition_attr(performer, attr_uri)
dispositions = performer[HAS_DISPOSITION_IRI]
return [performer] if dispositions.nil?
uniques = dispositions.map{|d| d[attr_uri]}.uniq
puts(uniques)
splits = uniques.map do |attr|
p = performer.dup
p[HAS_DISPOSITION_IRI] = dispositions.select do |d|
d[attr_uri] == attr
end
puts("2-------")
puts(p.class)
puts(p)
p
end
return splits
end
def test1
performer = {}
attr_uri = ""
result = split_by_disposition_attr(performer, attr_uri)
puts(result.class)
puts(result)
end
def test2
performer = {HAS_DISPOSITION_IRI => []}
attr_uri = ""
result = split_by_disposition_attr(performer, attr_uri)
puts(result.class)
puts(result)
end
def test3
# expected [{"http://purl.obolibrary.org/obo/RO_0000091"=>[{"uri"=>"a1", "b"=>"b1"}, {"uri"=>"a1", "b"=>"b2"}]}]
performer = {HAS_DISPOSITION_IRI => [{"uri" =>"a1", "b" =>"b1"}, {"uri" =>"a1", "b" =>"b2"}]}
attr_uri = "uri"
result = split_by_disposition_attr(performer, attr_uri)
puts(result.class)
puts(result)
end
def test4
# expected
# {"http://purl.obolibrary.org/obo/RO_0000091"=>[{"uri"=>"a1", "b"=>"b1"}]}
# {"http://purl.obolibrary.org/obo/RO_0000091"=>[{"uri"=>"a2", "b"=>"b2"}]}
performer = {HAS_DISPOSITION_IRI => [{"uri" =>"a1", "b" =>"b1"}, {"uri" =>"a2", "b" =>"b2"}]}
attr_uri = "uri"
result = split_by_disposition_attr(performer, attr_uri)
puts(result.class)
puts(result)
end
def test5
# expected
# {"http://purl.obolibrary.org/obo/RO_0000091"=>[{"uri"=>"a1", "b"=>"b1"}, {"uri"=>"a1", "b"=>"b1"}]}
# {"http://purl.obolibrary.org/obo/RO_0000091"=>[{"uri"=>"a1", "b"=>"b2"}]}
performer = {HAS_DISPOSITION_IRI => [{"uri" =>"a1", "b" =>"b1"}, {"uri" =>"a1", "b" =>"b2"}, {"uri" =>"a5", "b" =>"b1"}]}
attr_uri = "b"
result = split_by_disposition_attr(performer, attr_uri)
puts(result.class)
puts(result)
end
def test6()
# expected
performer = {HAS_DISPOSITION_IRI => [{"uri" =>"a1", "b" =>"b1"}, {"uri" =>"a1", "b" =>"b2"}, {"uri" =>"a5", "b" =>"b1"}]}
attr_uri = "d"
result = split_by_disposition_attr(performer, attr_uri)
puts(result.class)
puts(result)
end
test6()