<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <br>
    Hi Leyla,<br>
    <br>
    Can you login to the web site with that API key?  Does it work on
    this URI<br>
    <br>
    <a class="moz-txt-link-freetext"
      href="http://data.bioontology.org/ontologies?apikey=">http://data.bioontology.org/ontologies?apikey=</a>{YOUR_API_KEY}<br>
    <br>
    <br>
    -- Darren<br>
    <br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 2/16/14, 1:07 PM, Leyla Jael García
      Castro wrote:<br>
    </div>
    <blockquote
cite="mid:CACLxDV6vdu2cw5T6ajnkmFWYABvUk026pOMwRRtqij_2j0Y4rA@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hi Paul, 
        <div><br>
        </div>
        <div>We just realized that the parameter "stopWords" should be
          "stop_words", but that was not the problem. Nor is the number
          of requests that we do. Just tried to send all the paragraphs
          at once and it did not work,same error about the API key.
          Would it help if I send you the file we are annotating? Is
          RDF/XML.</div>
        <div><br>
        </div>
        <div>Regards,</div>
        <div>lj</div>
      </div>
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote">On Sat, Feb 15, 2014 at 9:55 PM, Leyla
          Jael García Castro <span dir="ltr"><<a
              moz-do-not-send="true" href="mailto:leylajael@gmail.com"
              target="_blank">leylajael@gmail.com</a>></span> wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div dir="ltr">Hi Paul, 
              <div><br>
              </div>
              <div>Here is the excerpt of the code that is calling the
                annotation. btw, I have been playing around with the
                text that is giving us troubles, for instance I moved it
                above other paragraphs that are correctly annotated.
                Then, it was another paragraph the one that gave us the
                error. Is there maybe a maximum API calls per second?
                Could be that why at some point the API key seems to be
                not valid any more? I tried to look for hidden chars but
                there was nothing special, just regular text with tabs
                and spaces.</div>
              <div>We also tried to replace the "+" added by the encoder
                instead of the spaces to "%20", and to spaces again, but
                 we got the same API key problem.</div>
              <div><br>
              </div>
              <div>String ontologiesToAnnotate =
