inukshuk / bibtex-ruby

A BibTeX library, parser, and converter for Ruby.
http://inukshuk.github.com/bibtex-ruby
GNU General Public License v3.0
156 stars 31 forks source link

Refactor Entry#to_rdf #83

Closed tmaier closed 10 years ago

tmaier commented 10 years ago

This pull request is a work in progress and related to #82. Critics, suggestions or hints for the conversion of more fields are highly welcome.

Todo

inukshuk commented 10 years ago

Looks great so far!

One minor suggestion: I would add an instance method #convert! or something like that that goes through all the methods instead of doing that in the constructor by default. I imagine this will give you more flexibility and make testing easier (you can create an instance and call individual converters or change the source object in between etc.).

Have you considered adding an RDF to BibTeX conversion as well? Would that be useful do you think?

tmaier commented 10 years ago

The #convert! Thing is exactly something I thought about when I woke up today :)

Yes, I will definitely write a rdf to bibtex conversion. I just wonder if bibtex-ruby is the right place and where there exactly.

One more thing: I would like to avoid data loss when converting to rdf. Theoretically, it would be possible to mix in bibtexml into the rdf for fields which cannot be represented as expected. What do you think?

inukshuk commented 10 years ago

Unfortunately, I have too little practical experience using RDF to have an informed opinion on field mappings or mixing in BibTeXML. Perhaps you could ask @bdarcus for advice?

One more thing I noticed: please make sure to require the rdf gem only the first time that to_rdf is called — otherwise users who do not use RDF will be confused by the load error message.

bdarcus commented 10 years ago

RDF is an general data model. BibTeX is a very specific one. So it doesn't make sense to talk aboutconverting from RDF, unless you talk specific vocabularies. I'd leave it out.

tmaier commented 10 years ago

Yeah, this is the reason why I'm not sure if bibtex-ruby is the right place for it.

But coming back to adding bibtexml to the rdf. Is this ok (as an addition to bibo)?

bdarcus commented 10 years ago

RDF/XML allows you to embed XML within a property, so long as you use the right attribute (per the RDF/XML spec).

But you need to think about the trade-offs in doing that. Yes, you preserve the data, but if that RDF gets consumed more broadly, it may be that the data can't get properly displayed.

On Sat, Jan 18, 2014 at 9:25 AM, Tobias L. Maier notifications@github.comwrote:

Yeah, this is the reason why I'm not sure if bibtex-ruby is the right place for it.

But coming back to adding bibtexml to the rdf. Is this ok (as an addition to bibo)?

— Reply to this email directly or view it on GitHubhttps://github.com/inukshuk/bibtex-ruby/pull/83#issuecomment-32683013 .

tmaier commented 10 years ago

Almost done.

I didn't come up with a good way to test the graph. I would appreciate some ideas.

inukshuk commented 10 years ago

Great job! Thanks also for moving the converters to separate files and tidying up.

What's your own use case for the RDF export? In my experience this usually gives you a good test case (e.g., some expectation you have on the graph object ) if it's possible to strip it down to the bare minimum. Any ideas?

Otherwise just let me know when you want this merged; I'll also push this out to rubygems afterwards.

tmaier commented 10 years ago

Alright. I consider it as done for now.

The only thing what should be highlighted in the README is, that one needs to convert the LaTeX code to UTF-8 before exporting to RDF or anything else.

convert(:latex).to_rdf

Please have an extra look at 171983fed36625b8ded23955be74ee66169b7765. This is a change which is not really related with this pull request. If you're unhappy with this, please let me know. I would remove it from here and open a new PR just for this change.

inukshuk commented 10 years ago

That's fine. Landed in 3.1.0. Cheers!