<?
/*
    ANISEED, NISEED System and Database
    Copyright (C) 2007 Olivier Tassy, Fabrice Daian, Patrick Lemaire

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/
include ("connection.php");
include ("frames_header.php");

$pmid=$_GET["pmid"];

$web="http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?id=$pmid&db=pubmed&report=xml";


$resource=curl_init("http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?id=$pmid&db=pubmed&report=xml");
curl_setopt($resource, CURLOPT_RETURNTRANSFER, 1);
$contents=curl_exec($resource);
curl_close($resource);



$contents=trim($contents);
$one=explode("AbstractText",$contents);
$tmp=$one[1];

$tmp=str_replace("&gt;","",$tmp); 
$tmp=str_replace("&lt;","",$tmp);
$tmp=substr($tmp,0,strlen($tmp)-1);

$abstract=$tmp;


//Traitement sur la ponctuation
$new=strtoupper($abstract);
$new=str_replace(",","",$new);
$new=str_replace("(","",$new);
$new=str_replace(")","",$new);
$new=str_replace(".","",$new);
$new=str_replace(";","",$new);
$new=str_replace("[","",$new);
$new=str_replace("]","",$new);


//Traitement sur les pronoms,articles, ....
$new=str_replace("THE","",$new);
$new=str_replace("IN","",$new);
$new=str_replace("BY","",$new);
$new=str_replace("WAS","",$new);
$new=str_replace("AS","",$new);
$new=str_replace("OR","",$new);



print $new."<hr>";





$new=str_replace(" ","','",$new);
$new="('$new')";



//$abstract=$new;
print $abstract."<br><br>";


$requete="SELECT \"SYNO\" from \"SYNO\" where \"SYNO_UPPER_CASE\" in $new";

//$requete="SELECT \"SYNO_UPPER_CASE\" from \"SYNO\"intersectSELECT $new";

$stmt=pg_query($c,$requete);
while ($row=pg_fetch_array($stmt))
{
print $row["SYNO"]."<br>";
}






include ("frames_footer.php");
?>
