@@ -11,20 +11,40 @@ source("endpoints.R")
1111
1212shinyServer(function (input , output ) {
1313 interm <- reactive({
14- words <- strsplit(input $ term , " +" )[[1 ]]
15- if (length(words )> 1 )
16- interm <- paste(words ,collapse = " .*" )
17- else
18- interm <- paste(" .*" ,input $ term ," .*" ,sep = " " )
19- })
20-
21- intermMatch <- reactive({
22- words <- strsplit(input $ term , " +" )[[1 ]]
23- if (length(words )> 1 )
24- interm <- paste(" (" ,paste(words ,collapse = " |" )," )" ,sep = " " )
25- else
26- interm <- paste(" (" ,input $ term ," )" ,sep = " " )
14+ words <- translateJ2E(strsplit(input $ term , " +" )[[1 ]])
15+ interm <- paste(" (" ,paste(words ,collapse = " |" )," )" ,sep = " " )
2716 })
17+
18+ translateJ2E <- function (terms ){
19+ trterms <- vector()
20+ for (term in terms ) {
21+ if (grepl(" \\ w+" ,term ))
22+ trterms <- append(trterms , term )
23+ else {
24+ query <- paste("
25+ PREFIX lsd: <http://purl.jp/bio/10/lsd/ontology/201209#>
26+ PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
27+ PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
28+
29+ SELECT DISTINCT ?synonymLabelJa ?synonymLabelEn WHERE {
30+ ?code1 rdfs:label \" " ,term , " \" @ja ;
31+ skos:closeMatch ?synonymJa .
32+ ?synonymJa rdfs:label ?synonymLabelJa ;
33+ lsd:hasEntry [lsd:hasEnglishTranslationOf ?synonymEn].
34+ ?synonymEn rdfs:label ?synonymLabelEn .
35+ FILTER(lang(?synonymLabelJa) = \" ja\" )
36+ FILTER(lang(?synonymLabelEn) = \" en\" )
37+ } ORDER BY ?synonymLabelJa ?synonymLabelEn" , sep = " " )
38+ ns <- c(
39+ ' lsd' ,' <http://purl.jp/bio/10/lsd/ontology/201209#>' )
40+ dtr <- SPARQL(url = endpoint_lsd ,
41+ query = query , ns = ns )
42+ if (nrow(dtr $ results )> 0 )
43+ trterms <- append(trterms , gsub(" (\" |@en)" ," " ,dtr $ results $ synonymLabelEn ))
44+ }
45+ }
46+ return (trterms )
47+ }
2848
2949 dto_terminology <- list (createdRow = I(" function(nRow, aData,index) {
3050 $('td:eq(0)',nRow).html(aData[0].replace(/</g,'<').replace(/>/g,'>'));
89109 code2 <- idsplit [3 ]
90110 linkcode <- paste(code1 , " ." , subv , sep = " " )
91111 dispcode <- paste(category , " :" , subv , " ." , code2 , sep = " " )
92- dispcode <- gsub(intermMatch ()," <span style='background-color: #FFFF00'>\\ 1</span>" , dispcode ,ignore.case = TRUE )
112+ dispcode <- gsub(interm ()," <span style='background-color: #FFFF00'>\\ 1</span>" , dispcode ,ignore.case = TRUE )
93113 link <- " "
94114 if (category == " sdtm" )
95115 link <- " http://evs.nci.nih.gov/ftp1/CDISC/SDTM/SDTM%20Terminology.html#CL."
@@ -106,10 +126,10 @@ WHERE
106126 }
107127 d1 $ results $ domainsubv <- NULL
108128 d1 $ results $ nciCode <- NULL
109- if (intermMatch () != " ()" ) {
110- d1 $ results $ SubmissionValue <- gsub(intermMatch ()," <span style='background-color: #FFFF00'>\\ 1</span>" , d1 $ results $ SubmissionValue ,ignore.case = TRUE )
111- d1 $ results $ Definition <- gsub(intermMatch ()," <span style='background-color: #FFFF00'>\\ 1</span>" , d1 $ results $ Definition ,ignore.case = TRUE )
112- d1 $ results $ Synonyms <- gsub(intermMatch ()," <span style='background-color: #FFFF00'>\\ 1</span>" , d1 $ results $ Synonyms ,ignore.case = TRUE )
129+ if (interm () != " ()" ) {
130+ d1 $ results $ SubmissionValue <- gsub(interm ()," <span style='background-color: #FFFF00'>\\ 1</span>" , d1 $ results $ SubmissionValue ,ignore.case = TRUE )
131+ d1 $ results $ Definition <- gsub(interm ()," <span style='background-color: #FFFF00'>\\ 1</span>" , d1 $ results $ Definition ,ignore.case = TRUE )
132+ d1 $ results $ Synonyms <- gsub(interm ()," <span style='background-color: #FFFF00'>\\ 1</span>" , d1 $ results $ Synonyms ,ignore.case = TRUE )
113133 }
114134 d1 $ results
115135 },options = dto_terminology )
@@ -140,11 +160,11 @@ WHERE
140160
141161 d2 <- SPARQL(url = endpoint_std ,
142162 query = query , ns = ns )
143- if (intermMatch () != " ()" ) {
144- write(intermMatch (),stderr())
145- d2 $ results $ DataElementName <- gsub(intermMatch ()," <span style='background-color: #FFFF00'>\\ 1</span>" , d2 $ results $ DataElementName ,ignore.case = TRUE )
146- d2 $ results $ DataElementDescription <- gsub(intermMatch ()," <span style='background-color: #FFFF00'>\\ 1</span>" , d2 $ results $ DataElementDescription ,ignore.case = TRUE )
147- d2 $ results $ QuestionOrAssumption <- gsub(intermMatch ()," <span style='background-color: #FFFF00'>\\ 1</span>" , d2 $ results $ QuestionOrAssumption ,ignore.case = TRUE )
163+ if (interm () != " ()" ) {
164+ write(interm (),stderr())
165+ d2 $ results $ DataElementName <- gsub(interm ()," <span style='background-color: #FFFF00'>\\ 1</span>" , d2 $ results $ DataElementName ,ignore.case = TRUE )
166+ d2 $ results $ DataElementDescription <- gsub(interm ()," <span style='background-color: #FFFF00'>\\ 1</span>" , d2 $ results $ DataElementDescription ,ignore.case = TRUE )
167+ d2 $ results $ QuestionOrAssumption <- gsub(interm ()," <span style='background-color: #FFFF00'>\\ 1</span>" , d2 $ results $ QuestionOrAssumption ,ignore.case = TRUE )
148168 }
149169
150170 qst <- d2 $ results $ QuestionOrAssumption
@@ -154,7 +174,7 @@ WHERE
154174 Description = d2 $ results $ DataElementDescription ,
155175 " QuestionOrAssumptionText" = qst ,
156176 stringsAsFactors = FALSE )
157- cat(str(results ))
177+ # cat(str(results))
158178 results
159179 },options = dto_standard )
160180
@@ -172,10 +192,10 @@ WHERE
172192 ' config-sdtm-3.2' ,' <http://www.okada.jp.org/schema/config2rdf#>' )
173193 d3 <- SPARQL(url = endpoint_config ,
174194 query = query , ns = ns )
175- if (intermMatch () != " ()" ) {
176- write(intermMatch (),stderr())
177- d3 $ results $ Variable <- gsub(intermMatch ()," <span style='background-color: #FFFF00'>\\ 1</span>" , d3 $ results $ Variable ,ignore.case = TRUE )
178- d3 $ results $ RuleDescription <- gsub(intermMatch ()," <span style='background-color: #FFFF00'>\\ 1</span>" , d3 $ results $ RuleDescription ,ignore.case = TRUE )
195+ if (interm () != " ()" ) {
196+ # write(interm (),stderr())
197+ d3 $ results $ Variable <- gsub(interm ()," <span style='background-color: #FFFF00'>\\ 1</span>" , d3 $ results $ Variable ,ignore.case = TRUE )
198+ d3 $ results $ RuleDescription <- gsub(interm ()," <span style='background-color: #FFFF00'>\\ 1</span>" , d3 $ results $ RuleDescription ,ignore.case = TRUE )
179199 }
180200
181201 d3 $ results
0 commit comments