Re: Call for comments: File BibTex
| From: | Elmar Pitschke | Date: | Sun, 09 Apr 2006 21:37:49 +0000 |
| Subject: | Re: Call for comments: File BibTex | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-42180@lists.php.net to get a copy of this message | ||
Hi Jesus,
> Am Freitag, 7. April 2006 18:43 schrieb Jesus M. Castagnetto:
> Hi Elmar,
>
> --- Elmar Pitschke <elmar.pitschke@gmx.de> wrote:
> > Am Donnerstag, 6. April 2006 22:07 schrieb Arnaud Limbourg:
> > > Elmar Pitschke wrote:
> > > > Hello,
> > > >
> > > > this is my first proposal to Pear so please be patient if i'm doing
> > > > some stupid mistakes. I have proposed the outcome of a project i did
> > > > at my university to work with BibTex data. The class works but i
> > > > don't know if there is anything more needed for proposal.
> > > >
> > > > If you have a minute to spare please take a look at this proposal:
> > > >
> > > > http://pear.php.net/pepr/pepr-proposal-show.php?id=386
> > > >
> > > > Thanks for your time
> > > > Regards
> > > > Elmar Pitschke
> > >
> > > Hi,
> > >
> > > It would be great if you could put .phps files online.
> > >
> > > Does the class generate the bibtex.tex file as well, it looks like the
> > > most useful feature to me ?
> > >
> > > Arnaud.
> >
> > Hi,
> > thanks for the comment. I put a .phps file online at:
> > http://www.helftgreg.de/bibtex/BibTex.phps
> > Also i updated the proposal. Of course there is also a method to export
> > the data in BibTex Format again it is called "bibTex".
>
> The code for the parser is very naive. Seems like you did not test it with
> a variety of BIBTEX input. For one, you cannot rely on the field data being
> on just one line. That is an artificial restriction you are putting in your
> code and does not exist in the original Bibtex spec. Your code fails in
> many sample files known in the literature.
>
> Also, it seems like the code is just the start of a Bibtex parser, because
> it does not do any validation of the entries being added, or parsed (see
> example below). It might be nice to have some sort of encapsulation and
> validation of entries, but this could be a new package (Structure_BibTex
> perhaps?), so one could do:
>
> $art = new Structure_BibTex_Article();
> $art->setAuthor(array('Random Nerd', 'Unix Foggie'));
> ... etc.
>
> In any case, take a look at:
>
>
> ftp://sunsite.unc.edu/pub/packages/TeX/biblio/bibtex/distribs/doc/btxdoc.te
>x (or the similar document in the tetex distribution)
> http://en.wikipedia.org/wiki/BibTeX
>
> http://www-static.cc.gatech.edu/classes/RWL/Projects/citation/Docs/UserManu
>als/Reference_Pages/bibtex_doc.html
> http://www.ecst.csuchico.edu/~jacobsd/bib/formats/bibtex.html
>
> From the second URL we can take an example that will break your code:
>
> [ex.bib]
> @Book{abramowitz+stegun,
> author = "Milton Abramowitz and Irene A. Stegun",
> title = "Handbook of Mathematical Functions with
> Formulas, Graphs, and Mathematical Tables",
> publisher = "Dover",
> year = 1964,
> address = "New York",
> edition = "ninth Dover printing, tenth GPO printing",
> isbn = "0-486-61272-4"
> }
>
> when run with your code:
>
> $ex = new File_BibTex();
> $ex->loadFile('ex.bib');
> $ex->parse();
> print_r($ex->data);
>
> gives the incorrect:
>
> Array
> (
> [0] => Array
> (
> [type] => Book
> [cite] => abramowitz+stegun
> [author] => Array
> (
> [0] => Milton Abramowitz
> [1] => Irene A. Stegun
> )
>
> [title] => Handbook of Mathematical Functions wit
> [Formulas, Graphs, and Mathematical Tables",
> publisher] => Dover
> [year] => 1964
> [address] => New York
> [edition] => ninth Dover printing, tenth GPO printing
> [isbn] => 0-486-61272-4
> )
>
> )
>
>
> --
> Jesus M. Castagnetto (jcastagnetto@yahoo.com)
> Web site: http://www.castagnetto.org/
> Research: http://metallo.scripps.edu/
> PEAR stuff: http://pear.php.net/user/jmcastagnetto
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
thanks for the remarks. The funny thing is that with the example which is in
the german version of wikipedia my code won't break. Nevertheless on the
weekend i had a rather good idea to get a better parser but it takes me some
time to implement it. I will get back to this list as soon as it is finished.
And i also added your BibTex example to my Unit Testings.
I also see this as the beginning of a BibTex class. Validation would be
another possibility what may be implemented later. Another possibility would
be some export functions: BibTex, text or even RTF. But first i am satisfied
if the parser works ;)
Thanks for your help
Regards
Elmar