Skip to content

Commit

Permalink
⚡improve: improve SG results; #37
Browse files Browse the repository at this point in the history
  • Loading branch information
hueyy committed Jun 11, 2021
1 parent 4782b21 commit 82e0d3f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "clerkent",
"version": "2.4.3",
"version": "2.4.4",
"private": true,
"description": "quick search for international caselaw and legislation",
"repository": "https://github.com/lacuna-technologies/clerkent.git",
Expand Down
8 changes: 6 additions & 2 deletions src/utils/Finder/CaseCitationFinder/SG.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ import type { CaseCitationFinderResult } from './types'

export const SGAbbrs = [
{ abbr: `SGCA`, appendum: `(I)?` },
{ abbr: `SGHC`, appendum: `(I)?` },
{ abbr: `SGHC`, appendum: `(F|\\(I\\))?` },
{ abbr: `SLR`, appendum: `(\\(r\\))?` },
{ abbr: `SGDC` },
{ abbr: `SGMC` },
{ abbr: `SGIPOS` },
]

export const sortSGCitations = (citationsArray: any[], attribute = null) => sortCitationsByVolume(SGAbbrs, citationsArray, attribute)
export const sortSGCitations = (citationsArray: any[], attribute = null) => sortCitationsByVolume(
SGAbbrs,
citationsArray,
attribute,
)

export const findSGCaseCitationMatches = (query: string) => {
const regex = new RegExp(`\\[[12]\\d{3}]( \\d{1,2})? (${
Expand Down
2 changes: 1 addition & 1 deletion src/utils/scraper/SG/SG.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const getLegislation = SSO.getLegislation
const getCaseByName = async (caseName: string): Promise<Law.Case[]> => {
try {
const results = (await Promise.allSettled([
// SGSC.getCaseByName(caseName),
SGSC.getCaseByName(caseName),
// SLW.getCaseByName(caseName),
Common.CommonLII.getCaseByName(caseName, Constants.JURISDICTIONS.SG.name),
]))
Expand Down
5 changes: 4 additions & 1 deletion src/utils/scraper/SG/SLW.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ const getCaseByCitation = async (citation: string): Promise<Law.Case[]> => {

const results = data
.map(([name, link]) => parseCase(name, link))
.filter(({ citation}) => Helpers.isCitationValid(citation))
.filter(({ citation: scrapedCitation }) => (
Helpers.isCitationValid(scrapedCitation) &&
citation === scrapedCitation
))
Logger.log(`SLW scrape results`, results)
return results
}
Expand Down

0 comments on commit 82e0d3f

Please sign in to comment.