1 | #!/bin/bash |
---|
2 | # |
---|
3 | # Behera, S. K., J. Luo, S. Masson, S. Rao, S. Gualdi, P. Delecluse, A. |
---|
4 | # Navarra and T. Yamagata, 2004 : Paramount Impact of the Indian Ocean |
---|
5 | # Dipole on the East African Short Rains: A CGCM Study, J. Climate, In |
---|
6 | # press. |
---|
7 | # |
---|
8 | # donnerait |
---|
9 | # |
---|
10 | # <biblioentry xml:id="behara2004"> |
---|
11 | # <authorgroup> |
---|
12 | # <author><surname>Behera</surname> <firstname>S. K.</firstname> </author> |
---|
13 | # <author><firstname>J.</firstname> <surname>Luo</surname></author> |
---|
14 | # <author><firstname>S.</firstname> <surname>Masson</surname></author> |
---|
15 | # <author><firstname>S.</firstname> <surname>Rao</surname></author> |
---|
16 | # <author><firstname>S.</firstname> <surname>Gualdi</surname></author> |
---|
17 | # <author><firstname>P.</firstname> <surname>Delecluse</surname></author> |
---|
18 | # <author><firstname>A.</firstname> <surname>Navara</surname></author> |
---|
19 | # <author><firstname>T.</firstname> <surname>Yamagata</surname></author> |
---|
20 | # </authorgroup> |
---|
21 | # <date>2004</date> |
---|
22 | # <title>Paramount Impact of the Indian Ocean Dipole on the East African |
---|
23 | # Short Rains: A CGCM Study</title> |
---|
24 | # <publishername>J. Climate</publishername> |
---|
25 | # <biblioid class="doi">doi</biblioid> |
---|
26 | # <bibliomisc role="pseudoref">In press.</bibliomisc> |
---|
27 | # <bibliomisc role="internalref">from |
---|
28 | # http://www.lodyc.jussieu.fr/~opatlod/NEMO_v1/6_Menu/2_page/index.html |
---|
29 | # 2007-03-29T16:24:31Z fplod by hand</bibliomisc> |
---|
30 | # </biblioentry> |
---|
31 | # |
---|
32 | # @book{MetReiCoh2004 , |
---|
33 | # author = {Michael Metcalf and |
---|
34 | # John Reid and Malcolm Cohen}, |
---|
35 | # title = {Fortran 95/2003 explained}, |
---|
36 | # year = {2004}, |
---|
37 | # publisher = {Oxford University Press}, |
---|
38 | # edition = {Third}, |
---|
39 | # ISBN = {0-19-852693-8}, |
---|
40 | # pages = {434} |
---|
41 | # } |
---|
42 | # donnerait |
---|
43 | # <biblioentry xml:id="MetReiCoh2004"> |
---|
44 | # <authorgroup> |
---|
45 | # <author><firstname>Michael</firstname> <surname>Metcalf</surname></author> |
---|
46 | # <author><firstname>John</firstname> <surname>Reid</surname></author> |
---|
47 | # <author><firstname>Malcolm</firstname> <surname>Cohen</surname></author> |
---|
48 | # </authorgroup> |
---|
49 | # <date>2004}</date> |
---|
50 | # <title>Fortran 95/2003 explained</title> |
---|
51 | # <publisher><publishername>Oxford University Press</publishername></publisher> |
---|
52 | # <biblioid class="isbn">0-19-852693-8</biblioid> |
---|
53 | # <pagenums>434</pagenums> |
---|
54 | # <edition>Third</edition> |
---|
55 | # |
---|
56 | # example : |
---|
57 | # $ ./bibopa.sh -p birefnemo -i data/biball.txt -t raw |
---|
58 | # $ ./bibopa.sh -p bibrefnemo -i data/mail2007-05-10T09:01:56Z -t mailbody |
---|
59 | # $ ./bibopa.sh -p polyfortran -i data/petitpolyfp.bib -t bibtex -l fr |
---|
60 | # $ ./bibopa.sh -p demo1 -i data/bibdemo1.txt -t raw -l fr |
---|
61 | # |
---|
62 | # see also mailtouser.sh |
---|
63 | # |
---|
64 | # original location : |
---|
65 | # /usr/home/fplod/incas/bibnemo/src/bibnemomaf/bibopa.sh sur cerbere.locean-ipsl.upmc.fr |
---|
66 | # |
---|
67 | # update |
---|
68 | # ++ gestion des comments |
---|
69 | # ++ gestion des id existants (cf à la fin) |
---|
70 | # ++ option debug |
---|
71 | # $Id$ |
---|
72 | # fplod 2008-04-30T07:11:58Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
73 | # chgt for dbk5 out |
---|
74 | # xmlto 0.0.18 does'nt like this docbook release. remove |
---|
75 | # usage of xml (xmlstarlet) for validation |
---|
76 | # bug fix |
---|
77 | # add journal names from demo1 |
---|
78 | # fplod 2008-03-12T16:11:07Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
79 | # add -p option (to overide bibrefnemo in file name and id) |
---|
80 | # add -l option by default en |
---|
81 | # fplod 2008-03-11T11:25:27Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
82 | # add bibtex entry (not finished)++ |
---|
83 | # fplod 2007-06-20T17:18:02Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
84 | # <bibliomisc role="id"> replace by <biblioid class="doi"> |
---|
85 | # smasson 2007-06-07T16:43:42Z arete.locean-ipsl.upmc.fr (Darwin) |
---|
86 | # Add journals |
---|
87 | # fplod 2007-05-10T09:17:09Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
88 | # dernières touches |
---|
89 | # fplod 2007-04-25T10:59:49Z cerbere.locean-ipsl.upmc.fr (Linux) |
---|
90 | # add a filein parameter and an option for mailbody |
---|
91 | # comments (line begininig with #) are now possible |
---|
92 | # Sebastien Masson avril 2007 creation |
---|
93 | # |
---|
94 | |
---|
95 | rmbl () { |
---|
96 | echo "${1}" | sed -e "s/^ *//" | sed -e "s/ *$//" |
---|
97 | } |
---|
98 | cleanname () { |
---|
99 | echo "${1}" | sed -e "s/^ *//" \ |
---|
100 | -e "s/^ *,//" \ |
---|
101 | -e "s/^ *;//" \ |
---|
102 | -e "s/^ *\.//" \ |
---|
103 | -e "s/ *$//" \ |
---|
104 | -e "s/, *$//" \ |
---|
105 | -e "s/; *$//" \ |
---|
106 | -e "s/\. *$//" |
---|
107 | } |
---|
108 | # |
---|
109 | set -o posix |
---|
110 | command=$(basename ${0}) |
---|
111 | log_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") |
---|
112 | log=/tmp/${command}.${log_date} |
---|
113 | # |
---|
114 | # test if xsltproc is available |
---|
115 | type xsltproc 1> /dev/null 2>&1 |
---|
116 | status=${?} |
---|
117 | if [ ${status} -ne 0 ] |
---|
118 | then |
---|
119 | echo " eee : xsltproc not found" |
---|
120 | exit 1 |
---|
121 | fi |
---|
122 | unset status |
---|
123 | # |
---|
124 | # test if xml is available |
---|
125 | type xml 1> /dev/null 2>&1 |
---|
126 | status=${?} |
---|
127 | if [ ${status} -ne 0 ] |
---|
128 | then |
---|
129 | echo " eee : xml not found" |
---|
130 | exit 1 |
---|
131 | fi |
---|
132 | unset status |
---|
133 | # |
---|
134 | usage=" Usage : ${command} -i filein -t type -p project -l lang" |
---|
135 | # |
---|
136 | # default |
---|
137 | lang=en |
---|
138 | # |
---|
139 | minargcount=6 |
---|
140 | #echo " narg ${#}" |
---|
141 | if [ ${#} -lt ${minargcount} ] |
---|
142 | then |
---|
143 | echo "eee : not enought arguments" |
---|
144 | echo "${usage}" |
---|
145 | exit 1 |
---|
146 | fi |
---|
147 | unset minargcount |
---|
148 | # |
---|
149 | while [ ! -z "${1}" ] |
---|
150 | do |
---|
151 | case ${1} in |
---|
152 | -i) # filein |
---|
153 | filein=${2} |
---|
154 | shift |
---|
155 | ;; |
---|
156 | -t) # type |
---|
157 | type=${2} |
---|
158 | shift |
---|
159 | ;; |
---|
160 | -p) |
---|
161 | project=${2} |
---|
162 | shift |
---|
163 | ;; |
---|
164 | -l) |
---|
165 | lang=${2} |
---|
166 | shift |
---|
167 | ;; |
---|
168 | -h) |
---|
169 | echo "${usage}" |
---|
170 | exit 0 |
---|
171 | ;; |
---|
172 | *) # other choice |
---|
173 | echo "${usage}" |
---|
174 | exit 1 |
---|
175 | ;; |
---|
176 | esac |
---|
177 | shift # next flag |
---|
178 | done |
---|
179 | unset usage |
---|
180 | # |
---|
181 | set -u |
---|
182 | # |
---|
183 | # check for filein |
---|
184 | if [ ! -f ${filein} ] |
---|
185 | then |
---|
186 | echo "eee : ${filein} not found" |
---|
187 | exit 1 |
---|
188 | fi |
---|
189 | # |
---|
190 | case ${type} in |
---|
191 | raw) # file like data/biball.txt |
---|
192 | fileraw=${filein} |
---|
193 | ;; |
---|
194 | mailbody) # file like data/mail2007-04-25T08:58:16Z.txt |
---|
195 | fileraw=/tmp/$(basename ${filein}).raw |
---|
196 | echo "# from ${filein}" > ${fileraw} |
---|
197 | echo "# ${log_date}" >> ${fileraw} |
---|
198 | echo "# corrections" >> ${fileraw} |
---|
199 | grep "correction_.*=" ${filein} | grep -v "correction_.*=$" | \ |
---|
200 | sed -e "s/correction_.*=//">> ${fileraw} |
---|
201 | echo "# new references" >> ${fileraw} |
---|
202 | awk "/newreferences=/,/comments=/" ${filein} | sed -e "s/newreferences=//" -e "/comments=/d" >> ${fileraw} |
---|
203 | #more ${fileraw} # ++ if debug |
---|
204 | #read a #++ if debug |
---|
205 | ;; |
---|
206 | bibtex) # file like data/petitpoly.bib |
---|
207 | fileraw=/tmp/$(basename ${filein}).raw |
---|
208 | awk -f join_endcomma.awk ${filein} >> ${fileraw} |
---|
209 | #more ${fileraw} # ++ if debug |
---|
210 | #read a #++ if debug |
---|
211 | ;; |
---|
212 | *) |
---|
213 | echo "eee : type should be raw, mailbody or bibtex" |
---|
214 | exit 1 |
---|
215 | ;; |
---|
216 | esac |
---|
217 | # |
---|
218 | # check for output |
---|
219 | fileou=$( basename ${filein} .txt).xml |
---|
220 | if [ -f ${fileou} ] |
---|
221 | then |
---|
222 | echo "eee : ${fileou} already exist" |
---|
223 | exit 1 |
---|
224 | fi |
---|
225 | # |
---|
226 | ij=1 |
---|
227 | jlist[${ij}]="J. Climate" |
---|
228 | ij=$(( ${ij} + 1)) |
---|
229 | jlist[${ij}]="Journal of Climate" |
---|
230 | ij=$(( ${ij} + 1)) |
---|
231 | jlist[${ij}]="Ocean Modelling" |
---|
232 | ij=$(( ${ij} + 1)) |
---|
233 | jlist[${ij}]="Geophys. Res. Lett." |
---|
234 | ij=$(( ${ij} + 1)) |
---|
235 | jlist[${ij}]="J. Geophys. Res." |
---|
236 | ij=$(( ${ij} + 1)) |
---|
237 | jlist[${ij}]="Tellus A" |
---|
238 | ij=$(( ${ij} + 1)) |
---|
239 | jlist[${ij}]="Tellus B" |
---|
240 | ij=$(( ${ij} + 1)) |
---|
241 | jlist[${ij}]="J. Phys. Oceanogr." |
---|
242 | ij=$(( ${ij} + 1)) |
---|
243 | jlist[${ij}]="Clim. Dyn." |
---|
244 | ij=$(( ${ij} + 1)) |
---|
245 | jlist[${ij}]="Climate Dynamics" |
---|
246 | ij=$(( ${ij} + 1)) |
---|
247 | jlist[${ij}]="Dyn. Atmos. Oceans" |
---|
248 | ij=$(( ${ij} + 1)) |
---|
249 | jlist[${ij}]="Mon. Wea. Rev." |
---|
250 | ij=$(( ${ij} + 1)) |
---|
251 | jlist[${ij}]="Global Biogeochem. Cycles" |
---|
252 | ij=$(( ${ij} + 1)) |
---|
253 | jlist[${ij}]="Nonlinear Processes in Geophysics" |
---|
254 | ij=$(( ${ij} + 1)) |
---|
255 | jlist[${ij}]="Ocean Science" |
---|
256 | ij=$(( ${ij} + 1)) |
---|
257 | jlist[${ij}]="J. Mar. Systems" |
---|
258 | ij=$(( ${ij} + 1)) |
---|
259 | jlist[${ij}]="J. Atmos. Sc." |
---|
260 | ij=$(( ${ij} + 1)) |
---|
261 | jlist[${ij}]="Proc. Royal Soc." |
---|
262 | ij=$(( ${ij} + 1)) |
---|
263 | jlist[${ij}]="Bull. Amer. Meteorol. Soc." |
---|
264 | ij=$(( ${ij} + 1)) |
---|
265 | jlist[${ij}]="Ocean Dyn." |
---|
266 | ij=$(( ${ij} + 1)) |
---|
267 | jlist[${ij}]="Geophysical Monograph Series, Earth's Climate: The Ocean-Atmosphere Interaction" |
---|
268 | ij=$(( ${ij} + 1)) |
---|
269 | jlist[${ij}]="Paleoceanography" |
---|
270 | ij=$(( ${ij} + 1)) |
---|
271 | jlist[${ij}]="Annales Geophysicae" |
---|
272 | ij=$(( ${ij} + 1)) |
---|
273 | jlist[${ij}]="Annals of Geophys." |
---|
274 | ij=$(( ${ij} + 1)) |
---|
275 | jlist[${ij}]="Deep Sea Research Part II: Topical Studies in Oceanography" |
---|
276 | ij=$(( ${ij} + 1)) |
---|
277 | jlist[${ij}]="Deep Sea Res. II" |
---|
278 | ij=$(( ${ij} + 1)) |
---|
279 | jlist[${ij}]="Atmospheric Chemistry and Physics" |
---|
280 | ij=$(( ${ij} + 1)) |
---|
281 | jlist[${ij}]="Atmospheric Chemistry and Physics Discussions" |
---|
282 | ij=$(( ${ij} + 1)) |
---|
283 | jlist[${ij}]="Earth Plan. Sc. Lett." |
---|
284 | ij=$(( ${ij} + 1)) |
---|
285 | jlist[${ij}]="J. Mar. Res." |
---|
286 | ij=$(( ${ij} + 1)) |
---|
287 | jlist[${ij}]="PCMDI Report Series" |
---|
288 | ij=$(( ${ij} + 1)) |
---|
289 | jlist[${ij}]="J. Mar. Syst." |
---|
290 | ij=$(( ${ij} + 1)) |
---|
291 | jlist[${ij}]="Note du Pole de Modelisation" |
---|
292 | ij=$(( ${ij} + 1)) |
---|
293 | jlist[${ij}]="Calculateurs Paralleles" |
---|
294 | ij=$(( ${ij} + 1)) |
---|
295 | jlist[${ij}]="Note Scientifique du Pole de Modelisation" |
---|
296 | ij=$(( ${ij} + 1)) |
---|
297 | jlist[${ij}]="Lecture Notes in Computer Science" |
---|
298 | ij=$(( ${ij} + 1)) |
---|
299 | jlist[${ij}]="Prog. Oceanogr." |
---|
300 | ij=$(( ${ij} + 1)) |
---|
301 | jlist[${ij}]="Deep Sea Research Part I: Oceanographic Research Papers" |
---|
302 | ij=$(( ${ij} + 1)) |
---|
303 | jlist[${ij}]="Deep Sea Res. I" |
---|
304 | ij=$(( ${ij} + 1)) |
---|
305 | jlist[${ij}]="IEEE Trans. Geosci. Remote Sensing" |
---|
306 | ij=$(( ${ij} + 1)) |
---|
307 | jlist[${ij}]="ECMWF Tech. Memorandum" |
---|
308 | ij=$(( ${ij} + 1)) |
---|
309 | jlist[${ij}]="J. Environ. Radioactivity" |
---|
310 | ij=$(( ${ij} + 1)) |
---|
311 | jlist[${ij}]="Int. WOCE Newsletter" |
---|
312 | ij=$(( ${ij} + 1)) |
---|
313 | jlist[${ij}]="C. R. Acad. Sci. Paris" |
---|
314 | ij=$(( ${ij} + 1)) |
---|
315 | jlist[${ij}]="C. R. Acad. Sci. Paris, Earth and Planetary Sciences" |
---|
316 | ij=$(( ${ij} + 1)) |
---|
317 | jlist[${ij}]="In The mathematics of models for climatology and environment" |
---|
318 | ij=$(( ${ij} + 1)) |
---|
319 | jlist[${ij}]="Oceanol. Acta" |
---|
320 | ij=$(( ${ij} + 1)) |
---|
321 | jlist[${ij}]="The global atmosphere and ocean system" |
---|
322 | ij=$(( ${ij} + 1)) |
---|
323 | jlist[${ij}]="NATO Advanced Study Institute" |
---|
324 | ij=$(( ${ij} + 1)) |
---|
325 | jlist[${ij}]="WCRP" |
---|
326 | ij=$(( ${ij} + 1)) |
---|
327 | jlist[${ij}]="The Courier" |
---|
328 | ij=$(( ${ij} + 1)) |
---|
329 | jlist[${ij}]="Elsevier Oceanographic Series" |
---|
330 | ij=$(( ${ij} + 1)) |
---|
331 | jlist[${ij}]="In Conference Proceedings of the 1988 International Conference on Supercomputing" |
---|
332 | ij=$(( ${ij} + 1)) |
---|
333 | jlist[${ij}]="In Science and engineering on Cray Supercomputers" |
---|
334 | ij=$(( ${ij} + 1)) |
---|
335 | jlist[${ij}]="In Modeling the Earth's Climate and its Variability" |
---|
336 | ij=$(( ${ij} + 1)) |
---|
337 | jlist[${ij}]="Fish. Oceanogr." |
---|
338 | ij=$(( ${ij} + 1)) |
---|
339 | jlist[${ij}]="Q. J. R. Meteor. Soc." |
---|
340 | ij=$(( ${ij} + 1)) |
---|
341 | jlist[${ij}]="In High performance computing in the geosciences" |
---|
342 | ij=$(( ${ij} + 1)) |
---|
343 | jlist[${ij}]="Int. J. Numer. Meth. in Fluids" |
---|
344 | ij=$(( ${ij} + 1)) |
---|
345 | jlist[${ij}]="Lecture notes in Physics" |
---|
346 | ij=$(( ${ij} + 1)) |
---|
347 | jlist[${ij}]="J. Meterol. Soc. Japan" |
---|
348 | ij=$(( ${ij} + 1)) |
---|
349 | jlist[${ij}]="Journal of Marine Systems" |
---|
350 | ij=$(( ${ij} + 1)) |
---|
351 | jlist[${ij}]="Canadian Journal of Fisheries and Aquatic Sciences" |
---|
352 | ij=$(( ${ij} + 1)) |
---|
353 | jlist[${ij}]="J. Atmos. Ocean. Tech." |
---|
354 | ij=$(( ${ij} + 1)) |
---|
355 | jlist[${ij}]="EOS" |
---|
356 | ij=$(( ${ij} + 1)) |
---|
357 | jlist[${ij}]="Nature" |
---|
358 | ij=$(( ${ij} + 1)) |
---|
359 | jlist[${ij}]="Physics and Chemistry of the Earth, Part B: Hydrology, Oceans and Atmosphere" |
---|
360 | ij=$(( ${ij} + 1)) |
---|
361 | jlist[${ij}]="Journal of Atmospheric and Oceanic Technology" |
---|
362 | ij=$(( ${ij} + 1)) |
---|
363 | jlist[${ij}]="Lecture Notes in Computational Science Engineering" |
---|
364 | ij=$(( ${ij} + 1)) |
---|
365 | jlist[${ij}]="In Greenhouse Gas Control Technologies" |
---|
366 | ij=$(( ${ij} + 1)) |
---|
367 | jlist[${ij}]="Chemical Geology" |
---|
368 | ij=$(( ${ij} + 1)) |
---|
369 | jlist[${ij}]="Marine Geology" |
---|
370 | ij=$(( ${ij} + 1)) |
---|
371 | jlist[${ij}]="Developments in Paleoenvironmental Research" |
---|
372 | ij=$(( ${ij} + 1)) |
---|
373 | jlist[${ij}]="Science" |
---|
374 | ij=$(( ${ij} + 1)) |
---|
375 | jlist[${ij}]="In Mediterranean Climate Variability" |
---|
376 | ij=$(( ${ij} + 1)) |
---|
377 | jlist[${ij}]="Global and Planetary Change" |
---|
378 | ij=$(( ${ij} + 1)) |
---|
379 | jlist[${ij}]="Physical Review Letters" |
---|
380 | # |
---|
381 | # following Journal name are fake ones for demo1 : references extracted from |
---|
382 | # Cantratrix Sopronica L. written by Georges Perec |
---|
383 | #find in http://www-rocq.inria.fr/who/Marc.Thiriet/PsFil/Biblio/cantatrix.ps |
---|
384 | ij=$(( ${ij} + 1)) |
---|
385 | jlist[$ij]="Res. Proc. neurophysiol. Fanatic Soc." |
---|
386 | ij=$(( ${ij} + 1)) |
---|
387 | jlist[$ij]="New Records Ass. J." |
---|
388 | ij=$(( ${ij} + 1)) |
---|
389 | jlist[$ij]="Am. J. Allegrol." |
---|
390 | ij=$(( ${ij} + 1)) |
---|
391 | jlist[$ij]="J. Neurochem. Neurocytol. Enzymol." |
---|
392 | ij=$(( ${ij} + 1)) |
---|
393 | jlist[$ij]="Hammersmith J." |
---|
394 | ij=$(( ${ij} + 1)) |
---|
395 | jlist[$ij]="Nasa Rept." |
---|
396 | ij=$(( ${ij} + 1)) |
---|
397 | jlist[$ij]="C.r. Assoc. Conc. Lam." |
---|
398 | ij=$(( ${ij} + 1)) |
---|
399 | jlist[$ij]="Gaz. med. franco-rus." |
---|
400 | ij=$(( ${ij} + 1)) |
---|
401 | jlist[$ij]="Amer. J. music. Deciency" |
---|
402 | # |
---|
403 | cat <<EOF > ${fileou} |
---|
404 | <?xml version='1.0' encoding='ISO-8859-1'?> |
---|
405 | <bibliography |
---|
406 | version="5.0" |
---|
407 | xmlns="http://docbook.org/ns/docbook" |
---|
408 | xml:id="bib${project}ref" |
---|
409 | xml:lang="${lang}"> |
---|
410 | |
---|
411 | <info> |
---|
412 | <date>$( date -u +"%Y-%m-%dT%H:%M:%SZ" )</date> |
---|
413 | </info> |
---|
414 | EOF |
---|
415 | unset lang |
---|
416 | # |
---|
417 | # strip comments |
---|
418 | fileraw_strict=/tmp/$(basename ${fileraw})_strict |
---|
419 | grep -v "^#" ${fileraw} > ${fileraw_strict} |
---|
420 | totlines=$( wc -l ${fileraw_strict} | awk '{print $1}' ) |
---|
421 | l=1 |
---|
422 | while [ ${l} -le ${totlines} ] |
---|
423 | do |
---|
424 | # extract one line |
---|
425 | line=$( sed -n ${l}p ${fileraw_strict} ) |
---|
426 | orgline=$( echo ${line} | sed -e "s/--/- -/g" ) |
---|
427 | line=$( echo ${line} | sed -e "s/</\</g" -e "s/>/\>/g" ) |
---|
428 | # detect if bibtex or not bibtex (starting with @) |
---|
429 | if [ ${line:0:1} != "@" ] |
---|
430 | then |
---|
431 | # parsing non bibtex line |
---|
432 | bibtex=0 |
---|
433 | # before the first : |
---|
434 | tmp=${line%%:*} |
---|
435 | # before the last , |
---|
436 | auths=${tmp%,*}, |
---|
437 | # replace "and" by "," |
---|
438 | auths=$( echo "${auths}" | sed -e "s/ and /,/g" ) |
---|
439 | # after the last , |
---|
440 | year=${tmp##*,} |
---|
441 | year=$( rmbl "${year}" ) |
---|
442 | ## first author before the first ., |
---|
443 | first=${auths%%.,*}. |
---|
444 | # its firstname after the last , |
---|
445 | firstfn=${first##*,} |
---|
446 | firstfn=$( rmbl "${firstfn}" ) |
---|
447 | # its surname ; before the first , |
---|
448 | firstsn=${first%%,*} |
---|
449 | firstsn=$( rmbl "${firstsn}" ) |
---|
450 | ## ref id |
---|
451 | refid=$( echo ${firstsn} | tr "[:upper:]" "[:lower:]" | tr -s " " "_" | tr -s "'" "_" | recode -d -f ISO-8859-1..flat )${year} |
---|
452 | num=$( grep -c "<biblioentry xml:id=\"${refid}_[0-9][0-9]\">" ${fileou} ) |
---|
453 | num=$(( ${num} + 1 )) |
---|
454 | [ ${num} -le 9 ] && num=0${num} |
---|
455 | refid=${refid}_${num} |
---|
456 | hasauthor=1 |
---|
457 | else |
---|
458 | # parsing bibtex line |
---|
459 | bibtex=1 |
---|
460 | # before the first , |
---|
461 | tmp=${line%%,*} |
---|
462 | endline=${line#*,} |
---|
463 | # refid is after { and before the first comma |
---|
464 | refid=${tmp#*{} |
---|
465 | # ++ test if refid already exist |
---|
466 | # check if author field is there |
---|
467 | echo ${endline} | grep -q "author" |
---|
468 | hasauthor=${?} |
---|
469 | if [ ${hasauthor} -eq 0 ] |
---|
470 | then |
---|
471 | auths=$( echo ${endline} | awk -F "," '{print $1}' | sed -e "s/\(author * = *{\)\(.*\)\(}\)/\2/") |
---|
472 | #echo "auths $auths" # genre Michael Metcalf and John Reid and Malcolm Cohen |
---|
473 | else |
---|
474 | echo "pas d'auteurs" # ++ |
---|
475 | fi |
---|
476 | endline=${endline#*,} |
---|
477 | title=$( echo ${endline} | awk -F "," '{print $1}' | sed -e "s/\(title * = *{\)\(.*\)\(}\)/\2/") |
---|
478 | #echo "title : ${title}" |
---|
479 | endline=${endline#*,} |
---|
480 | #echo ${endline} | awk -F "," '{print $1}' #++debug |
---|
481 | year=$( echo ${endline} | awk -F "," '{print $1}' | sed -e "s/\(year * = *{\)\(.*\)\(}\)/\2/") |
---|
482 | endline=${endline#*,} |
---|
483 | publisher=$( echo ${endline} | awk -F "," '{print $1}' | sed -e "s/\(publisher * = *{\)\(.*\)\(}\)/\2/") |
---|
484 | endline=${endline#*,} |
---|
485 | edition=$( echo ${endline} | awk -F "," '{print $1}' | sed -e "s/\(edition * = *{\)\(.*\)\(}\)/\2/") |
---|
486 | endline=${endline#*,} |
---|
487 | isbn=$( echo ${endline} | awk -F "," '{print $1}' | sed -e "s/\(isbn * = *{\)\(.*\)\(}\)/\2/") |
---|
488 | endline=${endline#*,} |
---|
489 | pag=$( echo ${endline} | awk -F "," '{print $1}' | sed -e "s/\(page * = *{\)\(.*\)\(}\)/\2/") |
---|
490 | |
---|
491 | if [ ${hasauthor} -eq 1 ] |
---|
492 | then |
---|
493 | ## first author before the first and |
---|
494 | first=${auths%%and*} |
---|
495 | # its surname after the last " " ++ pas vrai double nom et pb blanc dans la syntaxe |
---|
496 | # firstsn=${first##* } . ok en interactif . pas ok en script |
---|
497 | firstsn=$( echo ${first} | awk '{print $2}') |
---|
498 | #echo "firstsn $firstsn" |
---|
499 | # its firstname before the first " " |
---|
500 | firstfn=${first%% *} |
---|
501 | fi |
---|
502 | fi |
---|
503 | |
---|
504 | cat <<EOF >> ${fileou} |
---|
505 | <biblioentry xml:id="${refid}"> |
---|
506 | <!-- date |
---|
507 | $( date -u +"%Y-%m-%dT%H:%M:%SZ" ) |
---|
508 | --> |
---|
509 | <!-- original text |
---|
510 | ${orgline} |
---|
511 | --> |
---|
512 | EOF |
---|
513 | if [ ${hasauthor} -eq 1 ] |
---|
514 | then |
---|
515 | cat <<EOF >> ${fileou} |
---|
516 | <authorgroup> |
---|
517 | <author> <personname> <surname>${firstsn}</surname> <firstname>${firstfn}</firstname> </personname> </author> |
---|
518 | EOF |
---|
519 | |
---|
520 | ## other authors.. |
---|
521 | if [ ${bibtex} -eq 0 ] |
---|
522 | then |
---|
523 | previous=${first}, |
---|
524 | # next authors... |
---|
525 | next=${auths##*${previous}} |
---|
526 | fi |
---|
527 | if [ ${bibtex} -eq 1 ] |
---|
528 | then |
---|
529 | previous=${first}"and " |
---|
530 | # next authors... |
---|
531 | #echo "auths ${auths}" |
---|
532 | next=${auths##*${previous}} |
---|
533 | if [ "${next}and " = "${previous}" ] |
---|
534 | then |
---|
535 | next="" |
---|
536 | fi |
---|
537 | fi |
---|
538 | #echo "previous ${previous}" |
---|
539 | #echo "next ${next}" |
---|
540 | # while the next author is not empty |
---|
541 | while [ "${next}" != "" ] |
---|
542 | do |
---|
543 | if [ ${bibtex} -eq 0 ] |
---|
544 | then |
---|
545 | # get the first next author; before the first , |
---|
546 | next=${next%%,*} |
---|
547 | # its surname ; after the last . |
---|
548 | nextsn=${next##*.} |
---|
549 | nextsn=$( rmbl "${nextsn}" ) |
---|
550 | # its firstname ; before the last . |
---|
551 | nextfn=${next%.*}. |
---|
552 | nextfn=$( rmbl "${nextfn}" ) |
---|
553 | fi |
---|
554 | if [ ${bibtex} -eq 1 ] |
---|
555 | then |
---|
556 | # get the first next author; before the first "and" |
---|
557 | next=${next%%and *} |
---|
558 | # its surname after the last " " ++ pas vrai double nom et pb blanc dans la syntaxe |
---|
559 | # nextsn=${next##* } . ok en interactif . pas ok en script |
---|
560 | nextsn=$( echo ${next} | awk '{print $2}') |
---|
561 | #echo "nextsn $nextsn" |
---|
562 | # its nextname before the first " " |
---|
563 | nextfn=${next%% *} |
---|
564 | fi |
---|
565 | # |
---|
566 | echo " <author> <personname> <surname>${nextsn}</surname> <firstname>${nextfn}</firstname> </personname> </author>" >> ${fileou} |
---|
567 | #echo " <author> <personname> <surname>${nextsn}</surname> <firstname>${nextfn}</firstname> </personname> </author>" #++debug |
---|
568 | if [ ${bibtex} -eq 0 ] |
---|
569 | then |
---|
570 | previous=${next}, |
---|
571 | next=${auths##*${previous}} |
---|
572 | fi |
---|
573 | if [ ${bibtex} -eq 1 ] |
---|
574 | then |
---|
575 | previous=${next}"and " |
---|
576 | next=${auths##*${previous}} |
---|
577 | fi |
---|
578 | done |
---|
579 | echo " </authorgroup>" >> ${fileou} |
---|
580 | fi |
---|
581 | |
---|
582 | # end of the line ; after the first : |
---|
583 | endline=${line#*:} |
---|
584 | ## find the journal |
---|
585 | j=1 |
---|
586 | jfound="" |
---|
587 | jlistsize=${#jlist[@]} |
---|
588 | while [[ ${j} -le ${jlistsize} && "${jfound}" == "" ]] |
---|
589 | do |
---|
590 | ok=$( echo ${endline} | grep -ci "${jlist[j]} *," ) |
---|
591 | [ ${ok} -eq 1 ] && jfound="${jlist[j]}" |
---|
592 | j=$(( ${j} + 1 )) |
---|
593 | done |
---|
594 | unset ok |
---|
595 | if [ "${jfound}" == "" ] |
---|
596 | then |
---|
597 | echo "eee: Journal not found " |
---|
598 | echo "${endline}" |
---|
599 | #++set |
---|
600 | #++exit 1 |
---|
601 | #+++ following lines are not yet validate |
---|
602 | # it might be a book, a manual, a conference, etc. ++ |
---|
603 | echo " <title>${title}</title>" >> ${fileou} |
---|
604 | cat <<EOF >> ${fileou} |
---|
605 | <biblioset relation="nojournal"> |
---|
606 | <title>${title}</title> |
---|
607 | <pagenums>${pag}</pagenums> |
---|
608 | <pubdate>${year}</pubdate> |
---|
609 | </biblioset> |
---|
610 | EOF |
---|
611 | cat <<EOF >> ${fileou} |
---|
612 | </biblioentry> |
---|
613 | |
---|
614 | EOF |
---|
615 | fi # end of if jfound empty (ie not an article) |
---|
616 | if [ "${jfound}" != "" ] |
---|
617 | then |
---|
618 | ## title |
---|
619 | # before the first : |
---|
620 | title=${endline%%${jfound}*} |
---|
621 | title=$( cleanname "${title}" ) |
---|
622 | echo " <title>${title}</title>" >> ${fileou} |
---|
623 | ## end |
---|
624 | ## end of the line ; after the first ${jfound} |
---|
625 | endline=${endline#*${jfound}} |
---|
626 | endline=$( cleanname "${endline}" ) |
---|
627 | ## doi |
---|
628 | endline=$( echo ${endline} | sed -e "s/[dD][oO][iI] *\t* *: *\t* */doi:/" ) |
---|
629 | ok=$( echo ${endline} | grep -ic "doi:" ) |
---|
630 | if [ ${ok} -eq 1 ] |
---|
631 | then |
---|
632 | doi=${endline##*doi:} |
---|
633 | echo " <biblioid class=\"doi\">${doi}</biblioid>" >> ${fileou} |
---|
634 | unset doi |
---|
635 | endline=${endline%doi:*} |
---|
636 | endline=$( cleanname "${endline}" ) |
---|
637 | else |
---|
638 | echo "non doi: ${line}" |
---|
639 | echo "" |
---|
640 | fi |
---|
641 | num=$( echo ${endline} | tr -dc "," | wc -c ) |
---|
642 | case ${num} in |
---|
643 | 0) |
---|
644 | ### echo ${num}: ${endline} |
---|
645 | cat <<EOF >> ${fileou} |
---|
646 | <biblioset relation="journal"> |
---|
647 | <title>${jfound}</title> |
---|
648 | <pubdate>${year}</pubdate> |
---|
649 | <bibliomisc>${endline}</bibliomisc> |
---|
650 | </biblioset> |
---|
651 | EOF |
---|
652 | unset jfound |
---|
653 | unset year |
---|
654 | ;; |
---|
655 | |
---|
656 | 1) |
---|
657 | ### echo ${num}: ${endline} |
---|
658 | vol=${endline%,*} |
---|
659 | vol=$( cleanname "${vol}" ) |
---|
660 | pag=${endline##*,} |
---|
661 | pag=$( cleanname "${pag}" ) |
---|
662 | cat <<EOF >> ${fileou} |
---|
663 | <biblioset relation="journal"> |
---|
664 | <title>${jfound}</title> |
---|
665 | <volumenum>${vol}</volumenum><pagenums>${pag}</pagenums> |
---|
666 | <pubdate>${year}</pubdate> |
---|
667 | </biblioset> |
---|
668 | EOF |
---|
669 | unset vol |
---|
670 | unset pag |
---|
671 | unset jfound |
---|
672 | unset year |
---|
673 | ;; |
---|
674 | 2) |
---|
675 | vol=${endline%,*} |
---|
676 | vol=$( cleanname "${vol}" ) |
---|
677 | iss=${vol##*,} |
---|
678 | iss=$( cleanname "${iss}" ) |
---|
679 | vol=${vol%,*} |
---|
680 | vol=$( cleanname "${vol}" ) |
---|
681 | pag=${endline##*,} |
---|
682 | pag=$( cleanname "${pag}" ) |
---|
683 | cat <<EOF >> ${fileou} |
---|
684 | <biblioset relation="journal"> |
---|
685 | <title>${jfound}</title> |
---|
686 | <volumenum>${vol}</volumenum><issuenum>${iss}</issuenum><pagenums>${pag}</pagenums> |
---|
687 | <pubdate>${year}</pubdate> |
---|
688 | </biblioset> |
---|
689 | EOF |
---|
690 | unset vol |
---|
691 | unset pag |
---|
692 | unset jfound |
---|
693 | unset year |
---|
694 | unset iss |
---|
695 | ;; |
---|
696 | 6) |
---|
697 | conftitle=${endline%%,*} |
---|
698 | endline=${endline#*,} |
---|
699 | confdates=${endline%%,*} # day(s) month |
---|
700 | endline=${endline#*,} |
---|
701 | confdates="${confdates}, ${endline%%,*}" # day(s) month and year |
---|
702 | confdates=$( cleanname "${confdates}" ) |
---|
703 | endline=${endline#*,} |
---|
704 | confaddress=${endline%%,*} # Town |
---|
705 | endline=${endline#*,} |
---|
706 | confaddress="${confaddress}, ${endline%%,*}" # Town and country |
---|
707 | confaddress=$( cleanname "${confaddress}" ) |
---|
708 | endline=${endline#*,} |
---|
709 | publishername=${endline%%,*} |
---|
710 | publishername=$( cleanname "${publishername}" ) |
---|
711 | endline=${endline#*,} |
---|
712 | pag=${endline##*,} |
---|
713 | pag=$( cleanname "${pag}" ) |
---|
714 | #set |
---|
715 | #read a |
---|
716 | cat <<EOF >> ${fileou} |
---|
717 | <biblioset relation="conference"> |
---|
718 | <title>${jfound}</title> |
---|
719 | <pubdate>${year}</pubdate> |
---|
720 | <publisher><publishername>${publishername}</publishername></publisher> |
---|
721 | <pagenums>${pag}</pagenums> |
---|
722 | <confgroup> |
---|
723 | <conftitle>${conftitle}</conftitle> |
---|
724 | <confdates>${confdates}</confdates> |
---|
725 | <address>${confaddress}</address> |
---|
726 | </confgroup> |
---|
727 | </biblioset> |
---|
728 | EOF |
---|
729 | unset confaddress |
---|
730 | unset conftitle |
---|
731 | unset confdates |
---|
732 | unset pag |
---|
733 | unset publishername |
---|
734 | unset year |
---|
735 | unset jfound |
---|
736 | ;; |
---|
737 | 10) |
---|
738 | publishername=${endline%%Editors,*} |
---|
739 | publishername="${publishername} Editors" |
---|
740 | publishername=$( cleanname "${publishername}" ) |
---|
741 | endline=${endline#*Editors,} |
---|
742 | vol=${endline%%,*} |
---|
743 | vol=$( cleanname "${vol}" ) |
---|
744 | endline=${endline#*,} |
---|
745 | pag=${endline%%,*} |
---|
746 | pag=$( cleanname "${pag}" ) |
---|
747 | endline=${endline#*,} |
---|
748 | isbn=${endline%%,*} |
---|
749 | isbn=$(echo ${isbn} | sed -e "s/ISBN ://") |
---|
750 | isbn=$( cleanname "${isbn}" ) |
---|
751 | endline=${endline#*,} |
---|
752 | agu=${endline%%,*} |
---|
753 | agu=$(echo ${agu} | sed -e "s/AGU ://") |
---|
754 | agu=$( cleanname "${agu}" ) |
---|
755 | |
---|
756 | endline=${endline#*${agu}} |
---|
757 | endline=$( cleanname "${endline}" ) |
---|
758 | endline=$( cleanname "${endline}" ) |
---|
759 | |
---|
760 | cat <<EOF >> ${fileou} |
---|
761 | <biblioid class="isbn">${isbn}</biblioid> |
---|
762 | <biblioid class="other" otherclass="AGU">${agu}</biblioid> |
---|
763 | <biblioset relation="journal"> |
---|
764 | <title>${jfound}</title> |
---|
765 | <pubdate>${year}</pubdate> |
---|
766 | <publisher><publishername>${publishername}</publishername></publisher> |
---|
767 | <volumenum>${vol}</volumenum> |
---|
768 | <pagenums>${pag}</pagenums> |
---|
769 | <bibliomisc>${endline}</bibliomisc> |
---|
770 | </biblioset> |
---|
771 | EOF |
---|
772 | unset isbn |
---|
773 | unset agu |
---|
774 | unset pag |
---|
775 | unset publishername |
---|
776 | unset year |
---|
777 | unset jfound |
---|
778 | unset vol |
---|
779 | |
---|
780 | ;; |
---|
781 | *) |
---|
782 | echo ${num}: ${endline} # ++debug |
---|
783 | #set |
---|
784 | #exit 1 #++ debug |
---|
785 | cat <<EOF >> ${fileou} |
---|
786 | <biblioset relation="journal"> |
---|
787 | <title>${jfound}</title> |
---|
788 | <pubdate>${year}</pubdate> |
---|
789 | <bibliomisc>${endline}</bibliomisc> |
---|
790 | </biblioset> |
---|
791 | EOF |
---|
792 | ;; |
---|
793 | esac |
---|
794 | |
---|
795 | cat <<EOF >> ${fileou} |
---|
796 | </biblioentry> |
---|
797 | |
---|
798 | EOF |
---|
799 | fi # end of if jfound not empty |
---|
800 | unset title |
---|
801 | unset vol |
---|
802 | unset year |
---|
803 | unset pag |
---|
804 | l=$(( ${l} + 1 )) |
---|
805 | |
---|
806 | done |
---|
807 | unset totlines |
---|
808 | unset l |
---|
809 | echo "</bibliography>" >> ${fileou} |
---|
810 | |
---|
811 | xml val --err \ |
---|
812 | --xsd http://www.docbook.org/xml/5.0/xsd/docbook.xsd \ |
---|
813 | ${fileou} 1> xmlstarlet.log 2>&1 |
---|
814 | |
---|
815 | # clean |
---|
816 | echo "iii : xslstarlet.log contains sdtout and stderr from xml command on ${fileou}" |
---|
817 | echo "iii : which was done just to check consistence of ${fileou}" |
---|
818 | more xmlstarlet.log |
---|
819 | rm -i xmlstarlet.log |
---|
820 | # |
---|
821 | case ${type} in |
---|
822 | raw) |
---|
823 | echo "iii : ${fileraw_strict} contains a copy of input file without comments" |
---|
824 | rm -i ${fileraw_strict} |
---|
825 | ;; |
---|
826 | mailbody) |
---|
827 | echo "iii : ${fileraw} contains a copy of input file" |
---|
828 | rm -i ${fileraw} |
---|
829 | echo "iii : ${fileraw_strict} contains a copy of input file without comments" |
---|
830 | rm -i ${fileraw_strict} |
---|
831 | ;; |
---|
832 | esac |
---|
833 | # |
---|
834 | echo " iii : you have a some new or modified bibliographic references in ${fileou} (biblioentry)" |
---|
835 | echo " iii : you can add them in ${fileou}" #++ filename path |
---|
836 | echo " iii : modify date in ${fileou}" #++ filename path |
---|
837 | echo " iii : but please take care of id last part (after underscore) that may" |
---|
838 | echo " iii : be in conflict with existing ones" #++ pour s'affranchir de ce souci il faudrait donner en entrée complémentaire le fichier à compléter. |
---|
839 | # |
---|
840 | exit 0 |
---|