"MDDB,MEDLINEPLUS,suicideo,MO,NCIT,NDDF,OMIM,FMA,ICD10,PW,PO,GO,MEDDRA,CHEBI,NDFRT,OBI,SNOMEDCT,SYMP,MESH";<br>
              </div>
              <div>String annotatorURL = "<a moz-do-not-send="true"
                  href="http://data.bioontology.org/annotator"
                  target="_blank">http://data.bioontology.org/annotator</a>";</div>
              <div>String stopwords =
                "a,able,about,above,abst,accordance,according,accordingly,across,act";
                //and some others</div>
              <div><br>
              </div>
              <div>
                <div>        try {        <span
                    style="white-space:pre-wrap"> </span></div>
                <div>        <span style="white-space:pre-wrap"> </span>paragraph
                  =
                  paragraph.replaceAll("[^\\p{Alpha}\\p{Z}\\p{P}\\p{N}]",
                  "_");        <span style="white-space:pre-wrap"> </span></div>
                <div>        <span style="white-space:pre-wrap"> </span>paragraph
                  = URLEncoder.encode(paragraph,
                  Publication2RDF.UTF_ENCODING);</div>
                <div>        <span style="white-space:pre-wrap"> </span>System.out.println("TO
                  ANNOT: " + urlContext + "\n" + paragraph);</div>
                <div>            HttpClient client = new HttpClient();</div>
                <div>           
                  client.getParams().setParameter(HttpMethodParams.USER_AGENT,
                  "Annotator Client Scientific Publications");  //Set
                  this string for your application </div>
                <div>            </div>
                <div>            PostMethod method = new
                  PostMethod(annotatorURL);</div>
                <div>            </div>
                <div>            // Configure the form parameters</div>
                <div>           
                  method.addParameter("stopWords",stopWords);</div>
                <div>           
                  method.addParameter("minimum_match_length","3");</div>
                <div>            method.addParameter("ontologies",
                  ontologiesToAnnotate);            </div>
                <div>            method.addParameter("text", paragraph);</div>
                <div>            method.addParameter("format", "xml");
                  //Options are 'text', 'xml', 'tabDelimited'   </div>
                <div>            method.addParameter("apikey",
                  Config.getNCBOAPIKey());</div>
                <div><br>
                </div>
                <div>            // Execute the POST method</div>
                <div>            int statusCode =
                  client.executeMethod(method);</div>
                <div>            </div>
                <div>            if( statusCode != -1 ) {</div>
                <div>                try {</div>
              </div>
              <div><span style="white-space:pre-wrap"> </span>        
                       InputStream temporal  =
                method.getResponseBodyAsStream();<br>
              </div>
              <div>
                <div><span style="white-space:pre-wrap"> </span>      
                           //testing, we want to see the response and if
                  it is ok we want to process it so we need it twice<span
                    style="white-space:pre-wrap"> </span>             
                    </div>
                <div><span style="white-space:pre-wrap"> </span>      
                           ByteArrayOutputStream baos = new
                  ByteArrayOutputStream();</div>
                <div><span style="white-space:pre-wrap"> </span>      
                           byte[] buf = new byte[1024];</div>
                <div><span style="white-space:pre-wrap"> </span>      
                           int n = 0;</div>
                <div><span style="white-space:pre-wrap"> </span>      
                           while ((n = temporal.read(buf)) >= 0) {</div>
                <div><span style="white-space:pre-wrap"> </span>      
                               baos.write(buf, 0, n);</div>
                <div><span style="white-space:pre-wrap"> </span>      
                           }</div>
                <div><span style="white-space:pre-wrap"> </span>      
                           byte[] content = baos.toByteArray();</div>
                <div><span style="white-space:pre-wrap"> </span>      
                           InputStream annotatedParagraph = new
                  ByteArrayInputStream(content);<span
                    style="white-space:pre-wrap"> </span>  <span
                    style="white-space:pre-wrap"> </span>             
                                  </div>
                <div><span style="white-space:pre-wrap"> </span>      
                           if (annotatedParagraph != null) {<span
                    style="white-space:pre-wrap"> </span>              
                   <span style="white-space:pre-wrap"> </span></div>
                <div>
                  <span style="white-space:pre-wrap"> </span>          
                       <span style="white-space:pre-wrap"> </span>//Reader
                  reader = new StringReader(annotatedParagraph);</div>
                <div><span style="white-space:pre-wrap"> </span>      
                       <span style="white-space:pre-wrap"> </span>JAXBContext
                  jc =
JAXBContext.newInstance("ws.biotea.ld2rdf.util.ncbo.annotator.jaxb.newgenerated");</div>
                <div><span style="white-space:pre-wrap"> </span>      
                       <span style="white-space:pre-wrap"> </span>Unmarshaller
                  unmarshaller = jc.createUnmarshaller();</div>
                <div><span style="white-space:pre-wrap"> </span>      
                       <span style="white-space:pre-wrap"> </span>AnnotationCollection
                  xml;</div>
                <div><span style="white-space:pre-wrap"> </span>      
                       <span style="white-space:pre-wrap"> </span>Object
                  obj = new Object();</div>
                <div><span style="white-space:pre-wrap"> </span>      
                       <span style="white-space:pre-wrap"> </span>try {<span
                    style="white-space:pre-wrap"> </span>            <span
                    style="white-space:pre-wrap"> </span></div>
                <div><span style="white-space:pre-wrap"> </span>      
                       <span style="white-space:pre-wrap"> </span>obj =
                  unmarshaller.unmarshal(annotatedParagraph);</div>
                <div><span style="white-space:pre-wrap"> </span>      
                       <span style="white-space:pre-wrap"> </span>if
                  (obj instanceof Empty) {</div>
                <div><span style="white-space:pre-wrap"> </span>      
                       <span style="white-space:pre-wrap"> </span>return
                  true; //no annotations were found but everything was
                  ok with the response</div>
                <div><span style="white-space:pre-wrap"> </span>      
                       <span style="white-space:pre-wrap"> </span>}</div>
                <div><span style="white-space:pre-wrap"> </span>      
                       <span style="white-space:pre-wrap"> </span>xml =
                  (AnnotationCollection)obj; //otherwise,
                  AnnotationCollection should be the unmarshalled object</div>
                <div>
                  <span style="white-space:pre-wrap"> </span>          
                   <span style="white-space:pre-wrap"> </span>} catch
                  (Exception e) {</div>
                <div><span style="white-space:pre-wrap"> </span>      
                       <span style="white-space:pre-wrap"> </span>InputStream
                  temp = new ByteArrayInputStream(content);</div>
                <div><span style="white-space:pre-wrap"> </span>      
                       <span style="white-space:pre-wrap"> </span>String
                  line;</div>
                <div><span style="white-space:pre-wrap"> </span>    <span
                    style="white-space:pre-wrap"> </span>              
                   BufferedReader reader = new BufferedReader(new
                  InputStreamReader(temp, "UTF-8"));</div>
                <div><span style="white-space:pre-wrap"> </span>    <span
                    style="white-space:pre-wrap"> </span>              
                   while ((line = reader.readLine()) != null) {</div>
                <div><span style="white-space:pre-wrap"> </span>    <span
                    style="white-space:pre-wrap"> </span>              
                   <span style="white-space:pre-wrap"> </span>System.out.println(line);</div>
                <div><span style="white-space:pre-wrap"> </span>    <span
                    style="white-space:pre-wrap"> </span>              
                   }</div>
                <div><span style="white-space:pre-wrap"> </span>    <span
                    style="white-space:pre-wrap"> </span>              
                   reader.close();</div>
                <div><span style="white-space:pre-wrap"> </span>    <span
                    style="white-space:pre-wrap"> </span>              
                   System.out.println(paragraph);</div>
                <div>            <span style="white-space:pre-wrap"> </span>logger.fatal("-
                  FATAL DTD ERROR ANNOTATOR - NCBO annotations for " +
                  this.documentId + "(" + urlContext + ") cannot be
                  unmarshalled: " + e.getMessage() + " - class: " +
                  obj.getClass());</div>
                <div><span style="white-space:pre-wrap"> </span>      
                       <span style="white-space:pre-wrap"> </span>return
                  false;<span style="white-space:pre-wrap"> </span></div>
                <div><span style="white-space:pre-wrap"> </span>      
                       <span style="white-space:pre-wrap"> </span>}</div>
              </div>
              <div>[...]</div>
              <div><br>
              </div>
              <div>then I just start processing the response. If you
                need, I can send you the actual java class, but I am
                afraid that it depends on some other libraries, jaxb,
                etc. so unless I share you the whole project it would
                not work. Please let me know should you need any further
                information.</div>
              <div><br>
              </div>
              <div>Regards,</div>
              <div>lj</div>
              <div><br>
              </div>
            </div>
            <div class="HOEnZb">
              <div class="h5">
                <div class="gmail_extra"><br>
                  <br>
                  <div class="gmail_quote">On Fri, Feb 14, 2014 at 11:11
                    PM, Paul R Alexander <span dir="ltr"><<a
                        moz-do-not-send="true"
                        href="mailto:palexander@stanford.edu"
                        target="_blank">palexander@stanford.edu</a>></span>
                    wrote:<br>
                    <blockquote class="gmail_quote" style="margin:0 0 0
                      .8ex;border-left:1px #ccc solid;padding-left:1ex">
                      <div style="word-wrap:break-word">How is the call
                        being invoked? Can you share the code that is
                        actually doing the call?
                        <div>
                          <br>
                        </div>
                        <div>Thanks,</div>
                        <div>Paul</div>
                        <div><br>
                        </div>
                        <div><br>
                          <div>
                            <div>
                              <div>
                                <div>On Feb 14, 2014, at 1:20 PM, Leyla
                                  Jael García Castro <<a
                                    moz-do-not-send="true"
                                    href="mailto:leylajael@gmail.com"
                                    target="_blank">leylajael@gmail.com</a>>
                                  wrote:</div>
                                <br>
                              </div>
                            </div>
                            <blockquote type="cite">
                              <div>
                                <div>
                                  <div dir="ltr">
                                    <div class="gmail_extra">Hi all, </div>
                                    <div class="gmail_extra"><br>
                                    </div>
                                    <div class="gmail_extra">I am using
                                      the Annotator service successfully
                                      on Windows but, what the odds, the
                                      same code with the same text is
                                      not working on Linux.</div>
                                    <div class="gmail_extra"><br>
                                    </div>
                                    <div class="gmail_extra">This is the
                                      text after URL enconding:</div>
                                    <div class="gmail_extra"><br>
                                    </div>
                                    <div class="gmail_extra">
                                      <div class="gmail_extra">This+analysis+evidence+that+there+is+a+large+difference+in+efficiency+of+the+tested+methods+and+that+care+has+to+be+taken+when+deciding+which+method+to+be+used+for+the+analysis+of+missing+covariates+in+nonlinear+mixed+effects+modelling.</div>
                                      <div class="gmail_extra"><br>
                                      </div>
                                      <div class="gmail_extra">And this
                                        is the response we are getting:</div>
                                      <div class="gmail_extra"><br>
                                      </div>
                                      <div class="gmail_extra"><?xml
                                        version="1.0"
                                        encoding="UTF-8"?></div>
                                      <div class="gmail_extra"><hash></div>
                                      <div class="gmail_extra"> 
                                        <status>401</status></div>
                                      <div class="gmail_extra"> 
                                        <error>You must provide a
                                        valid API Key. Your API Key can
                                        be obtained by logging in at <a
                                          moz-do-not-send="true"
                                          href="http://bioportal.bioontology.org/account"
                                          target="_blank">http://bioportal.bioontology.org/account</a></error></div>
                                      <div class="gmail_extra"></hash></div>
                                      <div class="gmail_extra"><br>
                                      </div>
                                      <div class="gmail_extra">Any
                                        suggestions? This is really
                                        puzzle me.</div>
                                      <div class="gmail_extra"><br>
                                      </div>
                                      <div class="gmail_extra">Best
                                        regards,</div>
                                      <div class="gmail_extra">lj</div>
                                      <div><br>
                                      </div>
                                    </div>
                                  </div>
                                </div>
                              </div>
_______________________________________________<br>
                              bioontology-support mailing list<br>
                              <a moz-do-not-send="true"
                                href="mailto:bioontology-support@lists.stanford.edu"
                                target="_blank">bioontology-support@lists.stanford.edu</a><br>
                              <a moz-do-not-send="true"
                                href="https://mailman.stanford.edu/mailman/listinfo/bioontology-support"
                                target="_blank">https://mailman.stanford.edu/mailman/listinfo/bioontology-support</a><br>
                            </blockquote>
                          </div>
                          <br>
                        </div>
                      </div>
                    </blockquote>
                  </div>
                  <br>
                </div>
              </div>
            </div>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
bioontology-support mailing list
<a class="moz-txt-link-abbreviated" href="mailto:bioontology-support@lists.stanford.edu">bioontology-support@lists.stanford.edu</a>
<a class="moz-txt-link-freetext" href="https://mailman.stanford.edu/mailman/listinfo/bioontology-support">https://mailman.stanford.edu/mailman/listinfo/bioontology-support</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>