22,6 → 22,8 |
private $informations = null; |
private $mois = array('janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', |
'septembre', 'octobre', 'novembre', 'décembre'); |
private $CosteFormate; |
private $CosteTexte; |
|
public function __construct(Conteneur $conteneur) { |
$this->conteneur = $conteneur; |
149,42 → 151,70 |
} |
|
public function MettreEnFormeCoste($texte){ |
$resultat = array(); |
if ( preg_match('/\*\*(.+)\*\*([^–]*)–/', $texte, $retour)){ |
|
$this->CosteFormate = array(); |
$this->CosteTexte = $texte; |
//decouper elements remarquables avant le texte |
$this->separerNomScientifique_a_NomCommun(); |
$this->CosteTexte = preg_replace('/\//','',$this->CosteTexte); |
//decouper elements remarquables après le texte |
$this-> separerEcologie_a_Usages(); |
//le morceau qui reste est le gros de la description |
$this->CosteTexte = str_replace(';','</br> -','- '.$this->CosteTexte); |
$this->CosteTexte = str_replace('–','',$this->CosteTexte); |
$this->CosteFormate['texte'] = $this->CosteTexte; |
return $this->CosteFormate; |
} |
|
|
public function separerNomScientifique_a_NomCommun(){ |
if ( preg_match('/\*\*(.+)\*\*([^–]*)–/', $this->CosteTexte, $retour)){ |
/* !! attention on enlève un tiret cadratin – pas un trait d'union - !! */ |
$a_enlever = array('/–/','/[0-9]+/','/\./' ); |
$resultat['nom_scientifique'] = preg_replace($a_enlever,'',$retour[1]); |
$resultat['nom_scientifique'] .= $retour[2]; |
$texte = str_replace($retour[0],'',$texte); |
$a_enlever = array('/–/','/\./' ); |
$this->CosteFormate['nom_scientifique'] = preg_replace($a_enlever,'',$retour[1]); |
if(preg_match('/\((.+)\)/',$retour[2],$synonymes)){ |
$this->CosteFormate['synonymes'] = $synonymes[1]; |
} else { |
$this->CosteFormate['nom_scientifique'] .= $retour[2]; |
} |
$this->CosteTexte = str_replace($retour[0],'',$this->CosteTexte); |
} |
/* !! attention il y a un espace avant les // du début !! */ |
if ( preg_match('/^ \/\/([^\/\/]+)\/\//', $texte, $retour)){ |
if ( preg_match('/^ \/\/([^\/\/]+)\/\//', $this->CosteTexte, $retour)){ |
$a_enlever = array('/–/','/\./' ); |
$resultat['nom_commun'] = preg_replace($a_enlever,'',$retour[1]); |
$texte = str_replace($retour[0],'',$texte); |
$this->CosteFormate['nom_commun'] = preg_replace($a_enlever,'',$retour[1]); |
$this->CosteTexte = str_replace($retour[0],'',$this->CosteTexte); |
} |
$texte = preg_replace('/\//','',$texte); |
if ( preg_match('/\.[ ]*([A-ZÉÀÈ].+)$/', $texte, $retour)){ |
$resultat['ecologie'] = $retour[1]; |
$texte = str_replace($retour[0],'.',$texte); |
if ( preg_match('/–(.+)/', $resultat['ecologie'] , $retour)){ |
$resultat['repartition'] = $retour[1]; |
$resultat['ecologie'] = str_replace($retour[0],'',$resultat['ecologie']); |
} |
|
|
public function separerEcologie_a_Usages(){ |
if ( preg_match('/\.[ ]*([A-ZÉÀÈ].+)$/',$this->CosteTexte, $retour)){ |
$this->CosteFormate['ecologie'] = $retour[1]; |
$this->CosteTexte = str_replace($retour[0],'.',$this->CosteTexte); |
if ( preg_match('/–(.+)/', $this->CosteFormate['ecologie'] , $retour)){ |
$this->CosteFormate['repartition'] = $retour[1]; |
$this->CosteFormate['ecologie'] = str_replace($retour[0],'',$this->CosteFormate['ecologie']); |
} |
if ( preg_match('/=(.+)$/', $resultat['repartition'], $retour)){ |
$resultat['floraison'] = $retour[1]; |
$resultat['repartition'] = str_replace($retour[0],'',$resultat['repartition']); |
if ( preg_match('/=(.+)$/', $this->CosteFormate['repartition'], $retour)){ |
$this->CosteFormate['floraison'] = $retour[1]; |
$this->CosteFormate['repartition'] = str_replace($retour[0],'',$this->CosteFormate['repartition']); |
} |
if ( preg_match('/–(.+)$/',$resultat['floraison'], $retour)){ |
$resultat['consommation'] = $retour[1]; |
$resultat['floraison'] = str_replace($retour[0],'.',$resultat['floraison']); |
if ( preg_match('/–(.+)$|\n(.+)$/',$this->CosteFormate['floraison'], $retour)){ |
$this->CosteFormate['usages'] = isset($retour[1]) ? $retour[1] : $retour[2]; |
$this->CosteFormate['floraison'] = str_replace($retour[0],'.',$this->CosteFormate['floraison']); |
} |
} |
$texte = str_replace(';','</br> -','- '.$texte); |
$texte = str_replace('–','',$texte); |
$resultat['texte'] = $texte; |
return $resultat; |
if ( preg_match('/([Ff]l\.) (.+)/',$this->CosteFormate['floraison'], $retour)){ |
$this->CosteFormate['floraison'] = $retour[2]; |
$this->CosteFormate['floraison'] = str_replace($retour[1],'',$this->CosteFormate['floraison']); |
} |
if ( preg_match('/([Ff]r\.) (.+)/',$this->CosteFormate['floraison'], $retour)){ |
$this->CosteFormate['fructification'] = $retour[2]; |
$this->CosteFormate['floraison'] = str_replace($retour[0],'',$this->CosteFormate['floraison']); |
$this->CosteFormate['floraison'] = str_replace(',','',$this->CosteFormate['floraison']); |
$this->CosteFormate['fructification'] = str_replace($retour[1],'',$this->CosteFormate['fructification']); |
$this->CosteFormate['fructification'] = str_replace('.','',$this->CosteFormate['fructification']); |
} |
} |
} |
|
|