Commit 324d98b6 authored by Günter Hipler's avatar Günter Hipler
Browse files

intermediate result while working on CHO obejct

parent ba0c2111
Pipeline #22902 passed with stages
in 6 minutes and 30 seconds
......@@ -10,3 +10,32 @@ Erstellen wir dc:date mit diesen properties?
#### dc:description
nochmal anschauen, ob die bestehende Implementierung ok ist (war eine der ersten)
#### dc:language
s. Kommentar in CHOSpec.scala test case "has language"
//todo: in der bestehenden Implementierung wird _:b43 (resultsFrom)
// ausgefiltert - s. hier auch Kommentar von Silvia
// nehmen wir property @language oder Mapping nach Wikidata???
#### dc:relation
jetzt nicht benutzt (Wochenschau, wann?)
#### dc:rights
rico:conditionsOfAccess habe ich kein einziges Beispiel im kompletten Datenebstand gefunden
müssen wir das in der Implementierung berücksichtigen?
IIIF arbeitet mit digital object. EDM (ausschliesslich?) mit record?
vergleiche
Extractors.regulatedMultipleByHolder
Extractors.regulatedByHolder
#### dc:source
ist die Kardinalität tatsächlich 0-n?
Ich finde bei uns nur literal
-> muss noch eine geeignete Implementierung her, die beide Fälle berücksichtigt
......@@ -74,7 +74,20 @@ class EDM {
private def createChoObject(graph: JArr, record: JObj, digitalObject: JObj): ExtractionResult[ProvidedCHO] = {
val cho = new ProvidedCHO(Extractors.recordId(record).get)
cho.addTitel(Extractors.title(record))
//at first we are looking for main title in blank nodes
//if this is not successful we try to use the title property in record
val titlesFromBlankNodes = Extractors.resourceTitles(graph)(record.value)
if (titlesFromBlankNodes.nonEmpty) {
titlesFromBlankNodes
.foreach(c => cho.addTitel(Some(c)))
} else {
Extractors.title(record).foreach(c => cho.addTitel(Some(c)))
}
cho.addDescription(Extractors.dctAbstract(record))
cho.addDescription(Extractors.scopeAndContent(record))
cho.addDescription(Extractors.descriptiveNote(record))
......@@ -97,7 +110,30 @@ class EDM {
.identifiedBy(graph)(record.value)
.foreach(c => cho.addIdentifier(Some(c)))
Extractors
.resourceAllLanguages(graph)(record.value)
.foreach(c => cho.addLanguage(Some(c)))
Extractors
.publishedByGH(graph)(record.value)
.foreach(c => cho.addPublisher(Some(c)))
Extractors
.regulatedMultipleByHolder(graph)(record.value)
.foreach(c => cho.addRights(Some(c)))
Extractors
.recordSource(record.value)
.foreach(c => cho.addSource(Some(c)))
Extractors
.resourceSubjects(graph)(record.value)
.foreach(c => cho.addSubject(Some(c)))
Extractors
.resourceGenres(graph)(record.value)
.foreach(c => cho.addSubject(Some(c)))
ExtractionResult(cho)
......
......@@ -55,11 +55,13 @@ object Extractors {
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
resource.value.get(property).map(v => {
v.strOpt.isDefined && v.str == value || v.arrOpt.isDefined && v.arr.exists(_.str == value)
}) match {
case Some(true) => true
case _ => false
}
}
private val getAllBlankNodeContent = (graph: JArr) =>
......@@ -100,7 +102,6 @@ object Extractors {
jsonObj.value.get(valueKey).flatMap(v => Some(v.arr.toList.map(_.str)))
val ricoType: JObj => Option[String] = record => stringValue(record)("type")
val title: JObj => Option[String] = record => stringValue(record)("title")
val descriptiveNote: JObj => Option[String] = record =>
stringValue(record)("descriptiveNote")
val scopeAndContent: JObj => Option[String] = record =>
......@@ -112,6 +113,16 @@ object Extractors {
getBlankNodeContent(graph)(record)("publishedBy").flatMap(v =>
stringValue(v)("name")
)
val publishedByGH
: JArr => mutable.LinkedHashMap[String, JValue] => List[String] =
graph =>
record =>
getAllBlankNodeContent(graph)(record)("publishedBy").flatMap(v =>
stringValue(v)("name")
).toList
val placeOfCapture
: JArr => mutable.LinkedHashMap[String, JValue] => Option[String] =
graph =>
......@@ -133,6 +144,20 @@ object Extractors {
stringValue(v)("name")
)
//GH
val resourceAllLanguages
: JArr => mutable.LinkedHashMap[String, JValue] => List[String] =
graph =>
record =>
getAllBlankNodeContent(graph)(record)(
"hasLanguage"
)
.filter(obj =>
((obj("type").str == "content") || (obj("type").str == "caption")))
.flatMap(
v => stringValue(v)("name")).toList
//noinspection ScalaStyle
val resourceCreator: JArr => mutable.LinkedHashMap[String, JValue] => List[
(String, String)
......@@ -186,7 +211,7 @@ object Extractors {
obj("type").str == "main" || obj("type").str == "original")
.flatMap(v =>
stringValue(v)("identifier") match {
case Some(identifier) =>
case Some(_) =>
Some(v.getOrElse("identifier", v("type")).str)
case None => None
}
......@@ -194,6 +219,60 @@ object Extractors {
)
val resourceSubjects
: JArr => mutable.LinkedHashMap[String, JValue] => List[String] =
graph =>
record =>
getAllBlankNodeContent(graph)(record)("hasSubject")
.filter(obj =>
obj("@type").str == """http://www.w3.org/2004/02/skos/core#Concept""")
.flatMap(v =>
stringValue(v)("prefLabel") match {
case Some(s) => Some(s)
case None => None
}
).toList :::
getAllBlankNodeContent(graph)(record)("hasSubject")
.filter(obj =>
obj("@type").str == """https://www.ica.org/standards/RiC/ontology#Agent""")
.flatMap(v =>
stringValue(v)("name") match {
case Some(s) => Some(s)
case None => None
}
).toList
val resourceGenres
: JArr => mutable.LinkedHashMap[String, JValue] => List[String] =
graph =>
record =>
getAllBlankNodeContent(graph)(record)("hasGenre")
.filter(obj =>
obj("@type").str == "http://www.w3.org/2004/02/skos/core#Concept")
.flatMap(v =>
stringValue(v)("prefLabel") match {
case Some(s) => Some(s)
case None => None
}
).toList
val resourceTitles
: JArr => mutable.LinkedHashMap[String, JValue] => List[String] =
graph =>
record =>
getAllBlankNodeContent(graph)(record)("hasTitle")
.filter(obj =>
obj("type").str == "main")
.flatMap(v =>
stringValue(v)("title") match {
case Some(s) => Some(s)
case None => None
}
).toList
val title: JObj => Option[String] = record => stringValue(record)("title")
val producer
: JArr => mutable.LinkedHashMap[String, JValue] => Option[String] =
graph =>
......@@ -220,6 +299,19 @@ object Extractors {
case res if res.obj("type").str == "holder" =>
res.obj("name").str
}
//IIIF arbeitet mit digital object
val regulatedMultipleByHolder
: JArr => mutable.LinkedHashMap[String, JValue] => List[String] =
graph =>
record =>
getAllBlankNodeContent(graph)(record)("regulatedBy")
.collect {
case res if res.obj("type").str == "holder" =>
res.obj("name").str
}.toList
val license: JArr => mutable.LinkedHashMap[String, JValue] => Option[String] =
graph =>
digitalObject =>
......@@ -241,6 +333,8 @@ object Extractors {
val recordId: JObj => Option[String] = record => stringValue(record)("@id").flatMap(Some(_))
val recordSource: JObj => Option[String] = record => stringValue(record)("source")
val manifestId: JObj => Option[String] = digitalObject =>
digitalObjectId(digitalObject).flatMap(v => Some(s"$v/manifest"))
......
......@@ -46,16 +46,33 @@ class ProvidedCHO (val id: String) {
def addCreationDate(createDate:Option[String]): Unit =
createDate.map(t => model.add(iri(id),DC.DATE,factory.createLiteral(t)))
def addCreator(contributor:Option[String]): Unit =
contributor.map(t => model.add(iri(id),DC.CREATOR,factory.createLiteral(t)))
def addCreator(creator:Option[String]): Unit =
creator.map(t => model.add(iri(id),DC.CREATOR,factory.createLiteral(t)))
def addContributor(contributor:Option[String]): Unit =
contributor.map(t => model.add(iri(id),DC.CONTRIBUTOR,factory.createLiteral(t)))
def addIdentifier(contributor:Option[String]): Unit =
contributor.map(t => model.add(iri(id),DC.IDENTIFIER,factory.createLiteral(t)))
def addIdentifier(identifier:Option[String]): Unit =
identifier.map(t => model.add(iri(id),DC.IDENTIFIER,factory.createLiteral(t)))
def addLanguage(language:Option[String]): Unit =
language.map(t => model.add(iri(id),DC.LANGUAGE,factory.createLiteral(t)))
def addPublisher(publisher:Option[String]): Unit =
publisher.map(t => model.add(iri(id),DC.PUBLISHER,factory.createLiteral(t)))
def addRights(rights:Option[String]): Unit =
rights.map(t => model.add(iri(id),DC.RIGHTS,factory.createLiteral(t)))
def addSource(source:Option[String]): Unit =
source.map(t => model.add(iri(id),DC.SOURCE,factory.createLiteral(t)))
def addSubject(subject:Option[String]): Unit =
subject.map(t => model.add(iri(id),DC.SUBJECT,factory.createLiteral(t)))
def addGenre(genre:Option[String]): Unit =
genre.map(t => model.add(iri(id),DC.TYPE,factory.createLiteral(t)))
def getModel: Model = model
......
{
"@graph": [
{
"@id": "_:b0",
"@type": "https://www.ica.org/standards/RiC/ontology#Place",
"name": "Rosengarten"
},
{
"@id": "_:b1",
"@type": "https://www.ica.org/standards/RiC/ontology#Rule",
"sameAs": "http://rightsstatements.org/vocab/CNE/1.0/",
"name": "Copyright Not Evaluated (CNE)",
"regulates": "https://memobase.ch/physical/bbb-002-387250-1",
"type": "usage"
},
{
"@id": "_:b10",
"@type": "https://www.ica.org/standards/RiC/ontology#Rule",
"name": "onsite",
"regulates": "https://memobase.ch/physical/bbb-002-387250-1",
"type": "access"
},
{
"@id": "_:b11",
"@type": "https://www.ica.org/standards/RiC/ontology#Identifier",
"identifier": "387250",
"type": "original"
},
{
"@id": "_:b12",
"@type": "https://www.ica.org/standards/RiC/ontology#CarrierType",
"name": "Kunststoff"
},
{
"@id": "_:b13",
"@type": "https://www.ica.org/standards/RiC/ontology#Identifier",
"identifier": "N Eugen Thierstein 489/12",
"type": "callNumber"
},
{
"@id": "_:b14",
"@type": "https://www.ica.org/standards/RiC/ontology#Identifier",
"identifier": "bbb-002-387250-1",
"type": "main"
},
{
"@id": "_:b15",
"@type": "https://www.ica.org/standards/RiC/ontology#Identifier",
"identifier": "Burgerbib-387250",
"type": "oldMemobase"
},
{
"@id": "_:b16",
"@type": "https://www.ica.org/standards/RiC/ontology#Place",
"name": "Obstberg"
},
{
"@id": "_:b17",
"@type": "https://www.ica.org/standards/RiC/ontology#Rule",
"name": "Erben von Eugen Thierstein",
"regulates": "https://memobase.ch/record/bbb-002-387250",
"type": "holder"
},
{
"@id": "_:b18",
"@type": "https://www.ica.org/standards/RiC/ontology#Place",
"name": "Bern (BE)"
},
{
"@id": "_:b19",
"@type": "https://www.ica.org/standards/RiC/ontology#Title",
"title": "Bern: Rosengarten",
"type": "main"
},
{
"@id": "_:b2",
"@type": "https://www.ica.org/standards/RiC/ontology#Person",
"firstName": "Eugen",
"lastName": "Thierstein",
"agentIsTargetOfCreationRelation": "_:b3",
"name": "Thierstein, Eugen"
},
{
"@id": "_:b20",
"@type": "https://www.ica.org/standards/RiC/ontology#Identifier",
"identifier": "bbb-002-387250",
"type": "main"
},
{
"@id": "_:b3",
"@type": "https://www.ica.org/standards/RiC/ontology#CreationRelation",
"creationRelationHasSource": "https://memobase.ch/record/bbb-002-387250",
"creationRelationHasTarget": "_:b2",
"name": "Author",
"type": "creator"
},
{
"@id": "_:b4",
"@type": "https://www.ica.org/standards/RiC/ontology#Rule",
"name": "public",
"regulates": "https://memobase.ch/digital/bbb-002-387250-1",
"type": "access"
},
{
"@id": "_:b5",
"@type": "https://www.ica.org/standards/RiC/ontology#Identifier",
"identifier": "bbb-002-387250-1",
"type": "main"
},
{
"@id": "_:b6",
"@type": "https://www.ica.org/standards/RiC/ontology#Rule",
"sameAs": "http://rightsstatements.org/vocab/CNE/1.0/",
"name": "Copyright Not Evaluated (CNE)",
"regulates": "https://memobase.ch/digital/bbb-002-387250-1",
"type": "usage"
},
{
"@id": "_:b7",
"@type": "http://www.w3.org/2004/02/skos/core#Concept",
"prefLabel": "Restaurant"
},
{
"@id": "_:b8",
"@type": "http://www.w3.org/2004/02/skos/core#Concept",
"prefLabel": "Fotos"
},
{
"@id": "_:b9",
"@type": "https://www.ica.org/standards/RiC/ontology#SingleDate",
"normalizedDateValue": "1942-08-07"
},
{
"@id": "https://memobase.ch/digital/bbb-002-387250-1",
"@type": "https://www.ica.org/standards/RiC/ontology#Instantiation",
"P60558": "Grayscale",
"hasFormat": "fmt/43",
"hasMimeType": "image/jpeg",
"height": "1200.0",
"isDistributedOn": "image",
"locator": "sftp:/swissbib_index/mb_sftp/bbb-002/media/387250.jpg",
"orientation": "Undefined",
"width": "1035.0",
"componentColor": [
"527F76",
"A8A8A8",
"A9A9A9",
"545454",
"000000",
"C0D9D9",
"2F2F4F"
],
"eventType": "CREATE",
"identifiedBy": "_:b5",
"instantiates": "https://memobase.ch/record/bbb-002-387250",
"isDerivedFromInstantiation": "https://memobase.ch/physical/bbb-002-387250-1",
"regulatedBy": [
"_:b4",
"_:b6"
],
"type": "digitalObject"
},
{
"@id": "https://memobase.ch/physical/bbb-002-387250-1",
"@type": "https://www.ica.org/standards/RiC/ontology#Instantiation",
"hasCarrierType": "_:b12",
"hasDerivedInstantiation": "https://memobase.ch/digital/bbb-002-387250-1",
"identifiedBy": [
"_:b13",
"_:b14"
],
"instantiates": "https://memobase.ch/record/bbb-002-387250",
"physicalCharacteristics": "Bemerkung: Fotografie; Bildmasse: 6 x 6 cm",
"regulatedBy": [
"_:b10",
"_:b1"
],
"type": "physicalObject"
},
{
"@id": "https://memobase.ch/record/bbb-002-387250",
"@type": "https://www.ica.org/standards/RiC/ontology#Record",
"created": "_:b9",
"spatial": [
"_:b16",
"_:b0",
"_:b18"
],
"P60451": "https://memobase.ch/institution/mrv",
"sameAs": "http://katalog.burgerbib.ch/detail.aspx?id=387250",
"hasGenre": "_:b8",
"eventType": "CREATE",
"isPublished": false,
"conditionsOfUse": "Burgerbibliothek Bern",
"descriptiveNote": "Künstler: Thierstein, Eugen (1919-2011)",
"hasInstantiation": [
"https://memobase.ch/physical/bbb-002-387250-1",
"https://memobase.ch/digital/bbb-002-387250-1"
],
"hasSubject": "_:b7",
"hasTitle": "_:b19",
"heldBy": "https://memobase.ch/institution/bbb",
"identifiedBy": [
"_:b15",
"_:b11",
"_:b20"
],
"isPartOf": "https://memobase.ch/recordSet/bbb-002",
"recordResourceOrInstantiationIsSourceOfCreationRelation": "_:b3",
"regulatedBy": "_:b17",
"title": "Bern: Rosengarten",
"type": "Foto"
}
],
"@context": {
"name": {"@id": "https://www.ica.org/standards/RiC/ontology#name"},
"type": {"@id": "https://www.ica.org/standards/RiC/ontology#type"},
"sameAs": {"@id": "http://schema.org/sameAs"},
"regulates": {
"@id": "https://www.ica.org/standards/RiC/ontology#regulates",
"@type": "@id"
},
"agentIsTargetOfCreationRelation": {
"@id": "https://www.ica.org/standards/RiC/ontology#agentIsTargetOfCreationRelation",
"@type": "@id"
},
"lastName": {"@id": "http://xmlns.com/foaf/0.1/lastName"},
"firstName": {"@id": "http://xmlns.com/foaf/0.1/firstName"},
"componentColor": {
"@id": "http://www.europeana.eu/schemas/edm/componentColor",
"@type": "http://www.w3.org/2001/XMLSchema#hexBinary"
},
"instantiates": {
"@id": "https://www.ica.org/standards/RiC/ontology#instantiates",
"@type": "@id"
},
"width": {"@id": "http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#width"},
"hasFormat": {"@id": "http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#hasFormat"},
"hasMimeType": {"@id": "http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#hasMimeType"},
"eventType": {"@id": "https://memobase.ch/internal/eventType"},
"isDistributedOn": {"@id": "http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#isDistributedOn"},
"regulatedBy": {
"@id": "https://www.ica.org/standards/RiC/ontology#regulatedBy",
"@type": "@id"
},
"height": {"@id": "http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#height"},
"isDerivedFromInstantiation": {
"@id": "https://www.ica.org/standards/RiC/ontology#isDerivedFromInstantiation",
"@type": "@id"
},
"identifiedBy": {
"@id": "https://www.ica.org/standards/RiC/ontology#identifiedBy",
"@type": "@id"
},
"orientation": {"@id": "http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#orientation"},
"locator": {"@id": "http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#locator"},
"P60558": {"@id": "http://rdaregistry.info/Elements/u/P60558"},
"prefLabel": {"@id": "http://www.w3.org/2004/02/skos/core#prefLabel"},
"normalizedDateValue": {"@id": "https://www.ica.org/standards/RiC/ontology#normalizedDateValue"},
"identifier": {"@id": "https://www.ica.org/standards/RiC/ontology#identifier"},
"hasCarrierType": {
"@id": "https://www.ica.org/standards/RiC/ontology#hasCarrierType",
"@type": "@id"
},
"physicalCharacteristics": {"@id": "https://www.ica.org/standards/RiC/ontology#physicalCharacteristics"},
"hasDerivedInstantiation": {
"@id": "https://www.ica.org/standards/RiC/ontology#hasDerivedInstantiation",
"@type": "@id"
},
"spatial": {
"@id": "http://purl.org/dc/terms/spatial",
"@type": "@id"
},
"P60451": {
"@id": "http://rdaregistry.info/Elements/u/P60451",
"@type": "@id"
},
"hasGenre": {
"@id": "http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#hasGenre",
"@type": "@id"
},
"recordResourceOrInstantiationIsSourceOfCreationRelation": {
"@id": "https://www.ica.org/standards/RiC/ontology#recordResourceOrInstantiationIsSourceOfCreationRelation",
"@type": "@id"
},
"title": {"@id": "https://www.ica.org/standards/RiC/ontology#title"},
"heldBy": {
"@id": "https://www.ica.org/standards/RiC/ontology#heldBy",
"@type": "@id"
},
"descriptiveNote": {"@id": "https://www.ica.org/standards/RiC/ontology#descriptiveNote"},
"isPublished": {
"@id": "https://memobase.ch/internal/isPublished",
"@type": "http://www.w3.org/2001/XMLSchema#boolean"
},
"hasInstantiation": {
"@id": "https://www.ica.org/standards/RiC/ontology#hasInstantiation",
"@type": "@id"