Changeset 21 for trunk/bibopa.sh
- Timestamp:
- 06/21/07 13:32:01 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bibopa.sh
r15 r21 23 23 # Short Rains: A CGCM Study</title> 24 24 # <publishername>J. Climate</publishername> 25 # <biblio misc role="doi">doi</bibliomisc>25 # <biblioid class="doi">doi</bibliomisc> 26 26 # <bibliomisc role="pseudoref">In press.</bibliomisc> 27 27 # <bibliomisc role="internalref">from … … 44 44 # ++ gestion des id existants (cf à la fin) 45 45 # ++ option debug 46 # fplod 2007-06-20T17:18:02Z aedon.locean-ipsl.upmc.fr (Darwin) 47 # <bibliomisc role="id"> replace by <biblioid class="doi"> 46 48 # smasson 2007-06-07T16:43:42Z arete.locean-ipsl.upmc.fr (Darwin) 47 49 # Add journals … … 237 239 totlines=$( wc -l ${fileraw_strict} | awk '{print $1}' ) 238 240 l=1 239 while [ $ l -le $totlines]241 while [ ${l} -le ${totlines} ] 240 242 do 241 243 # extract one line 242 244 243 245 line=$( sed -n ${l}p ${fileraw_strict} ) 244 orgline=$( echo $ line| sed -e "s/--/- -/g" )245 line=$( echo $ line| sed -e "s/</\</g" -e "s/>/\>/g" )246 orgline=$( echo ${line} | sed -e "s/--/- -/g" ) 247 line=$( echo ${line} | sed -e "s/</\</g" -e "s/>/\>/g" ) 246 248 # before the first : 247 249 tmp=${line%%:*} … … 249 251 auths=${tmp%,*}, 250 252 # supress and 251 auths=$( echo "$ auths" | sed -e "s/ and //g" )253 auths=$( echo "${auths}" | sed -e "s/ and //g" ) 252 254 # after the last , 253 255 year=${tmp##*,} 254 year=$( rmbl "$ year" )256 year=$( rmbl "${year}" ) 255 257 ## first author before the first ., 256 258 first=${auths%%.,*}. 257 259 # its firstname after the last , 258 260 firstfn=${first##*,} 259 firstfn=$( rmbl "$ firstfn" )261 firstfn=$( rmbl "${firstfn}" ) 260 262 # its surname ; before the first , 261 263 firstsn=${first%%,*} 262 firstsn=$( rmbl "$ firstsn" )264 firstsn=$( rmbl "${firstsn}" ) 263 265 ## ref id 264 refid=$( echo $ firstsn | tr "[:upper:]" "[:lower:]" | tr -s " " "_" | tr -s "'" "_" | recode -d -f ISO-8859-1..flat )$year265 num=$( grep -c "<biblioentry id=\"${refid}_[0-9][0-9]\">" $ fileou)266 num=$(( $ num+ 1 ))267 [ $ num -le 9 ] && num=0$num268 refid=${refid}_$ num269 270 cat <<EOF >> $ fileou266 refid=$( echo ${firstsn} | tr "[:upper:]" "[:lower:]" | tr -s " " "_" | tr -s "'" "_" | recode -d -f ISO-8859-1..flat )${year} 267 num=$( grep -c "<biblioentry id=\"${refid}_[0-9][0-9]\">" ${fileou} ) 268 num=$(( ${num} + 1 )) 269 [ ${num} -le 9 ] && num=0${num} 270 refid=${refid}_${num} 271 272 cat <<EOF >> ${fileou} 271 273 <biblioentry id="${refid}"> 272 274 <!-- date … … 285 287 next=${auths##*${previous}} 286 288 # while the next author is not empty 287 while [ "$ next" != "" ]289 while [ "${next}" != "" ] 288 290 do 289 291 # get the first next author; before the first , … … 291 293 # its surname ; after the last . 292 294 nextsn=${next##*.} 293 nextsn=$( rmbl "$ nextsn" )295 nextsn=$( rmbl "${nextsn}" ) 294 296 # its firstname ; before the last . 295 297 nextfn=${next%.*}. 296 nextfn=$( rmbl "$ nextfn" )298 nextfn=$( rmbl "${nextfn}" ) 297 299 # 298 300 echo " <author> <personname> <surname>${nextsn}</surname> <firstname>${nextfn}</firstname> </personname> </author>" >> ${fileou} … … 301 303 302 304 done 303 echo " </authorgroup>" >> $ fileou305 echo " </authorgroup>" >> ${fileou} 304 306 305 307 # end of the line ; after the first : … … 312 314 while [[ $j -le $jlistsize && "${jfound}" == "" ]] 313 315 do 314 ok=$( echo $ endline| grep -ci "${jlist[j]} *," )316 ok=$( echo ${endline} | grep -ci "${jlist[j]} *," ) 315 317 [ $ok -eq 1 ] && jfound="${jlist[j]}" 316 318 j=$(( $j + 1 )) … … 318 320 if [ "$jfound" == "" ] 319 321 then 320 echo ERROR Journal not found321 echo $endline322 echo "ERROR Journal not found" 323 echo "${endline}" 322 324 exit 323 325 fi … … 325 327 # before the first : 326 328 title=${endline%%${jfound}*} 327 title=$( cleanname "$ title" )328 echo " <title>${title}</title>" >> $ fileou329 title=$( cleanname "${title}" ) 330 echo " <title>${title}</title>" >> ${fileou} 329 331 ## end 330 332 ## end of the line ; after the first ${jfound} 331 333 endline=${endline#*${jfound}} 332 endline=$( cleanname "$ endline" )334 endline=$( cleanname "${endline}" ) 333 335 ## doi 334 endline=$( echo $ endline| sed -e "s/[dD][oO][iI] *\t* *: *\t* */doi:/" )335 ok=$( echo $ endline| grep -ic "doi:" )336 endline=$( echo ${endline} | sed -e "s/[dD][oO][iI] *\t* *: *\t* */doi:/" ) 337 ok=$( echo ${endline} | grep -ic "doi:" ) 336 338 if [ $ok -eq 1 ] 337 339 then 338 340 doi=${endline##*doi:} 339 echo " <biblio misc role=\"doi\">${doi}</bibliomisc>" >> $fileou341 echo " <biblioid class=\"doi\">${doi}</biblioid>" >> ${fileou} 340 342 endline=${endline%doi:*} 341 endline=$( cleanname "$ endline" )343 endline=$( cleanname "${endline}" ) 342 344 else 343 echo non doi: $line345 echo "non doi: ${line}" 344 346 fi 345 num=$( echo $ endline| tr -dc "," | wc -c )346 case $ numin347 num=$( echo ${endline} | tr -dc "," | wc -c ) 348 case ${num} in 347 349 1) 348 ### echo $ num: ${endline}350 ### echo ${num}: ${endline} 349 351 vol=${endline%,*} 350 vol=$( cleanname "$ vol" )352 vol=$( cleanname "${vol}" ) 351 353 pag=${endline##*,} 352 pag=$( cleanname "$ pag" )353 cat <<EOF >> $ fileou354 pag=$( cleanname "${pag}" ) 355 cat <<EOF >> ${fileou} 354 356 <biblioset relation="journal"> 355 357 <title>${jfound}</title> … … 361 363 2) 362 364 vol=${endline%,*} 363 vol=$( cleanname "$ vol" )365 vol=$( cleanname "${vol}" ) 364 366 iss=${vol##*,} 365 iss=$( cleanname "$ iss" )367 iss=$( cleanname "${iss}" ) 366 368 vol=${vol%,*} 367 vol=$( cleanname "$ vol" )369 vol=$( cleanname "${vol}" ) 368 370 pag=${endline##*,} 369 pag=$( cleanname "$ pag" )370 cat <<EOF >> $ fileou371 pag=$( cleanname "${pag}" ) 372 cat <<EOF >> ${fileou} 371 373 <biblioset role="journal"> 372 374 <title>${jfound}</title> … … 377 379 ;; 378 380 *) 379 echo $ num: ${endline}380 cat <<EOF >> $ fileou381 echo ${num}: ${endline} 382 cat <<EOF >> ${fileou} 381 383 <biblioset role="journal"> 382 384 <title>${jfound}</title> … … 388 390 esac 389 391 390 cat <<EOF >> $ fileou392 cat <<EOF >> ${fileou} 391 393 </biblioentry> 392 394 … … 400 402 401 403 done 402 echo "</bibliography>" >> $ fileou404 echo "</bibliography>" >> ${fileou} 403 405 404 406 xsltproc \
Note: See TracChangeset
for help on using the changeset viewer.