-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merge dev in re7 : appealNumber and ExtractRoute (#91)
* Feature/appeal number 399 (#82) * adding regex to get registreNUmber || pourvoie * adding logique to extract RG or Appeal or NumeroRoleGeneral for title in label * renaming and resolving bug * renaming and resolving bug * rename and lint * optimisation of code * little clean * updating sder commit --------- Co-authored-by: Antoine Jeanneney <[email protected]> * Fix/updateRoute (#90) * updating status to done for automatic route decisions * updating readme * updating antoine's request --------- Co-authored-by: Antoine Jeanneney <[email protected]>
- Loading branch information
1 parent
9426735
commit 9905273
Showing
12 changed files
with
207 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 0 additions & 19 deletions
19
packages/courDeCassation/src/connector/mapper/extractors/extractAppealNumber.spec.ts
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
packages/courDeCassation/src/connector/mapper/extractors/extractAppealNumber.ts
This file was deleted.
Oops, something went wrong.
69 changes: 69 additions & 0 deletions
69
...eCassation/src/connector/mapper/extractors/extractAppealRegisterRoleGeneralNumber.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { extractAppealRegisterRoleGeneralNumber } from './extractAppealRegisterRoleGeneralNumber'; | ||
|
||
describe('extractAppealRegisterRoleGeneralNumber', () => { | ||
const text = 'Pourvoi n° K 08-16.486 de telle décision'; | ||
it('should extract appeal number from text', () => { | ||
const appealNumber = extractAppealRegisterRoleGeneralNumber(text, ''); | ||
expect(appealNumber).toBe('08-16.486'); | ||
}); | ||
|
||
it('should extract registerNumber if source jurica', () => { | ||
const regsiterNumber = extractAppealRegisterRoleGeneralNumber( | ||
text, | ||
'jurica', | ||
"Cour d'appel de...", | ||
'appeal', | ||
'22/3455', | ||
'numeroRoleGenaral', | ||
); | ||
|
||
expect(regsiterNumber).toBe('22/3455'); | ||
}); | ||
|
||
it('should extract numeroRoleGeneral if source juritj', () => { | ||
const regsiterNumber = extractAppealRegisterRoleGeneralNumber( | ||
text, | ||
'juritj', | ||
'Tribunal de justice de...', | ||
'', | ||
'', | ||
'23/456', | ||
); | ||
|
||
expect(regsiterNumber).toBe('23/456'); | ||
}); | ||
|
||
it('should extract appeal and cour de cassation (return formatedAppeal) if source jurinet', () => { | ||
const regsiterNumber = extractAppealRegisterRoleGeneralNumber( | ||
text, | ||
'jurinet', | ||
'Cour de cassation de...', | ||
's1122333', | ||
'', | ||
'numeroRoleGeneral', | ||
); | ||
|
||
expect(regsiterNumber).toBe('11-22.333'); | ||
}); | ||
|
||
it('should extract appeal but with other cour (it is register number format : 19/000101 in this case) if source jurinet', () => { | ||
const regsiterNumber = extractAppealRegisterRoleGeneralNumber( | ||
text, | ||
'jurinet', | ||
"Cour d'appel de Rennes", | ||
'19/000101', | ||
'registerNumber', | ||
'numeroRoleGeneral', | ||
); | ||
|
||
expect(regsiterNumber).toBe('19/000101'); | ||
}); | ||
|
||
it('should extract no appeal number', () => { | ||
const text = 'Pas de pourvoi'; | ||
|
||
const appealNumber = extractAppealRegisterRoleGeneralNumber(text, ''); | ||
|
||
expect(appealNumber).toBe(undefined); | ||
}); | ||
}); |
52 changes: 52 additions & 0 deletions
52
...courDeCassation/src/connector/mapper/extractors/extractAppealRegisterRoleGeneralNumber.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
export { extractAppealRegisterRoleGeneralNumber }; | ||
|
||
function extractAppealRegisterRoleGeneralNumber( | ||
text: string, | ||
source: string, | ||
jurisdictionName?: string, | ||
appeal?: string, | ||
registerNumber?: string, | ||
numeroRoleGeneral?: string, | ||
) { | ||
if (source === 'jurica' && registerNumber != undefined) { | ||
return registerNumber?.split(' ')[0]; | ||
} else if (source === 'jurinet') { | ||
const verifappeal = /^[A-Za-z]\d+$/; | ||
if ( | ||
jurisdictionName?.includes('cassation') && | ||
appeal != undefined && | ||
verifappeal.test(appeal) | ||
) { | ||
appeal = appeal?.replace(/[A-Za-z]/g, ''); | ||
const formattedappeal = | ||
appeal.substring(0, 2) + | ||
'-' + | ||
appeal.substring(2, 4) + | ||
'.' + | ||
appeal.substring(4); | ||
return formattedappeal; | ||
} else { | ||
return appeal; | ||
} | ||
} else if (source === 'juritj' && numeroRoleGeneral != undefined) { | ||
return numeroRoleGeneral; | ||
} else { | ||
return regexExtractAppealNumber(text); | ||
} | ||
} | ||
|
||
// regex de base | ||
const REGEX_1 = /\D\s(\d{2}-\d{2}\.\d{3})/; | ||
const REGEX_2 = /\d{2}-\d{5}/; | ||
export function regexExtractAppealNumber(text: string) { | ||
const match1 = text.match(REGEX_1); | ||
if (!!match1 && match1[1]) { | ||
return match1[1]; | ||
} | ||
|
||
const match2 = text.match(REGEX_2); | ||
if (!!match2 && match2[0]) { | ||
return match2[0]; | ||
} | ||
return undefined; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 6 additions & 2 deletions
8
packages/courDeCassation/src/connector/mapper/extractors/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
import { extractReadableChamberName } from './extractReadableChamberName'; | ||
import { extractReadableJurisdictionName } from './extractReadableJurisdictionName'; | ||
import { extractAppealNumber } from './extractAppealNumber'; | ||
import { | ||
extractAppealRegisterRoleGeneralNumber, | ||
regexExtractAppealNumber, | ||
} from './extractAppealRegisterRoleGeneralNumber'; | ||
import { extractRoute } from './extractRoute'; | ||
|
||
export { | ||
extractReadableChamberName, | ||
extractReadableJurisdictionName, | ||
extractAppealNumber, | ||
extractAppealRegisterRoleGeneralNumber, | ||
regexExtractAppealNumber, | ||
extractRoute, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.