Advertisement
LrdArc

intip.in/sparqlauto

Dec 17th, 2016
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.95 KB | None | 0 0
  1. <?php
  2. include( 'library/csc_pdo.php' );
  3. $db = new CsC_PDO( $db_user, $db_pass, $dbname );
  4.  
  5. $isi = "
  6. @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
  7. @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
  8. @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
  9. @prefix ex: <http://example.com/filariasis.csv> .
  10.  
  11. ex:provinsi a rdfs:Class .
  12. ex:penyakit a rdfs:Class .
  13.  
  14.  
  15. ex:nama_provinsi a rdf:Property .
  16. ex:nama_provinsi rdfs:domain ex:provinsi .
  17. ex:nama_provinsi rdfs:range xsd:string .
  18.  
  19. ex:pemberian_asi_2013 a rdf:Property .
  20. ex:pemberian_asi_2013 rdfs:domain ex:penyakit .
  21. ex:pemberian_asi_2013 rdfs:range xsd:float .
  22.  
  23. ex:terjangkit a rdf:Property .
  24. ex:terjangkit rdfs:domain ex:penyakit .
  25. ex:terjangkit rdfs:range xsd:integer .
  26.  
  27. ex:penderita_balita_u1 a rdf:Property .
  28. ex:penderita_balita_u1 rdfs:domain ex:penyakit .
  29. ex:penderita_balita_u1 rdfs:range xsd:integer .
  30.  
  31. ex:penderita_balita_1to4 a rdf:Property .
  32. ex:penderita_balita_1to4 rdfs:domain ex:penyakit .
  33. ex:penderita_balita_1to4 rdfs:range xsd:integer .
  34.  
  35. ";
  36.  
  37. $f = $db->r( 'bro', '*', 'GROUP BY nama_provinsi' );
  38. foreach ( $f as $r ) {
  39.     $prov = $r['nama_provinsi'];
  40.     $provs = str_replace( ' ', '_', $r['nama_provinsi'] );
  41.     $asi = str_replace( ',', '.', $r['pemberian_asi'] );
  42.     $isi .= "
  43. ex:$provs a ex:provinsi .
  44. ex:$provs ex:nama_provinsi \"$prov\" .
  45. ex:$provs ex:pemberian_asi_2013 $asi .
  46.     ";
  47. }
  48.  
  49. $f = $db->r( 'bro', '*' );
  50. foreach ( $f as $r ) {
  51.     $prov = $r['nama_provinsi'];
  52.     $provs = str_replace( ' ', '_', $r['nama_provinsi'] );
  53.     $isi .= "
  54. ex:$provs ex:terjangkit ex:pneumonia_ringan_" . $provs . "_2012 .
  55. ex:pneumonia_ringan_" . $provs . "_2012 ex:penderita_balita_u1 354 .
  56. ex:pneumonia_ringan_" . $provs . "_2012 ex:penderita_balita_1to4 1316 .
  57.  
  58. ex:$provs ex:terjangkit ex:pneumonia_berat_" . $provs . "_2012 .
  59. ex:pneumonia_berat_" . $provs . "_2012 ex:penderita_balita_u1 25 .
  60. ex:pneumonia_berat_" . $provs . "_2012 ex:penderita_balita_1to4 23 .
  61. ";
  62. }
  63.  
  64. echo $isi;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement