Page MenuHomePhabricator

Look into how the Citoid/translate-server service approaches input
Closed, ResolvedPublic

Description

Context

To allow better support for user that use the Citoid service we need to better understand how the service works and especially how it prioritizes the different methods to lookup metadata or return the information to the Citoid extension.

What to look into
  • Which methods does Citoid know to analyze the source and create metadata

( e.g. ISBN/DOI/plain URL handling )

  • In which order does Citoid evaluate the input?
  • What changes could be made to possibly improve that process?
  • Is content type negotiation something that's involved?
Ideal outcome

Would be great to have a visualized decision tree.

Example

https://www.pnas.org/doi/pdf/10.1073/pnas.2108146119

Notes

https://docs.google.com/document/d/1KRbcDP8Q52lUbvsqwakjAFZk_AyDZg8tdENTgv7F_5o/edit?tab=t.j8w6c4lbnsp9

Outcome

Summary

The native Citoid scraper first extracts structured metadata from commonly used metadata standards, including Highwire Press, bePress, Open Graph, and Dublin Core. Extracted identifiers such as DOIs are used to enrich metadata through Crossref where possible. The collected metadata is translated into a unified citation format. If structured metadata is incomplete, additional fallback extraction methods are applied directly to the HTML document.

InputWorkflow
URLZotero Web → Native Scraper → DOI-Fallback
DOIZotero Search → URL Workflow + Crossref
PMID/PMCIDZotero Search → PubMed DOI Lookup → DOI Workflow
ISBNZotero Search
Free textCrossref Search
Input type check order

Citoid checks the user input first for different input types in this order:

#input typeexampleservice
1PMC URLhttps://pmc.ncbi.nlm.nih.gov/articles/PMC6751825/requestFromPM()
2PubMed URLhttps://pubmed.ncbi.nlm.nih.gov/33305422/requestFromPM()
3HTTP/WWW URLhttps://example.com/articlerequestFromURL() comment: this would also match for above two types, so it make sense that they happen before, unclear if an overwrite happens often if this is faster
4DOI10.1038/nature12373requestFromDOI()
5QIDQ42requestFromURL()
6PMCIDPMC6751825requestFromPM()
7ISBN978-3-12-732320-7requestToZotISBN()
8PMID31533695requestFromPM() this is only checked if the input type is not an ISBN
9Domain-like URLwikipedia.derequestFromURL()
10Open SearchBook by Douglas Adam
image.png (418×355 px, 54 KB)
requestFromSearch() comment: this does not seem to always work
11Embedded URL extraction (additional lookup)This is an interesting article https://example.com/articlerequestFromURL()

This information has been extracted from the code (lib/CitoidService.js).
The first match ends the check. This does not necessarily need to be the first one. If the first checks takes longer, a later one could be faster.
This means that results can vary over time.

Metadata retrieval

Next one of the following function is called depending on the input type:

  • PMC URL / PubMed URL / PMCID / PMID --> requestFromPM(): Resolve PubMed identifier and retrieve metadata with Zotero. Fallback: get DOI via PubMed & requestFromDOI()
  • HTTP/WWW URL / QID / Domain-like URL / Embedded URL extraction --> requestFromURL(): here happens the magic! fetchPubMedIDs, content type check (here are the forbidden pdfs), archive.org check (stored in its own field), if not: Zotero, Fallback: HTML scraper, DOI check
  • DOI --> requestFromDOI(): Get metadata of the DOI from Zotero. Fallback: unshorten DOI & requestFromURL() with a timer(!) in parallel: retrieve metadata via CrossRef & translate into Zotero format. When URL request takes too long, take crossref data.
  • ISBN --> requestToZotISBN(): Gets the metadata via Zotero.
  • Open Search --> requestFromSearch(): Free text search in CrossRef

Event Timeline

While looking at the logstash I found an interesting use case. There seems to be a user agent that is adding the following into Citoid's autogeneration input field:
/wikibase/ISBN%3D8484379736

The message I see says "Unable to retrieve metadata from ISBN 8484379736 from Zotero".

See: https://logstash.wikimedia.org/app/dashboards#/view/5eaf4e40-f6b6-11eb-85b7-9d1831ce7631?_g=h@9bed57b&_a=h@bb2e1a5

lilients_WMDE updated the task description. (Show Details)