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