Skip to content

Commit

Permalink
Merge pull request #10 from ministryofjustice/data-entry-typos
Browse files Browse the repository at this point in the history
Added title typo fixer
  • Loading branch information
MalcolmVonMoJ committed Sep 21, 2023
2 parents a1d921c + 16f518c commit 05d4d00
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion inc/OleeoFeedParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ class OleeoFeedParser {
"Case Administrator",
"Community Payback",
"Youth Justice Worker",
"Probation Service Officer"
"Probation Services Officer"
];

private $feedType = 'complex';
private $filters = [];
private $optionalFields = [];
Expand Down Expand Up @@ -111,6 +112,19 @@ class OleeoFeedParser {
]
];

/**
* Replaces certain phrases in the job title
*/
public function fixJobTitleTypos($title) {
$typos = [
["Probation Service Officer","Probation Services Officer"]
];
foreach ($typos as $typo) {
$title = str_replace($typo[0],$typo[1],$title);
}
return $title;
}

/**
* Converts XML File to JSON FIle
* @param string $sourceFile Source XML File to be parsed
Expand Down Expand Up @@ -372,6 +386,8 @@ function validateOptionalFieldsbySpan($job, $jobContent){
}
}

$job['title'] = $this->fixJobTitleTypos($job['title']);

foreach ($this->artificial_role_types as $job_type) {
if(strpos("x".$job['title'], $job_type)) {
array_push($job['roleTypes'], (string) $job_type);
Expand All @@ -392,6 +408,8 @@ function validateOptionalFieldsbyNewLine($job, $jobContent){
$job['roleTypes'] = [];
}

$job['title'] = $this->fixJobTitleTypos($job['title']);

foreach ($this->artificial_role_types as $job_type) {
if(strpos("x".$job['title'], $job_type)) {
// strpos returns false if the "needle" is at position zero in the "haystack",
Expand Down

0 comments on commit 05d4d00

Please sign in to comment.