public function identifyDetails($text, $lastCandidateID, $cv, $connect, $s, $sessionID) { $patternEmail = '/[A-Za-z0-9!#$%&\'\\=*+\\/\\?^_`{|}\\.~-]+@[A-Za-z0-9!#$%&\'\\=*+\\/\\?^_`{|}\\.~-]+\\.(?:[A-Za-z]{4}|lk|com|org|net|edu|biz|info|asia)/'; $patternNIC = '/[0-9]{9}+(V|v)/'; $patternDateOfBirth1 = '/([1|2][0-9\\.\\/-]{4}[0|1][0-9][\\.\\/-][0|1|2|3][0-9])/'; $patternDateOfBirth2 = '/([0|1|2|3][0-9][\\.\\/-][0|1|2|3][0-9][\\.\\/-][1|2][0-9]{3})/'; $patternContactNo1 = '/[0][0-9]{9}/'; $patternContactNo2 = '/[0][0-9]{2}[-" "][0-9]{7}/'; $patternContactNo3 = '/[+|0][0-9]{11}/'; preg_match_all($patternNIC, $text, $nicList); preg_match_all($patternEmail, $text, $emailList); preg_match_all($patternDateOfBirth1, $text, $dobList1); preg_match_all($patternDateOfBirth2, $text, $dobList2); preg_match_all($patternContactNo1, $text, $contactList1); /*** new Candidate Object is created***/ /*and putting extracted details to that object's attributes*/ if ($lastCandidateID == null) { $newCandidate = new Candidate("C001"); } else { ++$lastCandidateID; $newCandidate = new Candidate("{$lastCandidateID}"); } if ($nicList[0] != null) { $newCandidate->setNIC($nicList[0][0]); } else { /*If NIC is not extracted,cand status would be marked to unchecked*/ $newCandidate->setCandStatus("CS003"); } if ($emailList[0] != null) { $newCandidate->setEmail($emailList[0][0]); } $minYear = 3000; $minDOB = ""; if ($dobList1[0] != null) { for ($i = 0; $i < sizeof($dobList1[0]); $i++) { $year = $dobList1[0][0][0] . $dobList1[0][0][1] . $dobList1[0][0][2] . $dobList1[0][0][3]; if ($year <= $minYear) { $minYear = $year; $minDOB = $dobList1[0][$i]; } } } if ($dobList2[0] != null) { for ($i = 0; $i < sizeof($dobList2[0]); $i++) { $date = $this->changeDateFormat($dobList2[0][$i]); if (strlen($date) == 10) { $year = $date[0] . $date[1] . $date[2] . $date[3]; if ($year <= $minYear) { $minYear = $year; $minDOB = $date; } } } } if (date("Y") - $minYear <= 15) { $minDOB = ""; } $newCandidate->setDateOfBirth($minDOB); if ($contactList1[0] != null) { $newCandidate->setContactNo($contactList1[0][0]); } else { preg_match_all($patternContactNo2, $text, $contactList2); if ($contactList2[0] != null) { $contact = $this->changeContactNoFormat($contactList2[0][0]); $newCandidate->setContactNo($contact); } else { preg_match_all($patternContactNo3, $text, $contactList3); if ($contactList3[0] != null) { $contact = $this->changeContactNoFormat($contactList3[0][0]); $newCandidate->setContactNo($contact); } } } if ($nicList[0] != null) { if (sizeof($nicList[0]) == 1) { $s->checkInDB($nicList[0][0], $cv, $newCandidate, $connect, $sessionID); } } else { $matchToFlag = $s->needToFlag($cv, $newCandidate, $connect, $sessionID); } return $newCandidate; }