- Timestamp:
- 03/12/08 14:35:41 (16 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bibopa.sh
r45 r46 55 55 # 56 56 # example : 57 # $ ./bibopa.sh -i /Users/smasson/Bibopa/biball.txt -t raw57 # $ ./bibopa.sh -i data/biball.txt -t raw 58 58 # $ ./bibopa.sh -i data/mail2007-04-25T08:58:16Z.txt -t mailbody 59 59 # $ ./bibopa.sh -i data/petitpolyfp.bib -t bibtex … … 175 175 #more ${fileraw} # ++ if debug 176 176 #read a #++ if debug 177 echo "not yet implemented. sorry."178 exit 1179 177 ;; 180 178 *) … … 293 291 orgline=$( echo ${line} | sed -e "s/--/- -/g" ) 294 292 line=$( echo ${line} | sed -e "s/</\</g" -e "s/>/\>/g" ) 295 # before the first : 296 tmp=${line%%:*} 297 # before the last , 298 auths=${tmp%,*}, 299 # supress and 300 auths=$( echo "${auths}" | sed -e "s/ and //g" ) 301 # after the last , 302 year=${tmp##*,} 303 year=$( rmbl "${year}" ) 304 ## first author before the first ., 305 first=${auths%%.,*}. 306 # its firstname after the last , 307 firstfn=${first##*,} 308 firstfn=$( rmbl "${firstfn}" ) 309 # its surname ; before the first , 310 firstsn=${first%%,*} 311 firstsn=$( rmbl "${firstsn}" ) 312 ## ref id 313 refid=$( echo ${firstsn} | tr "[:upper:]" "[:lower:]" | tr -s " " "_" | tr -s "'" "_" | recode -d -f ISO-8859-1..flat )${year} 314 num=$( grep -c "<biblioentry id=\"${refid}_[0-9][0-9]\">" ${fileou} ) 315 num=$(( ${num} + 1 )) 316 [ ${num} -le 9 ] && num=0${num} 317 refid=${refid}_${num} 293 # detect if bibtex or not bibtex (starting with @) 294 if [ ${line:0:1} != "@" ] 295 then 296 # parsing non bibtex line 297 bibtex=0 298 # before the first : 299 tmp=${line%%:*} 300 # before the last , 301 auths=${tmp%,*}, 302 # supress and 303 auths=$( echo "${auths}" | sed -e "s/ and //g" ) 304 # after the last , 305 year=${tmp##*,} 306 year=$( rmbl "${year}" ) 307 ## first author before the first ., 308 first=${auths%%.,*}. 309 # its firstname after the last , 310 firstfn=${first##*,} 311 firstfn=$( rmbl "${firstfn}" ) 312 # its surname ; before the first , 313 firstsn=${first%%,*} 314 firstsn=$( rmbl "${firstsn}" ) 315 ## ref id 316 refid=$( echo ${firstsn} | tr "[:upper:]" "[:lower:]" | tr -s " " "_" | tr -s "'" "_" | recode -d -f ISO-8859-1..flat )${year} 317 num=$( grep -c "<biblioentry id=\"${refid}_[0-9][0-9]\">" ${fileou} ) 318 num=$(( ${num} + 1 )) 319 [ ${num} -le 9 ] && num=0${num} 320 refid=${refid}_${num} 321 else 322 # parsing bibtex line 323 bibtex=1 324 # ++ 325 # before the first , 326 tmp=${line%%,*} 327 endline=${line#*,} 328 # refid is after { and before the first comma 329 refid=${tmp#*{} 330 # ++ test if refid already exist 331 auths=$( echo ${endline} | awk -F "," '{print $1}' | sed -e "s/\(author * = *{\)\(.*\)\(}\)/\2/") 332 echo "auths $auths" # genre Michael Metcalf and John Reid and Malcolm Cohen 333 endline=${endline#*,} 334 title=$( echo ${endline} | awk -F "," '{print $1}' | sed -e "s/\(title * = *{\)\(.*\)\(}\)/\2/") 335 endline=${endline#*,} 336 echo ${endline} | awk -F "," '{print $1}' 337 year=$( echo ${endline} | awk -F "," '{print $1}' | sed -e "s/\(year * = *{\)\(.*\)\(}\)/\2/") 338 endline=${endline#*,} 339 publisher=$( echo ${endline} | awk -F "," '{print $1}' | sed -e "s/\(publisher * = *{\)\(.*\)\(}\)/\2/") 340 341 ## first author before the first and 342 first=${auths%%and*} 343 # its surname after the last " " ++ pas vrai double nom et pb blanc dans la syntaxe 344 # firstsn=${first##* } . ok en interactif . pas ok en script 345 firstsn=$( echo ${first} | awk '{print $2}') 346 echo "firstsn $firstsn" 347 # its firstname before the first " " 348 firstfn=${first%% *} 349 fi 318 350 319 351 cat <<EOF >> ${fileou} … … 330 362 331 363 ## other authors.. 332 previous=${first}, 333 # next authors... 334 next=${auths##*${previous}} 364 if [ ${bibtex} -eq 0 ] 365 then 366 previous=${first}, 367 # next authors... 368 next=${auths##*${previous}} 369 fi 370 if [ ${bibtex} -eq 1 ] 371 then 372 previous=${first}"and " 373 # next authors... 374 echo "auths ${auths}" 375 next=${auths##*${previous}} 376 if [ "${next}and " = "${previous}" ] 377 then 378 next="" 379 fi 380 read a 381 fi 382 echo "previous ${previous}" 383 echo "next ${next}" 335 384 # while the next author is not empty 336 385 while [ "${next}" != "" ] 337 386 do 338 # get the first next author; before the first , 339 next=${next%%,*} 340 # its surname ; after the last . 341 nextsn=${next##*.} 342 nextsn=$( rmbl "${nextsn}" ) 343 # its firstname ; before the last . 344 nextfn=${next%.*}. 345 nextfn=$( rmbl "${nextfn}" ) 387 if [ ${bibtex} -eq 0 ] 388 then 389 # get the first next author; before the first , 390 next=${next%%,*} 391 # its surname ; after the last . 392 nextsn=${next##*.} 393 nextsn=$( rmbl "${nextsn}" ) 394 # its firstname ; before the last . 395 nextfn=${next%.*}. 396 nextfn=$( rmbl "${nextfn}" ) 397 fi 398 if [ ${bibtex} -eq 1 ] 399 then 400 # get the first next author; before the first "and" 401 next=${next%%and *} 402 echo "next 2= ${next}" 403 read a 404 405 # its surname after the last " " ++ pas vrai double nom et pb blanc dans la syntaxe 406 # nextsn=${next##* } . ok en interactif . pas ok en script 407 nextsn=$( echo ${next} | awk '{print $2}') 408 echo "nextsn $nextsn" 409 # its nextname before the first " " 410 nextfn=${next%% *} 411 fi 346 412 # 347 413 echo " <author> <personname> <surname>${nextsn}</surname> <firstname>${nextfn}</firstname> </personname> </author>" >> ${fileou} 348 414 echo " <author> <personname> <surname>${nextsn}</surname> <firstname>${nextfn}</firstname> </personname> </author>" #++debug 349 previous=${next}, 350 next=${auths##*${previous}} 351 415 if [ ${bibtex} -eq 0 ] 416 then 417 previous=${next}, 418 next=${auths##*${previous}} 419 fi 420 if [ ${bibtex} -eq 1 ] 421 then 422 previous=${next}"and " 423 next=${auths##*${previous}} 424 fi 352 425 done 353 426 echo " </authorgroup>" >> ${fileou} -
trunk/data/petitpolyfp.bib
r45 r46 1 1 @book{MetReiCoh2004 , 2 author = {Michael Metcalf and 3 John Reid and Malcolm Cohen}, 2 author = {Michael Metcalf and John Reid and Malcolm Cohen}, 4 3 title = {Fortran 95/2003 explained}, 5 4 year = {2004},
Note: See TracChangeset
for help on using the changeset viewer.