Skip to content

Commit

Permalink
feat: fix typo in communes
Browse files Browse the repository at this point in the history
  • Loading branch information
LAU-MG committed Oct 31, 2023
1 parent da3cd9d commit edc5f01
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .husky/commit-msg
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no -- commitlint --edit "${1}"
npx --no -- commitlint --edit "${1}" --config ./.tooling/.commitlint/commitlint.config.cjs
2 changes: 1 addition & 1 deletion .husky/pre-commit
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

lint.staged
lint-staged --config=./.tooling/.lintstaged/.lintstagedrc
7 changes: 7 additions & 0 deletions src/transformer/fields/adresse/clean-commune.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,11 @@ describe('clean commune', (): void => {

expect(commune).toBe("L'ESCARÈNE");
});
it('should add missing le', (): void => {
const commune: string = CLEAN_COMMUNE.reduce(toCleanField, communeField('', 'Pont-de-Claix'));

expect(commune).toBe("Le Pont-de-Claix");
});


});
52 changes: 51 additions & 1 deletion src/transformer/fields/adresse/clean-commune.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable max-lines */

import { CleanOperation } from './clean-operations';

const FIX_WRONG_ACCENT_CHARS: CleanOperation = {
Expand Down Expand Up @@ -84,6 +86,47 @@ const FIX_UNEXPECTED_DETAILS: CleanOperation = {
fix: (toFix: number | string): string => toFix.toString().replace(/\s*\(.*\)\s*/u, '')
};

const FIX_FORGOTTEN_ARTICLE_FROM_PONTDECLAIX: CleanOperation = {
name: 'put forgotten definite article',
selector: /Pont-de-Claix/u,
fix: (toFix: string): string => toFix.toString().replace(/Pont-de-Claix/u, 'Le Pont-de-Claix')
};

const FIX_FORGOTTEN_ARTICLE_FROM_NOUVION_EN_THIERACHE: CleanOperation = {
name: 'put forgotten definite article',
selector: /NOUVION-EN-THIÉRACHE/u,
fix: (toFix: string): string => toFix.toString().replace(/NOUVION-EN-THIÉRACHE/u, 'Le NOUVION-EN-THIÉRACHE')
};

const FIX_FORGOTTEN_ARTICLE_FROM_FAY_SAINT_QUENTIN: CleanOperation = {
name: 'put forgotten definite article',
selector: /FAY-SAINT-QUENTIN/u,
fix: (toFix: string): string => toFix.toString().replace(/FAY-SAINT-QUENTIN/u, 'Le FAY-SAINT-QUENTIN')
};

const FIX_ADDED_LETTER_FROM_GRANDCHAMPS_DES_FONTAINES: CleanOperation = {
name: 'delete the letter s',
selector: /Grandchamps-des-Fontaines/u,
fix: (toFix: string): string => toFix.toString().replace(/Grandchamps-des-Fontaines/u, 'Grandchamp-des-Fontaines')
};

const FIX_FORGOTTEN_ARTICLE_FROM_PRECHEUR: CleanOperation = {
name: 'put forgotten definite article',
selector: /Prêcheur/u,
fix: (toFix: string): string => toFix.toString().replace(/Prêcheur/u, 'Le Prêcheur')
};

const FIX_SPELLING_NAME_OF_BORDERES_ET_LAMESENS: CleanOperation = {
name: 'correct the name of the commune ',
selector: /Bordères-et-Lamensens/u,
fix: (toFix: string): string => toFix.toString().replace(/Bordères-et-Lamensens/u, 'Bordères-et-Lamensans')
};

const FIX_SPELLING_NAME_OF_PIERREFFITTES_NESTALAS: CleanOperation = {
name: 'correct the name of the commune ',
selector: /Pierreffitte-Nestalas/u,
fix: (toFix: string): string => toFix.toString().replace(/Pierreffitte-Nestalas/u, 'Pierrefitte-Nestalas')
};
export const CLEAN_COMMUNE: CleanOperation[] = [
FIX_UNEXPECTED_DETAILS,
FIX_WRONG_ACCENT_CHARS,
Expand All @@ -98,7 +141,14 @@ export const CLEAN_COMMUNE: CleanOperation[] = [
REMOVE_NUMERIC_CHARS,
REMOVE_SPACE_AFTER_QUOTE,
REMOVE_HEADING_AND_TRAILING_SPACES,
REPLACE_SPACES_WITH_DASHES
REPLACE_SPACES_WITH_DASHES,
FIX_FORGOTTEN_ARTICLE_FROM_PONTDECLAIX,
FIX_FORGOTTEN_ARTICLE_FROM_NOUVION_EN_THIERACHE,
FIX_FORGOTTEN_ARTICLE_FROM_FAY_SAINT_QUENTIN,
FIX_ADDED_LETTER_FROM_GRANDCHAMPS_DES_FONTAINES,
FIX_FORGOTTEN_ARTICLE_FROM_PRECHEUR,
FIX_SPELLING_NAME_OF_BORDERES_ET_LAMESENS,
FIX_SPELLING_NAME_OF_PIERREFFITTES_NESTALAS
];

const communeFromVoie = (voie: string): string =>
Expand Down

0 comments on commit edc5f01

Please sign in to comment.