https://www.bioontology.org//mediawiki/api.php?action=feedcontributions&user=Andrew+Su&feedformat=atom
NCBO Wiki - User contributions [en]
2024-03-29T08:57:53Z
User contributions
MediaWiki 1.35.9
https://www.bioontology.org//mediawiki/index.php?title=Annotator_R_Client&diff=12643
Annotator R Client
2013-12-19T17:41:14Z
<p>Andrew Su: /* Example */ minor tweaks for clarity</p>
<hr />
<div>=== Example ===<br />
<br />
<pre><br />
#<br />
# sample client for NCBO Annotator in R<br />
# Author: Andrew Su <br />
#<br />
<br />
<br />
annotate.it <- function( queryText, yourAPIKey ) {<br />
<br />
library(RCurl)<br />
library(XML)<br />
<br />
# Login to BioPortal to get YourAPIKey<br />
res<- postForm('http://rest.bioontology.org/obs/annotator',<br />
"textToAnnotate"=queryText,<br />
"apikey"=yourAPIKey, <br />
"style"="POST",<br />
"longestOnly"="false",<br />
"wholeWordOnly"="true",<br />
"filterNumber"="true",<br />
"withDefaultStopWords"="true",<br />
"isStopWordsCaseSensitive"="false",<br />
"minTermSize"="3",<br />
"scored"="true",<br />
"withSynonyms"="true",<br />
"ontologiesToExpand"="1353,1032,1351,1009",<br />
"ontologiesToKeepInResult"="1353,1032,1351,1009",<br />
"isVirtualOntologyId"="true", <br />
"semanticTypes"="T017,T047,T191,T999",<br />
"levelMax"="0",<br />
"mappingTypes"="null",<br />
"format"="xml",<br />
"email"="YourEmail@Somewhere.com")<br />
<br />
x <- xmlInternalTreeParse(res)<br />
<br />
matchedConcepts <- list()<br />
conceptNodes <- getNodeSet(x,"/success/data/annotatorResultBean/annotations/annotationBean/concept")<br />
for( concept in conceptNodes ) {<br />
localConceptId <- xmlValue(getNodeSet(concept,"./localConceptId")[[1]])<br />
print( paste( "ID = ",localConceptId ))<br />
<br />
preferredName <- xmlValue(getNodeSet(concept,"./preferredName")[[1]])<br />
print( paste( "Name = ",preferredName ))<br />
<br />
semanticType <- xmlValue(getNodeSet(concept,"./semanticTypes/semanticTypeBean/semanticType")[[1]])<br />
print( paste( "Type = ",semanticType ))<br />
<br />
description <- xmlValue(getNodeSet(concept,"./semanticTypes/semanticTypeBean/description")[[1]])<br />
print( paste( "Type name = ",description ))<br />
<br />
matchedConcepts[[localConceptId]] <- preferredName<br />
}<br />
<br />
matchedPhrase <- list()<br />
resultNodes <- getNodeSet(x, "/success/data/annotatorResultBean/annotations/annotationBean/context")<br />
for( result in resultNodes ) {<br />
localConceptId <- xmlValue(getNodeSet(result,"./term/concept/localConceptId")[[1]])<br />
print( paste( "ID = ", localConceptId ) )<br />
<br />
term.name <- xmlValue(getNodeSet(result,"./term/name")[[1]])<br />
print( paste( "Match = ", term.name ) )<br />
<br />
from <- xmlValue(getNodeSet(result,"./from")[[1]])<br />
print( paste( "From = ", from ) )<br />
<br />
to <- xmlValue(getNodeSet(result,"./to")[[1]])<br />
print( paste( "To = ", to ) )<br />
<br />
matchedPhrase[[localConceptId]] <- term.name<br />
}<br />
<br />
for( key in names(matchedConcepts) ) {<br />
print(paste(key,matchedConcepts[[key]],"matched",matchedPhrase[[key]]))<br />
}<br />
}<br />
<br />
queryText <- "Melanoma is a malignant tumor of melanocytes which are found predominantly in skin but also in the bowel and the eye"<br />
<br />
# Instructions on getting an API key are at http://www.bioontology.org/wiki/index.php/Annotator_User_Guide#Annotator_Web_service_Validation<br />
yourAPIKey <- "XXXXXXXXXXXXX"<br />
<br />
annotate.it( queryText, yourAPIKey )<br />
<br />
</pre></div>
Andrew Su
https://www.bioontology.org//mediawiki/index.php?title=Annotator_R_Client&diff=12593
Annotator R Client
2013-03-22T00:52:04Z
<p>Andrew Su: fix xpath</p>
<hr />
<div>=== Example ===<br />
<br />
<pre><br />
#<br />
# sample client for NCBO Annotator in R<br />
# Author: Andrew Su <br />
#<br />
<br />
AnnotatorURL <- "http://rest.bioontology.org/obs/annotator"<br />
<br />
queryText <- "Melanoma is a malignant tumor of melanocytes which are found predominantly in skin but also in the bowel and the eye"<br />
<br />
annotate.it( queryText )<br />
<br />
<br />
annotate.it <- function( queryText ) {<br />
<br />
library(RCurl)<br />
library(XML)<br />
<br />
# Login to BioPortal to get YourAPIKey<br />
res<- postForm('http://rest.bioontology.org/obs/annotator',<br />
"textToAnnotate"=queryText,<br />
"apikey"=YourAPIKey, <br />
"style"="POST",<br />
"longestOnly"="false",<br />
"wholeWordOnly"="true",<br />
"filterNumber"="true",<br />
"withDefaultStopWords"="true",<br />
"isStopWordsCaseSensitive"="false",<br />
"minTermSize"="3",<br />
"scored"="true",<br />
"withSynonyms"="true",<br />
"ontologiesToExpand"="1353,1032,1351,1009",<br />
"ontologiesToKeepInResult"="1353,1032,1351,1009",<br />
"isVirtualOntologyId"="true", <br />
"semanticTypes"="T017,T047,T191,T999",<br />
"levelMax"="0",<br />
"mappingTypes"="null",<br />
"format"="xml",<br />
"email"="YourEmail@Somewhere.com")<br />
<br />
x <- xmlInternalTreeParse(res)<br />
<br />
matchedConcepts <- list()<br />
conceptNodes <- getNodeSet(x,"/success/data/annotatorResultBean/annotations/annotationBean/concept")<br />
for( concept in conceptNodes ) {<br />
localConceptId <- xmlValue(getNodeSet(concept,"./localConceptId")[[1]])<br />
print( paste( "ID = ",localConceptId ))<br />
<br />
preferredName <- xmlValue(getNodeSet(concept,"./preferredName")[[1]])<br />
print( paste( "Name = ",preferredName ))<br />
<br />
semanticType <- xmlValue(getNodeSet(concept,"./semanticTypes/semanticTypeBean/semanticType")[[1]])<br />
print( paste( "Type = ",semanticType ))<br />
<br />
description <- xmlValue(getNodeSet(concept,"./semanticTypes/semanticTypeBean/description")[[1]])<br />
print( paste( "Type name = ",description ))<br />
<br />
matchedConcepts[[localConceptId]] <- preferredName<br />
}<br />
<br />
matchedPhrase <- list()<br />
resultNodes <- getNodeSet(x, "/success/data/annotatorResultBean/annotations/annotationBean/context")<br />
for( result in resultNodes ) {<br />
localConceptId <- xmlValue(getNodeSet(result,"./term/concept/localConceptId")[[1]])<br />
print( paste( "ID = ", localConceptId ) )<br />
<br />
term.name <- xmlValue(getNodeSet(result,"./term/name")[[1]])<br />
print( paste( "Match = ", term.name ) )<br />
<br />
from <- xmlValue(getNodeSet(result,"./from")[[1]])<br />
print( paste( "From = ", from ) )<br />
<br />
to <- xmlValue(getNodeSet(result,"./to")[[1]])<br />
print( paste( "To = ", to ) )<br />
<br />
matchedPhrase[[localConceptId]] <- term.name<br />
}<br />
<br />
for( key in names(matchedConcepts) ) {<br />
print(paste(key,matchedConcepts[[key]],"matched",matchedPhrase[[key]]))<br />
}<br />
}<br />
<br />
</pre></div>
Andrew Su