Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support alternate versions #61

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
8 changes: 8 additions & 0 deletions src/main/scala/org/renci/chemotext/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ object PubMedTripleGenerator extends LazyLogging {
pmidIRI,
RDF.`type`,
ResourceFactory.createResource(s"$FaBiONamespace/Article")
),
(
// <pmidIRI> dct:isVersionOf <pmid IRI without version>
ResourceFactory.createStatement(
pmidIRI,
DCTerms.isVersionOf,
ResourceFactory.createResource(pubMedArticleWrapped.pmidIRI)
)
)
) ++ (
// <pmidIRI> fabio:hasPublicationYear "2019"^xsd:gYear
Expand Down
5 changes: 5 additions & 0 deletions src/main/scala/org/renci/chemotext/PubMedArticleWrapper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ object PubMedArticleWrapper {
class PubMedArticleWrapper(val article: Node) {
// The following methods extract particular fields from the wrapped PubMed article.
val pmid: String = (article \ "MedlineCitation" \ "PMID").text
val version: String = (article \ "MedlineCitation" \ "PMID" \ "@Version").text
val title: String = (article \\ "ArticleTitle").map(_.text).mkString(" ")
val abstractText: String = (article \\ "AbstractText").map(_.text).mkString(" ")
val journalNodes: NodeSeq = (article \\ "Article" \ "Journal")
Expand Down Expand Up @@ -145,6 +146,10 @@ class PubMedArticleWrapper(val article: Node) {

// Generate an IRI for this PubMedArticleWrapper.
val iriAsString: String = {
val PMIDNamespace = "https://www.ncbi.nlm.nih.gov/pubmed"
s"$PMIDNamespace/$pmid.$version"
}
val pmidIRI: String = {
val PMIDNamespace = "https://www.ncbi.nlm.nih.gov/pubmed"
s"$PMIDNamespace/$pmid"
}
Expand Down
Loading