Hi all<br><br>This is my first post but I hope it won&#39;t be the last<br><br>I have found referencer pretty interesting. Its main feature (in my opinion) is its capability to read a pdf-file and get metadata automatically from crossref.<br>
However, as a scientist, I use everyday the most famous scientific database (isi-web-of-knowledge)<br><br>I have made a little script (in a couple of days so it&#39;s very very quick and dirty) that takes a referencer database file and use some fields in it to obtain further information about the paper from isi-web.<br>
<br>It doesn&#39;t work perfectly and some extra tuning is needed. But I was guessing if something similar could be incorporated in referencer. I mean, pick a field of a referencer record and complete other fields from the information obtained from isi-web. If so, i think it would be very valuable.<br>
<br>Here I attach the two files needed to run my script (you also need a subscription to isi-web, but all the universities have one collective subscription)<br><br>The first file is called refine_reflist.sh and it contains the following:<br>
#################<br>#!/bin/bash<br>if [ $# -ne 2 ]; then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo &quot;Sintaxis: $0 infile.pdf outfile.bib (it appends if exist and creates if not)&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit<br>fi<br>rm -f .temp_query_* temp_answer_*;<br>
#The main functionality is contained in the following awk script<br>#but I&#39;m pretty sure that it would be simpler in pyhton (which I don&#39;t know<br>#very well)<br>awk -F &quot;&gt;&quot; &#39;<br>BEGIN {<br># Prints the initial xml fields of the referencer file<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; doit=&quot;false&quot;;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;UTF-8\&quot;?&gt;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;&lt;library&gt;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;&lt;manage_target braces=\&quot;false\&quot; utf8=\&quot;false\&quot;&gt;&lt;/manage_target&gt;&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;&lt;taglist&gt;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;&lt;/taglist&gt;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;&lt;doclist&gt;&quot;<br><br>}<br>/&lt;doc&gt;/ {<br>print &quot;&lt;doc&gt;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getline;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; safe=$0; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gsub(&quot;&lt;&quot;,&quot;&gt;&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while ($2!=&quot;/doc&quot;) { # while you are in this record...<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #print &quot;1:&quot;,$1,&quot;2:&quot;,$2,&quot;3:&quot;,$3,&quot;4:&quot;,$4;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #if($2==&quot;bib_doi&quot; &amp;&amp; $3!=&quot;&quot;) {&nbsp; doit=&quot;true&quot;; print doit,NF;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if($2==&quot;bib_title&quot;) {title=$3; gsub(&quot; &quot;,&quot;%20&quot;,title); gsub(/[(&quot;)]/,&quot;&quot;,title)&nbsp; } #extract the paper title<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if($2==&quot;bib_year&quot;) {year=$3; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if($2==&quot;bib_authors&quot; &amp;&amp; $3==&quot;&quot;) {doit=&quot;true&quot;;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else print safe;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getline;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; safe=$0; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gsub(&quot;&lt;&quot;,&quot;&gt;&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(doit==&quot;true&quot;) { #creates a query_file for isi (I learn how this was done with a sniffer)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; temp_file=sprintf(&quot;.temp_query_%s_%s&quot;,title,year);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf &quot;GET /esti/cgi?databaseID=WOS&amp;SID=V2gB%40mljF1oPdjhlcF2&amp;rspType=endnote&amp;method=searchRetrieve&amp;firstRec=1&amp;numRecs=2&amp;query=TI%3D(%s)%20and%20PY%3D(%s) HTTP/1.1&quot;,title,year &gt; temp_file;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;User-Agent: Mozilla/5.0 (compatible; Konqueror/3.5; Linux) KHTML/3.5.8 (like Gecko)&quot;&gt;&gt; temp_file;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;Accept: text/html, image/jpeg, image/png, text/*, image/*, */*&quot;&gt;&gt; temp_file;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;Accept-Encoding: x-gzip, x-deflate, gzip, deflate&quot;&gt;&gt; temp_file;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;Accept-Charset: utf-8, utf-8;q=0.5, *;q=0.5&quot;&gt;&gt; temp_file;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;Accept-Language: en&quot;&gt;&gt; temp_file;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;Host: <a href="http://estipub.isiknowledge.com">estipub.isiknowledge.com</a>&quot;&gt;&gt; temp_file;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;Connection: Keep-Alive&quot;&gt;&gt; temp_file;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;&quot;&gt;&gt; temp_file;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;QUIT&quot; &gt;&gt; temp_file;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; doit=&quot;false&quot;;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fflush(temp_file);<br>#the following uses netcat to perform a query in isi-web. Be careful with the &quot;^M&quot; character it is written with Ctrl-v-m no simple ^M<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; comando=sprintf(&quot;cat %s |nc <a href="http://estipub.isiknowledge.com">estipub.isiknowledge.com</a> 80 |tail -n +10 - |head -n -11 |sed &#39;s/^M//g&#39; &gt;&gt; .temp_answer_%s_%s&quot;,temp_file,title,year);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; system(comando);<br>#The following command parses the isi-web query and add the learnt fields to the referencer record<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; comando2=sprintf(&quot;awk -f extract_field.awk .temp_answer_%s_%s&quot;,title,year);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; system(comando2);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>print &quot;&lt;/doc&gt;&quot;<br>}<br>END{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;&lt;/doclist&gt;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;&lt;/library&gt;&quot;<br><br>}<br>&#39; $1 &gt;$2<br>rm -f .temp_query_* temp_answer_*;<br>
###############<br><br>to run it simply type:<br>./refine_reflist.sh old.reflist new.reflist<br><br>the other file you need is called extract_field.awk:<br>################<br>BEGIN{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FS=&quot;&gt;&quot;;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IGNORECASE=1;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; authcount=0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; keycount=0;<br>}<br>/AuCollectiveName/{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gsub(&quot;&lt;&quot;,&quot;&gt;&quot;); <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; author[++authcount]=$3; <br>}<br>/&lt;keyword&gt;/{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gsub(&quot;&lt;&quot;,&quot;&gt;&quot;); <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; keywords[++keycount]=$3; <br>}<br>/article_no/ &amp;&amp; /doi/ {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gsub(&quot;&lt;&quot;,&quot;&gt;&quot;); <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; doi=$3;<br>}<br>END{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;&lt;bib_authors&gt;&quot;); <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for(i=1;i&lt;authcount;i++) printf &quot;%s and &quot;,author[i]; printf &quot;%s&lt;/bib_authors&gt;\n&quot;,author[authcount];<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;&lt;bib_extra key=\&quot;Keywords\&quot;&gt;&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for(i=1;i&lt;keycount;i++) printf &quot;%s,&quot;,keywords[i]; printf &quot;%s&lt;/bib_extra&gt;\n&quot;,keywords[keycount];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf(&quot;&lt;bib_extra key=\&quot;Doi\&quot;&gt; %s &lt;/bib_extra&gt;\n&quot;,doi);<br>
}<br><br>###############<br><br><br>I would like to contribute to the referencer project, and I hope that this idea could be incorporated (and of course improved) for future versions.<br><br>Another source of inspiration could be a Mac program called &quot;papers&quot;. I&#39;ve seen it in action and it&#39;s all I would like for referencer.<br>
<br>Best regards, <br><br>Mario<br>