本文整理汇总了PHP中Functions::canonical_form方法的典型用法代码示例。如果您正苦于以下问题:PHP Functions::canonical_form方法的具体用法?PHP Functions::canonical_form怎么用?PHP Functions::canonical_form使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Functions
的用法示例。
在下文中一共展示了Functions::canonical_form方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check_st_john
public function check_st_john($start, $limit)
{
$query = "SELECT id, string FROM names WHERE string REGEXP BINARY 'st\\\\\\.-[a-z]'\n AND id BETWEEN {$start} AND " . ($start + $limit - 1);
foreach ($this->mysqli->iterate_file($query) as $row) {
$id = $row[0];
$string = $row[1];
$canonical_form_string = Functions::canonical_form($string);
if ($canonical_form = CanonicalForm::find_or_create_by_string($canonical_form_string)) {
echo "UPDATE names SET canonical_form_id={$canonical_form->id} WHERE id={$id}\n";
$this->mysqli->update("UPDATE names SET canonical_form_id={$canonical_form->id}, ranked_canonical_form_id={$canonical_form->id} WHERE id={$id}");
}
}
$this->mysqli->commit();
}
示例2: get_details
private function get_details($xml, $orig_sciname, $strict)
{
$taxa = array();
foreach ($xml->entry as $species) {
if ($strict) {
if (strtolower(trim($orig_sciname)) == strtolower(trim(Functions::canonical_form(trim($species->title))))) {
$taxon_do = self::get_objects_info($species->id, $species->title, $orig_sciname);
$taxa[] = $taxon_do;
}
} else {
$taxon_do = self::get_objects_info($species->id, $species->title, $orig_sciname);
$taxa[] = $taxon_do;
}
}
return $taxa;
}
示例3: canonical_forms
function canonical_forms()
{
$mysqli =& $GLOBALS['mysqli_connection'];
$mysqli->begin_transaction();
$mysqli->delete("DELETE FROM canonical_forms");
$mysqli->update("UPDATE names SET canonical_form_id=0");
$result = $mysqli->query("SELECT MAX(id) as max FROM names");
$row = $result->fetch_assoc();
$max = $row["max"];
$start = 1;
$interval = 50000;
while ($start < $max) {
debug($start);
$result = $mysqli->query("SELECT id, string FROM names WHERE id BETWEEN {$start} AND " . ($start + $interval - 2) . " AND canonical_form_verified!=0");
while ($result && ($row = $result->fetch_assoc())) {
$id = $row["id"];
$string = $row["string"];
$canonical_form_id = $row["id"];
$canonical_form_verified = $row["id"];
$canonical_form = "";
if ($canonical_form_verified) {
$result2 = $mysqli->query("SELECT string FROM canonical_forms WHERE id={$canonical_form_id}");
if ($result2 && ($row2 = $result2->fetch_assoc())) {
$canonical_form = $row2["string"];
}
}
if (!$canonical_form) {
$canonical_form = Functions::canonical_form($string);
}
if (@(!$canonical_form_ids[$canonical_form])) {
$result2 = $mysqli->query("SELECT id FROM canonical_forms WHERE string='" . $mysqli->escape($canonical_form) . "'");
if ($result2 && ($row2 = $result2->fetch_assoc())) {
$canonical_form_ids[$canonical_form] = $row2["id"];
} else {
$result2 = $mysqli->insert("INSERT INTO canonical_forms VALUES (NULL,'" . $mysqli->escape($canonical_form) . "')");
$canonical_form_ids[$canonical_form] = $mysqli->insert_id;
}
}
$query = "UPDATE names SET canonical_form_id ({$id},'" . $mysqli->escape($canonical_form) . "')";
$mysqli->update($query);
}
flush();
$start += $interval;
}
$mysqli->end_transaction();
}
示例4: get_details
function get_details($xml, $orig_sciname, $strict)
{
$taxa = array();
foreach ($xml->entry as $species) {
if ($strict == 'canonical_match') {
if (strtolower(trim($orig_sciname)) == strtolower(trim(Functions::canonical_form(trim($species->title))))) {
print "<br>" . strtolower(trim($orig_sciname)) . " == " . strtolower(trim(Functions::canonical_form(trim($species->title)))) . " == " . $species->title . "<br>";
$taxon_do = self::get_objects_info($species->id, $species->title, $orig_sciname);
$taxa[] = $taxon_do;
}
} elseif ($strict == 'exact_string') {
if (strtolower(trim($orig_sciname)) == strtolower(trim($species->title))) {
print "<br>" . strtolower(trim($orig_sciname)) . " == " . $species->title . "<br>";
$taxon_do = self::get_objects_info($species->id, $species->title, $orig_sciname);
$taxa[] = $taxon_do;
}
} else {
$taxon_do = self::get_objects_info($species->id, $species->title, $orig_sciname);
$taxa[] = $taxon_do;
}
}
return $taxa;
}
示例5: is_sciname_synonym
private function is_sciname_synonym($sciname)
{
/*
Squatarola squatarola
http://eol.org/api/search/1.0.xml?q=Xanthopsar+flavus&page=1&exact=false&filter_by_taxon_concept_id=&filter_by_hierarchy_entry_id=&filter_by_string=&cache_ttl=
http://eol.org/api/pages/1.0.xml?batch=false&id=686274&images_per_page=0&images_page=0&videos_per_page=0&videos_page=0&sounds_per_page=0&sounds_page=0&maps_per_page=0&maps_page=0&texts_per_page=0&texts_page=0&iucn=false&subjects=overview&licenses=all&details=false&common_names=false&synonyms=true&references=false&taxonomy=false&vetted=0&cache_ttl=&language=en
*/
$search_call = "http://eol.org/api/search/1.0.xml?q=" . $sciname . "&page=1&exact=false&filter_by_taxon_concept_id=&filter_by_hierarchy_entry_id=&filter_by_string=&cache_ttl=";
if ($xml = Functions::lookup_with_cache($search_call, array('timeout' => 30, 'expire_seconds' => false, 'resource_id' => 'eol_api'))) {
$xml = simplexml_load_string($xml);
$sciname = Functions::canonical_form($sciname);
if ($sciname == Functions::canonical_form($xml->entry[0]->title)) {
return false;
} else {
$titles = array();
echo "\n" . $xml->entry[0]->id . "\n";
foreach ($xml->entry as $entry) {
$titles[] = Functions::canonical_form($entry->title);
}
// print_r($titles);
if (in_array($sciname, $titles)) {
return false;
} else {
return true;
}
}
}
return false;
}
示例6: process_mushroom_observer_list
private function process_mushroom_observer_list($wrong_urls)
{
if ($file = Functions::lookup_with_cache($this->mushroom_observer_eol, $this->download_options)) {
$xml = simplexml_load_string($file);
$i = 0;
$total = count($xml->taxon);
foreach ($xml->taxon as $t) {
$i++;
// if($i > 40) break; //debug
$t_dwc = $t->children("http://rs.tdwg.org/dwc/dwcore/");
$t_dc = $t->children("http://purl.org/dc/elements/1.1/");
$sciname = Functions::import_decode($t_dwc->ScientificName);
$sciname = Functions::canonical_form($sciname);
echo "\n{$i} of {$total}: {$sciname}";
$url = "http://en.wikipedia.org/wiki/" . str_replace(" ", "_", $sciname);
self::get_triple($url, $wrong_urls);
}
}
}
示例7: get_vernacular_names
private function get_vernacular_names()
{
$temp_filepath = Functions::save_remote_file_to_local($this->vernacular_path, array('timeout' => 4800, 'download_attempts' => 5));
foreach (new FileIterator($temp_filepath, true) as $line_number => $line) {
if ($line) {
$fields = explode("\t", trim($line));
$fields = array_map('trim', $fields);
//trims all array values in the array
$common_name = @$fields[1];
$sciname = Functions::canonical_form(trim(@$fields[0]));
$taxon_id = @$this->taxa_all[$sciname]['Identifier'];
if ($common_name == '' || $taxon_id == '' || $sciname == '') {
continue;
}
$language = self::get_language(@$fields[3]);
$vernacular = new \eol_schema\VernacularName();
$vernacular->taxonID = $taxon_id;
$vernacular->vernacularName = (string) $common_name;
$vernacular->language = $language;
$vernacular_id = md5("{$vernacular->taxonID}|{$vernacular->vernacularName}|{$vernacular->language}");
if (!isset($this->vernacular_name_ids[$vernacular_id])) {
$this->archive_builder->write_object_to_file($vernacular);
$this->vernacular_name_ids[$vernacular_id] = 1;
}
}
}
}
示例8: generate_taxon_extension_for_dwca
private function generate_taxon_extension_for_dwca($rec)
{
/*
<field index="0" term="http://rs.tdwg.org/dwc/terms/taxonID"/>
<field index="2" term="http://rs.tdwg.org/dwc/terms/scientificName"/>
<field index="3" term="http://rs.tdwg.org/dwc/terms/taxonRank"/>
http://rs.tdwg.org/ontology/voc/TaxonRank#Subfamily
http://rs.tdwg.org/ontology/voc/TaxonRank#Tribe
http://rs.tdwg.org/ontology/voc/TaxonRank#Subtribe
<field index="4" term="http://rs.tdwg.org/dwc/terms/genus"/>
<field index="5" term="http://rs.tdwg.org/dwc/terms/subgenus"/>
http://rs.tdwg.org/ontology/voc/TaxonRank#Species
*/
// taxonID scientificName taxonRank Subfamily Tribe Subtribe genus subgenus Species
if ($OUT = Functions::file_open($this->taxon_tab_file, "a")) {
if ($val = @$rec['sciname2']) {
$scientificName = $val;
} elseif ($val = @$rec['sciname']) {
$scientificName = $val;
}
fwrite($OUT, $rec['taxon_id'] . "\t");
fwrite($OUT, $scientificName . "\t");
fwrite($OUT, $rec['rank'] . "\t");
fwrite($OUT, @$rec['ancestry']['subfamily']['name'] . "\t");
fwrite($OUT, @$rec['ancestry']['tribe']['name'] . "\t");
fwrite($OUT, @$rec['ancestry']['subtribe']['name'] . "\t");
fwrite($OUT, @$rec['ancestry']['genus']['name'] . "\t");
fwrite($OUT, @$rec['ancestry']['subgenus']['name'] . "\t");
$final_species = "";
if ($species = @$rec['ancestry']['species']['name']) {
$final_species = Functions::canonical_form($rec['ancestry']['genus']['name']);
if ($val = @$rec['ancestry']['subgenus']['name']) {
$final_species .= " (" . Functions::canonical_form($val) . ")";
}
$final_species .= " {$species}";
}
fwrite($OUT, $final_species . "\n");
fclose($OUT);
}
}
示例9: check_sciname_ancestry_values
private function check_sciname_ancestry_values($taxon)
{
//scientificname should not be equal to any of the ancestry
$canonical = Functions::canonical_form($taxon->scientificName);
if ($taxon->kingdom == $canonical) {
$taxon->kingdom = '';
}
if ($taxon->phylum == $canonical) {
$taxon->phylum = '';
}
if ($taxon->class == $canonical) {
$taxon->class = '';
}
if ($taxon->order == $canonical) {
$taxon->order = '';
}
if ($taxon->family == $canonical) {
$taxon->family = '';
}
if ($taxon->genus == $canonical) {
$taxon->genus = '';
}
return $taxon;
}
示例10: get_taxon_id
private function get_taxon_id($rec)
{
$taxon_id = trim((string) $rec["http://rs.tdwg.org/dwc/terms/taxonID"]);
if (!$taxon_id) {
if ($val = trim((string) $rec["http://rs.tdwg.org/dwc/terms/scientificName"])) {
$taxon_id = str_replace(" ", "_", Functions::canonical_form($val));
} elseif ($val = trim((string) $rec["http://rs.tdwg.org/dwc/terms/genus"])) {
$taxon_id = md5($val);
} elseif ($val = trim((string) $rec["http://rs.tdwg.org/dwc/terms/family"])) {
$taxon_id = md5($val);
} elseif ($val = trim((string) $rec["http://rs.tdwg.org/dwc/terms/order"])) {
$taxon_id = md5($val);
} elseif ($val = trim((string) $rec["http://rs.tdwg.org/dwc/terms/class"])) {
$taxon_id = md5($val);
} elseif ($val = trim((string) $rec["http://rs.tdwg.org/dwc/terms/phylum"])) {
$taxon_id = md5($val);
} elseif ($val = trim((string) $rec["http://rs.tdwg.org/dwc/terms/kingdom"])) {
$taxon_id = md5($val);
} else {
exit("\n got it \n");
}
}
return $taxon_id;
}
示例11: manuall_add_taxon
private function manuall_add_taxon()
{
$records[] = array("sciname" => "Cordulegaster diastatops", "length" => "60-65", "url" => "http://www.americaninsects.net/d/cordulegaster-diastatops.html");
$records[] = array("sciname" => "Cordulegaster bilineata", "length" => "60-65", "url" => "http://www.americaninsects.net/d/cordulegaster-diastatops.html");
$records[] = array("sciname" => "Enallagma cyathigerum", "length" => "29-40", "url" => "http://americaninsects.net//d/enallagma-cyathigerum.html");
$records[] = array("sciname" => "Enallagma boreale", "length" => "28-36", "url" => "http://americaninsects.net//d/enallagma-cyathigerum.html");
foreach ($records as $rec) {
$r = array();
$r["sciname"] = Functions::canonical_form($rec["sciname"]);
$r["taxon_id"] = str_replace(" ", "_", $r["sciname"]);
$r["source"] = $rec["url"];
self::create_instances_from_taxon_object($r);
$r["lengths"] = array($rec["length"]);
self::prepare_length_structured_data($r);
}
}
示例12: get_sciname
//.........这里部分代码省略.........
return "Annelida";
} elseif ($string == "Other Octocorals") {
return "Octocorallia";
} elseif ($string == "Other Sea Cucumbers") {
return "Echinodermata";
} elseif ($string == "Checkered Snapper Lutjanus decussatus") {
return "Lutjanus decussatus";
} elseif ($string == "Other Sea Anemones") {
return "Actiniaria";
} elseif ($string == "Blotched Goby Coryphopterus inframaculatus") {
return "Coryphopterus inframaculatus";
} elseif ($string == "One-spot Snapper Lutjanus monostigma") {
return "Lutjanus monostigma";
} elseif ($string == "Lined Fang Blenny; Meiacanthus-lineatus") {
return "Meiacanthus lineatus";
} elseif ($string == "Reef Octopus encounter May 2010") {
return "Octopus";
} elseif ($string == "Comb Jellys; Phyllum Ctenophora") {
return "Ctenophora";
} elseif ($string == "Stony Coral Heteropsammia eupammides") {
return "Heteropsammia eupammides";
} elseif ($string == "Stony Coral Balanophyllia elegans") {
return "Balanophyllia elegans";
} elseif ($string == "Giant clam with Montipora coral surrounding.") {
return "Acropora";
} elseif ($string == "bakaruda-n-bigeyes") {
return "Sphyraena";
} elseif ($string == "Bandfish Acanthocepola species") {
return "Acanthocepola";
} elseif ($string == "Snakefish Trachinocephalus myops") {
return "Trachinocephalus myops";
} elseif ($string == "Deep bodied Silverbelly Gerres erythrourus") {
return "Gerres erythrourus";
} elseif ($string == "Ponyfish Leiognathus fasciatus") {
return "Leiognathus fasciatus";
} elseif ($string == "Parapercis species we think") {
return "Parapercis";
} elseif ($string == "Moorish Idol Zanclus cornutus") {
return "Zanclus cornutus";
} elseif ($string == "Large Shrimp Goby Cryptocentrus species") {
return "Cryptocentrus";
} elseif ($string == "Green Shrimp Goby Cryptocentrus octafasciatus") {
return "Cryptocentrus octafasciatus";
} elseif (in_array($string, array("Flagfin Shrimp Goby Mahidolia mystacina with Shrimp", "Flagfin Shrimp Goby Mahidolia mystacina"))) {
return "Mahidolia mystacina";
} elseif (in_array($string, array("blenny-head", "blenny-head-2", "blenny-head-3", "blenny-upper-body"))) {
return "Blenniidae";
} elseif (in_array($string, array("false-cleanerfish-2", "false-cleanerfish-aspidontus-taeniatus"))) {
return "Aspidontus taeniatus";
} elseif ($string == "blenny-omobranchus-sp-uuh") {
return "Omobranchus";
} elseif (in_array($string, array("rabbitfish-juve-demise", "rabbitfish-juves", "rabbitfish-juves-2", "rabbitfish-juves-en-masse"))) {
return "Siganus";
} elseif (in_array($string, array("Unidentified Goby", "Unidentified Goby tail", "Shrimp Gobies unidentified", "Shrimp Goby unidentified", "Drab Shrimp Goby with Shrimp"))) {
return "Gobiidae";
} elseif (in_array($string, array("pallid-pipefish-uuh", "slender-pipefish-2"))) {
return "Syngnathinae";
} elseif (in_array($string, array("squirrelfish-red-1", "squirrelfish-red-3"))) {
return "Holocentrus";
} elseif ($string == "giant-trevally-caranx-ignobilis") {
return "Caranx ignobilis";
} elseif ($string == "trevally-fringe-finned-pantolobus-radiatus") {
return "Pantolobus radiatus";
} elseif ($string == "trevally-golden-juv-gnathanodon-speciosus") {
return "Gnathanodon speciosus";
} elseif ($string == "trevally-fringe-finned-2") {
return "Caranx";
} elseif ($string == "slender-pipefish-trachyrhampus-longirostris-1") {
return "Trachyrhampus longirostris";
} elseif ($string == "Platycephalus-caeruleopunctatus") {
return "Platycephalus caeruleopunctatus";
} elseif (in_array($string, array("Unidentified Juvenile", "Small juvenile fish with Sea Pen"))) {
return "";
} elseif ($string == "Unidentified Hard Coral") {
return "Scleractinia";
} elseif (in_array($string, array("Unidentified bivalve Mollusc", "Bivalve with encrusting Sponge and Barnacles", "Large Mussel, free standing out on the sand.", "Unidentified Clam; small", "Unidentified Clam"))) {
return "Bivalvia";
} elseif (in_array($string, array("Scythozoa; other Jellyfish", "Pelagidae; Sea nettles", "Ellisellidae fam; Wire Coral", "Pennatulacea; Sea Pens", "Gorgonacea; Sea Fans/Whip Corals", "Ellisellidae; Sea Fans.", "Echinigorgia; Sea Fans", "Nephtheidae; more Soft corals", "Alcyoniidae; some Soft Corals", "Heteractis Anemone, unknown species", "Anthopleura species, perhaps", "Dardanus lagapodes; Hermit Crab", "Dardanus megistos; Hermit Crab", "Oceanapia sagittaria; Porifera."))) {
$temp = explode(";", $string);
if (count($temp) == 1) {
$temp = explode(",", $string);
}
if ($val = @$temp[0]) {
return Functions::canonical_form($val);
} else {
return "";
}
} else {
$string = trim(str_ireplace(" family", "", $string));
$temp = explode(";", $string);
if (count($temp) == 1) {
$temp = explode(",", $string);
}
if ($val = @$temp[1]) {
return Functions::canonical_form($val);
} else {
return Functions::canonical_form($temp[0]);
}
}
}
示例13: evaluate_scientific_name
private static function evaluate_scientific_name($scientific_name)
{
if (preg_match_all("/<i>(.*?)<\\/i>/i", trim($scientific_name), $matches, PREG_SET_ORDER)) {
$canonical_form = trim($matches[0][1]);
if (@$matches[1]) {
$canonical_form .= " " . trim($matches[1][1]);
}
if (@$matches[2]) {
$canonical_form .= " " . trim($matches[2][1]);
}
$canonical_form = str_replace("ssp. ", "", $canonical_form);
$scientific_name = str_ireplace("<i>", "", $scientific_name);
$scientific_name = str_ireplace("</i>", "", $scientific_name);
$scientific_name = str_replace(" ", " ", $scientific_name);
$scientific_name = str_ireplace("’", "'", $scientific_name);
}
if (@(!$canonical_form)) {
$canonical_form = Functions::canonical_form($scientific_name);
}
$taxon_id = str_replace(" ", "_", strtolower($canonical_form));
return array($scientific_name, $canonical_form, $taxon_id);
}
示例14: get_taxon_id
private function get_taxon_id($name)
{
if (is_numeric(stripos($name, " sp"))) {
return str_ireplace(" ", "_", $name);
} else {
return str_ireplace(" ", "_", Functions::canonical_form($name));
}
}
示例15: name_exists_in_eol
private function name_exists_in_eol($name)
{
$eol_api = "http://eol.org/api/search/1.0.json?exact=true&q=";
if ($json = Functions::lookup_with_cache($eol_api . $name, $this->download_options)) {
$taxon = json_decode($json, true);
if (intval($taxon["totalResults"]) > 0) {
return Functions::canonical_form($taxon["results"][0]["title"]);
} else {
return false;
}
}
}