Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
memoriav
Memobase 2020
services
postprocessing
rico-edm-transformer
Commits
5a7f5e5d
Commit
5a7f5e5d
authored
Mar 08, 2021
by
Günter Hipler
Browse files
more evaluation on contributor vs. creator
parent
3231bc02
Pipeline
#22832
passed with stages
in 6 minutes and 32 seconds
Changes
3
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
src/main/scala/ch/memobase/edm/Extractors.scala
View file @
5a7f5e5d
...
@@ -52,6 +52,24 @@ object Extractors {
...
@@ -52,6 +52,24 @@ object Extractors {
res
.
obj
.
value
res
.
obj
.
value
}
}
private
val
objContainsValue
=
(
resource
:
JObj
)
=>
(
property
:
String
)
=>
(
value
:
String
)
=>
{
resource
(
property
).
getClass
match
{
case
_
:
Class
[
ujson.Arr
]
=>
resource
(
property
).
arr
.
exists
(
_
.
str
==
value
)
case
_
:
Class
[
ujson.Str
]
=>
resource
(
property
).
str
==
value
case
_
=>
false
}
}
private
val
getAllBlankNodeContent
=
(
graph
:
JArr
)
=>
(
resource
:
mutable.LinkedHashMap
[
String
,
JValue
])
=>
(
property
:
String
)
=>
graph
.
value
.
collect
{
case
res
if
objContainsValue
(
resource
)(
property
)
(
res
.
obj
(
"@id"
).
str
)
=>
res
.
obj
.
value
}
private
val
getBlankNodesContent
=
(
graph
:
JArr
)
=>
private
val
getBlankNodesContent
=
(
graph
:
JArr
)
=>
(
resource
:
mutable.LinkedHashMap
[
String
,
JValue
])
=>
(
resource
:
mutable.LinkedHashMap
[
String
,
JValue
])
=>
(
property
:
String
)
=>
(
property
:
String
)
=>
...
@@ -133,6 +151,40 @@ object Extractors {
...
@@ -133,6 +151,40 @@ object Extractors {
)
)
.
toList
.
toList
//noinspection ScalaStyle
val
resourceContributor
:
JArr
=>
mutable
.
LinkedHashMap
[
String
,
JValue
]
=>
List
[
(
String
,
String
)
]
=
graph
=>
record
=>
getBlankNodesContent
(
graph
)(
record
)(
"recordResourceOrInstantiationIsSourceOfCreationRelation"
)
.
flatMap
(
obj
=>
getBlankNodeContent
(
graph
)(
obj
)(
"creationRelationHasTarget"
)
.
filter
(
v
=>
v
(
"type"
).
str
==
"contributor"
)
.
flatMap
(
v
=>
stringValue
(
v
)(
"name"
))
match
{
case
Some
(
name
)
=>
Some
(
obj
.
getOrElse
(
"name"
,
obj
(
"type"
)).
str
,
name
)
case
None
=>
None
}
)
.
toList
val
resourceContributorBlanknodes
:
JArr
=>
mutable
.
LinkedHashMap
[
String
,
JValue
]
=>
List
[
mutable.LinkedHashMap
[
String
,
JValue
]
]
=
graph
=>
record
=>
getAllBlankNodeContent
(
graph
)(
record
)(
"recordResourceOrInstantiationIsSourceOfCreationRelation"
).
toList
val
producer
val
producer
:
JArr
=>
mutable
.
LinkedHashMap
[
String
,
JValue
]
=>
Option
[
String
]
=
:
JArr
=>
mutable
.
LinkedHashMap
[
String
,
JValue
]
=>
Option
[
String
]
=
graph
=>
graph
=>
...
...
src/test/resources/raw.contributor.json
0 → 100644
View file @
5a7f5e5d
This diff is collapsed.
Click to expand it.
src/test/scala/ch/memobase/edm/CHOSpec.scala
View file @
5a7f5e5d
...
@@ -31,8 +31,9 @@ class CHOSpec extends AnyFunSuite with Matchers{
...
@@ -31,8 +31,9 @@ class CHOSpec extends AnyFunSuite with Matchers{
private
lazy
val
rawRicoIndent
=
loadFile
(
"src/test/resources/rawIndent.json"
)
private
lazy
val
rawRicoIndent
=
loadFile
(
"src/test/resources/rawIndent.json"
)
private
lazy
val
rawRicoIndentNoContributor
=
loadFile
(
"src/test/resources/rawIndent.no.contributor.json"
)
private
lazy
val
rawRicoIndentNoContributor
=
loadFile
(
"src/test/resources/rawIndent.no.contributor.json"
)
private
lazy
val
ricoWithContributors
=
loadFile
(
"src/test/resources/raw.contributor.json"
)
test
(
"get c
ontribu
tor
s
"
)
{
test
(
"get c
rea
tor"
)
{
val
graph
=
Extractors
.
jsonGraph
(
rawRicoIndent
).
get
.
arr
val
graph
=
Extractors
.
jsonGraph
(
rawRicoIndent
).
get
.
arr
val
record
=
Extractors
.
record
(
graph
).
get
.
obj
val
record
=
Extractors
.
record
(
graph
).
get
.
obj
...
@@ -46,7 +47,7 @@ class CHOSpec extends AnyFunSuite with Matchers{
...
@@ -46,7 +47,7 @@ class CHOSpec extends AnyFunSuite with Matchers{
}
}
test
(
"missing c
ontribu
tors - wrong blank node"
)
{
test
(
"missing c
rea
tors - wrong blank node"
)
{
val
graph
=
Extractors
.
jsonGraph
(
rawRicoIndentNoContributor
).
get
.
arr
val
graph
=
Extractors
.
jsonGraph
(
rawRicoIndentNoContributor
).
get
.
arr
val
record
=
Extractors
.
record
(
graph
).
get
.
obj
val
record
=
Extractors
.
record
(
graph
).
get
.
obj
...
@@ -58,5 +59,18 @@ class CHOSpec extends AnyFunSuite with Matchers{
...
@@ -58,5 +59,18 @@ class CHOSpec extends AnyFunSuite with Matchers{
}
}
test
(
"get contributors"
)
{
val
graph
=
Extractors
.
jsonGraph
(
ricoWithContributors
).
get
.
arr
//val graph = Extractors.jsonGraph(rawRicoIndent).get.arr
val
record
=
Extractors
.
record
(
graph
).
get
.
obj
val
contributors
=
Extractors
.
resourceContributorBlanknodes
(
graph
)(
//.resourceCreator(graph)(
record
.
value
)
println
(
contributors
)
}
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment