-
Notifications
You must be signed in to change notification settings - Fork 756
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
AustLII translator updates #2882
Conversation
abbreviator for AustLII.
Capitalise titles of Acts, including parenthetical ones. Using lowercase 'code' as key. Added jurisdiction abbreviations. Added some informal report series abbreviations. Added more tests to demonstrate functionality works.
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.
Thanks! Some comments.
AustLII and NZLII.js
Outdated
var courtMap = new Map(); | ||
courtMap.set('Federal Court of Australia', 'FCA'); | ||
courtMap.set('High Court of Australia', 'HCA'); | ||
courtMap.set('Family Court of Australia', 'FamCA'); | ||
courtMap.set('Australian Information Commissioner', 'AICmr'); |
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.
Keep this (and the jMap
below) outside the function so we don't need to rebuild every time?
AustLII and NZLII.js
Outdated
newString += ZU.capitalizeTitle(words[i].toLowerCase(), true); | ||
} | ||
} | ||
Zotero.debug(newString); |
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.
No need to debug here
Hi, I wonder if there's any followup. This PR looks solid and it passes the tests. In addition to the suggested changes, there are a few things we need to update as a result of changes made to the websites.
@jpwarren if you're still on this and if you can make the changes, this can be accepted. |
Updated test URLs now that AustLII (mostly) doesn't redirect site to a www\d hostname.
Sorry, put it down for a moment and then… months went by somehow. Made the requested changes. The github action for the CI appears to have failed partway through due to what looks like a misconfiguration of which Chrome driver it's looking for, not something to do with this PR specifically. |
AustLII and NZLII.js
Outdated
function abbrevJurisdiction(fullname) { | ||
|
||
var abbrev = jMap.get(fullname); | ||
if (abbrev === undefined) { | ||
abbrev = fullname; | ||
} | ||
return abbrev; | ||
} |
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.
Hi, with the suggested changes now in place, we can observe that the functions abbrevJurisdiction
and abbrevCourt
are substantially similar. Either function is called only once. Therefore, I think we can further simplify them:
- Instead of using
Map
, we can just use object literals
var jMap = {
"Commonwealth": "Cth",
/* ... */
};
because we're ever going to just use it as a static mapping. Here the advantage of Map()
is not apparent, and it will be less verbose.
- Consequently, the
abbrevXXX
functions can be eliminated. And to get an abbreviation, we can use, say
jMap[fullname] || fullname;
(this is not theoretically bulletproof but it should suffice).
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.
Okay.
I've kept them as separate maps/dictionaries to avoid key collisions, rather than having a single jMap object.
court and jurisdictions abbreviations.
Thank you! |
Hello @jpwarren! You don't have to merge upstream main branch into your PR branch. Please rebase your PR branch instead, so that the PR will only contain your changes. |
This is what I get for mis-clicking in the website. I am unsure of how to do the rebase safely. Advice would be appreciated so I don't make things worse as I fumble about trying to figure it out. |
OK, don't worry, we don't have to do it now. I'd be afraid that my instructions might make things worse, without knowing your configuration of the repo. |
Hi
Thank you again for your work. |
A few updates to the AustLII translator to more closely align with the Australian Guide to Legal Citation, 4th Edition.