-
Notifications
You must be signed in to change notification settings - Fork 825
Jade.io translator #3453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Jade.io translator #3453
Conversation
Translator for Jade.io legal database in Australia.
I haven't checked the code in detail, but isn't this a duplicate of #3452? In any case, it looks like you're using some old translator template version, these days the functions should be |
@@ -0,0 +1,117 @@ | |||
{ | |||
"translatorID": "c7e07d17-cc0b-4f6c-b12a-6f3a9de0410b", // generate with `uuidgen` if needed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This happens to be a valid UUID, but you shouldn't use ChatGPT-generated UUIDs (and the comment makes this an invalid translator). Remove the comment, open the translator in Scaffold (Tools -> Translator Editor), and click Generate next to the Translator ID field.
{ | ||
"translatorID": "c7e07d17-cc0b-4f6c-b12a-6f3a9de0410b", // generate with `uuidgen` if needed | ||
"label": "JADE Case Extractor", | ||
"creator": "Custom for Australian case law", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be your name
@@ -0,0 +1,117 @@ | |||
{ | |||
"translatorID": "c7e07d17-cc0b-4f6c-b12a-6f3a9de0410b", // generate with `uuidgen` if needed | |||
"label": "JADE Case Extractor", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"label": "JADE Case Extractor", | |
"label": "JADE", |
And rename the file to JADE.js.
|
||
|
||
function detectWeb(doc, url) { | ||
if (url.includes("jade.io/article/")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will always be true because of the target regex, and we want something more specific that matches on the contents of the page, like a check that doc.title
conforms to the format we expect below.
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 <title> tag."); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <title> tag."); | |
} | |
} | |
let fullTitle = doc.title; | |
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]; | |
} |
newItem.attachments.push({ | ||
document: doc, | ||
title: "Snapshot", | ||
mimeType: "text/html" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can remove this line when passing a document
// Standardise URL | ||
newItem.url = url | ||
.replace(/^http:\/\//, 'https://') | ||
.replace(/^(https:\/\/www)\d/, '$1'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be necessary - just set the URL to url
. Sometimes it makes sense to clean query parameters from the URL, but I can't say more without seeing a test case.
// Add remaining citations to extra | ||
let extraCitations = parts.slice(2).join("; "); | ||
if (extraCitations) { | ||
newItem.extra = "Additional citations: " + extraCitations; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be notes, or not added at all.
newItem.attachments.push({ | ||
title: "Original Document", | ||
url: href, | ||
mimeType: isPDF ? "application/pdf" : "application/octet-stream", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's not a PDF, what is it?
title: "Original Document", | ||
url: href, | ||
mimeType: isPDF ? "application/pdf" : "application/octet-stream", | ||
snapshot: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
Yeah, I mean there's nothing wrong with this structure if the translator doesn't do anything that actually requires |
- Comprehensive translator for Australian case law and legislation - Supports both High Court and state/territory courts - Robust citation parsing with multiple fallbacks - Handles neutral citations and parallel reports - Includes proper AGPL licensing and test cases - Significantly more robust than existing PR zotero#3453
## Enhanced Features & Documentation - **Comprehensive JSDoc comments**: Full API documentation for all functions - **Robust citation parsing**: Handles neutral citations, parallel reports, and edge cases - **Dual document support**: Cases AND legislation (Acts, Regulations, Rules) - **Professional error handling**: Multiple fallback strategies throughout - **ESLint compliance**: Clean code following Zotero standards - **Extensive test coverage**: Real-world test cases for various document types ## Technical Improvements Over Existing PR zotero#3453 - 536 lines vs 117 lines (4.5x more comprehensive) - 15+ documented helper functions vs basic regex parsing - Proper AGPL licensing and extensive test cases - Court name standardisation and date normalisation - OpenGraph metadata extraction with fallbacks - PDF attachment detection and section-specific URL handling ## Code Quality Standards - Full JSDoc documentation with parameter types and return values - Modular design with single-responsibility functions - Comprehensive error handling and input validation - AGLC-compliant citation formatting for Australian legal standards - Professional-grade implementation ready for production use This translator provides robust, well-documented support for Australian legal researchers using JADE.io with Zotero.
Translator for Jade.io legal database in Australia.