5j9 / citer

An online citation generator for Wikipedia
GNU General Public License v3.0
26 stars 13 forks source link

Handling incollection #4

Closed AndreasLoow closed 7 years ago

AndreasLoow commented 7 years ago

Consider e.g. DOI 10.1007/BFb0064872. Trying to extract a citation entry for this DOI results in an error because the script cannot handle incollection:

Traceback (most recent call last):
  File "main.py", line 130, in application
    response = get_response(user_input, date_format)
  File "main.py", line 109, in get_response
    return doi_response(m.group(1), pure=True, date_format=date_format)
  File "/Users/loow/dev/yadkard/doi.py", line 49, in doi_response
    return dictionary_to_response(dictionary)
  File "/Users/loow/dev/yadkard/commons.py", line 151, in dictionary_to_response
    cite, sfn, ref = citations(dictionary)
  File "/Users/loow/dev/yadkard/generator_en.py", line 22, in citations
    raise KeyError(type_ + " is not a valid value for d['type']")
KeyError: "incollection is not a valid value for d['type']"

But it’s not obvious (to me) what citation template to map this to… Any ideas?

5j9 commented 7 years ago

I'm not sure either, for now I'll fix it using cite book.

AndreasLoow commented 7 years ago

Thank you, but I'm not sure I agree with this solution. Having thought about it a little more, I think it makes sense to guess a type (maybe cite book is fine), but there should be some warning that this guessing took place and what the guess was based on. And as it's only a guess there should be some way for the reader to override the type. But this is only me thinking out loud, I haven't looked at this more closely yet. For example, if all parameter names are the same in all citation templates there's no need for the override option, as it's equally easy to just replace the template name manually.

5j9 commented 7 years ago

According to BibTeX documentation, incollection is used for "A part of a book having its own title." Therefore using cite book seems to be safe, but I have to look for more real-world examples.

AndreasLoow commented 7 years ago

The reason I got confused is that the article is a conference/symposium article (I think), so because of this cite conference would make sense... But it's also a book so I guess cite book is equally sensible. But I think cite conference makes the most sense here. Furthermore, there seems to exist various opinions about this.

Another interesting thing: If one does "Export citation" on the webpage one gets an @Inbook entry:

@Inbook{Meyer1975,
author="Meyer, Albert R.",
editor="Parikh, Rohit",
title="Weak monadic second order theory of succesor is not elementary-recursive",
bookTitle="Logic Colloquium: Symposium on Logic Held at Boston, 1972--73",
year="1975",
publisher="Springer Berlin Heidelberg",
address="Berlin, Heidelberg",
pages="132--154",
isbn="978-3-540-37483-1",
doi="10.1007/BFb0064872",
url="http://dx.doi.org/10.1007/BFb0064872"
}

But using the DOI interface one gets this instead:

> curl -LH "Accept: application/x-bibtex" http://dx.doi.org/10.1007/BFb0064872
@incollection{Meyer_1975,
    doi = {10.1007/bfb0064872},
    url = {https://doi.org/10.1007%2Fbfb0064872},
    year = 1975,
    publisher = {Springer Berlin Heidelberg},
    pages = {132--154},
    author = {Albert R. Meyer},
    title = {Weak monadic second order theory of succesor is not elementary-recursive},
    booktitle = {Lecture Notes in Mathematics}
}

Notice e.g. how the editor is missing in the latter, and the book titles are different.

5j9 commented 7 years ago

But I think cite conference makes the most sense here.

I see, but I don't know how we can reliably and efficiently determine the best type here. They probably should've used proceedings or conference as type in their BibTeX output.

Notice e.g. how the editor is missing in the latter, and the book titles are different.

That's a shame. Again, I can't think of a good general solution for this... :/

BTW, thanks to this thread, I'm working on adding support for other bibtex types such as inbook (cite book), conference (cite conference), phdthesis (cite thesis), etc.

AndreasLoow commented 7 years ago

I see, but I don't know how we can reliably and efficiently determine the best type here. They probably should've used proceedings or conference as type in their BibTeX output.

Yeah, the best one can do here is probably various heuristics, such as looking for words such as colloquium, proceedings, conference etc. in e.g. the bookTitle field.

That's a shame. Again, I can't think of a good general solution for this... :/

Yes, I don't see one either. One would have to maintain a list och sites that publish more content in the website-specific bibtex export and use that export function when one notices that a DOI (or something else) points to one of those websites.