Page MenuHomePhabricator

Citoid configuration on some language wikis doesn't handle citations for book chapters correctly
Closed, ResolvedPublic8 Estimated Story Points

Description

I was looking into the possibility of adding citoid support to the RefToolbar gadget, but I noticed a potential complication. If the URL given to citoid is for a book chapter it will return the chapter title as "title" and the book title as "bookTitle", but if the URL is for a book (https://books.google.com/books?id=k-XBMNVRfw4C), it will return the book title as "title". I decided to take a look at how VisualEditor handles this problem and discovered that it doesn't. Because there is no way to set up a reliable mapping in the TemplateData (that I could figure out), it simply fills in the wrong value for the title param and drops the real book title in the case of URLs for book chapters.

Example:

http://accessemergencymedicine.mhmedical.com/content.aspx?sectionid=72121336&bookid=1345&Resultclick=2

10.1017/isbn-9780511132971.eh1-7

Done:

  • en
  • fr
  • sr

Event Timeline

kaldari raised the priority of this task from to Needs Triage.
kaldari updated the task description. (Show Details)
kaldari added projects: Citoid, VisualEditor.
kaldari subscribed.
kaldari renamed this task from Citoid Extension/VisualEditor doesn't handle Citations for book chapters correctly to Citoid/VisualEditor doesn't handle Citations for book chapters correctly.Oct 1 2015, 10:49 PM
kaldari set Security to None.

The easiest solution would probably be to change the output of the Citoid API in the case of book chapters:

"title":"A Book",
"chapterTitle":"A Chapter"

rather than:

"title":"A Chapter",
"bookTitle":"A Book"

Then the templateData could be mapped like so (regardless of whether the data was for a book or a chapter):

"title": "title",
"chapterTitle": "chapter"

I have no idea, however, if the citoid API is trying to conform to some 3rd party standard and thus can't be changed in such a way.

kaldari renamed this task from Citoid/VisualEditor doesn't handle Citations for book chapters correctly to Citoid/VisualEditor doesn't handle citations for book chapters correctly.Oct 1 2015, 11:44 PM

This is similar to: T93355

Basically, we are conforming to a third party standard, which is Zotero's type and field system, full list of types and fields here: http://aurimasv.github.io/z2csl/typeMap.xml

We didn't end up making templateData configurable such that multiple citation fields could correspond to a single template field because it would make it rather complicated/confusing to write, and there's a simple albeit ugly solution which is to make a template called bookChapter that is identical to some other template but give it its own template data, and then put that template into the mediawiki name space message, instead of cite book.

That said, you'll notice in the Zotero type map there that are "base types" that would cause us fewer issues since the base types tend to match across itemTypes more readily (publicationTitle instead of bookTitle, for instance. There would still be an issue with cite book but cite journal or citation might work okay.) The problem is that we can't currently get those from Zotero itself, see: https://github.com/zotero/dataserver/issues/23

So one possible solution might be to manually do the coersion ourselves locally, something I'd seriously consider doing. @mobrovac, @Jdforrester-WMF, thoughts? Worth doing the coersion? We theoretically could also change how the templateData functions but that's something I'd really prefer not to do.

Jdforrester-WMF edited a custom field.
Jdforrester-WMF moved this task from To Triage to Freezer on the VisualEditor board.

I've created a wrapper around Cite book that solves this issue here: https://en.wikipedia.org/wiki/Template:Cite_chapter

It's basically identical except there's a tiny change to the template data.

However I think we probably need community consensus before configuring the message to use it, because that means Template:Cite_chapter will start appearing in pages. Thoughts? Should we ask about this in the CS1 talk page maybe?

@Mvolz: Hmm, doesn't look like that went over very well. What's the downside to coercing "title" to "chapterTitle" in the case of itemType == bookSection? Just not conforming strictly to Zotero?

@Mvolz: Hmm, doesn't look like that went over very well. What's the downside to coercing "title" to "chapterTitle" in the case of itemType == bookSection? Just not conforming strictly to Zotero?

The problem is that we'd be mutating a standard to conform with a particular template, which is not standard. Other wikis could easily have the reverse problem. There are multiple ways to fix this in the template.

Another solution is to actually change the CS1 template to add a parameter "bookTitle" and add that as an alternate path of being interpreted as a book chapter.

The Zotero approach is the correct one IMO; the title of the work IS the title of the chapter for book chapters. CS1 handles this correctly for journal articles - the title of the work is the title of the journal article, and the title of the container is publication title, but not for book sections.

The CS1-based templates—which are actually in use across a lot of different language wikipedias—quite correctly provides distinct parameters for the title of the book and the title of a chapter within that book; much as it provides distinct parameters for an encyclopedia and a particular entry in that encyclopedia. Based on the description here, Zotero also provides distinct parameters for these, it just does so in a needlessly complicated way (changing the semantics of the title attribute based on type, when you need two "title" type fields anyway, is just asking for needless complications in implementation). Or put another way: both CS1 and Zotero appear to be capable of expressing the concepts in question here.

In other words, the actual problem here is that the current implementation of TemplateData is not sufficiently expressive to deal with the complicated way Zotero has chosen to present this information. If a main goal of TemplateData is to enable VisualEditor to make use of Zotero-based citation data in local citation templates, then TemplateData must implement the entire (relevant) information model from Zotero (including its intentional polymorphism). Altering widely used cross-project templates like CS1 to work around limitations in intermediary plumbing like TemplateData is a bad (costly) idea that really shouldn't even be on the table.

PS. The title of a book does not change just because you're citing a chapter within it. Given a set of citation data, you can design your information model such that the semantics of information elements like "title" change based on context, or you can design it such that the semantics of a given information element is always the same and some attribute gives the level of specificity you are after (i.e. book or chapter), or you can infer it from whether a particular subset of information elements are present. If your information model is poorly chosen you will have the kind of problem we're seeing here whenever multiple components are involved: the components are not semantically interoperable. It's not enough that the information model seemingly maps cleanly to a given data model, or that the data maps seemingly easily to an API. If all the components involved do not implement the same information model, they are not interoperable (semantically).

@Mvolz: I think part of the problem with my specific example in the description is that Citoid/Zotero identifies that URL as a "conferencePaper" rather than a "bookSection". So technically, I think that specific example is being handled correctly: it's handling the "title" as an article title (rather than a chapter title) and correctly putting it in the title parameter. We need to find a URL that Zotero actually recognizes as a bookSection and then see how that gets handled.

@Mvolz: I think part of the problem with my specific example in the description is that Citoid/Zotero identifies that URL as a "conferencePaper" rather than a "bookSection". So technically, I think that specific example is being handled correctly: it's handling the "title" as an article title (rather than a chapter title) and correctly putting it in the title parameter. We need to find a URL that Zotero actually recognizes as a bookSection and then see how that gets handled.

The other option is just to use Cite encyclopedia. I had thought that a wrapper around cite book would be more palatable - apparently not!

But the way it's currently handled is just totally wrong because it leaves out the title of the chapter entirely, so I think changing it to cite encyclopedia from cite book for bookSection is the preferred option for the time being, it's less wrong and doesn't require any wrapper templates and so nothing being altered about current templates.

Examples:

http://accessemergencymedicine.mhmedical.com/content.aspx?sectionid=72121336&bookid=1345&Resultclick=2

10.1017/isbn-9780511132971.eh1-7

@Mvolz: Actually it's not that bad due to how the TemplateData mapping is set up in Cite book. If you put http://accessemergencymedicine.mhmedical.com/content.aspx?sectionid=72121336&bookid=1345&Resultclick=2 into the cite interface in VisualEditor, it puts the bookTitle into the template's title parameter, which is good. I'm assuming this is because it comes after the title->title mapping in the TemplateData:

"title": "title",
"bookTitle": "title",
"publicationTitle": "title",

If we just have citoid also include a chapterTitle and map that to the chapter param in the TemplateData, our problem is solved. In that case citoid's title element is just unused (or rather overridden by later data), so it doesn't really matter that it's wrong.

@Mvolz: Actually it's not that bad due to how the TemplateData mapping is set up in Cite book. If you put http://accessemergencymedicine.mhmedical.com/content.aspx?sectionid=72121336&bookid=1345&Resultclick=2 into the cite interface in VisualEditor, it puts the bookTitle into the template's title parameter, which is good. I'm assuming this is because it comes after the title->title mapping in the TemplateData:

"title": "title",
"bookTitle": "title",
"publicationTitle": "title",

If we just have citoid also include a chapterTitle and map that to the chapter param in the TemplateData, our problem is solved. In that case citoid's title element is just unused (or rather overridden by later data), so it doesn't really matter that it's wrong.

This doesn't work because then it will add the chapterTitle to every single book with the title of the book when you're citing the book. This will cause all books to be interpreted as chapters instead.

I think using Citation instead which will handle the issue and put the bookTitle in "work" - or maybe "encyclopedia" - that actually might be a good way to do it anyway since not all bookSections are chapters.

Mvolz claimed this task.
Mvolz updated the task description. (Show Details)

Re-opening because this is only fixed for en wiki, i.e. fr even *has* a chapitre template but isn't using it.

I work on changing it on Serbian Wikipedia

Mvolz renamed this task from Citoid/VisualEditor doesn't handle citations for book chapters correctly to Citoid configuration on some language wikis doesn't handle citations for book chapters correctly.Nov 15 2018, 11:30 AM
Mvolz moved this task from Production to Site Config on the Citoid board.