public function analyzeTaxa($startIndex = 0, $limit = 50) { $status = true; $this->logOrEcho("Starting taxa check "); $sql = 'SELECT DISTINCT sciname, family ' . 'FROM omoccurrences ' . 'WHERE (collid = ' . $this->collid . ') AND (tidinterpreted IS NULL) AND (sciname IS NOT NULL) AND (sciname != "") ' . 'ORDER BY sciname ' . 'LIMIT ' . $startIndex . ',' . $limit; if ($rs = $this->conn->query($sql)) { //Check name through taxonomic resources $taxUtil = new TaxonomyUtilities(); $taxUtil->setVerboseMode(2); $this->setVerboseMode(2); $nameCnt = 0; while ($r = $rs->fetch_object()) { $this->logOrEcho('Resolving ' . $r->sciname . ($r->family ? ' (' . $r->family . ')' : '') . '...'); $newTid = $taxUtil->addSciname($r->sciname, $r->family); if (!$newTid) { //Check for near match using SoundEx $this->logOrEcho('Checking close matches in thesaurus...', 1); $closeArr = $taxUtil->getSoundexMatch($r->sciname); if (!$closeArr) { $closeArr = $taxUtil->getCloseMatchEpithet($r->sciname); } if ($closeArr) { $cnt = 0; foreach ($closeArr as $tid => $sciname) { $echoStr = '<i>' . $sciname . '</i> =><a href="#" onclick="remappTaxon(\'' . $r->sciname . '\',' . $tid . ',\'' . $sciname . '\')"> remap to this taxon</a>'; $this->logOrEcho($echoStr, 2); $cnt++; } } else { $this->logOrEcho('No close matches found', 1); } } $nameCnt++; } $rs->free(); } $this->linkNewTaxa(); $this->logOrEcho("Done with taxa check "); return $status; }