<commit_before><?php
/* MorphBank connector 

<?xml version="1.0" encoding="utf-8" ?>
<response>
    <url>http://services.morphbank.net/mb/request?method=search&amp;objecttype=Image&amp;limit=-1&amp;keywords=baskauf&amp;format=id</url>
</response>

http://www.morphbank.net/eolids.xml
http://services.morphbank.net/mb2/request?method=eol&format=id
http://services.morphbank.net/mb3/request?method=eol&format=id

*/

$GLOBALS['ENV_NAME'] = 'slave';
include_once(dirname(__FILE__) . "/../../config/environment.php");
$mysqli =& $GLOBALS['mysqli_connection'];

$resource = new Resource(83); 
//exit($resource->id);

$details_method_prefix = "http://services.morphbank.net/mb/request?method=id&format=svc&limit=2&id=";
$image_ids = array();

$schema_taxa = array();
$used_taxa = array();

$wrap = "\n"; 
//$wrap = "<br>";

//get all image ids
/* working but not being used as advised by Greg from MorphBank
$limit_of_inventory = 25; //300000
$inventory_method_url = "http://services.morphbank.net/mb/request?method=search&objecttype=Image&keywords=&limit=$limit_of_inventory&format=id&firstResult=100000";
$image_id_xml = simplexml_load_file($inventory_method_url);
foreach($image_id_xml->id as $id)
{$image_ids[] = $id;}
*/

$xml = simplexml_load_file("http://www.morphbank.net/eolids.xml");
foreach($xml->url as $url)
{
    print "$wrap [$url] $wrap";   
    $url = trim($url);
    /* used before as test
    $url = "http://services.morphbank.net/mb/request?method=search&objecttype=Image&limit=-1&keywords=baskauf&format=id";
    */    
    $image_id_xml = simplexml_load_file($url);
    foreach($image_id_xml->id as $id)
    {
        $image_ids[] = $id;
    }
}
$total_image_ids = count($image_ids);
print "$wrap $wrap count of image ID's = $total_image_ids"; //exit;


// loop through image ids
$k=0;
foreach($image_ids as $image_id)
{
    $k++;
    print "$wrap $image_id  [$k of $total_image_ids]";
    $image_details_url = $details_method_prefix . $image_id;
    if($xml = simplexml_load_file($image_details_url)){}
    else continue;
    $dwc = $xml->specimen->children("http://rs.tdwg.org/dwc/dwcore/");    
    $dwcc = $xml->specimen->children("http://rs.tdwg.org/dwc/curatorial/");        
    $dwcg = $xml->specimen->children("http://rs.tdwg.org/dwc/geospatial/");        
    
    $dwc_Kingdom = trim($dwc->Kingdom);
    $dwc_Phylum = trim($dwc->Phylum);
    $dwc_Class = trim($dwc->Class);<commit_msg>Update MorphBank connector<commit_after><?php
/* MorphBank connector 

<?xml version="1.0" encoding="utf-8" ?>
<response>
    <url>http://services.morphbank.net/mb/request?method=search&amp;objecttype=Image&amp;limit=-1&amp;keywords=baskauf&amp;format=id</url>
</response>

http://www.morphbank.net/eolids.xml
http://services.morphbank.net/mb2/request?method=eol&format=id
http://services.morphbank.net/mb3/request?method=eol&format=id

*/

$GLOBALS['ENV_NAME'] = 'slave';
include_once(dirname(__FILE__) . "/../../config/environment.php");
$mysqli =& $GLOBALS['mysqli_connection'];

$resource = new Resource(83); 
//exit($resource->id);

$details_method_prefix = "http://services.morphbank.net/mb/request?method=id&format=svc&limit=2&id=";
$image_ids = array();

$schema_taxa = array();
$used_taxa = array();

$wrap = "\n"; 
//$wrap = "<br>";

//get all image ids
/* working but not being used as advised by Greg from MorphBank
$limit_of_inventory = 25; //300000
$inventory_method_url = "http://services.morphbank.net/mb/request?method=search&objecttype=Image&keywords=&limit=$limit_of_inventory&format=id&firstResult=100000";
$image_id_xml = simplexml_load_file($inventory_method_url);
foreach($image_id_xml->id as $id)
{$image_ids[] = $id;}
*/

if($xml = simplexml_load_file("http://www.morphbank.net/eolids.xml")){}
else{exit("$wrap Service not available.");}
foreach($xml->url as $url)
{
    print "$wrap [$url] $wrap";   
    $url = trim($url);
    /* used before as test
    $url = "http://services.morphbank.net/mb/request?method=search&objecttype=Image&limit=-1&keywords=baskauf&format=id";
    */    
    if($image_id_xml = simplexml_load_file($url)){}
    else continue;
    foreach($image_id_xml->id as $id)
    {
        $image_ids[] = $id;
    }
}
$total_image_ids = count($image_ids);
print "$wrap $wrap count of image ID's = $total_image_ids"; //exit;


// loop through image ids
$k=0;
foreach($image_ids as $image_id)
{
    $k++;
    print "$wrap $image_id  [$k of $total_image_ids]";
    $image_details_url = $details_method_prefix . $image_id;
    if($xml = simplexml_load_file($image_details_url)){}
    else continue;
    $dwc = $xml->specimen->children("http://rs.tdwg.org/dwc/dwcore/");    
    $dwcc = $xml->specimen->children("http://rs.tdwg.org/dwc/curatorial/");        
    $dwcg = $xml->specimen->children("http://rs.tdwg.org/dwc/geospatial/");        
    
    $dwc_Kingdom = trim($dwc->Kingdom);
    $dwc_Phylum = trim($dwc->Phylum);
    $dwc_Class = trim($dwc->Class);
{'fraction_non_alphanumeric': 0.19014657980456026, 'fraction_numerical': 0.01017915309446254, 'mean_word_length': 4.621281464530893, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 2, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 34}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1767090', 'n_tokens_mistral': 1877, 'n_tokens_neox': 1813, 'n_words': 267}