Compare commits

..

3 Commits

5 changed files with 19 additions and 7 deletions

View File

@@ -35,7 +35,7 @@ The "short" named is created by taking the electorate name and removing the word
The file can be generated using the `jq` tool and the VEC data:
```
jq '[.[] | {name: .electorateName, electorateId: .electorateId, shortName: .parentElectorateName | match("(.*?)(?:(?: Rural)?(?: City| Shire) Council)").captures[0].string, parentElectorateId: .parentElectorateId, councilName: .parentElectorateName }] | group_by(.parentElectorateId) | map({shortName: .[0].shortName, slug: .[0].shortName | ascii_downcase | split(" ") | join("-"), councilName: .[0].councilName, wardNames: . | map(.name) }) | sort_by(.shortName)' "VEC Data\wards.json" > council_names.json
jq '[.[] | {name: .electorateName, electorateId: .electorateId, shortName: .parentElectorateName | match("(.*?)(?:(?: Rural)?(?: City| Shire| Borough) Council)").captures[0].string, parentElectorateId: .parentElectorateId, councilName: .parentElectorateName }] | group_by(.parentElectorateId) | map({shortName: .[0].shortName, slug: .[0].shortName | ascii_downcase | split(" ") | join("-"), councilName: .[0].councilName, wardNames: . | map(.name) }) | sort_by(.shortName)' "VEC Data\wards.json" > council_names.json
```
## lga-links-filter

View File

@@ -786,6 +786,14 @@
"Beaufort"
]
},
{
"shortName": "Queenscliffe",
"slug": "queenscliffe",
"councilName": "Queenscliffe Borough Council",
"wardNames": [
"Unsubdivided"
]
},
{
"shortName": "South Gippsland",
"slug": "south-gippsland",

View File

@@ -96,19 +96,23 @@ if (($handle = fopen($inputFile, "r")) !== FALSE) {
//print("Adding candidate " . $candidateName . " to ". $currentWard . "\n");
$name_split = explode(" ", str_replace(",", "", str_replace("'", "_", $data[1])));
$name_split = array_values(array_filter(explode(" ", str_replace(",", "", str_replace("'", "_", $data[1]))), function($value) { return !is_null($value) && $value !== ''; }));
$name_patterns = [
implode(".*", $name_split),
implode(".*", array_reverse($name_split)),
".*" . implode(".*", $name_split) . ".*",
".*" . implode(".*", array_reverse($name_split)) . ".*",
"^" . $name_split[array_key_last($name_split)] . ".*",
"^" . $name_split[0] . ".*"
];
$regex_groups = array_map(function($x) { return "(?:.*" . $x . ".*)"; }, $name_patterns);
$regex_groups = array_map(function($x) { return "(?:" . $x . ")"; }, $name_patterns);
$regex_pattern = "/" . implode("|", $regex_groups) . "/i";
$picture = "";
foreach ($mediaFiles as $mediaFile) {
if ($mediaFile == ".") continue;
if ($mediaFile == "..") continue;
if (preg_match($regex_pattern, $mediaFile)) {
$picture = $mediaFile;
break;

File diff suppressed because one or more lines are too long

View File

@@ -1,7 +1,7 @@
import polylabel from 'polylabel';
function normaliseCouncilName(str) {
const regex = /(.*?)(?:(?: Rural)?(?: City| Shire) Council)/g;
const regex = /(.*?)(?:(?: Rural)?(?: City| Shire| Borough) Council)/g;
const matches = str.matchAll(regex);
// If we get a match, convert to slug format