Created
July 13, 2010 10:14
-
-
Save rtirrell/473695 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns oba-client | |
(:use [clojure-http.resourcefully :as res] | |
[clojure.contrib.str-utils :only [str-join]]) | |
(:refer-clojure :exclude [get])) | |
(def default-timeout 30) | |
(def default-uri "http://rest.bioontology.org/obs/annotator") | |
(def all-annotator-parameters #{ | |
"email" | |
"filterNumber" | |
"format" | |
"isStopWordsCaseSensitive" | |
"isVirtualOntologyID" | |
"levelMax" | |
"longestOnly" | |
"ontologiesToExpand" | |
"ontologiesToKeepInResult" | |
"mappingTypes" | |
"minTermSize" | |
"scored" | |
"semanticTypes" | |
"stopWords" | |
"wholeWordOnly" | |
"withDefaultStopWords" | |
"withSynonyms"}) | |
(defn execute-request [uri timeout parse-xml parameters text] | |
(let [parameters (assoc parameters "textToAnnotate" text) | |
response (res/post uri {} parameters)] | |
(println response))) | |
(defn annotate | |
([] (annotate {})) | |
([options] | |
(let [uri (get options "uri" default-uri) | |
timeout (get options "timeout" default-timeout) | |
parse-xml (get options "parse-xml")] | |
(when-let [ontologies (get options "ontologies")] | |
(do (assoc options "ontologiesToExpand" ontologies) | |
(assoc options "ontologiesToKeepInResult" ontologies))) | |
(let [parameters (select-keys options all-annotator-parameters)] | |
(doseq [[k v] parameters] | |
(if (vector? v) (assoc parameters k (str-join ", " v)))) | |
(partial execute-request uri timeout parse-xml parameters))))) | |
(defn annotate-text [] | |
((annotate) "hello!? out there?!")) | |
(annotate-text) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment