1 | #!/bin/bash |
---|
2 | #+ |
---|
3 | # |
---|
4 | # .. _bibopa.sh: |
---|
5 | # |
---|
6 | # .. program:: bibopa.sh |
---|
7 | # |
---|
8 | # ========= |
---|
9 | # bibopa.sh |
---|
10 | # ========= |
---|
11 | # |
---|
12 | # SYNOPSIS |
---|
13 | # ======== |
---|
14 | # |
---|
15 | # .. code-block:: bash |
---|
16 | # |
---|
17 | # bibopa.sh -tmpdir tmpdir -i filein -e encoding -ti typein -o order -p project -l lang -to typeout |
---|
18 | # |
---|
19 | # DESCRIPTION |
---|
20 | # =========== |
---|
21 | # |
---|
22 | # .. option:: -tmpdir <tmpdir> |
---|
23 | # .. option:: -i <filein> |
---|
24 | # .. option:: -ti <typein> |
---|
25 | # .. option:: -e <encoding> |
---|
26 | # |
---|
27 | # default is encoding="iso-8859-1" |
---|
28 | # |
---|
29 | # .. option:: -o <order> |
---|
30 | # .. option:: -p <project> |
---|
31 | # .. option:: -l <lang> |
---|
32 | # .. option:: -to <typeout> |
---|
33 | # |
---|
34 | # transform a bibliography file in XML/DocBook 5 format |
---|
35 | # |
---|
36 | # Each entry in the same input file must follows the same order for authors |
---|
37 | # except the first one. |
---|
38 | # |
---|
39 | # With ``fs`` in option :option:`-o order` you will correctly process raw entry with |
---|
40 | # firstname and surname in this order for authors except the first one. |
---|
41 | # |
---|
42 | # If raw entry uses surname and firstname order, you should use ``sf``. |
---|
43 | # |
---|
44 | # .. parsed-literal:: |
---|
45 | # |
---|
46 | # Behera, S. K., J. Luo, S. Masson, S. Rao, S. Gualdi, P. Delecluse, A. |
---|
47 | # Navarra and T. Yamagata, 2004 : Paramount Impact of the Indian Ocean |
---|
48 | # Dipole on the East African Short Rains: A CGCM Study, J. Climate, In |
---|
49 | # press. |
---|
50 | # |
---|
51 | # donnerait |
---|
52 | # |
---|
53 | # .. parsed-literal:: |
---|
54 | # |
---|
55 | # <biblioentry xml:id="behara2004"> |
---|
56 | # <authorgroup> |
---|
57 | # <author><surname>Behera</surname> <firstname>S. K.</firstname> </author> |
---|
58 | # <author><firstname>J.</firstname> <surname>Luo</surname></author> |
---|
59 | # <author><firstname>S.</firstname> <surname>Masson</surname></author> |
---|
60 | # <author><firstname>S.</firstname> <surname>Rao</surname></author> |
---|
61 | # <author><firstname>S.</firstname> <surname>Gualdi</surname></author> |
---|
62 | # <author><firstname>P.</firstname> <surname>Delecluse</surname></author> |
---|
63 | # <author><firstname>A.</firstname> <surname>Navara</surname></author> |
---|
64 | # <author><firstname>T.</firstname> <surname>Yamagata</surname></author> |
---|
65 | # </authorgroup> |
---|
66 | # <date>2004</date> |
---|
67 | # <title>Paramount Impact of the Indian Ocean Dipole on the East African |
---|
68 | # Short Rains: A CGCM Study</title> |
---|
69 | # <publishername>J. Climate</publishername> |
---|
70 | # <biblioid class="doi">doi</biblioid> |
---|
71 | # <bibliomisc role="pseudoref">In press.</bibliomisc> |
---|
72 | # <bibliomisc role="internalref">from |
---|
73 | # http://www.lodyc.jussieu.fr/~opatlod/NEMO_v1/6_Menu/2_page/index.html |
---|
74 | # 2007-03-29T16:24:31Z fplod by hand</bibliomisc> |
---|
75 | # </biblioentry> |
---|
76 | # |
---|
77 | # .. parsed-literal:: |
---|
78 | # |
---|
79 | # @book{MetReiCoh2004 , |
---|
80 | # author = {Michael Metcalf and |
---|
81 | # John Reid and Malcolm Cohen}, |
---|
82 | # title = {Fortran 95/2003 explained}, |
---|
83 | # year = {2004}, |
---|
84 | # publisher = {Oxford University Press}, |
---|
85 | # edition = {Third}, |
---|
86 | # ISBN = {0-19-852693-8}, |
---|
87 | # pages = {434} |
---|
88 | # } |
---|
89 | # |
---|
90 | # donnerait |
---|
91 | # |
---|
92 | # .. parsed-literal:: |
---|
93 | # |
---|
94 | # <biblioentry xml:id="MetReiCoh2004"> |
---|
95 | # <authorgroup> |
---|
96 | # <author><firstname>Michael</firstname> <surname>Metcalf</surname></author> |
---|
97 | # <author><firstname>John</firstname> <surname>Reid</surname></author> |
---|
98 | # <author><firstname>Malcolm</firstname> <surname>Cohen</surname></author> |
---|
99 | # </authorgroup> |
---|
100 | # <date>2004}</date> |
---|
101 | # <title>Fortran 95/2003 explained</title> |
---|
102 | # <publisher><publishername>Oxford University Press</publishername></publisher> |
---|
103 | # <biblioid class="isbn">0-19-852693-8</biblioid> |
---|
104 | # <pagenums>434</pagenums> |
---|
105 | # <edition>Third</edition> |
---|
106 | # |
---|
107 | # EXAMPLES |
---|
108 | # ======== |
---|
109 | # |
---|
110 | # To transform the NEMO bibliography file written in raw format to XML/DocBook: |
---|
111 | # |
---|
112 | # .. code-block:: bash |
---|
113 | # |
---|
114 | # bibopa.sh -tmpdir /tmp -p birefnemo -i data/biball.txt -ti raw |
---|
115 | # |
---|
116 | # To transform a bibliography file written mailbody format to XML/DocBook: |
---|
117 | # |
---|
118 | # .. code-block:: bash |
---|
119 | # |
---|
120 | # bibopa.sh -tmpdir /tmp -p bibrefnemo -i data/mail2007-05-10T09:01:56Z -ti mailbody |
---|
121 | # |
---|
122 | # To transform a bibliography file written in bibtex format in french to XML/DocBook: |
---|
123 | # |
---|
124 | # .. code-block:: bash |
---|
125 | # |
---|
126 | # bibopa.sh -tmpdir /tmp -p polyfortran -i data/petitpolyfp.bib -ti bibtex -l fr |
---|
127 | # |
---|
128 | # To transform the SUPERBIB demo bibliography file written in raw format to XML/DocBook: |
---|
129 | # |
---|
130 | # .. code-block:: bash |
---|
131 | # |
---|
132 | # bibopa.sh -tmpdir /tmp -p demo1 -i data/bibdemo1.txt -ti raw -l fr |
---|
133 | # |
---|
134 | # Less official but possible: |
---|
135 | # |
---|
136 | # To transform the NEMO bibliography file written in raw format to bibtex: |
---|
137 | # |
---|
138 | # .. code-block:: bash |
---|
139 | # |
---|
140 | # bibopa.sh -tmpdir /tmp -p nemo -ti raw -to bib -i bibnemo.txt |
---|
141 | # |
---|
142 | # SEE ALSO |
---|
143 | # ======== |
---|
144 | # |
---|
145 | # :ref:`mailtouser.sh` |
---|
146 | # |
---|
147 | # TODO |
---|
148 | # ==== |
---|
149 | # |
---|
150 | # gestion des comments |
---|
151 | # |
---|
152 | # gestion des id existants (cf à la fin) |
---|
153 | # |
---|
154 | # option debug |
---|
155 | # |
---|
156 | # should use iconv instead of recode |
---|
157 | # for portability issue but not found yet the "flat" functionality in |
---|
158 | # iconv |
---|
159 | # tips 20101006 : iconv: //TRANSLIT feature not documented cf. |
---|
160 | # http://www.gnu.org/software/libiconv/documentation/libiconv/iconv_open.3.html |
---|
161 | # not already used because non-standard usage |
---|
162 | # |
---|
163 | # write something in the logfile ! |
---|
164 | # |
---|
165 | # handle fully written firstnames like in: |
---|
166 | # |
---|
167 | # .. parsed-literal:: |
---|
168 | # |
---|
169 | # Tsimplis, Michael, Marta Marcos, Jeanne Colin, Samuel Somot, Ananda Pascual, A.G.P. Shaw, 2009 : Sea level variability in the Mediterranean Sea during the 1990s on the basis of two 2d and one 3d model, Journal of Marine Systems, 78, 1, 109-123, doi:10.1016/j.jmarsys.2009.04.003 |
---|
170 | # |
---|
171 | # EVOLUTIONS |
---|
172 | # ========== |
---|
173 | # |
---|
174 | # $Id$ |
---|
175 | # |
---|
176 | # - fplod 20131017T085825Z callisto.locean-ipsl.upmc.fr (Linux) |
---|
177 | # |
---|
178 | # * add tmpdir argument |
---|
179 | # * dynamic xmlstarlet vs xml |
---|
180 | # * add journal "Earth and Planetary Sciences, série IIa, Paris," |
---|
181 | # (nb : diacritics tricks) |
---|
182 | # |
---|
183 | # - fplod 20130423T143122Z cratos.locean-ipsl.upmc.fr (Linux) |
---|
184 | # |
---|
185 | # * add encoding option for input file (too tricky to be implemented see |
---|
186 | # http://stackoverflow.com/questions/805418/how-to-find-encoding-of-a-file-in-unix-via-scripts) |
---|
187 | # |
---|
188 | # - fplod 20120227 |
---|
189 | # |
---|
190 | # * xmlstarlet vs xml |
---|
191 | # |
---|
192 | # - fplod 20101006T113902Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
193 | # |
---|
194 | # * add "Remote Sensing Env." |
---|
195 | # * add "Ocean Sciences" |
---|
196 | # * add "Dynamics of Atmospheres and Oceans" |
---|
197 | # * add "Comptes Rendus Geoscience" |
---|
198 | # * add "Marine Pollution Bulletin" |
---|
199 | # * add "Continental Shelf Research" |
---|
200 | # * add ""Ocean Sci." |
---|
201 | # * add "Environmental Fluid Mechanics" |
---|
202 | # * add "Geochem. Geophys. Geosyst." |
---|
203 | # * add "Journal of Applied Meteorology and Climatology" |
---|
204 | # * add "Monthly Weather Review" |
---|
205 | # * add "High Performance Computing on Vector Systems 2007" |
---|
206 | # * add "High Performance Computing on Vector Systems 2006" |
---|
207 | # * add "High Performance Computing in Science and Engineering '08" |
---|
208 | # * add "Developments in Earth and Environmental Sciences" |
---|
209 | # * add "Oceanography" |
---|
210 | # |
---|
211 | # - fplod 20101006T100532Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
212 | # |
---|
213 | # * bug fix (misplaced EOF) |
---|
214 | # * replace -t option by -ti |
---|
215 | # * add -to (typeout) option (by default dbk) |
---|
216 | # * add bibtex production |
---|
217 | # |
---|
218 | # - fplod 2009-03-13T09:35:42Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
219 | # |
---|
220 | # * add "High Performance Computing in Science and Engineering" |
---|
221 | # * add "Annals of Glaciology" |
---|
222 | # * add "Journal of Physical Oceanography" |
---|
223 | # |
---|
224 | # - fplod 2009-01-15T10:36:18Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
225 | # |
---|
226 | # * add description of ``-o`` option |
---|
227 | # * add journal "PNAS" |
---|
228 | # * add journal "Lettre PIGB-PMRC" |
---|
229 | # |
---|
230 | # - fplod 2009-01-14T15:27:48Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
231 | # |
---|
232 | # * add journal "Water Resources Research" |
---|
233 | # * add journal "Climate Research" |
---|
234 | # * add conf "Colloque du GIS « Climat-Environnement-Sociétés »" |
---|
235 | # * add journal "Agricultural and Forest Meteorology" |
---|
236 | # * add conf "VIIth IAHS Scientific Assembly" |
---|
237 | # * add conf "AGU fall Meeting" |
---|
238 | # * add journal "Phil. Trans. Roy. Soc. B" |
---|
239 | # * add journal "Phil. Trans. Roy. Soc. B" |
---|
240 | # * add conf "4th Alexander Von Humboldt International Conference" |
---|
241 | # * add journal/conf "??" (Should not be used too much !) |
---|
242 | # * add journal "Nature Geosciences" |
---|
243 | # * add journal "International Journal of Climatology" |
---|
244 | # * add journal "Journal of Hydrology" |
---|
245 | # * add journal "Revue de l'Ãnergie" |
---|
246 | # * add journal "Clim. Res." |
---|
247 | # * add journal "Hydrol. Earth Sys. Sci." |
---|
248 | # * add journal "Ambio" |
---|
249 | # * add journal "Theoretical and applied climatology" |
---|
250 | # * add journal "Remote Sensing of Environnement" |
---|
251 | # |
---|
252 | # - fplod 2008-10-28T11:40:19Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
253 | # |
---|
254 | # * add journal "Progress In Oceanography" |
---|
255 | # * add journal "Climatic Change" |
---|
256 | # * add journal "Ocean Dynamics" |
---|
257 | # * add journal "Phil. Trans. Roy. Soc. A" |
---|
258 | # * add journal "Izvestiya Atmospheric and Oceanic Physics" |
---|
259 | # * add journal "Journal of Hydrometeorology" |
---|
260 | # * add journal "Remote Sensing of Environment" |
---|
261 | # * add journal "Oceanology" |
---|
262 | # * add journal "Water Resour. Res." |
---|
263 | # * add journal "Advances in Atmospheric Sciences" |
---|
264 | # * add journal "Quaternary Science Reviews" |
---|
265 | # * replace "Elsevier Oceanography Series" by "Elsevier Oceanographic Series" |
---|
266 | # * bug fix : unclosed date tag |
---|
267 | # * trouble with flat conversion for id building ... |
---|
268 | # * remove interactivity at then end (allowing redirection of stderr and |
---|
269 | # stdout) |
---|
270 | # * strip blank lines |
---|
271 | # * bug fix : counting nb of occurrences of "," technique ... to be improved |
---|
272 | # |
---|
273 | # - fplod 2008-09-16T15:19:59Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
274 | # |
---|
275 | # * comments in reStructuredText |
---|
276 | # |
---|
277 | # - fplod 2008-05-16T10:33:16Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
278 | # |
---|
279 | # * add parameter -o for firstname/surname order in bibtex file |
---|
280 | # |
---|
281 | # - fplod 2008-05-15T15:15:04Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
282 | # |
---|
283 | # * new way of processing bibtex file : external/bibtex2xml.py |
---|
284 | # |
---|
285 | # - fplod 2008-04-30T07:11:58Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
286 | # |
---|
287 | # * chgt for dbk5 out |
---|
288 | # * xmlto 0.0.18 does'nt like this docbook release. remove |
---|
289 | # * usage of xml (xmlstarlet) for validation |
---|
290 | # * bug fix |
---|
291 | # * add journal names from demo1 |
---|
292 | # * fplod 2008-03-12T16:11:07Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
293 | # * add -p option (to overide bibrefnemo in file name and id) |
---|
294 | # * add -l option by default en |
---|
295 | # |
---|
296 | # - fplod 2008-03-11T11:25:27Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
297 | # |
---|
298 | # * add bibtex entry (not finished) |
---|
299 | # |
---|
300 | # - fplod 2007-06-20T17:18:02Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
301 | # |
---|
302 | # * <bibliomisc role="id"> replace by <biblioid class="doi"> |
---|
303 | # |
---|
304 | # - smasson 2007-06-07T16:43:42Z arete.locean-ipsl.upmc.fr (Darwin) |
---|
305 | # |
---|
306 | # * Add journals |
---|
307 | # |
---|
308 | # - fplod 2007-05-10T09:17:09Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
309 | # |
---|
310 | # * derniÚres touches |
---|
311 | # |
---|
312 | # - fplod 2007-04-25T10:59:49Z cerbere.locean-ipsl.upmc.fr (Linux) |
---|
313 | # |
---|
314 | # * add a filein parameter and an option for mailbody |
---|
315 | # * comments (line beginning with #) are now possible |
---|
316 | # |
---|
317 | # - Sebastien Masson avril 2007 |
---|
318 | # |
---|
319 | # * creation |
---|
320 | # |
---|
321 | #- |
---|
322 | |
---|
323 | rmbl () { |
---|
324 | echo "${1}" | sed -e "s/^ *//" | sed -e "s/ *$//" |
---|
325 | } |
---|
326 | cleanname () { |
---|
327 | echo "${1}" | sed -e "s/^ *//" \ |
---|
328 | -e "s/^ *,//" \ |
---|
329 | -e "s/^ *;//" \ |
---|
330 | -e "s/^ *\.//" \ |
---|
331 | -e "s/ *$//" \ |
---|
332 | -e "s/, *$//" \ |
---|
333 | -e "s/; *$//" \ |
---|
334 | -e "s/\. *$//" |
---|
335 | } |
---|
336 | # |
---|
337 | system=$(uname) |
---|
338 | case "${system}" in |
---|
339 | AIX|IRIX64) |
---|
340 | echo " www : no specific posix checking" |
---|
341 | ;; |
---|
342 | Darwin) |
---|
343 | ;; |
---|
344 | *) |
---|
345 | set -o posix |
---|
346 | ;; |
---|
347 | esac |
---|
348 | unset system |
---|
349 | # |
---|
350 | set -u |
---|
351 | # |
---|
352 | command=$(basename ${0}) |
---|
353 | log_date=$(date -u +"%Y%m%dT%H%M%SZ") |
---|
354 | log=/tmp/$(basename ${command} .sh).log.${log_date} |
---|
355 | # |
---|
356 | # test if xsltproc is available |
---|
357 | tool=xsltproc |
---|
358 | type ${tool} 1> /dev/null 2>&1 |
---|
359 | status=${?} |
---|
360 | if [ ${status} -ne 0 ] |
---|
361 | then |
---|
362 | echo " eee : ${tool} not found" |
---|
363 | exit 1 |
---|
364 | fi |
---|
365 | unset status |
---|
366 | unset tool |
---|
367 | # |
---|
368 | # test if xml is available |
---|
369 | tool=${xmlcmd} |
---|
370 | type ${tool} 1> /dev/null 2>&1 |
---|
371 | status=${?} |
---|
372 | if [ ${status} -ne 0 ] |
---|
373 | then |
---|
374 | echo " eee : ${tool} not found" |
---|
375 | exit 1 |
---|
376 | fi |
---|
377 | unset status |
---|
378 | unset tool |
---|
379 | # |
---|
380 | # test if python is available |
---|
381 | tool=python |
---|
382 | type ${tool} 1> /dev/null 2>&1 |
---|
383 | status=${?} |
---|
384 | if [ ${status} -ne 0 ] |
---|
385 | then |
---|
386 | echo " eee : ${tool} not found" |
---|
387 | exit 1 |
---|
388 | fi |
---|
389 | unset status |
---|
390 | unset tool |
---|
391 | # |
---|
392 | # test if recode is available |
---|
393 | tool=recode |
---|
394 | type ${tool} 1> /dev/null 2>&1 |
---|
395 | status=${?} |
---|
396 | if [ ${status} -ne 0 ] |
---|
397 | then |
---|
398 | echo " eee : ${tool} not found" |
---|
399 | exit 1 |
---|
400 | fi |
---|
401 | unset status |
---|
402 | unset tool |
---|
403 | # |
---|
404 | usage=" Usage : ${command} -tmpdir tmpdir -i filein -ti typein -e encoding -o order -p project -l lang -to typeout" |
---|
405 | # |
---|
406 | # default |
---|
407 | lang=en |
---|
408 | # fs mean "firstname surname" |
---|
409 | order="fs" |
---|
410 | typeout="dbk" |
---|
411 | encoding="iso-8859-1" |
---|
412 | tmpdir="/tmp" |
---|
413 | # |
---|
414 | minargcount=8 |
---|
415 | #echo " narg ${#}" |
---|
416 | if [ ${#} -lt ${minargcount} ] |
---|
417 | then |
---|
418 | echo "eee : not enough arguments" |
---|
419 | echo "${usage}" |
---|
420 | exit 1 |
---|
421 | fi |
---|
422 | unset minargcount |
---|
423 | # |
---|
424 | while [ ${#} -gt 0 ] |
---|
425 | do |
---|
426 | case ${1} in |
---|
427 | -tmpdir) |
---|
428 | tmpdir=${2} |
---|
429 | shift |
---|
430 | ;; |
---|
431 | -i) |
---|
432 | filein=${2} |
---|
433 | shift |
---|
434 | ;; |
---|
435 | -ti) |
---|
436 | typein=${2} |
---|
437 | shift |
---|
438 | ;; |
---|
439 | -e) |
---|
440 | encoding=${2} |
---|
441 | shift |
---|
442 | ;; |
---|
443 | -to) |
---|
444 | typeout=${2} |
---|
445 | shift |
---|
446 | ;; |
---|
447 | -o) |
---|
448 | # order of firstname surname in bibtex file |
---|
449 | order=${2} |
---|
450 | shift |
---|
451 | ;; |
---|
452 | -p) |
---|
453 | project=${2} |
---|
454 | shift |
---|
455 | ;; |
---|
456 | -l) |
---|
457 | lang=${2} |
---|
458 | shift |
---|
459 | ;; |
---|
460 | -h) |
---|
461 | echo "${usage}" |
---|
462 | exit 0 |
---|
463 | ;; |
---|
464 | *) |
---|
465 | # other choice |
---|
466 | echo "eee : unknown option ${1}" |
---|
467 | echo "${usage}" |
---|
468 | exit 1 |
---|
469 | ;; |
---|
470 | esac |
---|
471 | # next flag |
---|
472 | shift |
---|
473 | done |
---|
474 | unset usage |
---|
475 | # |
---|
476 | # check for filein |
---|
477 | if [ ! -f ${filein} ] |
---|
478 | then |
---|
479 | echo "eee : ${filein} not found" |
---|
480 | exit 1 |
---|
481 | fi |
---|
482 | # |
---|
483 | case ${typeout} in |
---|
484 | dbk) |
---|
485 | fileou=$( basename ${filein} .txt).xml |
---|
486 | ;; |
---|
487 | bibtex) |
---|
488 | fileou=$( basename ${filein} .txt).bib |
---|
489 | ;; |
---|
490 | *) |
---|
491 | echo "eee : typeout should be dbk or bibtex" |
---|
492 | exit 1 |
---|
493 | ;; |
---|
494 | esac |
---|
495 | # |
---|
496 | # check for output |
---|
497 | case ${typein} in |
---|
498 | raw) |
---|
499 | # file like data/biball.txt |
---|
500 | fileraw=${filein} |
---|
501 | ;; |
---|
502 | mailbody) |
---|
503 | # file like data/mail2007-04-25T08:58:16Z.txt |
---|
504 | fileraw=${tmpdir}/$(basename ${filein}).raw |
---|
505 | echo "# from ${filein}" > ${fileraw} |
---|
506 | echo "# ${log_date}" >> ${fileraw} |
---|
507 | echo "# corrections" >> ${fileraw} |
---|
508 | grep "correction_.*=" ${filein} | grep -v "correction_.*=$" | \ |
---|
509 | sed -e "s/correction_.*=//">> ${fileraw} |
---|
510 | echo "# new references" >> ${fileraw} |
---|
511 | awk "/newreferences=/,/comments=/" ${filein} | sed -e "s/newreferences=//" -e "/comments=/d" >> ${fileraw} |
---|
512 | #more ${fileraw} # ++ if debug |
---|
513 | #read a #++ if debug |
---|
514 | ;; |
---|
515 | bibtex) |
---|
516 | # file like data/petitpoly.bib |
---|
517 | fileraw=${tmpdir}/$(basename ${filein}).raw |
---|
518 | awk -f ${PROJECT}/join_endcomma.awk ${filein} > ${fileraw} |
---|
519 | ;; |
---|
520 | *) |
---|
521 | echo "eee : typein should be raw, mailbody or bibtex" |
---|
522 | exit 1 |
---|
523 | ;; |
---|
524 | esac |
---|
525 | # |
---|
526 | # check for output |
---|
527 | if [ -f ${fileou} ] |
---|
528 | then |
---|
529 | echo "eee : ${fileou} already exist" |
---|
530 | exit 1 |
---|
531 | fi |
---|
532 | # |
---|
533 | ij=1 |
---|
534 | jlist[${ij}]="J. Climate" |
---|
535 | ij=$(( ${ij} + 1)) |
---|
536 | jlist[${ij}]="Journal of Climate" |
---|
537 | ij=$(( ${ij} + 1)) |
---|
538 | jlist[${ij}]="Ocean Modelling" |
---|
539 | ij=$(( ${ij} + 1)) |
---|
540 | jlist[${ij}]="Geophys. Res. Lett." |
---|
541 | ij=$(( ${ij} + 1)) |
---|
542 | jlist[${ij}]="J. Geophys. Res." |
---|
543 | ij=$(( ${ij} + 1)) |
---|
544 | jlist[${ij}]="Tellus A" |
---|
545 | ij=$(( ${ij} + 1)) |
---|
546 | jlist[${ij}]="Tellus B" |
---|
547 | ij=$(( ${ij} + 1)) |
---|
548 | jlist[${ij}]="J. Phys. Oceanogr." |
---|
549 | ij=$(( ${ij} + 1)) |
---|
550 | jlist[${ij}]="Clim. Dyn." |
---|
551 | ij=$(( ${ij} + 1)) |
---|
552 | jlist[${ij}]="Clim. Res." |
---|
553 | ij=$(( ${ij} + 1)) |
---|
554 | jlist[${ij}]="Climate Dynamics" |
---|
555 | ij=$(( ${ij} + 1)) |
---|
556 | jlist[${ij}]="Dynamics of Atmospheres and Oceans" |
---|
557 | ij=$(( ${ij} + 1)) |
---|
558 | jlist[${ij}]="Dyn. Atmos. Oceans" |
---|
559 | ij=$(( ${ij} + 1)) |
---|
560 | jlist[${ij}]="Mon. Wea. Rev." |
---|
561 | ij=$(( ${ij} + 1)) |
---|
562 | jlist[${ij}]="Monthly Weather Review" |
---|
563 | ij=$(( ${ij} + 1)) |
---|
564 | jlist[${ij}]="Global Biogeochem. Cycles" |
---|
565 | ij=$(( ${ij} + 1)) |
---|
566 | jlist[${ij}]="Nonlinear Processes in Geophysics" |
---|
567 | ij=$(( ${ij} + 1)) |
---|
568 | jlist[${ij}]="Ocean Sci." |
---|
569 | ij=$(( ${ij} + 1)) |
---|
570 | jlist[${ij}]="Ocean Science" |
---|
571 | ij=$(( ${ij} + 1)) |
---|
572 | jlist[${ij}]="Ocean Sciences" |
---|
573 | ij=$(( ${ij} + 1)) |
---|
574 | jlist[${ij}]="J. Mar. Systems" |
---|
575 | ij=$(( ${ij} + 1)) |
---|
576 | jlist[${ij}]="J. Atmos. Sc." |
---|
577 | ij=$(( ${ij} + 1)) |
---|
578 | jlist[${ij}]="Proc. Royal Soc." |
---|
579 | ij=$(( ${ij} + 1)) |
---|
580 | jlist[${ij}]="Bull. Amer. Meteorol. Soc." |
---|
581 | ij=$(( ${ij} + 1)) |
---|
582 | jlist[${ij}]="Ocean Dyn." |
---|
583 | ij=$(( ${ij} + 1)) |
---|
584 | jlist[${ij}]="Geophysical Monograph Series, Earth's Climate: The Ocean-Atmosphere Interaction" |
---|
585 | ij=$(( ${ij} + 1)) |
---|
586 | jlist[${ij}]="Paleoceanography" |
---|
587 | ij=$(( ${ij} + 1)) |
---|
588 | jlist[${ij}]="Annales Geophysicae" |
---|
589 | ij=$(( ${ij} + 1)) |
---|
590 | jlist[${ij}]="Annals of Geophys." |
---|
591 | ij=$(( ${ij} + 1)) |
---|
592 | jlist[${ij}]="Deep Sea Research Part II: Topical Studies in Oceanography" |
---|
593 | ij=$(( ${ij} + 1)) |
---|
594 | jlist[${ij}]="Deep Sea Res. II" |
---|
595 | ij=$(( ${ij} + 1)) |
---|
596 | jlist[${ij}]="Atmospheric Chemistry and Physics" |
---|
597 | ij=$(( ${ij} + 1)) |
---|
598 | jlist[${ij}]="Atmospheric Chemistry and Physics Discussions" |
---|
599 | ij=$(( ${ij} + 1)) |
---|
600 | jlist[${ij}]="Earth Plan. Sc. Lett." |
---|
601 | ij=$(( ${ij} + 1)) |
---|
602 | jlist[${ij}]="J. Mar. Res." |
---|
603 | ij=$(( ${ij} + 1)) |
---|
604 | jlist[${ij}]="PCMDI Report Series" |
---|
605 | ij=$(( ${ij} + 1)) |
---|
606 | jlist[${ij}]="J. Mar. Syst." |
---|
607 | ij=$(( ${ij} + 1)) |
---|
608 | jlist[${ij}]="Note du PÎle de Modélisation" |
---|
609 | ij=$(( ${ij} + 1)) |
---|
610 | jlist[${ij}]="Calculateurs ParallÚles" |
---|
611 | ij=$(( ${ij} + 1)) |
---|
612 | jlist[${ij}]="Note Scientifique du PÎle de Modélisation" |
---|
613 | ij=$(( ${ij} + 1)) |
---|
614 | jlist[${ij}]="Lecture Notes in Computer Science" |
---|
615 | ij=$(( ${ij} + 1)) |
---|
616 | jlist[${ij}]="Prog. Oceanogr." |
---|
617 | ij=$(( ${ij} + 1)) |
---|
618 | jlist[${ij}]="Deep Sea Research Part I: Oceanographic Research Papers" |
---|
619 | ij=$(( ${ij} + 1)) |
---|
620 | jlist[${ij}]="Deep Sea Res. I" |
---|
621 | ij=$(( ${ij} + 1)) |
---|
622 | jlist[${ij}]="IEEE Trans. Geosci. Remote Sensing" |
---|
623 | ij=$(( ${ij} + 1)) |
---|
624 | jlist[${ij}]="ECMWF Tech. Memorandum" |
---|
625 | ij=$(( ${ij} + 1)) |
---|
626 | jlist[${ij}]="J. Environ. Radioactivity" |
---|
627 | ij=$(( ${ij} + 1)) |
---|
628 | jlist[${ij}]="Int. WOCE Newsletter" |
---|
629 | ij=$(( ${ij} + 1)) |
---|
630 | jlist[${ij}]="C. R. Acad. Sci. Paris" |
---|
631 | ij=$(( ${ij} + 1)) |
---|
632 | jlist[${ij}]="C. R. Acad. Sci. Paris, Earth and Planetary Sciences" |
---|
633 | ij=$(( ${ij} + 1)) |
---|
634 | jlist[${ij}]="In The mathematics of models for climatology and environment" |
---|
635 | ij=$(( ${ij} + 1)) |
---|
636 | jlist[${ij}]="Oceanol. Acta" |
---|
637 | ij=$(( ${ij} + 1)) |
---|
638 | jlist[${ij}]="The global atmosphere and ocean system" |
---|
639 | ij=$(( ${ij} + 1)) |
---|
640 | jlist[${ij}]="NATO Advanced Study Institute" |
---|
641 | ij=$(( ${ij} + 1)) |
---|
642 | jlist[${ij}]="WCRP" |
---|
643 | ij=$(( ${ij} + 1)) |
---|
644 | jlist[${ij}]="The Courier" |
---|
645 | ij=$(( ${ij} + 1)) |
---|
646 | jlist[${ij}]="Elsevier Oceanography Series" |
---|
647 | ij=$(( ${ij} + 1)) |
---|
648 | jlist[${ij}]="In Conference Proceedings of the 1988 International Conference on Supercomputing" |
---|
649 | ij=$(( ${ij} + 1)) |
---|
650 | jlist[${ij}]="In Science and engineering on Cray Supercomputers" |
---|
651 | ij=$(( ${ij} + 1)) |
---|
652 | jlist[${ij}]="In Modeling the Earth's Climate and its Variability" |
---|
653 | ij=$(( ${ij} + 1)) |
---|
654 | jlist[${ij}]="Fish. Oceanogr." |
---|
655 | ij=$(( ${ij} + 1)) |
---|
656 | jlist[${ij}]="Q. J. R. Meteor. Soc." |
---|
657 | ij=$(( ${ij} + 1)) |
---|
658 | jlist[${ij}]="In High performance computing in the geosciences" |
---|
659 | ij=$(( ${ij} + 1)) |
---|
660 | jlist[${ij}]="Int. J. Numer. Meth. in Fluids" |
---|
661 | ij=$(( ${ij} + 1)) |
---|
662 | jlist[${ij}]="Lecture notes in Physics" |
---|
663 | ij=$(( ${ij} + 1)) |
---|
664 | jlist[${ij}]="J. Meteorol. Soc. Japan" |
---|
665 | ij=$(( ${ij} + 1)) |
---|
666 | jlist[${ij}]="Journal of Marine Systems" |
---|
667 | ij=$(( ${ij} + 1)) |
---|
668 | jlist[${ij}]="Canadian Journal of Fisheries and Aquatic Sciences" |
---|
669 | ij=$(( ${ij} + 1)) |
---|
670 | jlist[${ij}]="J. Atmos. Ocean. Tech." |
---|
671 | ij=$(( ${ij} + 1)) |
---|
672 | jlist[${ij}]="EOS" |
---|
673 | ij=$(( ${ij} + 1)) |
---|
674 | jlist[${ij}]="Nature" |
---|
675 | ij=$(( ${ij} + 1)) |
---|
676 | jlist[${ij}]="Nature Geosciences" |
---|
677 | ij=$(( ${ij} + 1)) |
---|
678 | jlist[${ij}]="Physics and Chemistry of the Earth, Part B: Hydrology, Oceans and Atmosphere" |
---|
679 | ij=$(( ${ij} + 1)) |
---|
680 | jlist[${ij}]="Journal of Atmospheric and Oceanic Technology" |
---|
681 | ij=$(( ${ij} + 1)) |
---|
682 | jlist[${ij}]="Lecture Notes in Computational Science Engineering" |
---|
683 | ij=$(( ${ij} + 1)) |
---|
684 | jlist[${ij}]="In Greenhouse Gas Control Technologies" |
---|
685 | ij=$(( ${ij} + 1)) |
---|
686 | jlist[${ij}]="Chemical Geology" |
---|
687 | ij=$(( ${ij} + 1)) |
---|
688 | jlist[${ij}]="Marine Geology" |
---|
689 | ij=$(( ${ij} + 1)) |
---|
690 | jlist[${ij}]="Developments in Paleoenvironmental Research" |
---|
691 | ij=$(( ${ij} + 1)) |
---|
692 | jlist[${ij}]=" Developments in Earth and Environmental Sciences" |
---|
693 | ij=$(( ${ij} + 1)) |
---|
694 | jlist[${ij}]="Science" |
---|
695 | ij=$(( ${ij} + 1)) |
---|
696 | jlist[${ij}]="In Mediterranean Climate Variability" |
---|
697 | ij=$(( ${ij} + 1)) |
---|
698 | jlist[${ij}]="Global and Planetary Change" |
---|
699 | ij=$(( ${ij} + 1)) |
---|
700 | jlist[${ij}]="Physical Review Letters" |
---|
701 | ij=$(( ${ij} + 1)) |
---|
702 | jlist[${ij}]="Progress In Oceanography" |
---|
703 | ij=$(( ${ij} + 1)) |
---|
704 | jlist[${ij}]="Climatic Change" |
---|
705 | ij=$(( ${ij} + 1)) |
---|
706 | jlist[${ij}]="Ocean Dynamics" |
---|
707 | ij=$(( ${ij} + 1)) |
---|
708 | jlist[${ij}]="Phil. Trans. Roy. Soc. A" |
---|
709 | ij=$(( ${ij} + 1)) |
---|
710 | jlist[${ij}]="Phil. Trans. Roy. Soc. B" |
---|
711 | ij=$(( ${ij} + 1)) |
---|
712 | jlist[${ij}]="Izvestiya Atmospheric and Oceanic Physics" |
---|
713 | ij=$(( ${ij} + 1)) |
---|
714 | jlist[${ij}]="Journal of Hydrometeorology" |
---|
715 | ij=$(( ${ij} + 1)) |
---|
716 | jlist[${ij}]="Journal of Hydrology" |
---|
717 | ij=$(( ${ij} + 1)) |
---|
718 | jlist[${ij}]="Remote Sensing of Environment" |
---|
719 | ij=$(( ${ij} + 1)) |
---|
720 | jlist[${ij}]="Remote Sensing Env." |
---|
721 | ij=$(( ${ij} + 1)) |
---|
722 | jlist[${ij}]="Oceanology" |
---|
723 | ij=$(( ${ij} + 1)) |
---|
724 | jlist[${ij}]="Water Resour. Res." |
---|
725 | ij=$(( ${ij} + 1)) |
---|
726 | jlist[${ij}]="Water Resources Research" |
---|
727 | ij=$(( ${ij} + 1)) |
---|
728 | jlist[${ij}]="Advances in Atmospheric Sciences" |
---|
729 | ij=$(( ${ij} + 1)) |
---|
730 | jlist[${ij}]="Quaternary Science Reviews" |
---|
731 | ij=$(( ${ij} + 1)) |
---|
732 | jlist[${ij}]="AGU monograph Ocean Circulation Mechanisms and Impacts" |
---|
733 | ij=$(( ${ij} + 1)) |
---|
734 | jlist[${ij}]="Climate Research" |
---|
735 | ij=$(( ${ij} + 1)) |
---|
736 | jlist[${ij}]="Colloque du GIS « Climat-Environnement-Sociétés »" |
---|
737 | ij=$(( ${ij} + 1)) |
---|
738 | jlist[${ij}]="Agricultural and Forest Meteorology" |
---|
739 | ij=$(( ${ij} + 1)) |
---|
740 | jlist[${ij}]="VIIth IAHS Scientific Assembly" |
---|
741 | ij=$(( ${ij} + 1)) |
---|
742 | jlist[${ij}]="AGU fall Meeting" |
---|
743 | ij=$(( ${ij} + 1)) |
---|
744 | jlist[${ij}]="4th Alexander Von Humboldt International Conference" |
---|
745 | ij=$(( ${ij} + 1)) |
---|
746 | jlist[${ij}]="International Journal of Climatology" |
---|
747 | ij=$(( ${ij} + 1)) |
---|
748 | jlist[${ij}]="Revue de l'Ãnergie" |
---|
749 | ij=$(( ${ij} + 1)) |
---|
750 | jlist[${ij}]="Hydrol. Earth Sys. Sci." |
---|
751 | ij=$(( ${ij} + 1)) |
---|
752 | jlist[${ij}]="Ambio" |
---|
753 | ij=$(( ${ij} + 1)) |
---|
754 | jlist[${ij}]="Theoretical and applied climatology" |
---|
755 | ij=$(( ${ij} + 1)) |
---|
756 | jlist[${ij}]="Remote Sensing of Environnement" |
---|
757 | ij=$(( ${ij} + 1)) |
---|
758 | jlist[${ij}]="PNAS" |
---|
759 | ij=$(( ${ij} + 1)) |
---|
760 | jlist[${ij}]="Lettre PIGB-PMRC" |
---|
761 | ij=$(( ${ij} + 1)) |
---|
762 | jlist[${ij}]="High Performance Computing in Science and Engineering" |
---|
763 | ij=$(( ${ij} + 1)) |
---|
764 | jlist[${ij}]="High Performance Computing in Science and Engineering '08" |
---|
765 | ij=$(( ${ij} + 1)) |
---|
766 | jlist[${ij}]="High Performance Computing on Vector Systems 2006" |
---|
767 | ij=$(( ${ij} + 1)) |
---|
768 | jlist[${ij}]="High Performance Computing on Vector Systems 2007" |
---|
769 | ij=$(( ${ij} + 1)) |
---|
770 | jlist[${ij}]="Annals of Glaciology" |
---|
771 | ij=$(( ${ij} + 1)) |
---|
772 | jlist[${ij}]="Oceanography" |
---|
773 | ij=$(( ${ij} + 1)) |
---|
774 | jlist[${ij}]="Journal of Physical Oceanography" |
---|
775 | ij=$(( ${ij} + 1)) |
---|
776 | jlist[${ij}]="In Deep convection and deep water formation in the oceans" |
---|
777 | ij=$(( ${ij} + 1)) |
---|
778 | jlist[${ij}]="Journal of Applied Meteorology and Climatology" |
---|
779 | ij=$(( ${ij} + 1)) |
---|
780 | jlist[${ij}]="Geochem. Geophys. Geosyst." |
---|
781 | ij=$(( ${ij} + 1)) |
---|
782 | jlist[${ij}]="Environmental Fluid Mechanics" |
---|
783 | ij=$(( ${ij} + 1)) |
---|
784 | jlist[${ij}]="Continental Shelf Research" |
---|
785 | ij=$(( ${ij} + 1)) |
---|
786 | jlist[${ij}]="Marine Pollution Bulletin" |
---|
787 | ij=$(( ${ij} + 1)) |
---|
788 | jlist[${ij}]="Comptes Rendus Geosciences" |
---|
789 | ij=$(( ${ij} + 1)) |
---|
790 | #jlist[${ij}]="Earth and Planetary Sciences, série IIa, Paris" |
---|
791 | jlist[${ij}]="Earth and Planetary Sciences, série IIa, Paris" |
---|
792 | ij=$(( ${ij} + 1)) |
---|
793 | jlist[${ij}]="??" |
---|
794 | # |
---|
795 | # following Journal name are fake ones for demo1 : references extracted from |
---|
796 | # Cantratrix Sopronica L. written by Georges Perec |
---|
797 | #find in http://www-rocq.inria.fr/who/Marc.Thiriet/PsFil/Biblio/cantatrix.ps |
---|
798 | ij=$(( ${ij} + 1)) |
---|
799 | jlist[${ij}]="Res. Proc. neurophysiol. Fanatic Soc." |
---|
800 | ij=$(( ${ij} + 1)) |
---|
801 | jlist[${ij}]="New Records Ass. J." |
---|
802 | ij=$(( ${ij} + 1)) |
---|
803 | jlist[${ij}]="Am. J. Allegrol." |
---|
804 | ij=$(( ${ij} + 1)) |
---|
805 | jlist[${ij}]="J. Neurochem. Neurocytol. Enzymol." |
---|
806 | ij=$(( ${ij} + 1)) |
---|
807 | jlist[${ij}]="Hammersmith J." |
---|
808 | ij=$(( ${ij} + 1)) |
---|
809 | jlist[${ij}]="Nasa Rept." |
---|
810 | ij=$(( ${ij} + 1)) |
---|
811 | jlist[${ij}]="C.r. Assoc. Conc. Lam." |
---|
812 | ij=$(( ${ij} + 1)) |
---|
813 | jlist[${ij}]="Gaz. med. franco-rus." |
---|
814 | ij=$(( ${ij} + 1)) |
---|
815 | jlist[${ij}]="Amer. J. music. Deficiency" |
---|
816 | # |
---|
817 | # strip comments and blank lines |
---|
818 | fileraw_strict=${tmpdir}/$(basename ${fileraw})_strict |
---|
819 | grep -v "^#" ${fileraw} | grep -v "^%" | sed "/^$/d" > ${fileraw_strict} |
---|
820 | # following line is not compatible with XML header ++ |
---|
821 | if [ "${encoding}" = "iso-8859-1" ] |
---|
822 | then |
---|
823 | # convert ot UTF-8 to please bibtex2xml |
---|
824 | iconv -f ISO-8859-1 -t UTF-8 ${fileraw_strict} > ${fileraw_strict}2 |
---|
825 | mv ${fileraw_strict}2 ${fileraw_strict} |
---|
826 | fi |
---|
827 | case ${typein} in |
---|
828 | bibtex) |
---|
829 | fileou_bibtexml=${tmpdir}/$(basename ${fileraw})_bibtexml |
---|
830 | python ${PROJECT}/external/bibtex2xml.py ${fileraw_strict} > ${fileou_bibtexml} |
---|
831 | xsltproc --output ${fileou} \ |
---|
832 | --param lang "'${lang}'" \ |
---|
833 | --param project "'${project}'" \ |
---|
834 | --param makedate "'${log_date}'" \ |
---|
835 | --param order "'${order}'" \ |
---|
836 | ${PROJECT}/bibtexml2dbk.xsl ${fileou_bibtexml} |
---|
837 | read a |
---|
838 | head ${fileou} |
---|
839 | #++rm ${fileou_bibtexml} |
---|
840 | ;; |
---|
841 | *) |
---|
842 | case ${typeout} in |
---|
843 | dbk) |
---|
844 | cat <<EOF > ${fileou} |
---|
845 | <?xml version='1.0' encoding='ISO-8859-1'?> |
---|
846 | <bibliography |
---|
847 | version="5.0" |
---|
848 | xmlns="http://docbook.org/ns/docbook" |
---|
849 | xml:id="bib${project}ref" |
---|
850 | xml:lang="${lang}"> |
---|
851 | |
---|
852 | <info> |
---|
853 | <date>${log_date}</date> |
---|
854 | </info> |
---|
855 | EOF |
---|
856 | ;; |
---|
857 | bibtex) |
---|
858 | cat <<EOF > ${fileou} |
---|
859 | |
---|
860 | @PREAMBLE{"bibliography of ${project}"}" |
---|
861 | |
---|
862 | % ${log_date} |
---|
863 | |
---|
864 | EOF |
---|
865 | ;; |
---|
866 | esac |
---|
867 | totlines=$( wc -l ${fileraw_strict} | awk '{print $1}' ) |
---|
868 | l=1 |
---|
869 | while [ ${l} -le ${totlines} ] |
---|
870 | do |
---|
871 | #echo "line: ${l}" |
---|
872 | # extract one line |
---|
873 | line=$( sed -n ${l}p ${fileraw_strict} ) |
---|
874 | orgline=$( echo ${line} | sed -e "s/--/- -/g" ) |
---|
875 | line=$( echo ${line} | sed -e "s/</\</g" -e "s/>/\>/g" ) |
---|
876 | # parsing non bibtex line |
---|
877 | bibtex=0 |
---|
878 | # before the first : |
---|
879 | tmp=${line%%:*} |
---|
880 | # before the last , |
---|
881 | auths=${tmp%,*}, |
---|
882 | # replace " and " by "," |
---|
883 | auths=$( echo "${auths}" | sed -e "s/ and /,/g" ) |
---|
884 | # replace " et " by "," |
---|
885 | auths=$( echo "${auths}" | sed -e "s/ et /,/g" ) |
---|
886 | # after the last , |
---|
887 | year=${tmp##*,} |
---|
888 | year=$( rmbl "${year}" ) |
---|
889 | ## first author before the first ., |
---|
890 | first=${auths%%.,*}. |
---|
891 | # its firstname after the last , |
---|
892 | firstfn=${first##*,} |
---|
893 | firstfn=$( rmbl "${firstfn}" ) |
---|
894 | # its surname ; before the first , |
---|
895 | firstsn=${first%%,*} |
---|
896 | firstsn=$( rmbl "${firstsn}" ) |
---|
897 | ## ref id |
---|
898 | firstsn_flat=$( echo "${firstsn}" | recode -d -f ISO-8859-15..flat ) |
---|
899 | # echo "firstsn : ${firstsn}" # ++ debug |
---|
900 | # echo "firstsn_flat : ${firstsn_flat}" #++ debug |
---|
901 | # test if no encoding problem after ISO-8859-15 to flat conversion |
---|
902 | firstsn_test1=$(echo "${firstsn_flat}" | tr -d "[:alpha:]" | tr -d " " | tr -d "'" | tr -d "-" | tr -d ".") |
---|
903 | # echo "firstsn_test1 : ${firstsn_test1}" # ++ debug |
---|
904 | if [ ! -z "${firstsn_test1}" ] |
---|
905 | then |
---|
906 | echo "www : pb on ISO-8859-15 to flat conversion" |
---|
907 | echo "www : on ${firstsn}" |
---|
908 | echo "www : trying UTF-8 to flat conversion ..." |
---|
909 | firstsn_flat=$( echo "${firstsn}" | recode -d -f UTF-8..flat ) |
---|
910 | # test if no encoding problem after UTF-8 to flat conversion |
---|
911 | firstsn_test2=$(echo "${firstsn_flat}" | tr -d "[:alpha:]" | tr -d " " | tr -d "'") |
---|
912 | #echo "firstsn_test2 : A${firstsn_test2}A" # ++ debug |
---|
913 | if [ ! -z "${firstsn_test2}" ] |
---|
914 | then |
---|
915 | echo "eee : pb on flat conversion of ${firstsn}" |
---|
916 | exit 1 |
---|
917 | fi |
---|
918 | fi |
---|
919 | firstsn_lower=$( echo "${firstsn_flat}" | tr "[:upper:]" "[:lower:]") |
---|
920 | firstsn_nopunct=$( echo "${firstsn_lower}" | tr -s " " "_" | tr -s "'" "_") |
---|
921 | refid="${firstsn_nopunct}${year}" |
---|
922 | unset firstsn_lower |
---|
923 | unset firstsn_flat |
---|
924 | unset firstsn_test1 |
---|
925 | unset firstsn_test2 |
---|
926 | # look for id of biblio entry to produce a unique one |
---|
927 | case ${typeout} in |
---|
928 | dbk) |
---|
929 | num=$( grep -c "<biblioentry xml:id=\"${refid}_[0-9][0-9]\">" ${fileou} ) |
---|
930 | ;; |
---|
931 | bibtex) |
---|
932 | num=$( grep -c "@.*{${refid}_[0-9][0-9]," ${fileou} ) |
---|
933 | ;; |
---|
934 | esac |
---|
935 | num=$(( ${num} + 1 )) |
---|
936 | [ ${num} -le 9 ] && num=0${num} |
---|
937 | refid=${refid}_${num} |
---|
938 | hasauthor=1 |
---|
939 | case ${typeout} in |
---|
940 | dbk) |
---|
941 | cat <<EOF >> ${fileou} |
---|
942 | <biblioentry xml:id="${refid}"> |
---|
943 | <!-- date $( date -u +"%Y%m%dT%H%M%SZ" ) --> |
---|
944 | <!-- original text |
---|
945 | ${orgline} |
---|
946 | --> |
---|
947 | EOF |
---|
948 | ;; |
---|
949 | bibtex) |
---|
950 | cat <<EOF >> ${fileou} |
---|
951 | % |
---|
952 | % date $( date -u +"%Y%m%dT%H%M%SZ" ) |
---|
953 | % original text : |
---|
954 | % ${orgline} |
---|
955 | % |
---|
956 | @article{${refid}, |
---|
957 | EOF |
---|
958 | ;; |
---|
959 | esac |
---|
960 | if [ ${hasauthor} -eq 1 ] |
---|
961 | then |
---|
962 | case ${typeout} in |
---|
963 | dbk) |
---|
964 | cat <<EOF >> ${fileou} |
---|
965 | <authorgroup> |
---|
966 | <author> <personname> <surname>${firstsn}</surname> <firstname>${firstfn}</firstname> </personname> </author> |
---|
967 | EOF |
---|
968 | ;; |
---|
969 | bibtex) |
---|
970 | cat <<EOF >> ${fileou} |
---|
971 | author = {${firstsn}, ${firstfn}}, |
---|
972 | EOF |
---|
973 | ;; |
---|
974 | esac |
---|
975 | ## other authors.. |
---|
976 | if [ ${bibtex} -eq 0 ] |
---|
977 | then |
---|
978 | previous=${first}, |
---|
979 | # next authors... |
---|
980 | next=${auths##*${previous}} |
---|
981 | fi |
---|
982 | if [ ${bibtex} -eq 1 ] |
---|
983 | then |
---|
984 | previous=${first}"and " |
---|
985 | # next authors... |
---|
986 | #echo "auths ${auths}" |
---|
987 | next=${auths##*${previous}} |
---|
988 | if [ "${next}and " = "${previous}" ] |
---|
989 | then |
---|
990 | next="" |
---|
991 | fi |
---|
992 | fi |
---|
993 | #echo "previous ${previous}" |
---|
994 | #echo "next ${next}" |
---|
995 | # while the next author is not empty |
---|
996 | while [ "${next}" != "" ] |
---|
997 | do |
---|
998 | if [ ${bibtex} -eq 0 ] |
---|
999 | then |
---|
1000 | # get the first next author; before the first , |
---|
1001 | next=${next%%,*} |
---|
1002 | # its surname ; after the last . |
---|
1003 | nextsn=${next##*.} |
---|
1004 | nextsn=$( rmbl "${nextsn}" ) |
---|
1005 | # its firstname ; before the last . |
---|
1006 | nextfn=${next%.*}. |
---|
1007 | nextfn=$( rmbl "${nextfn}" ) |
---|
1008 | fi |
---|
1009 | if [ ${bibtex} -eq 1 ] |
---|
1010 | then |
---|
1011 | # get the first next author; before the first "and" |
---|
1012 | next=${next%%and *} |
---|
1013 | # its surname after the last " " |
---|
1014 | # ++ pas vrai double nom et pb blanc dans la syntaxe |
---|
1015 | # nextsn=${next##* } . |
---|
1016 | # ok en interactif . pas ok en script |
---|
1017 | nextsn=$( echo ${next} | awk '{print $2}') |
---|
1018 | #echo "nextsn ${nextsn}" |
---|
1019 | # its nextname before the first " " |
---|
1020 | nextfn=${next%% *} |
---|
1021 | fi |
---|
1022 | # |
---|
1023 | case ${typeout} in |
---|
1024 | dbk) |
---|
1025 | echo " <author> <personname> <surname>${nextsn}</surname> <firstname>${nextfn}</firstname> </personname> </author>" >> ${fileou} |
---|
1026 | ;; |
---|
1027 | bibtex) |
---|
1028 | echo "author = {${nextsn}, ${nextfn}}," >> ${fileou} |
---|
1029 | ;; |
---|
1030 | esac |
---|
1031 | if [ ${bibtex} -eq 0 ] |
---|
1032 | then |
---|
1033 | previous=${next}, |
---|
1034 | next=${auths##*${previous}} |
---|
1035 | fi |
---|
1036 | if [ ${bibtex} -eq 1 ] |
---|
1037 | then |
---|
1038 | previous=${next}"and " |
---|
1039 | next=${auths##*${previous}} |
---|
1040 | fi |
---|
1041 | done |
---|
1042 | case ${typeout} in |
---|
1043 | dbk) |
---|
1044 | echo " </authorgroup>" >> ${fileou} |
---|
1045 | ;; |
---|
1046 | esac |
---|
1047 | fi |
---|
1048 | # end of the line ; after the first : |
---|
1049 | endline=${line#*:} |
---|
1050 | ## find the journal |
---|
1051 | j=1 |
---|
1052 | jfound="" |
---|
1053 | jlistsize=${#jlist[@]} |
---|
1054 | while [[ ${j} -le ${jlistsize} && "${jfound}" = "" ]] |
---|
1055 | do |
---|
1056 | ok=$( echo ${endline} | grep -ci "${jlist[j]} *," ) |
---|
1057 | [ ${ok} -eq 1 ] && jfound="${jlist[j]}" |
---|
1058 | j=$(( ${j} + 1 )) |
---|
1059 | done |
---|
1060 | unset ok |
---|
1061 | if [ "${jfound}" = "" ] |
---|
1062 | then |
---|
1063 | echo "eee: Journal not found " |
---|
1064 | echo "${endline}" |
---|
1065 | # uncomment next line for debug |
---|
1066 | # set # ++ debug |
---|
1067 | exit 1 |
---|
1068 | #+++ following lines are not yet validate |
---|
1069 | # it might be a book, a manual, a conference, etc. ++ |
---|
1070 | case ${typeout} in |
---|
1071 | dbk) |
---|
1072 | echo " <title>${title}</title>" >> ${fileou} |
---|
1073 | cat <<EOF >> ${fileou} |
---|
1074 | <biblioset relation="nojournal"> |
---|
1075 | <title>${title}</title> |
---|
1076 | <pagenums>${pag}</pagenums> |
---|
1077 | <pubdate>${year}</pubdate> |
---|
1078 | </biblioset> |
---|
1079 | </biblioentry> |
---|
1080 | EOF |
---|
1081 | ;; |
---|
1082 | bibtex) |
---|
1083 | echo "title = {${title}}," >> ${fileou} |
---|
1084 | echo "pages = {${pag}}," >> ${fileou} |
---|
1085 | echo "year = {${year}}" >> ${fileou} |
---|
1086 | echo "}" >> ${fileou} |
---|
1087 | ;; |
---|
1088 | esac |
---|
1089 | # end of if jfound empty (ie not an article) |
---|
1090 | fi |
---|
1091 | if [ "${jfound}" != "" ] |
---|
1092 | then |
---|
1093 | ## title |
---|
1094 | # before the first : |
---|
1095 | title=${endline%%${jfound}*} |
---|
1096 | title=$( cleanname "${title}" ) |
---|
1097 | case ${typeout} in |
---|
1098 | dbk) |
---|
1099 | echo " <title>${title}</title>" >> ${fileou} |
---|
1100 | ;; |
---|
1101 | bibtex) |
---|
1102 | echo "title = {${title}}," >> ${fileou} |
---|
1103 | ;; |
---|
1104 | esac |
---|
1105 | ## end |
---|
1106 | ## end of the line ; after the first ${jfound} |
---|
1107 | endline=${endline#*${jfound}} |
---|
1108 | endline=$( cleanname "${endline}" ) |
---|
1109 | ## doi |
---|
1110 | endline=$( echo ${endline} | sed -e "s/[dD][oO][iI] *\t* *: *\t* */doi:/" ) |
---|
1111 | #echo "endline for doi ${endline}" |
---|
1112 | ok=$( echo ${endline} | grep -ic "doi:" ) |
---|
1113 | if [ ${ok} -eq 1 ] |
---|
1114 | then |
---|
1115 | doi=${endline##*doi:} |
---|
1116 | #echo "doi : ${doi}" |
---|
1117 | case ${typeout} in |
---|
1118 | dbk) |
---|
1119 | echo " <biblioid class=\"doi\">${doi}</biblioid>" >> ${fileou} |
---|
1120 | ;; |
---|
1121 | bibtex) |
---|
1122 | echo "doi={${doi}}," >> ${fileou} |
---|
1123 | ;; |
---|
1124 | esac |
---|
1125 | unset doi |
---|
1126 | endline=${endline%doi:*} |
---|
1127 | endline=$( cleanname "${endline}" ) |
---|
1128 | else |
---|
1129 | echo "non doi: ${line}" |
---|
1130 | echo "" |
---|
1131 | fi |
---|
1132 | num=$( echo "${endline}" | tr -dc "," | wc -c | tr -d " ") |
---|
1133 | case "${num}" in |
---|
1134 | 0) |
---|
1135 | ## echo ${num}: ${endline} |
---|
1136 | case ${typeout} in |
---|
1137 | dbk) |
---|
1138 | cat <<EOF >> ${fileou} |
---|
1139 | <biblioset relation="journal"> |
---|
1140 | <title>${jfound}</title> |
---|
1141 | <pubdate>${year}</pubdate> |
---|
1142 | <bibliomisc>${endline}</bibliomisc> |
---|
1143 | </biblioset> |
---|
1144 | EOF |
---|
1145 | ;; |
---|
1146 | bibtex) |
---|
1147 | cat <<EOF >> ${fileou} |
---|
1148 | journal = {${jfound}}, |
---|
1149 | year = {${year}}, |
---|
1150 | notes = {${endline}}, |
---|
1151 | EOF |
---|
1152 | ;; |
---|
1153 | esac |
---|
1154 | unset jfound |
---|
1155 | unset year |
---|
1156 | ;; |
---|
1157 | 1) |
---|
1158 | ### echo ${num}: ${endline} |
---|
1159 | vol=${endline%,*} |
---|
1160 | vol=$( cleanname "${vol}" ) |
---|
1161 | pag=${endline##*,} |
---|
1162 | pag=$( cleanname "${pag}" ) |
---|
1163 | case ${typeout} in |
---|
1164 | dbk) |
---|
1165 | cat <<EOF >> ${fileou} |
---|
1166 | <biblioset relation="journal"> |
---|
1167 | <title>${jfound}</title> |
---|
1168 | <volumenum>${vol}</volumenum><pagenums>${pag}</pagenums> |
---|
1169 | <pubdate>${year}</pubdate> |
---|
1170 | </biblioset> |
---|
1171 | EOF |
---|
1172 | ;; |
---|
1173 | bibtex) |
---|
1174 | echo "journal = {${jfound}}," >> ${fileou} |
---|
1175 | echo "volume = {${vol}}," >> ${fileou} |
---|
1176 | echo "pages = {${pag}}," >> ${fileou} |
---|
1177 | echo "year = {${year}}," >> ${fileou} |
---|
1178 | ;; |
---|
1179 | esac |
---|
1180 | ;; |
---|
1181 | bibtex) |
---|
1182 | unset vol |
---|
1183 | unset pag |
---|
1184 | unset jfound |
---|
1185 | unset year |
---|
1186 | ;; |
---|
1187 | 2) |
---|
1188 | vol=${endline%,*} |
---|
1189 | vol=$( cleanname "${vol}" ) |
---|
1190 | iss=${vol##*,} |
---|
1191 | iss=$( cleanname "${iss}" ) |
---|
1192 | vol=${vol%,*} |
---|
1193 | vol=$( cleanname "${vol}" ) |
---|
1194 | pag=${endline##*,} |
---|
1195 | pag=$( cleanname "${pag}" ) |
---|
1196 | case ${typeout} in |
---|
1197 | dbk) |
---|
1198 | cat <<EOF >> ${fileou} |
---|
1199 | <biblioset relation="journal"> |
---|
1200 | <title>${jfound}</title> |
---|
1201 | <volumenum>${vol}</volumenum><issuenum>${iss}</issuenum><pagenums>${pag}</pagenums> |
---|
1202 | <pubdate>${year}</pubdate> |
---|
1203 | </biblioset> |
---|
1204 | EOF |
---|
1205 | ;; |
---|
1206 | bibtex) |
---|
1207 | echo "journal = {${jfound}}," >> ${fileou} |
---|
1208 | echo "volume = {${vol}}," >> ${fileou} |
---|
1209 | echo "number = {${iss}}," >> ${fileou} |
---|
1210 | echo "pages = {${pag}}," >> ${fileou} |
---|
1211 | echo "year = {${year}}," >> ${fileou} |
---|
1212 | ;; |
---|
1213 | esac |
---|
1214 | unset vol |
---|
1215 | unset pag |
---|
1216 | unset jfound |
---|
1217 | unset year |
---|
1218 | unset iss |
---|
1219 | ;; |
---|
1220 | 6) |
---|
1221 | conftitle=${endline%%,*} |
---|
1222 | endline=${endline#*,} |
---|
1223 | # day(s) month |
---|
1224 | confdates=${endline%%,*} |
---|
1225 | endline=${endline#*,} |
---|
1226 | # day(s) month and year |
---|
1227 | confdates="${confdates}, ${endline%%,*}" |
---|
1228 | confdates=$( cleanname "${confdates}" ) |
---|
1229 | endline=${endline#*,} |
---|
1230 | # Town |
---|
1231 | confaddress=${endline%%,*} |
---|
1232 | endline=${endline#*,} |
---|
1233 | # Town and country |
---|
1234 | confaddress="${confaddress}, ${endline%%,*}" |
---|
1235 | confaddress=$( cleanname "${confaddress}" ) |
---|
1236 | endline=${endline#*,} |
---|
1237 | publishername=${endline%%,*} |
---|
1238 | publishername=$( cleanname "${publishername}" ) |
---|
1239 | endline=${endline#*,} |
---|
1240 | pag=${endline##*,} |
---|
1241 | pag=$( cleanname "${pag}" ) |
---|
1242 | #set |
---|
1243 | #read a |
---|
1244 | case ${typeout} in |
---|
1245 | dbk) |
---|
1246 | cat <<EOF >> ${fileou} |
---|
1247 | <biblioset relation="conference"> |
---|
1248 | <title>${jfound}</title> |
---|
1249 | <pubdate>${year}</pubdate> |
---|
1250 | <publisher><publishername>${publishername}</publishername></publisher> |
---|
1251 | <pagenums>${pag}</pagenums> |
---|
1252 | <confgroup> |
---|
1253 | <conftitle>${conftitle}</conftitle> |
---|
1254 | <confdates>${confdates}</confdates> |
---|
1255 | <address>${confaddress}</address> |
---|
1256 | </confgroup> |
---|
1257 | </biblioset> |
---|
1258 | EOF |
---|
1259 | ;; |
---|
1260 | bibtex) |
---|
1261 | echo "journal = {${jfound}}," >> ${fileou} |
---|
1262 | echo "year = {${year}}," >> ${fileou} |
---|
1263 | echo "publisher = {${publishername}}," >> ${fileou} |
---|
1264 | echo "booktitle = {${conftitle}}," >> ${fileou} |
---|
1265 | echo "date = {${confdates}}," >> ${fileou} |
---|
1266 | echo "address = {${confaddress}}," >> ${fileou} |
---|
1267 | ;; |
---|
1268 | esac |
---|
1269 | unset confaddress |
---|
1270 | unset conftitle |
---|
1271 | unset confdates |
---|
1272 | unset pag |
---|
1273 | unset publishername |
---|
1274 | unset year |
---|
1275 | unset jfound |
---|
1276 | ;; |
---|
1277 | 10) |
---|
1278 | publishername=${endline%%Editors,*} |
---|
1279 | publishername="${publishername} Editors" |
---|
1280 | publishername=$( cleanname "${publishername}" ) |
---|
1281 | endline=${endline#*Editors,} |
---|
1282 | vol=${endline%%,*} |
---|
1283 | vol=$( cleanname "${vol}" ) |
---|
1284 | endline=${endline#*,} |
---|
1285 | pag=${endline%%,*} |
---|
1286 | pag=$( cleanname "${pag}" ) |
---|
1287 | endline=${endline#*,} |
---|
1288 | isbn=${endline%%,*} |
---|
1289 | isbn=$(echo ${isbn} | sed -e "s/ISBN ://") |
---|
1290 | isbn=$( cleanname "${isbn}" ) |
---|
1291 | endline=${endline#*,} |
---|
1292 | agu=${endline%%,*} |
---|
1293 | agu=$(echo ${agu} | sed -e "s/AGU ://") |
---|
1294 | agu=$( cleanname "${agu}" ) |
---|
1295 | endline=${endline#*${agu}} |
---|
1296 | endline=$( cleanname "${endline}" ) |
---|
1297 | endline=$( cleanname "${endline}" ) |
---|
1298 | case ${typeout} in |
---|
1299 | dbk) |
---|
1300 | cat <<EOF >> ${fileou} |
---|
1301 | <biblioid class="isbn">${isbn}</biblioid> |
---|
1302 | <biblioid class="other" otherclass="AGU">${agu}</biblioid> |
---|
1303 | <biblioset relation="journal"> |
---|
1304 | <title>${jfound}</title> |
---|
1305 | <pubdate>${year}</pubdate> |
---|
1306 | <publisher><publishername>${publishername}</publishername></publisher> |
---|
1307 | <volumenum>${vol}</volumenum> |
---|
1308 | <pagenums>${pag}</pagenums> |
---|
1309 | <bibliomisc>${endline}</bibliomisc> |
---|
1310 | </biblioset> |
---|
1311 | EOF |
---|
1312 | ;; |
---|
1313 | bibtex) |
---|
1314 | echo "isbn= {${isbn}}," >> ${fileou} |
---|
1315 | echo "agu= {${agu}}," >> ${fileou} |
---|
1316 | echo "year = {${year}}," >> ${fileou} |
---|
1317 | echo "journal = {${jfound}}," >> ${fileou} |
---|
1318 | echo "publisher = {${publishername}}," >> ${fileou} |
---|
1319 | echo "volume = {${vol}}," >> ${fileou} |
---|
1320 | echo "pages = {${pag}}," >> ${fileou} |
---|
1321 | echo "notes = {${endline}}," >> ${fileou} |
---|
1322 | ;; |
---|
1323 | esac |
---|
1324 | unset isbn |
---|
1325 | unset agu |
---|
1326 | unset pag |
---|
1327 | unset publishername |
---|
1328 | unset year |
---|
1329 | unset jfound |
---|
1330 | unset vol |
---|
1331 | ;; |
---|
1332 | *) |
---|
1333 | #echo "${num}: ${endline}" # ++debug |
---|
1334 | #set # ++ debug |
---|
1335 | #exit 1 #++ debug |
---|
1336 | case ${typeout} in |
---|
1337 | dbk) |
---|
1338 | cat <<EOF >> ${fileou} |
---|
1339 | <biblioset relation="journal"> |
---|
1340 | <title>${jfound}</title> |
---|
1341 | <pubdate>${year}</pubdate> |
---|
1342 | <bibliomisc>${endline}</bibliomisc> |
---|
1343 | </biblioset> |
---|
1344 | EOF |
---|
1345 | ;; |
---|
1346 | bibtex) |
---|
1347 | echo "journal = {${jfound}}," >> ${fileou} |
---|
1348 | echo "year = {${year}}," >> ${fileou} |
---|
1349 | echo "notes = {${endline}}," >> ${fileou} |
---|
1350 | ;; |
---|
1351 | esac |
---|
1352 | ;; |
---|
1353 | esac |
---|
1354 | case ${typeout} in |
---|
1355 | dbk) |
---|
1356 | echo "</biblioentry>" >> ${fileou} |
---|
1357 | ;; |
---|
1358 | bibtex) |
---|
1359 | echo "}" >> ${fileou} |
---|
1360 | ;; |
---|
1361 | esac |
---|
1362 | # end of if jfound not empty |
---|
1363 | fi |
---|
1364 | unset title |
---|
1365 | unset vol |
---|
1366 | unset year |
---|
1367 | unset pag |
---|
1368 | l=$(( ${l} + 1 )) |
---|
1369 | done |
---|
1370 | unset totlines |
---|
1371 | unset l |
---|
1372 | case ${typeout} in |
---|
1373 | dbk) |
---|
1374 | echo "</bibliography>" >> ${fileou} |
---|
1375 | ;; |
---|
1376 | esac |
---|
1377 | ;; |
---|
1378 | # end of case bibtex vs other for processing |
---|
1379 | esac |
---|
1380 | |
---|
1381 | # check conformity of fileou |
---|
1382 | # if possible |
---|
1383 | case ${typeout} in |
---|
1384 | dbk) |
---|
1385 | ${xmlcmd} val --err \ |
---|
1386 | --xsd http://www.docbook.org/xml/5.0/xsd/docbook.xsd \ |
---|
1387 | ${fileou} 1> xmlstarlet.log 2>&1 |
---|
1388 | # |
---|
1389 | # clean |
---|
1390 | echo " iii : xmlstarlet.log contains sdtout and stderr from ${xmlcmd} command on ${fileou}" |
---|
1391 | echo " iii : which was done just to check consistence of ${fileou}" |
---|
1392 | more xmlstarlet.log |
---|
1393 | ;; |
---|
1394 | bibtex) |
---|
1395 | echo " iii : no check conformity of bibtex file" |
---|
1396 | ;; |
---|
1397 | esac |
---|
1398 | # |
---|
1399 | case ${typein} in |
---|
1400 | raw) |
---|
1401 | echo " iii : ${fileraw_strict} contains a copy of input file without comments" |
---|
1402 | ;; |
---|
1403 | mailbody) |
---|
1404 | echo " iii : ${fileraw} contains a copy of input file" |
---|
1405 | echo " iii : ${fileraw_strict} contains a copy of input file without comments" |
---|
1406 | ;; |
---|
1407 | esac |
---|
1408 | # |
---|
1409 | echo " iii : you have a some new or modified bibliographic references in ${fileou} (biblioentry)" |
---|
1410 | echo " iii : you can add them in ${fileou}" #++ filename path |
---|
1411 | echo " iii : modify date in ${fileou}" #++ filename path |
---|
1412 | echo " iii : but please take care of id last part (after underscore) that may" |
---|
1413 | 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. |
---|
1414 | # |
---|
1415 | exit 0 |
---|