inukshuk / citeproc-ruby

A Citation Style Language (CSL) Cite Processor
101 stars 22 forks source link

Publication breaks on date-parsing #10

Closed houshuang closed 12 years ago

houshuang commented 12 years ago

This publication:

@incollection{hrimech1998spontaneous, Author = {Hrimech, M. and Bouchard, Paul}, Container = {Developing paradigms in self-directed learning}, Date-Added = {2012-03-11 13:04:46 +0000}, Date-Modified = {2012-03-11 13:04:54 +0000}, Editor = {Long, H. and Associates}, Location = {Oklahoma, OK : Oklahoma}, Pages = {27–44}, Publisher = {University Press}, Title = {Spontaneous learning strategies in the natural setting}, Year = {1998}, Bdsk-File-1 = {YnBsaXN0MDDUAQIDBAUIJidUJHRvcFgkb2JqZWN0c1gkdmVyc2lvblkkYXJjaGl2ZXLRBgdUcm9vdIABqAkKFRYXGyIjVSRudWxs0wsMDQ4RFFpOUy5vYmplY3RzV05TLmtleXNWJGNsYXNzog8QgASABqISE4ACgAOAB1lhbGlhc0RhdGFccmVsYXRpdmVQYXRo0hgNGRpXTlMuZGF0YU8RAZgAAAAAAZgAAgAAB1NTREhvbWUAAAAAAAAAAAAAAAAAAAAAAAAAAMl5T9hIKwAAANrWUhpocmltZWNoMTk5OHNwb250YW5lb3VzLnBkZgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAETRzhy4IbIQAAAAAAAAAAAAIAAgAACSAAAAAAAAAAAAAAAAAAAAAHQmliZGVzawAAEAAIAADJeZYoAAAAEQAIAADLglNhAAAAAQAMANrWUgAXPTEAAZ9eAAIAOVNTREhvbWU6VXNlcnM6AFN0aWFuOgBCaWJkZXNrOgBocmltZWNoMTk5OHNwb250YW5lb3VzLnBkZgAADgA2ABoAaAByAGkAbQBlAGMAaAAxADkAOQA4AHMAcABvAG4AdABhAG4AZQBvAHUAcwAuAHAAZABmAA8AEAAHAFMAUwBEAEgAbwBtAGUAEgAuVXNlcnMvU3RpYW4vQmliZGVzay9ocmltZWNoMTk5OHNwb250YW5lb3VzLnBkZgATAAEvAAAVAAIADP//AACABdIcHR4fWCRjbGFzc2VzWiRjbGFzc25hbWWjHyAhXU5TTXV0YWJsZURhdGFWTlNEYXRhWE5TT2JqZWN0XxAoLi4vLi4vQmliZGVzay9ocmltZWNoMTk5OHNwb250YW5lb3VzLnBkZtIcHSQloiUhXE5TRGljdGlvbmFyeRIAAYagXxAPTlNLZXllZEFyY2hpdmVyAAgAEQAWAB8AKAAyADUAOgA8AEUASwBSAF0AZQBsAG8AcQBzAHYAeAB6AHwAhgCTAJgAoAI8Aj4CQwJMAlcCWwJpAnACeQKkAqkCrAK5Ar4AAAAAAAACAQAAAAAAAAAoAAAAAAAAAAAAAAAAAAAC0A==}}

and this command cit = CiteProc.process item.to_citeproc, :style => :apa

crashes

/usr/local/lib/ruby/1.9.1/date.rb:1022:in new_by_frags': invalid date (ArgumentError) from /usr/local/lib/ruby/1.9.1/date.rb:1066:inparse' from /usr/local/lib/ruby/gems/1.9.1/gems/citeproc-ruby-0.0.4/lib/citeproc/date.rb:54:in parse_date!' from /usr/local/lib/ruby/gems/1.9.1/gems/citeproc-ruby-0.0.4/lib/citeproc/date.rb:38:inparse!' from /usr/local/lib/ruby/gems/1.9.1/gems/citeproc-ruby-0.0.4/lib/citeproc/variable.rb:52:in initialize' from /usr/local/lib/ruby/gems/1.9.1/gems/citeproc-ruby-0.0.4/lib/citeproc/variable.rb:47:innew' from /usr/local/lib/ruby/gems/1.9.1/gems/citeproc-ruby-0.0.4/lib/citeproc/variable.rb:47:in parse' from /usr/local/lib/ruby/gems/1.9.1/gems/citeproc-ruby-0.0.4/lib/citeproc/item.rb:33:inblock in merge!' from /usr/local/lib/ruby/gems/1.9.1/gems/citeproc-ruby-0.0.4/lib/citeproc/item.rb:33:in each_pair' from /usr/local/lib/ruby/gems/1.9.1/gems/citeproc-ruby-0.0.4/lib/citeproc/item.rb:33:inmerge!' from /usr/local/lib/ruby/gems/1.9.1/gems/citeproc-ruby-0.0.4/lib/citeproc/item.rb:14:in initialize' from /usr/local/lib/ruby/gems/1.9.1/gems/citeproc-ruby-0.0.4/lib/citeproc/processor.rb:90:innew' from /usr/local/lib/ruby/gems/1.9.1/gems/citeproc-ruby-0.0.4/lib/citeproc/processor.rb:90:in block in import' from /usr/local/lib/ruby/gems/1.9.1/gems/citeproc-ruby-0.0.4/lib/citeproc/processor.rb:89:ineach' from /usr/local/lib/ruby/gems/1.9.1/gems/citeproc-ruby-0.0.4/lib/citeproc/processor.rb:89:in import' from /usr/local/lib/ruby/gems/1.9.1/gems/citeproc-ruby-0.0.4/lib/citeproc/processor.rb:22:inblock in process' from /usr/local/lib/ruby/gems/1.9.1/gems/citeproc-ruby-0.0.4/lib/citeproc/processor.rb:12:in initialize' from /usr/local/lib/ruby/gems/1.9.1/gems/citeproc-ruby-0.0.4/lib/citeproc/processor.rb:18:innew' from /usr/local/lib/ruby/gems/1.9.1/gems/citeproc-ruby-0.0.4/lib/citeproc/processor.rb:18:in process' from /usr/local/lib/ruby/gems/1.9.1/gems/citeproc-ruby-0.0.4/lib/citeproc.rb:82:inprocess' from bibtex-batch.rb:105:in block in <main>' from /usr/local/lib/ruby/gems/1.9.1/gems/bibtex-ruby-2.0.4/lib/bibtex/bibliography.rb:144:ineach' from /usr/local/lib/ruby/gems/1.9.1/gems/bibtex-ruby-2.0.4/lib/bibtex/bibliography.rb:144:in each' from bibtex-batch.rb:82:in

'

Note that I could not reproduce this from IRB (although the resulting citation is empty, so something is still going wrong):

irb(main):022:0> item = c[0] => #<BibTeX::Entry ./author = Hrimech, M. and Bouchard, Paul, ./container = Developing paradigms in self-directed learning, ./date-added = 2012-03-11 13:04:46 +0000, ./date-modified = 2012-03-11 13:04:54 +0000, ./editor = Long, H. and Associates, ./location = Oklahoma, OK : Oklahoma, ./pages = 27â44, ./publisher = University Press, ./title = Spontaneous learning strategies in the natural setting, ./year = 1998, ./bdsk-file-1 = YnBsaXN0MDDUAQIDBAUIJidUJHRvcFgkb2JqZWN0c1gkdmVyc2lvblkkYXJjaGl2ZXLRBgdUcm9vdIABqAkKFRYXGyIjVSRudWxs0wsMDQ4RFFpOUy5vYmplY3RzV05TLmtleXNWJGNsYXNzog8QgASABqISE4ACgAOAB1lhbGlhc0RhdGFccmVsYXRpdmVQYXRo0hgNGRpXTlMuZGF0YU8RAZgAAAAAAZgAAgAAB1NTREhvbWUAAAAAAAAAAAAAAAAAAAAAAAAAAMl5T9hIKwAAANrWUhpocmltZWNoMTk5OHNwb250YW5lb3VzLnBkZgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAETRzhy4IbIQAAAAAAAAAAAAIAAgAACSAAAAAAAAAAAAAAAAAAAAAHQmliZGVzawAAEAAIAADJeZYoAAAAEQAIAADLglNhAAAAAQAMANrWUgAXPTEAAZ9eAAIAOVNTREhvbWU6VXNlcnM6AFN0aWFuOgBCaWJkZXNrOgBocmltZWNoMTk5OHNwb250YW5lb3VzLnBkZgAADgA2ABoAaAByAGkAbQBlAGMAaAAxADkAOQA4AHMAcABvAG4AdABhAG4AZQBvAHUAcwAuAHAAZABmAA8AEAAHAFMAUwBEAEgAbwBtAGUAEgAuVXNlcnMvU3RpYW4vQmliZGVzay9ocmltZWNoMTk5OHNwb250YW5lb3VzLnBkZgATAAEvAAAVAAIADP//AACABdIcHR4fWCRjbGFzc2VzWiRjbGFzc25hbWWjHyAhXU5TTXV0YWJsZURhdGFWTlNEYXRhWE5TT2JqZWN0XxAoLi4vLi4vQmliZGVzay9ocmltZWNoMTk5OHNwb250YW5lb3VzLnBkZtIcHSQloiUhXE5TRGljdGlvbmFyeRIAAYagXxAPTlNLZXllZEFyY2hpdmVyAAgAEQAWAB8AKAAyADUAOgA8AEUASwBSAF0AZQBsAG8AcQBzAHYAeAB6AHwAhgCTAJgAoAI8Aj4CQwJMAlcCWwJpAnACeQKkAqkCrAK5Ar4AAAAAAAACAQAAAAAAAAAoAAAAAAAAAAAAAAAAAAAC0A==> irb(main):023:0> cit = CiteProc.process item.to_citeproc, :style => :apa => "In ."

When I removed this one citation from the file of more than 1000, everything else processed swimmingly. Looking at it, I can't see immediately what is wrong. Automatically generated from BibDesk.

houshuang commented 12 years ago

Seems like the issue was the field Container, which erroneously contained the book title. Maybe citeproc expected Container to contain a date, and thus tried to parse it.

inukshuk commented 12 years ago

Yes, I just debugged this as well and came to same conclusion. CSL defines 'container' as a date field (e.g., here) so the processor tries to convert the string into a date.

If CSL did not define it we could add the mapping to bibtex-ruby, but as it is, the best solution is to rename 'collection' to 'collection-title' (you can use 'booktitle', too, and bibtex-ruby will translate it to 'collection-title' during the citeproc export).