]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/metadata/postgresql_V7_mowgli/upload_sort.pl
First version of the stuff to create the DB.
[helm.git] / helm / metadata / postgresql_V7_mowgli / upload_sort.pl
diff --git a/helm/metadata/postgresql_V7_mowgli/upload_sort.pl b/helm/metadata/postgresql_V7_mowgli/upload_sort.pl
new file mode 100755 (executable)
index 0000000..1215ceb
--- /dev/null
@@ -0,0 +1,36 @@
+#!/usr/bin/perl
+
+my $inputfile = $ARGV[0];
+
+#print "Now splitting file $inputfile\n";
+open(IN, "<$inputfile") or die "Error opening file $inputfile";
+while(($skip = <IN>) && not ($skip =~ /<rdf:RDF/)) {}
+while(($line0 = <IN>) && not ($line0 =~ /<\/rdf:RDF>/)) { # <h:Object
+  chomp($line0);
+  $line0 =~ s/^[^"]*"([^"]*)">$/$1/;
+  $line1 = <IN>; #<h:refRel..
+  $obj = $line1;
+  $line2 = <IN>; # <h:position rdf:resource="&hns;value"/>
+  $position = $line2;
+  chomp($position);
+  $position =~ s/^[ \t]*[^"]*"&hns;([^"]*)"\/>/$1/;
+  $position = "http://www.cs.unibo.it/helm/schemas/schema-helm#$position";
+  $line3 = <IN>;#<h:sort..
+  $sort = $line3; 
+  chomp($sort);
+  $sort =~ s/^[ \t]*[^"]*"&hns;([^"]*)"\/>/$1/;
+  $sort = "http://www.cs.unibo.it/helm/schemas/schema-helm#$sort";
+  $line4 = <IN>; #<h:depth..
+  $depth = $line4;
+  chomp($depth);
+  $depth =~ s/^[ \t]*<h:depth>([^<]*)<\/h:depth>$/$1/;
+  $line5 = <IN>; # </h:refRel
+  $line6 = <IN>; # </h:Object>
+   
+  $line0 =~ s/'/\\'/g; 
+  $position =~ s/'/\\'/g;
+  $depth =~ s/'/\\'/g;
+  $sort =~ s/'/\\'/g;
+  print "insert into hrefSort values ('$line0', '$position', '$sort', $depth);\n\n";
+}
+close(IN);