Changeset 47 for trunk


Ignore:
Timestamp:
03/13/08 14:23:35 (16 years ago)
Author:
pinsard
Message:

add -p and -l parameter to bibopa.sh; add bibtex input (continuation)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bibopa.sh

    r46 r47  
    5555# 
    5656# example : 
    57 # $ ./bibopa.sh -i data/biball.txt -t raw 
    58 # $ ./bibopa.sh -i data/mail2007-04-25T08:58:16Z.txt -t mailbody 
    59 # $ ./bibopa.sh -i data/petitpolyfp.bib -t bibtex 
     57# $ ./bibopa.sh -p birefnemo -i data/biball.txt -t raw 
     58# $ ./bibopa.sh -p bibrefnemo -i data/mail2007-04-25T08:58:16Z.txt -t mailbody 
     59# $ ./bibopa.sh -p polyfortran -i data/petitpolyfp.bib -t bibtex -l fr 
    6060# 
    6161# see also mailtouser.sh 
     
    6969# ++ option debug 
    7070# $Id$ 
     71# fplod 2008-03-12T16:11:07Z aedon.locean-ipsl.upmc.fr (Darwin) 
     72# add -p option (to overide bibrefnemo in file name and id) 
     73# add -l option by default en 
    7174# fplod 2008-03-11T11:25:27Z aedon.locean-ipsl.upmc.fr (Darwin) 
    7275# add bibtex entry (not finished)++ 
     
    111114fi 
    112115# 
    113 usage=" Usage : ${command} -i filein -t type" 
    114 # 
    115 minargcount=4 
     116usage=" Usage : ${command} -i filein -t type -p project -l lang" 
     117# 
     118# default 
     119lang=en 
     120# 
     121minargcount=6 
    116122echo " narg ${#}" 
    117123if [ ${#} -lt ${minargcount} ] 
    118124then 
    119   echo "eee : not enought arguments" 
    120   echo "${usage}" 
    121   exit 1 
     125   echo "eee : not enought arguments" 
     126   echo "${usage}" 
     127   exit 1 
    122128fi 
    123129# 
     
    131137 -t) # type 
    132138  type=${2} 
     139  shift 
     140 ;; 
     141 -p) 
     142  project=${2} 
     143  shift 
     144 ;; 
     145 -l) 
     146  lang=${2} 
    133147  shift 
    134148 ;; 
     
    150164if [ ! -f ${filein} ] 
    151165then 
    152   echo "eee : ${filein} not found" 
    153   exit 1 
     166   echo "eee : ${filein} not found" 
     167   exit 1 
    154168fi 
    155169# 
     
    274288<!DOCTYPE bibliography PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" 
    275289 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"> 
    276 <bibliography id="bibrefnemo" lang="en"> 
     290<bibliography id="bib${project}ref" lang="${lang}"> 
    277291<bibliographyinfo> 
    278292<date>$( date -u +"%Y-%m-%dT%H:%M:%SZ" )</date> 
     
    322336      # parsing bibtex line 
    323337      bibtex=1 
    324 # ++ 
    325338      # before the first , 
    326339      tmp=${line%%,*} 
     
    329342      refid=${tmp#*{} 
    330343      # ++ 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 
     344      # check if author field is there 
     345      echo ${endline} | grep -q "author" 
     346      hasauthor=${?} 
     347      if [ ${hasauthor} -eq 0 ]  
     348      then  
     349         auths=$( echo ${endline} | awk -F "," '{print $1}' | sed -e "s/\(author * = *{\)\(.*\)\(}\)/\2/") 
     350         echo "auths $auths" # genre  Michael Metcalf and John Reid and Malcolm Cohen 
     351      else 
     352        echo "pas d'auteurs" # ++ 
     353      fi 
    333354      endline=${endline#*,} 
    334355      title=$( echo ${endline} | awk -F "," '{print $1}' | sed -e "s/\(title * = *{\)\(.*\)\(}\)/\2/") 
     
    338359      endline=${endline#*,} 
    339360      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%% *} 
     361      endline=${endline#*,} 
     362      edition=$( echo ${endline} | awk -F "," '{print $1}' | sed -e "s/\(edition * = *{\)\(.*\)\(}\)/\2/") 
     363      endline=${endline#*,} 
     364      isbn=$( echo ${endline} | awk -F "," '{print $1}' | sed -e "s/\(isbn * = *{\)\(.*\)\(}\)/\2/") 
     365      endline=${endline#*,} 
     366      pag=$( echo ${endline} | awk -F "," '{print $1}' | sed -e "s/\(page * = *{\)\(.*\)\(}\)/\2/") 
     367 
     368      if [ ${hasauthor} -eq 1 ]  
     369      then  
     370         ## first author before the first and 
     371         first=${auths%%and*} 
     372         # its surname after the last " "  ++ pas vrai double nom et pb blanc dans la syntaxe 
     373         # firstsn=${first##* } . ok en interactif . pas ok en script 
     374         firstsn=$( echo ${first}  | awk '{print $2}') 
     375         echo "firstsn $firstsn" 
     376         # its firstname before the first " " 
     377         firstfn=${first%% *} 
     378      fi 
    349379   fi 
    350380 
     
    357387  ${orgline} 
    358388  --> 
     389EOF 
     390      if [ ${hasauthor} -eq 1 ]  
     391      then  
     392          cat <<EOF >> ${fileou} 
    359393  <authorgroup> 
    360394    <author> <personname> <surname>${firstsn}</surname> <firstname>${firstfn}</firstname> </personname> </author> 
     
    378412     next="" 
    379413   fi 
    380    read a 
    381414  fi 
    382415  echo "previous ${previous}" 
     
    400433         # get the first next author; before the first "and" 
    401434         next=${next%%and *} 
    402   echo "next 2= ${next}" 
    403   read a 
    404  
    405435         # its surname after the last " "  ++ pas vrai double nom et pb blanc dans la syntaxe 
    406436         # nextsn=${next##* } . ok en interactif . pas ok en script 
     
    425455  done 
    426456  echo "  </authorgroup>"  >> ${fileou} 
     457  fi 
    427458 
    428459# end of the line ; after the first : 
     
    443474      echo "eee: Journal not found " 
    444475      echo "${endline}" 
    445       exit 
    446   fi 
     476      exit 1 
     477#+++ following lines are not yet validate 
     478      # it might be a book, a manual, a conference, etc. ++ 
     479      echo "  <title>${title}</title>" >> ${fileou} 
     480      echo "  <biblioid class=\"isbn\">${isbn}</biblioid>" >> ${fileou} 
     481          cat <<EOF >> ${fileou} 
     482  <biblioset relation="nojournal"> 
     483    <title>${title}</title> 
     484    <pagenums>${pag}</pagenums> 
     485    <pubdate>${year}</pubdate> 
     486  </biblioset> 
     487EOF 
     488          cat <<EOF >> ${fileou} 
     489</biblioentry> 
     490 
     491EOF 
     492  fi # end of if jfound empty (ie not an article) 
     493  if [ "${jfound}" != "" ] 
     494  then 
    447495## title 
    448496# before the first : 
     
    519567 
    520568 
    521  
     569  fi # end of if jfound not empty 
    522570  l=$(( ${l} + 1 )) 
    523571 
     
    551599# 
    552600echo " iii : you have a some new or modified bibliographic references in ${fileou} (biblioentry)" 
    553 echo " iii : you can add them in bibrefnemo.xml" #++ filename path 
    554 echo " iii : modify date in bibrefnemo.xml" #++ filename path 
     601echo " iii : you can add them in ${fileou}" #++ filename path 
     602echo " iii : modify date in ${fileou}" #++ filename path 
    555603echo " iii : but please take care of id last part (after underscore) that may" 
    556604echo " 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. 
Note: See TracChangeset for help on using the changeset viewer.