New Translator: JADE.io (Australian Case Law)

I’ve written (well, used ChatGPT to write) a custom translator for JADE.io to extract Australian case citations including parallel reports. It supports paragraph citations (e.g. FLC ¶93–380), CLR/ALJR/ALR-style citations, and logs remaining citations to extra.

I am not sure how to submit it, etc. Code etc is below. I am happy to get instructions on steps to take or for someone to take it from here (I am not a programer)

G
 '''javascript ///
function detectWeb(doc, url) {
if (url.includes("jade.io/article/")) {
return "case";
}
return false;
}

function scrape(doc, url) {
let newItem = new Zotero.Item("case");

// Extract case name and MNC from
let titleElement = doc.querySelector("title");
if (titleElement) {
let fullTitle = titleElement.innerText.trim();
let titleMatch = fullTitle.match(/^(.+?)\s\[(\d{4})\]\s+(\w+)\s+(\d+)/);
if (titleMatch) {
newItem.caseName = titleMatch[1];
newItem.dateDecided = titleMatch[2];
newItem.court = titleMatch[3];
newItem.docketNumber = titleMatch[4];
} else {
Zotero.debug("Failed to parse case details from tag.");
}
}

// Extract second citation from metadata row and store others in extra
let rows = doc.querySelectorAll("table tr");
for (let row of rows) {
let citationCell = row.querySelector("td span.gwt-InlineLabel");
if (citationCell) {
let text = citationCell.textContent.trim();

// Look for typical citation string: starts with [year] and has semicolons
if (/^\[\d{4}\]/.test(text) && text.includes(";")) {
let parts = text.split(";").map(p => p.trim());

if (parts.length > 1) {
let secondCitation = parts[1];

// Try parsing as traditional page-based citation
let match = secondCitation.match(/(?:\(?(\d{4})\)?\s+)?(\d+)\s+([A-Z.]+)\s+(\d+)/);
if (match) {
const year = match[1] || newItem.dateDecided;
newItem.reporterVolume = match[2];
newItem.reporter = match[3].replace(/\./g, "");
newItem.firstPage = match[4];
} else {
// Try parsing as paragraph-based citation
match = secondCitation.match(/(?:\(?(\d{4})\)?\s+)?([A-Z.]+)\s+(¶?\d+(?:[-–]\d+)?)/);
if (match) {
const year = match[1] || newItem.dateDecided;
newItem.reporter = match[2].replace(/\./g, "");
newItem.firstPage = match[3];
}
}
}

// Add remaining citations to extra
let extraCitations = parts.slice(2).join("; ");
if (extraCitations) {
newItem.extra = "Additional citations: " + extraCitations;
}

break; // Stop after first match
}
}
}

// Standardise URL
newItem.url = url
.replace(/^http:\/\//, 'https://')
.replace(/^(https:\/\/www)\d/, '$1');

// Add page snapshot
newItem.attachments.push({
document: doc,
title: "Snapshot",
mimeType: "text/html"
});

// Attach original document if available
let downloadLink = Array.from(doc.querySelectorAll("a"))
.find(a => a.textContent.includes("Download Original Document"));
if (downloadLink) {
let href = downloadLink.href;
let filename = href.split('/').pop().split('?')[0];
let isPDF = filename.toLowerCase().endsWith(".pdf");

newItem.attachments.push({
title: "Original Document",
url: href,
mimeType: isPDF ? "application/pdf" : "application/octet-stream",
snapshot: false
});
}

newItem.complete();
}

function doWeb(doc, url) {
scrape(doc, url);
}
'''

Sample URL is https://jade.io/article/81345

It extracts case name, media neutral citations (as the AustLII translator does) and also the reported citations (the first one in the appropriate fields and the others in the extra field.

I have tested it locally and it seems to work
  • thanks for the link poettli.
    Sorry to be annoying with my lack of knowledge.
    I tried but cant see how to create a pull request and where to do it from the instructions. Happy to be given more explicit instructions.
    I got to https://github.com/zotero/translators and clicked on pull requests, then on New Pull Request, then the create pull request was greyed out unless i chose one of these but didn't know which one:
    dependabot/npm_and_yarn/word-wrap-1.2.4
    on Jul 20, 2023
    em-hw-priority
    on Mar 10, 2021
    ci-test
    on Feb 4, 2021
    github-actions-test
    on Jan 31, 2021
    master@{1day}...master
    24 hours ago

    Are there some clearer instructions for a first time submitted to the git repository? Or can you send a link to where I add the proposed translator?
  • OK - gave it a go follow Chat instructions, but hit an error. I really need a hand to take this further.
  • I know your struggles, I was there many years ago.
    Click on the "+" and choose "Create new file". The rest you'll figure out.
  • The pull request is up
  • Thanks adamsmith.
    Sorry I couldn't navigate GitHub successfully.
Sign In or Register to comment.