39,7 → 39,6 |
$this->$name = $value; |
} |
|
|
/** |
* Reduce Spaces |
* This will reduce the string to only allow once space between characters |
54,7 → 53,6 |
return( $str ); |
} |
|
|
/** |
* Function: parse_auth |
* Purpose: Produce a parsed version of authority of a taxon name |
144,18 → 142,18 |
|
foreach( explode(' ', $temp) as $this_word ) { |
|
$this->debug['parse_auth'][] = "7 (this_word:$this_word)"; |
|
//$this->debug['parse_auth'][] = "7 (this_word:$this_word)"; |
$elapsed_chars = ''; |
// like '(%' |
if ( preg_match('/^\(/', $this_word) ) { |
$elapsed_chars .= '('; |
$this_word = substr( $this_word, 1 ); |
$this->debug['parse_auth'][] = "7a (this_word:$this_word) (elapsed_chars:$elapsed_chars)"; |
//$this->debug['parse_auth'][] = "7a (this_word:$this_word) (elapsed_chars:$elapsed_chars)"; |
} |
|
// Add back the word to the final translation |
$elapsed_chars .= $this_word . ' '; |
$this->debug['parse_auth'][] = "7c (this_word:$this_word) (elapsed_chars:$elapsed_chars)"; |
//$this->debug['parse_auth'][] = "7c (this_word:$this_word) (elapsed_chars:$elapsed_chars)"; |
} |
|
$elapsed_chars = $this->reduce_spaces( str_replace(' )', ')', $elapsed_chars) ); |
201,7 → 199,6 |
|
unset($this->debug['parse']); |
|
|
$temp = ''; |
$first_str_part = NULL; |
$second_str_part = NULL; |
211,34 → 208,34 |
$temp_authority = ''; |
$temp_infra = ''; |
|
$this->debug['parse'][] = "1"; |
//$this->debug['parse'][] = "1"; |
|
if ( ($str == NULL) || ( trim($str) == '') ) { |
$this->debug[] = "N1a<br>"; |
//$this->debug[] = "N1a<br>"; |
return ''; |
} else { |
// trim any leading, trailing spaces or line feeds |
$temp = trim( $str ); |
$this->debug['parse'][] = "1b"; |
//$this->debug['parse'][] = "1b"; |
} |
|
if ( $temp == NULL || $temp == '') { |
$this->debug['parse'][] = "2a"; |
//$this->debug['parse'][] = "2a"; |
return ''; |
} else { |
$this->debug['parse'][] = "2b"; |
//$this->debug['parse'][] = "2b"; |
|
// replace any HTML ampersands |
$set = array('%', '&', 'amp;%', 'AMP;%'); |
$temp = str_replace( $set, '&', $temp ); |
|
$this->debug['parse'][] = "2b1 (temp:$temp)"; |
//$this->debug['parse'][] = "2b1 (temp:$temp)"; |
|
// remove any content in angle brackets (e.g. html tags - <i>, </i>, etc.) |
$html_pattern = "(\<(/?[^\>]+)\>)"; |
//? This should not just handle html tags but all <*> |
$temp = preg_replace( $html_pattern, '', $temp); |
$this->debug['parse'][] = "2b2 (temp:$temp)"; |
//$this->debug['parse'][] = "2b2 (temp:$temp)"; |
|
// if second term (only) is in round brackets, presume it is a subgenus or a comment and remove it |
// examples: Barbatia (Mesocibota) bistrigata (Dunker, 1866) => Barbatia bistrigata (Dunker, 1866) |
248,7 → 245,7 |
//if ( $temp like '% (%)%' |
$temp = preg_replace( "/ \(\w*\W*\)/", '', $temp, 1 ); |
//? Not sure if this will catch if |
$this->debug['parse'][] = "2b3 (temp:$temp)"; |
//$this->debug['parse'][] = "2b3 (temp:$temp)"; |
|
// if second term (only) is in square brackets, presume it is a comment and remove it |
// example: Aphis [?] ficus Theobald, [1918] => Aphis ficus Theobald, [1918] |
255,7 → 252,7 |
//if ( $temp like '% [%]%' |
$temp = preg_replace( "/ \[\w*\W*\]/", '', $temp, 1 ); |
//? Not sure if this will catch if |
$this->debug['parse'][] = "2b4 (temp:$temp)"; |
//$this->debug['parse'][] = "2b4 (temp:$temp)"; |
|
// drop indicators of questionable id's - presume all are lowercase for now (could extend as needed) |
$temp = preg_replace( "/ cf /", " ", $temp ); |
266,12 → 263,12 |
$temp = preg_replace( "/ spp\. /", " ", $temp ); |
$temp = preg_replace( "/ spp /", " ", $temp ); |
|
$this->debug['parse'][] = "2b5 (temp:$temp)"; |
//$this->debug['parse'][] = "2b5 (temp:$temp)"; |
|
// eliminate or close up any stray spaces introduced by the above |
$temp = $this->reduce_spaces( $temp ); |
|
$this->debug['parse'][] = "2b6 (temp:$temp)"; |
//$this->debug['parse'][] = "2b6 (temp:$temp)"; |
|
// now presume first element is genus, second (if present) is species, remainder |
// (if present) is authority |
285,7 → 282,7 |
$temp = ''; |
} |
|
$this->debug['parse'][] = "2b7 (temp_genus:$temp_genus) (temp:$temp)"; |
//$this->debug['parse'][] = "2b7 (temp_genus:$temp_genus) (temp:$temp)"; |
|
// look for species epithet and authority |
$ar = explode( " ", $temp, 2); |
305,12 → 302,13 |
$temp_authority = preg_replace( "/subsp /", "subsp.", $temp_authority); |
$temp_authority = preg_replace( "/var /", "var.", $temp_authority); |
|
$temp_infra_authority = ''; |
$temp_infra_type = ''; |
foreach ($infras as $infra) { |
$pos = strpos($temp_authority, $infra); |
if ($pos === false) { |
continue; |
} |
else { |
} else { |
$temp_infra=substr($temp_authority,$pos+strlen($infra)); |
$temp_authority=substr($temp_authority,0,$pos); |
$temp_infra=trim($temp_infra); |
325,17 → 323,15 |
} |
} |
|
$this->debug['parse'][] = "2b8 (temp_genus:$temp_genus) (temp_species:$temp_species) (temp_authority:$temp_authority) (temp_infra:$temp_infra) (temp_infra_authority:$temp_infra_authority) (temp:$temp)"; |
//$this->debug['parse'][] = "2b8 (temp_genus:$temp_genus) (temp_species:$temp_species) (temp_authority:$temp_authority) (temp_infra:$temp_infra) (temp_infra_authority:$temp_infra_authority) (temp:$temp)"; |
|
|
// replace selected ligatures here (Genus names can contain Æ, OE ligature) |
$temp_genus = str_replace( 'Æ', 'AE', $temp_genus); |
$temp_species = str_replace( 'Æ', 'AE', $temp_species); |
$temp_infra = str_replace( 'Æ', 'AE', $temp_infra ); |
|
//$this->debug['parse'][] = "2b9 (temp_genus:$temp_genus) (temp_species:$temp_species) (temp_authority:$temp_authority) (temp_infra:$temp_infra) (temp_infra_authority:$temp_infra_authority) (temp:$temp)"; |
|
$this->debug['parse'][] = "2b9 (temp_genus:$temp_genus) (temp_species:$temp_species) (temp_authority:$temp_authority) (temp_infra:$temp_infra) (temp_infra_authority:$temp_infra_authority) (temp:$temp)"; |
|
$temp_genus= trim($temp_genus); |
$temp_species= trim($temp_species); |
$temp_infra= trim($temp_infra ); |
345,7 → 341,7 |
$temp_species= $this->reduce_spaces( $temp_species ); |
$temp_infra= $this->reduce_spaces( $temp_infra ); |
|
$this->debug['parse'][] = "2b10 (temp_genus:$temp_genus) (temp_species:$temp_species) (temp_authority:$temp_authority) (temp_infra:$temp_infra) (temp_infra_authority:$temp_infra_authority) (temp:$temp)"; |
//$this->debug['parse'][] = "2b10 (temp_genus:$temp_genus) (temp_species:$temp_species) (temp_authority:$temp_authority) (temp_infra:$temp_infra) (temp_infra_authority:$temp_infra_authority) (temp:$temp)"; |
|
if (isset($temp_authority) && ($temp_authority!='') ) { |
$temp_authority=$this->parse_auth($temp_authority); |
354,18 → 350,9 |
if (isset($temp_infra_authority) && ($temp_infra_authority!='') ) { |
$temp_infra_authority=$this->parse_auth($temp_infra_authority); |
} |
|
|
$this->debug['parse'][] = "2b11 (temp_genus:$temp_genus) (temp_species:$temp_species) (temp_authority:$temp_authority) (temp_infra:$temp_infra) (temp_infra_authority:$temp_infra_authority) (temp:$temp)"; |
|
//$this->debug['parse'][] = "2b11 (temp_genus:$temp_genus) (temp_species:$temp_species) (temp_authority:$temp_authority) (temp_infra:$temp_infra) (temp_infra_authority:$temp_infra_authority) (temp:$temp)"; |
return array("genus"=>$temp_genus, "species"=>$temp_species, "authority"=>$temp_authority, "infra"=>$temp_infra, "infra_authority"=>$temp_infra_authority, "infra_type"=>$temp_infra_type); |
|
} |
|
} // End NameParser |
|
|
|
} // End Class |
|
?> |
?> |