forked from D-Net/dnet-hadoop
[DOIBoost] extended mapping for funder #8407
This commit is contained in:
parent
016337a0f9
commit
d617c3e812
|
@ -309,8 +309,6 @@ case object Crossref2Oaf {
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def generateAuhtor(given: String, family: String, orcid: String, index: Int): Author = {
|
def generateAuhtor(given: String, family: String, orcid: String, index: Int): Author = {
|
||||||
val a = new Author
|
val a = new Author
|
||||||
a.setName(given)
|
a.setName(given)
|
||||||
|
@ -372,28 +370,22 @@ case object Crossref2Oaf {
|
||||||
case dataset: Dataset => convertDataset(dataset)
|
case dataset: Dataset => convertDataset(dataset)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val doisReference: List[String] = for {
|
||||||
val doisReference:List[String] = for {
|
|
||||||
JObject(reference_json) <- json \ "reference"
|
JObject(reference_json) <- json \ "reference"
|
||||||
JField("DOI", JString(doi_json)) <- reference_json
|
JField("DOI", JString(doi_json)) <- reference_json
|
||||||
} yield doi_json
|
} yield doi_json
|
||||||
|
|
||||||
|
if (doisReference != null && doisReference.nonEmpty) {
|
||||||
|
val citation_relations: List[Relation] = generateCitationRelations(doisReference, result)
|
||||||
if (doisReference!= null && doisReference.nonEmpty) {
|
|
||||||
val citation_relations:List[Relation] = generateCitationRelations(doisReference, result)
|
|
||||||
resultList = resultList ::: citation_relations
|
resultList = resultList ::: citation_relations
|
||||||
}
|
}
|
||||||
resultList = resultList ::: List(result)
|
resultList = resultList ::: List(result)
|
||||||
resultList
|
resultList
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private def createCiteRelation(source: Result, targetPid: String, targetPidType: String): List[Relation] = {
|
||||||
|
|
||||||
|
val targetId = IdentifierFactory.idFromPid("50", targetPidType, targetPid, true)
|
||||||
private def createCiteRelation(source:Result, targetPid:String, targetPidType:String) :List[Relation] = {
|
|
||||||
|
|
||||||
|
|
||||||
val targetId = IdentifierFactory.idFromPid("50",targetPidType, targetPid, true)
|
|
||||||
|
|
||||||
val from = new Relation
|
val from = new Relation
|
||||||
from.setSource(source.getId)
|
from.setSource(source.getId)
|
||||||
|
@ -405,7 +397,6 @@ case object Crossref2Oaf {
|
||||||
from.setDataInfo(source.getDataInfo)
|
from.setDataInfo(source.getDataInfo)
|
||||||
from.setLastupdatetimestamp(source.getLastupdatetimestamp)
|
from.setLastupdatetimestamp(source.getLastupdatetimestamp)
|
||||||
|
|
||||||
|
|
||||||
val to = new Relation
|
val to = new Relation
|
||||||
to.setTarget(source.getId)
|
to.setTarget(source.getId)
|
||||||
to.setSource(targetId)
|
to.setSource(targetId)
|
||||||
|
@ -416,10 +407,10 @@ case object Crossref2Oaf {
|
||||||
to.setDataInfo(source.getDataInfo)
|
to.setDataInfo(source.getDataInfo)
|
||||||
to.setLastupdatetimestamp(source.getLastupdatetimestamp)
|
to.setLastupdatetimestamp(source.getLastupdatetimestamp)
|
||||||
|
|
||||||
List(from,to)
|
List(from, to)
|
||||||
}
|
}
|
||||||
|
|
||||||
def generateCitationRelations(dois:List[String], result:Result):List[Relation] = {
|
def generateCitationRelations(dois: List[String], result: Result): List[Relation] = {
|
||||||
dois.flatMap(d => createCiteRelation(result, d, "doi"))
|
dois.flatMap(d => createCiteRelation(result, d, "doi"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -495,6 +486,7 @@ case object Crossref2Oaf {
|
||||||
case "10.13039/501100000781" =>
|
case "10.13039/501100000781" =>
|
||||||
generateSimpleRelationFromAward(funder, "corda_______", extractECAward)
|
generateSimpleRelationFromAward(funder, "corda_______", extractECAward)
|
||||||
generateSimpleRelationFromAward(funder, "corda__h2020", extractECAward)
|
generateSimpleRelationFromAward(funder, "corda__h2020", extractECAward)
|
||||||
|
generateSimpleRelationFromAward(funder, "corda_____he", extractECAward)
|
||||||
case "10.13039/100000001" => generateSimpleRelationFromAward(funder, "nsf_________", a => a)
|
case "10.13039/100000001" => generateSimpleRelationFromAward(funder, "nsf_________", a => a)
|
||||||
case "10.13039/501100001665" => generateSimpleRelationFromAward(funder, "anr_________", a => a)
|
case "10.13039/501100001665" => generateSimpleRelationFromAward(funder, "anr_________", a => a)
|
||||||
case "10.13039/501100002341" => generateSimpleRelationFromAward(funder, "aka_________", a => a)
|
case "10.13039/501100002341" => generateSimpleRelationFromAward(funder, "aka_________", a => a)
|
||||||
|
@ -536,6 +528,34 @@ case object Crossref2Oaf {
|
||||||
val targetId = getProjectId("wt__________", "1e5e62235d094afd01cd56e65112fc63")
|
val targetId = getProjectId("wt__________", "1e5e62235d094afd01cd56e65112fc63")
|
||||||
queue += generateRelation(sourceId, targetId, ModelConstants.IS_PRODUCED_BY)
|
queue += generateRelation(sourceId, targetId, ModelConstants.IS_PRODUCED_BY)
|
||||||
queue += generateRelation(targetId, sourceId, ModelConstants.PRODUCES)
|
queue += generateRelation(targetId, sourceId, ModelConstants.PRODUCES)
|
||||||
|
//ASAP
|
||||||
|
case "10.13039/100018231" => generateSimpleRelationFromAward(funder, "asap________", a => a)
|
||||||
|
//CHIST-ERA
|
||||||
|
case "10.13039/501100001942" =>
|
||||||
|
val targetId = getProjectId("chistera____", "1e5e62235d094afd01cd56e65112fc63")
|
||||||
|
queue += generateRelation(sourceId, targetId, ModelConstants.IS_PRODUCED_BY)
|
||||||
|
queue += generateRelation(targetId, sourceId, ModelConstants.PRODUCES)
|
||||||
|
//HE
|
||||||
|
case "10.13039/100018693" | "10.13039/100018694" | "10.13039/100019188" | "10.13039/100019180" |
|
||||||
|
"10.13039/100018695" | "10.13039/100019185" | "10.13039/100019186" | "10.13039/100019187" =>
|
||||||
|
generateSimpleRelationFromAward(funder, "corda_____he", extractECAward)
|
||||||
|
//FCT
|
||||||
|
case "10.13039/501100001871" =>
|
||||||
|
generateSimpleRelationFromAward(funder, "fct_________", extractECAward)
|
||||||
|
//NHMRC
|
||||||
|
case "10.13039/501100000925" =>
|
||||||
|
generateSimpleRelationFromAward(funder, "mhmrc_______", extractECAward)
|
||||||
|
//NIH
|
||||||
|
case "10.13039/100000002" =>
|
||||||
|
generateSimpleRelationFromAward(funder, "nih_________", extractECAward)
|
||||||
|
//NWO
|
||||||
|
case "10.13039/501100003246" =>
|
||||||
|
generateSimpleRelationFromAward(funder, "nwo_________", extractECAward)
|
||||||
|
//UKRI
|
||||||
|
case "10.13039/100014013" | "10.13039/501100000267" | "10.13039/501100000268" | "10.13039/501100000269" |
|
||||||
|
"10.13039/501100000266" | "10.13039/501100006041" | "10.13039/501100000265" | "10.13039/501100000270" |
|
||||||
|
"10.13039/501100013589" | "10.13039/501100000271" =>
|
||||||
|
generateSimpleRelationFromAward(funder, "nwo_________", extractECAward)
|
||||||
|
|
||||||
case _ => logger.debug("no match for " + funder.DOI.get)
|
case _ => logger.debug("no match for " + funder.DOI.get)
|
||||||
|
|
||||||
|
|
|
@ -114,8 +114,7 @@ class CrossrefMappingTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private def parseJson(input: String): JValue = {
|
||||||
private def parseJson(input:String):JValue = {
|
|
||||||
implicit lazy val formats: DefaultFormats.type = org.json4s.DefaultFormats
|
implicit lazy val formats: DefaultFormats.type = org.json4s.DefaultFormats
|
||||||
lazy val json: json4s.JValue = JsonMethods.parse(input)
|
lazy val json: json4s.JValue = JsonMethods.parse(input)
|
||||||
|
|
||||||
|
@ -123,18 +122,18 @@ class CrossrefMappingTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
def testCitationRelations():Unit = {
|
def testCitationRelations(): Unit = {
|
||||||
val json = Source.fromInputStream(getClass.getResourceAsStream("/eu/dnetlib/doiboost/crossref/publication_license_embargo.json")).mkString
|
val json = Source
|
||||||
|
.fromInputStream(getClass.getResourceAsStream("/eu/dnetlib/doiboost/crossref/publication_license_embargo.json"))
|
||||||
|
.mkString
|
||||||
|
|
||||||
assertNotNull(json)
|
assertNotNull(json)
|
||||||
assertFalse(json.isEmpty)
|
assertFalse(json.isEmpty)
|
||||||
|
|
||||||
val result:List[Oaf] = Crossref2Oaf.convert(json)
|
val result: List[Oaf] = Crossref2Oaf.convert(json)
|
||||||
|
|
||||||
assertTrue(result.nonEmpty)
|
assertTrue(result.nonEmpty)
|
||||||
|
|
||||||
|
|
||||||
val j = parseJson(json)
|
val j = parseJson(json)
|
||||||
|
|
||||||
val doisReference: List[String] = for {
|
val doisReference: List[String] = for {
|
||||||
|
@ -142,14 +141,18 @@ class CrossrefMappingTest {
|
||||||
JField("DOI", JString(doi_json)) <- reference_json
|
JField("DOI", JString(doi_json)) <- reference_json
|
||||||
} yield doi_json
|
} yield doi_json
|
||||||
|
|
||||||
|
val relationList: List[Relation] = result
|
||||||
|
.filter(s => s.isInstanceOf[Relation])
|
||||||
val relationList:List[Relation] = result.filter(s => s.isInstanceOf[Relation]).map(r=> r.asInstanceOf[Relation]).filter(r => r.getSubRelType.equalsIgnoreCase(ModelConstants.CITATION))
|
.map(r => r.asInstanceOf[Relation])
|
||||||
|
.filter(r => r.getSubRelType.equalsIgnoreCase(ModelConstants.CITATION))
|
||||||
|
|
||||||
assertNotNull(relationList)
|
assertNotNull(relationList)
|
||||||
assertFalse(relationList.isEmpty)
|
assertFalse(relationList.isEmpty)
|
||||||
|
|
||||||
assertEquals(doisReference.size*2, relationList.size)
|
assertEquals(doisReference.size * 2, relationList.size)
|
||||||
|
|
||||||
|
mapper.getSerializationConfig.enable(SerializationConfig.Feature.INDENT_OUTPUT)
|
||||||
|
relationList.foreach(p => println(mapper.writeValueAsString(p)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue