Start generating image download script.
This commit is contained in:
@@ -23,6 +23,11 @@ function parse_generic_csv($generic_csv) {
|
||||
if (strstr($data[$key], "I pledge")) $data[$key] = "Yes";
|
||||
else $data[$key] = "No";
|
||||
}
|
||||
|
||||
if ($value === "Photo") {
|
||||
$candidate['photo_url'] = $data[$key];
|
||||
$data[$key] = preg_filter("/.*id=/", "", $data[$key]);
|
||||
}
|
||||
|
||||
if ($is_question) {
|
||||
$candidate['q'.$question_no++] = $data[$key];
|
||||
@@ -44,3 +49,40 @@ function parse_generic_csv($generic_csv) {
|
||||
|
||||
return $candidate_data;
|
||||
}
|
||||
|
||||
function match_lga(&$candidate_data, $lga_list) {
|
||||
foreach ($candidate_data as &$candidate) {
|
||||
/* Match user typed LGA/Ward to our database */
|
||||
$max_score = 0;
|
||||
foreach ($lga_list as $lga) {
|
||||
$aa = preg_split("/[^a-z]/", strtolower($candidate['LGA']));
|
||||
$bb = preg_split("/[^a-z]/", $lga['slug']);
|
||||
|
||||
$score_sum = 0;
|
||||
foreach ($aa as $a) {
|
||||
foreach ($bb as $b) {
|
||||
similar_text($a, $b, $score);
|
||||
if ($score > 70) $score_sum += $score;
|
||||
else $score_sum -= 10;
|
||||
}
|
||||
}
|
||||
|
||||
if ($score_sum > $max_score) {
|
||||
$max_score = $score_sum;
|
||||
$match_lga = $lga;
|
||||
}
|
||||
}
|
||||
|
||||
$max_score = 0;
|
||||
foreach ($match_lga['wardNames'] as $ward) {
|
||||
similar_text($ward, $candidate['Ward'], $score);
|
||||
if ($score > $max_score) {
|
||||
$max_score = $score;
|
||||
$match_ward = $ward;
|
||||
}
|
||||
}
|
||||
|
||||
$candidate['match_lga'] = $match_lga['slug'];
|
||||
$candidate['match_ward'] = $match_ward;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user