+++ /dev/null
-output rdf
+++ /dev/null
-all:
- @echo Available targets:
- @echo " forward, backward, compress, clean-forward, clean-backward"
-
-forward:
- time for i in `cat pluto` ; do mk_forward/mk_forward.opt $$i ; done > log 2>&1
- (cd forward ; ../mkindex.sh forward)
-
-backward:
- time for i in `cat pluto` ; do touch/touch.opt $$i ; done
- find forward -type f -exec ./invert.pl {} \;
- find backward -type f -exec ./fix_rdf.pl {} \;
- (cd backward ; ../mkindex.sh backward)
-
-compress:
- find forward -name "*.xml" -exec gzip {} \;
- find backward -name "*.xml" -exec gzip {} \;
- (cd forward ; ../mkindex.sh forward)
- (cd backward ; ../mkindex.sh backward)
-
-clean-forward:
- rm -rf forward/*
-
-clean-backward:
- rm -rf backward/*
-
-.PHONY: all forward backward compress clean-forward clean-backward
+++ /dev/null
-#!/usr/bin/perl
-
-$filename = $uri = $ARGV[0];
-$outputfile = $filename.".xml";
-$uri =~ s/^backward/cic:/;
-$uri =~ s/(.*),([^,]*),([^,]*)/$1#xpointer(1\/$2\/$3)/;
-$uri =~ s/(.*),([^,]*)/$1#xpointer(1\/$2)/;
-
-print "Now processing file $filename\n";
-
-open(HEADER,">>$outputfile");
-print HEADER <<EOT;
-<?xml version="1.0" encoding="ISO-8859-1"?>
-
-<rdf:RDF xml:lang="en" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:h="http://www.cs.unibo.it/helm/schemas/schema-h.rdf#">
- <h:Object rdf:about="$uri">
-EOT
-close(HEADER);
-
-system("cat $filename >> $outputfile");
-
-open(FOOTER,">>$outputfile");
-print FOOTER <<EOT;
- </h:Object>
-</rdf:RDF>
-EOT
-close(FOOTER);
-
-unlink $filename;
+++ /dev/null
-#!/usr/bin/perl
-
-my $inputfile = $ARGV[0];
-
-print "Now splitting file $inputfile\n";
-open(IN, "<$inputfile") or die "Error opening file $inputfile";
-$dummy = <IN>; # <?xml version="1.0" encoding="ISO-8859-1"?>
-$dummy = <IN>; #
-$dummy = <IN>; # <rdf:RDF .../>
-$where = <IN>; # <h:Object rdf:about="...">
-chomp($where);
-$where =~ s/^[^"]*"([^"]*)">$/$1/;
-while(($line1 = <IN>) && not ($line1 =~ /<\/h:Object>/)) {
- $line2 = <IN>;
- $line3 = <IN>; # </refObj>
- $uri = $line2;
- chomp($uri);
- $uri =~ s/^ *<h:Occurrence rdf:about="[^"]*" rdf:value="([^"]*)"\/>$/$1/;
- $who = $uri;
- $who =~ s/^cic:/backward/;
- $who =~ s/#xpointer\(1\/([^\/]*)\/([^\/]*)\)/,$1,$2/;
- $who =~ s/#xpointer\(1\/([^\/]*)\)/,$1/;
- $line2 =~ s/\Q$uri\E/$where/;
-
- open(OUT, ">>$who") or die "Error opening file $who";
- print OUT " <h:backPointer>\n";
- print OUT $line2;
- print OUT " </h:backPointer>\n";
- close(OUT);
-}
-close(IN);
+++ /dev/null
-*.cmi *.cmo *.cmx mk_forward mk_forward.opt
+++ /dev/null
-REQUIRES = helm-xml helm-cic_proof_checking
-PREDICATES = miniReduction
-OCAMLOPTIONS = -package "$(REQUIRES)" -predicates "$(PREDICATES)" -pp camlp4o
-OCAMLDEP = ocamldep
-OCAMLFIND = ocamlfind
-OCAMLC = $(OCAMLFIND) ocamlc $(OCAMLOPTIONS)
-OCAMLOPT = $(OCAMLFIND) ocamlopt $(OCAMLOPTIONS)
-
-LIBRARIES = $(shell ocamlfind query -recursive -predicates "byte $(PREDICATES)" -format "%d/%a" $(REQUIRES))
-LIBRARIES_OPT = $(shell ocamlfind query -recursive -predicates "native $(PREDICATES)" -format "%d/%a" $(REQUIRES))
-
-all: mk_forward
-opt: mk_forward.opt
-
-DEPOBJS = mk_forward.ml
-
-MKFORWARDOBJS = mk_forward.cmo
-
-depend:
- $(OCAMLDEP) $(DEPOBJS) > .depend
-
-mk_forward: $(MKFORWARDOBJS) $(LIBRARIES)
- $(OCAMLC) -linkpkg -o mk_forward $(MKFORWARDOBJS)
-
-mk_forward.opt: $(MKFORWARDOBJS:.cmo=.cmx) $(LIBRARIES_OPT)
- $(OCAMLOPT) -linkpkg -o mk_forward.opt $(MKFORWARDOBJS:.cmo=.cmx)
-
-.SUFFIXES: .ml .mli .cmo .cmi .cmx
-.ml.cmo: $(LIBRARIES)
- $(OCAMLC) -c $<
-.mli.cmi: $(LIBRARIES)
- $(OCAMLC) -c $<
-.ml.cmx: $(LIBRARIES_OPT)
- $(OCAMLOPT) -c $<
-
-clean:
- rm -f *.cm[iox] *.o mk_forward mk_forward.opt
-
-.PHONY: clean
-
-include .depend
+++ /dev/null
-(* Copyright (C) 2000, HELM Team.
- *
- * This file is part of HELM, an Hypertextual, Electronic
- * Library of Mathematics, developed at the Computer Science
- * Department, University of Bologna, Italy.
- *
- * HELM 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 2
- * of the License, or (at your option) any later version.
- *
- * HELM 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 HELM; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA.
- *
- * For details, see the HELM World-Wide-Web page,
- * http://cs.unibo.it/helm/.
- *)
-
-(******************************************************************************)
-(* *)
-(* PROJECT HELM *)
-(* *)
-(* Claudio Sacerdoti Coen <sacerdot@cs.unibo.it> *)
-(* 03/04/2001 *)
-(* *)
-(* Missing description *)
-(* *)
-(******************************************************************************)
-
-let iteri foo =
- let counter = ref 0 in
- List.iter (function e -> incr counter ; foo e !counter)
-;;
-
-let pathname_of_uri uristring =
- "forward" ^
- Str.replace_first (Str.regexp "^cic:") "" uristring
-;;
-
-let make_dirs dirpath =
- ignore (Unix.system ("mkdir -p \"" ^ dirpath ^ "\""))
-;;
-
-module UriHash =
- struct
- type classification =
- Backbone
- | Branch
- | InConclusion
- | InHypothesis
- | InBody
- ;;
-
-let soften_classification =
- function
- Backbone -> InConclusion
- | Branch -> InHypothesis
- | InBody -> assert false
- | k -> k
-;;
-
- let hash = Hashtbl.create 117 ;;
-
- let add_uri uri kind =
- let old_kinds =
- try
- Hashtbl.find hash uri
- with
- Not_found -> []
- in
- let new_kinds =
- match kind,old_kinds with
- InBody,[] -> [InBody]
- | InBody,_ -> old_kinds
- | k,_ when List.mem k old_kinds -> old_kinds
- | k,_ -> k::old_kinds
- in
- Hashtbl.replace hash uri new_kinds
- ;;
-
- (* It also removes every element in the hash *)
- let uris_fold foo init =
- let xml_element_name_of_kind =
- function
- Backbone -> "MainConclusion"
- | Branch -> "MainHypothesis"
- | InConclusion -> "InConclusion"
- | InHypothesis -> "InHypothesis"
- | InBody -> "InBody"
- in
- let res =
- Hashtbl.fold
- (fun uri kinds i ->
- List.fold_left
- (fun j kind ->
- foo j uri (xml_element_name_of_kind kind)
- ) i kinds
- ) hash init
- in
- Hashtbl.clear hash ;
- res
- ;;
- end
-;;
-
-let output_content () =
- UriHash.uris_fold
- (fun i uri kind ->
- [< Xml.xml_nempty "h:refObj" []
- (Xml.xml_empty "h:Occurrence"
- ["rdf:about","http://www.cs.unibo.it/helm/schemas/schema-h.rdf#" ^ kind ;
- "rdf:value",uri]
- ) ;
- i
- >]
- ) [<>]
-;;
-
-let output_file cic_string_uri rdf_string_uri =
- let module U = UriManager in
- let module X = Xml in
- let content = output_content () in
- let rdf_uri = U.uri_of_string rdf_string_uri in
- make_dirs (pathname_of_uri (U.buri_of_uri rdf_uri)) ;
- X.pp
- [< X.xml_cdata "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" ;
- X.xml_nempty "rdf:RDF"
- ["xml:lang","en" ;
- "xmlns:rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#";
- "xmlns:h","http://www.cs.unibo.it/helm/schemas/schema-h.rdf#"]
-
- (try
- Stream.empty content ; (* raise Stream.failure if not empty *)
- X.xml_empty "h:Object" ["rdf:about",cic_string_uri]
- with
- Stream.Failure ->
- X.xml_nempty "h:Object" ["rdf:about",cic_string_uri] content
- )
- >]
- (Some (pathname_of_uri rdf_string_uri ^ ".xml"))
-;;
-
-let get_obj uri =
- let cicfilename = Getter.getxml uri in
- let res = CicParser.obj_of_xml cicfilename uri in
- Unix.unlink cicfilename ;
- res
-;;
-
-let add_every_constructor uri typeno kind =
- let module C = Cic in
- match (get_obj uri) with
- (C.InductiveDefinition (itys,_,_)) ->
- let string_uri = UriManager.string_of_uri uri in
- let sn = string_of_int (typeno + 1) in
- let (_,_,_,cons) = List.nth itys typeno in
- iteri
- (fun (_,cty,_) m ->
- let sm = string_of_int m in
- UriHash.add_uri
- (string_uri ^ "#xpointer(1/" ^ sn ^ "/" ^ sm ^ ")")
- kind
- ) cons
- | _ -> assert false
-;;
-
-let process_type term =
- let module U = UriManager in
- let module H = UriHash in
- let module C = Cic in
- let rec process_type_aux kind =
- function
- | C.Var uri ->
- H.add_uri (U.string_of_uri uri) kind
- | C.Cast (te,_) ->
- (* type ignored *)
- process_type_aux kind te
- | C.Prod (_,sou,ta) ->
- let (source_kind,target_kind) =
- match kind with
- H.Backbone -> (H.Branch,H.Backbone)
- | H.Branch -> (H.InHypothesis,H.InHypothesis)
- | H.InBody -> assert false
- | k -> (k,k)
- in
- process_type_aux source_kind sou ;
- process_type_aux target_kind ta
- | C.Lambda (_,sou,ta) ->
- let kind' = H.soften_classification kind in
- process_type_aux kind' sou ;
- process_type_aux kind' ta
- | C.LetIn (_,te,ta)->
- let kind' = H.soften_classification kind in
- process_type_aux kind' te ;
- process_type_aux kind ta
- | C.Appl (he::tl) ->
- let kind' = H.soften_classification kind in
- process_type_aux kind he ;
- List.iter (process_type_aux kind') tl
- | C.Appl _ -> assert false
- | C.Const (uri,_) ->
- UriHash.add_uri (U.string_of_uri uri) kind
- | C.MutInd (uri,_,typeno) ->
- H.add_uri
- (U.string_of_uri uri ^ "#xpointer(1/" ^
- string_of_int (typeno + 1) ^ ")")
- kind
- | C.MutConstruct (uri,_,typeno,consno) ->
- H.add_uri
- (U.string_of_uri uri ^ "#xpointer(1/" ^
- string_of_int (typeno + 1) ^ "/" ^ string_of_int consno ^ ")")
- kind
- | C.MutCase (uri,_,typeno,_,term,patterns) ->
- (* outtype ignored *)
- let kind' = H.soften_classification kind in
- add_every_constructor uri typeno kind' ;
- process_type_aux kind' term ;
- List.iter (process_type_aux kind') patterns
- | C.Fix (_,funs) ->
- let kind' = H.soften_classification kind in
- List.iter
- (function (_,_,bo,ty) ->
- process_type_aux kind' bo ;
- process_type_aux kind' ty ;
- ) funs
- | C.CoFix (_,funs) ->
- let kind' = H.soften_classification kind in
- List.iter
- (function (_,bo,ty) ->
- process_type_aux kind' bo ;
- process_type_aux kind' ty ;
- ) funs
- | _ -> ()
-in
- process_type_aux H.Backbone (CicMiniReduction.letin_nf term)
-;;
-
-let process_body =
- let module U = UriManager in
- let module H = UriHash in
- let module C = Cic in
- let rec process_body_aux =
- function
- C.Var uri ->
- H.add_uri (U.string_of_uri uri) H.InBody
- | C.Cast (te,ty) ->
- process_body_aux te ;
- process_body_aux ty
- | C.Prod (_,sou,ta) ->
- process_body_aux sou ;
- process_body_aux ta
- | C.Lambda (_,sou,ta) ->
- process_body_aux sou ;
- process_body_aux ta
- | C.LetIn (_,te,ta)->
- process_body_aux te ;
- process_body_aux ta
- | C.Appl l ->
- List.iter process_body_aux l
- | C.Const (uri,_) ->
- UriHash.add_uri (U.string_of_uri uri) H.InBody
- | C.MutInd (uri,_,typeno) ->
- H.add_uri
- (U.string_of_uri uri ^ "#xpointer(1/" ^
- string_of_int (typeno + 1) ^ ")")
- H.InBody
- | C.MutConstruct (uri,_,typeno,consno) ->
- H.add_uri
- (U.string_of_uri uri ^ "#xpointer(1/" ^
- string_of_int (typeno + 1) ^ "/" ^ string_of_int consno ^ ")")
- H.InBody
- | C.MutCase (uri,_,typeno,outtype,term,patterns) ->
- add_every_constructor uri typeno H.InBody ;
- process_body_aux outtype ;
- process_body_aux term ;
- List.iter process_body_aux patterns
- | C.Fix (_,funs) ->
- List.iter
- (function (_,_,bo,ty) ->
- process_body_aux bo ;
- process_body_aux ty ;
- ) funs
- | C.CoFix (_,funs) ->
- List.iter
- (function (_,bo,ty) ->
- process_body_aux bo ;
- process_body_aux ty ;
- ) funs
- | _ -> ()
-in
- process_body_aux
-;;
-
-let process_obj string_uri =
- let module U = UriManager in
- let module C = Cic in
- function
- (C.Definition (_,bo,ty,_)) ->
- process_type ty ;
- process_body bo ;
- output_file string_uri string_uri
- | (C.Axiom (_,ty,_)) ->
- process_type ty ;
- output_file string_uri string_uri
- | (C.Variable (_,bo,ty)) ->
- process_type ty ;
- begin
- match bo with
- (Some bo') -> process_body bo'
- | _ -> ()
- end ;
- output_file string_uri string_uri
- | (C.InductiveDefinition _) as id ->
- begin
- let id' =
- CicSubstitution.undebrujin_inductive_def
- (U.uri_of_string string_uri) id
- in
- match id' with
- (C.InductiveDefinition (itys,_,_)) ->
- iteri
- (fun (_,_,ty,cons) n ->
- let sn = string_of_int n in
- process_type ty ;
- output_file
- (string_uri ^ "#xpointer(1/" ^ sn ^ ")")
- (string_uri ^ "," ^ sn) ;
- iteri
- (fun (_,cty,_) m ->
- let sm = string_of_int m in
- process_type cty ;
- output_file
- (string_uri ^ "#xpointer(1/" ^ sn ^ "/" ^ sm ^ ")")
- (string_uri ^ "," ^ sn ^ "," ^ sm)
- ) cons
- ) itys
- | _ -> assert false
- end
- | (C.CurrentProof _) -> assert false
-;;
-
-let mk_forward string_uri =
- let module U = UriManager in
- print_endline ("Now computing metadata of " ^ string_uri) ;
- flush stdout ;
- let uri = U.uri_of_string string_uri in
- let obj = get_obj uri in
- process_obj string_uri obj
-;;
-
-let _ =
- let usage_msg = "usage: mk_forward[.opt] URI" in
- let uri = ref "" in
- Arg.parse []
- (fun x ->
- if x = "" then
- begin
- prerr_string "No URI provided.\n" ;
- Arg.usage [] usage_msg ;
- exit (-1)
- end
- else if !uri = "" then
- uri := x
- else
- begin
- prerr_string "More than two arguments provided.\n" ;
- Arg.usage [] usage_msg ;
- exit (-1)
- end
- ) usage_msg ;
- if !uri = "" then
- begin
- prerr_string "No URI provided.\n" ;
- Arg.usage [] usage_msg ;
- exit (-1)
- end ;
- mk_forward !uri
-;;
+++ /dev/null
-#!/bin/bash
-
-echo `find . -name "*.xml"` | ../uris_of_filenames.pl $1 > rdf_index.txt
-echo `find . -name "*.xml.gz"` | ../uris_of_filenames.pl $1 -gz >> rdf_index.txt
+++ /dev/null
-*.cmi *.cmo *.cmx touch touch.opt
+++ /dev/null
-REQUIRES = helm-getter helm-cic str
-PREDICATES =
-OCAMLOPTIONS = -package "$(REQUIRES)" -predicates "$(PREDICATES)"
-OCAMLDEP = ocamldep
-OCAMLFIND = ocamlfind
-OCAMLC = $(OCAMLFIND) ocamlc $(OCAMLOPTIONS)
-OCAMLOPT = $(OCAMLFIND) ocamlopt $(OCAMLOPTIONS)
-
-LIBRARIES = $(shell ocamlfind query -recursive -predicates "byte $(PREDICATES)" -format "%d/%a" $(REQUIRES))
-LIBRARIES_OPT = $(shell ocamlfind query -recursive -predicates "native $(PREDICATES)" -format "%d/%a" $(REQUIRES))
-
-all: touch
-opt: touch.opt
-
-DEPOBJS = touch.ml
-
-TOUCHOBJS = touch.cmo
-
-depend:
- $(OCAMLDEP) $(DEPOBJS) > .depend
-
-touch: $(TOUCHOBJS) $(LIBRARIES)
- $(OCAMLC) -linkpkg -o touch $(TOUCHOBJS)
-
-touch.opt: $(TOUCHOBJS:.cmo=.cmx) $(LIBRARIES_OPT)
- $(OCAMLOPT) -linkpkg -o touch.opt $(TOUCHOBJS:.cmo=.cmx)
-
-.SUFFIXES: .ml .mli .cmo .cmi .cmx
-.ml.cmo: $(LIBRARIES)
- $(OCAMLC) -c $<
-.mli.cmi: $(LIBRARIES)
- $(OCAMLC) -c $<
-.ml.cmx: $(LIBRARIES_OPT)
- $(OCAMLOPT) -c $<
-
-clean:
- rm -f *.cm[iox] *.o touch touch.opt
-
-.PHONY: clean
-
-include .depend
+++ /dev/null
-(* Copyright (C) 2000, HELM Team.
- *
- * This file is part of HELM, an Hypertextual, Electronic
- * Library of Mathematics, developed at the Computer Science
- * Department, University of Bologna, Italy.
- *
- * HELM 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 2
- * of the License, or (at your option) any later version.
- *
- * HELM 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 HELM; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA.
- *
- * For details, see the HELM World-Wide-Web page,
- * http://cs.unibo.it/helm/.
- *)
-
-(******************************************************************************)
-(* *)
-(* PROJECT HELM *)
-(* *)
-(* Claudio Sacerdoti Coen <sacerdot@cs.unibo.it> *)
-(* 03/04/2001 *)
-(* *)
-(* Missing description *)
-(* *)
-(******************************************************************************)
-
-let iteri foo =
- let counter = ref 0 in
- List.iter (function e -> incr counter ; foo e !counter)
-;;
-
-let pathname_of_uri uristring =
- "backward" ^
- Str.replace_first (Str.regexp "^cic:") "" uristring
-;;
-
-let make_dirs dirpath =
- ignore (Unix.system ("mkdir -p \"" ^ dirpath ^ "\""))
-;;
-
-let touch_file rdf_string_uri =
- let module U = UriManager in
- let rdf_uri = U.uri_of_string rdf_string_uri in
- make_dirs (pathname_of_uri (U.buri_of_uri rdf_uri)) ;
- ignore (
- Unix.system
- ("touch \"" ^ (pathname_of_uri rdf_string_uri) ^ "\"")
- )
-;;
-
-let get_obj uri =
- let cicfilename = Getter.getxml uri in
- let res = CicParser.obj_of_xml cicfilename uri in
- Unix.unlink cicfilename ;
- res
-;;
-
-let touch_obj string_uri =
- let module U = UriManager in
- let module C = Cic in
- function
- Some (C.InductiveDefinition (itys,_,_)) ->
- iteri
- (fun (_,_,_,cons) n ->
- let sn = string_of_int n in
- touch_file
- (string_uri ^ "," ^ sn) ;
- iteri
- (fun (_,_,_) m ->
- let sm = string_of_int m in
- touch_file
- (string_uri ^ "," ^ sn ^ "," ^ sm)
- ) cons
- ) itys
- | Some _ -> assert false
- | None ->
- touch_file string_uri
-;;
-
-let touch string_uri =
- let module S = String in
- let module U = UriManager in
- print_endline ("Now touching metadata file for " ^ string_uri) ;
- flush stdout ;
- let uri = U.uri_of_string string_uri in
- let obj =
- if S.sub string_uri (S.length string_uri - 3) 3 = "ind" then
- Some (get_obj uri)
- else
- None
- in
- touch_obj string_uri obj
-;;
-
-let _ =
- let usage_msg = "usage: touch[.opt] URI" in
- let uri = ref "" in
- Arg.parse []
- (fun x ->
- if x = "" then
- begin
- prerr_string "No URI provided.\n" ;
- Arg.usage [] usage_msg ;
- exit (-1)
- end
- else if !uri = "" then
- uri := x
- else
- begin
- prerr_string "More than two arguments provided.\n" ;
- Arg.usage [] usage_msg ;
- exit (-1)
- end
- ) usage_msg ;
- if !uri = "" then
- begin
- prerr_string "No URI provided.\n" ;
- Arg.usage [] usage_msg ;
- exit (-1)
- end ;
- touch !uri
-;;
+++ /dev/null
-#!/usr/bin/perl
-
-while(<STDIN>) {
- chomp;
- split / /;
- for (@_) {
- $GZSUFF = "";
- if (/.gz$/)
- { s/.gz$//; $GZSUFF = " gz" if ($ARGV[1] == "-gz"); }
- s/\./helm:rdf:www.cs.unibo.it\/helm\/rdf\/$ARGV[0]\/\/cic:/;
- s/\.xml//;
- print $_.$GZSUFF."\n";
- }
-}
+++ /dev/null
-CC = gcc
-
-meta: lex.yy.o sthandler.o
- gcc lex.yy.o sthandler.o -o meta
-
-lex.yy.c: meta_lex.l sthandler.h
- flex meta_lex.l
-
-sthandler.o: sthandler.c sthandler.h
-
-lex.yy.o: lex.yy.c sthandler.h
- gcc -c lex.yy.c
-
-clean:
- -rm *.o
- -rm lex.yy.c
- -rm meta
+++ /dev/null
- /******************************************************************/
- /* Copyright (C) 2000, HELM Team */
- /* */
- /* This file is part of HELM, an Hypertextual, Electronic */
- /* Library of Mathematics, developed at the Computer Science */
- /* Department, University of Bologna, Italy. */
- /* */
- /* HELM 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 */
- /* 2 of the License, or (at your option) any later version. */
- /* */
- /* HELM 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 HELM; if not, write to the Free Software */
- /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, */
- /* MA 02111-1307, USA. */
- /* */
- /* For details, see the HELM World-Wide-Web page, */
- /* http://cs.unibo.it/helm/. */
- /******************************************************************/
-
- /***************************************************************/
- /* META_LEXAN */
- /* Automatic Metadata Extractor */
- /* First draft 11/12/2001, by Andrea Asperti */
- /***************************************************************/
-
- /***************************************************************/
- /* 1. Inclusion of header files. */
- /***************************************************************/
-
-%{
-#include <string.h>
-#include <stdlib.h>
-#include "sthandler.h"
-%}
-
- /***************************************************************/
- /* 2. Constants and Variables Definitions */
- /***************************************************************/
-
-%{
-#define NOWHERE 0
-#define CONST 1
-#define MUTIND 2
-#define MUTCONSTRUCT 3
-
-#define INBODY 0
-#define MAINHYP 1
-#define INHYP 2
-#define INCONCL 3
-#define MAINCONCL 4
-#define INTYPE 5
-#define NOTFOUND 6
-
-#define BEFORE 0
-#define HERE 1
-#define AFTER 2
-
-
-int where = NOWHERE;
-int found = NOTFOUND;
-int position = INBODY;
-int first_child = BEFORE;
-int no_open_source =0;
-int tmp_n;
-char sep = '"';
-char *xpointer = "#xpointer(1/";
-char *uri;
-char *tmp;
-%}
-
- /***************************************************************/
- /* 3. Regular definitions. */
- /***************************************************************/
-
-uri [^"]+
-digits [0-9]+
-
- /***************************************************************/
- /* 4. Rules. */
- /***************************************************************/
-
-
-
-%%
-
-"<type>" {
- position = INTYPE;
- first_child = BEFORE;
- }
-
-"<source" {
- if ((position == INTYPE) ||
- (position == INHYP))
- { position = INHYP;
- no_open_source++;};
- /* printf("source %d\n", no_open_source); */
- }
-
-"</source>" {
- if (position == INHYP)
- {
- no_open_source--;
- /* printf("source %d\n", no_open_source); */
- if (no_open_source == 0)
- { position = INTYPE;
- first_child = BEFORE; };
- };
- }
-
-
-"<body>" {
- position = INBODY;
- }
-
-.|\n {
- }
-
-"<APPLY" {
- if (first_child == BEFORE)
- first_child = HERE;
- else if (first_child == HERE)
- first_child = AFTER;
- }
-
-"<LAMBDA" |
-"<REL" |
-"<MUTCASE" |
-"<FIX" |
-"<COFIX" {
- if ((first_child == BEFORE) || (first_child == HERE))
- first_child = AFTER;
- }
-
-"<CONST" {
- if (position == INTYPE) /* CONST on the spine */
- position = INCONCL;
- if (first_child == BEFORE)
- first_child = HERE;
- where = CONST;
- }
-
-"<MUTIND" {
- if (position == INTYPE) /* MUTIND on the spine */
- position = INCONCL;
- if (first_child == BEFORE)
- first_child = HERE;
- where = MUTIND;
- }
-
-"<MUTCONSTRUCT" {
- if (position == INTYPE) /* MUTCONSTRUCT on the spine */
- position = INCONCL;
- if (first_child == BEFORE)
- first_child = HERE;
- where = MUTCONSTRUCT;
- }
-
-"uri=\""{uri} {
- uri=(char *)malloc((sizeof('a')*200));
- strcpy(uri,yytext);
- strsep(&uri,&sep);
- if (where == CONST)
- {
- search(uri,first_child,position);
- where = NOWHERE;
- first_child = AFTER;
- free(uri);
- };
- }
-
-"noType=\""{digits} {
- if ((where == MUTIND) || (where == MUTCONSTRUCT))
- { strsep(&yytext,&sep);
- tmp=(char *)malloc((sizeof(sep)*(strlen(yytext)+1)));
- strcpy(tmp,yytext);
- tmp_n = atoi(tmp)+1;
- sprintf(tmp,"%d",tmp_n);
- strcat(uri,"#xpointer(1/");
- strcat(uri,tmp);
- };
- if (where == MUTIND)
- {
- strcat(uri,")");
- search(uri,first_child,position);
- free(uri);
- free(tmp);
- where = NOWHERE;
- first_child = AFTER;};
- }
-
-"noConstr=\""{digits} {
- if (where == MUTCONSTRUCT)
- { strsep(&yytext,&sep);
- tmp=(char *)malloc((sizeof(sep)*(strlen(yytext)+1)));
- strcpy(tmp,yytext);
- strcat(uri,"/");
- strcat(uri,tmp);
- strcat(uri,")");
- search(uri,first_child,position);
- free(uri);
- free(tmp);
- where = NOWHERE;
- first_child = AFTER;};
- }
-
-
-
-%%
-
- /***************************************************************/
- /* 6. Auxiliary functions. */
- /***************************************************************/
-
-main(int argc, char *argv[])
-{
- init_symbol_table();
- yylex();
- printf("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n");
- printf("<rdf:RDF xml:lang=\"en\" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:h=\"http:/www.cs.unibo.it/helm/schemas/schema-h.rdf#\">\n");
- printf("<h:Object rdf:about=\"");
- printf("%s",argv[1]);
- printf("\">\n");
- print_all();
- printf("</h:Object>\n");
- printf("</rdf:RDF>\n");
- }
-
-search(uri,first_child,position)
-char *uri;
-int first_child;
-int position;
-{
- if (first_child == HERE)
- {
- if (position == INHYP)
- found = search_bucket(uri,MAINHYP);
- else if (position == INCONCL)
- found = search_bucket(uri,MAINCONCL);
- /* if (found == NOTFOUND)
- printf( "pos = %d, uri = %s\n", MAINCONCL, uri); */
- }
- else found = search_bucket(uri,position);
- /* if (found == NOTFOUND)
- printf( "pos = %d, uri = %s\n", position, uri); */
- }
-
-int yywrap() {
- return 1;
- }
-
-
-
-
-
-
-
+++ /dev/null
-/*********************************************************************/
-/* Copyright (C) 2000, HELM Team */
-/* */
-/* This file is part of HELM, an Hypertextual, Electronic */
-/* Library of Mathematics, developed at the Computer Science */
-/* Department, University of Bologna, Italy. */
-/* */
-/* HELM 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 2 */
-/* of the License, or (at your option) any later version. */
-/* */
-/* HELM 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 HELM; if not, write to the Free Software */
-/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, */
-/* MA 02111-1307, USA. */
-/* */
-/* For details, see the HELM World-Wide-Web page, */
-/* http://cs.unibo.it/helm/. */
- /*********************************************************************/
-
-/****************************************************************/
-/* STHANDLER.C */
-/****************************************************************/
-/* This module supplies routines for symbol table handling. */
-/* - init_symbol_table(): it initializes the symbol table */
-/* to void. */
-/* - search_bucket(): it searches the symbol table for the */
-/* bucket containing a given identifier, and */
-/* inserts it if it is not present; */
-/****************************************************************/
-/* First draft 11/12/2001, by Andrea Asperti */
-/****************************************************************/
-
-/****************************************************************/
-/* 1. Inclusion of header files. */
-/****************************************************************/
-
-#include <stdio.h>
-#include <malloc.h>
-
-/****************************************************************/
-/* 2. Declarations */
-/****************************************************************/
-
-
-#define DICTSIZE 211
-#define HASH1 4
-#define HASH2 0xf0000000
-#define HASH3 24
-#define EOS '\0'
-
-#define INBODY 0
-#define MAINHYP 1
-#define INHYP 2
-#define INCONCL 3
-#define MAINCONCL 4
-#define INTYPE 5
-#define NOTFOUND 6
-
-/****************************************************************/
-/* 3. Types. */
-/****************************************************************/
-
-struct st_bucket {
- char *id;
- /* identifier */
- struct st_bucket *next_st_bucket;
- /* next bucket in the list */
- struct st_bucket *all_next;
- /* all buckets in symbol
- table are linked together */
- int pos[5];
-
- };
-
-struct st_bucket *dictionary[DICTSIZE];
- /* pointers to bucket lists */
-
-/****************************************************************/
-/* 4. Definitions of functions to be exported. */
-/****************************************************************/
-
-struct st_bucket *all;
-
- /* The following function initializes the symbol table to NULL */
-void init_symbol_table()
-{
- struct st_bucket *st;
- int i;
-
- /* initialize the dictionary */
- for (i = 0; i < DICTSIZE; i++)
- dictionary[i] = NULL;
- all = NULL;
-}
-
- /* The following function searches the symbol table for an identifier */
- /* and inserts it if it is not present.
- /* The bucket associated with the given identifier */
- /* becomes the first one in its list. */
-
-search_bucket(id, where)
- char *id;
- /* identifier */
- int where;
-{
- int dict_index;
- /* value returned by the */
- /* hash function */
- struct st_bucket
- *prev,
- *curr;
-
- struct st_bucket *st;
-
- /* apply the hash function */
- dict_index = hash_pjw(id);
- /* printf( "%d\n", dict_index); */
-
- /* scan the bucket list indicated by the hash function */
- prev = curr = dictionary[dict_index];
- while ((curr != NULL) && (strcmp(id, curr->id)))
- {
- prev = curr;
- curr = curr->next_st_bucket;
- }
- if (curr == NULL)
- /* the identifier is not in the list */
- {
- allocate_bucket(&st,id,where);
- move_bucket(st,dict_index);
- return NOTFOUND;
- }
- else
- /* printf("uno=%s\n", id);
- printf("st=%s\n", curr->id); */
-
- /* the identifier is already in the list */
- {
- /* st = curr; */
- curr->pos[where] = 1;
- if (where >= 1)
- curr->pos[0] = 0; /* it will never be set again to 1 */
- if (prev != curr)
- /* the identifier is not in the first position */
- {
- prev->next_st_bucket = curr->next_st_bucket;
- move_bucket(curr,
- dict_index);
- };
- return where;
- }
-}
-
-print_all()
-{
- int i;
- struct st_bucket *curr;
- curr = all;
-
- while (curr != NULL)
- {
- for (i = 0; i < 5; ++i)
- if (curr->pos[i] == 1)
- print_one(curr->id,i);
- curr = curr->all_next;
- }
-}
-
-
-/****************************************************************/
-/* 5. Definitions of functions local to the module. */
-/****************************************************************/
-
-print_one(uri,pos)
- char *uri;
- int pos;
-{
- printf("<h:refObj>\n");
- printf("<h:Occurrence rdf:about=\"http://www.cs.unibo.it/helm/schemas/schema-h.rdf#");
- if (pos == INBODY)
- printf("InBody");
- else if (pos == MAINHYP)
- printf("MainHypothesis");
- else if (pos == INHYP)
- printf("InHypothesis");
- else if (pos == INCONCL)
- printf("InConclusion");
- else if (pos == MAINCONCL)
- printf("MainConclusion");
- printf("\" rdf:value=\"");
- printf("%s", uri);
- printf("\"/>\n");
- printf("</h:refObj>\n");
-}
-
- /* The following function allocates a bucket for an identifier. */
-allocate_bucket(st, id, where)
- struct st_bucket
- **st;
- /* pointer to the bucket to be */
- /* allocated */
- char *id;
- /* identifier */
- int where;
-{
- int i;
-
- *st = (struct st_bucket *)malloc(sizeof(struct st_bucket));
- (*st)->id = (char *)malloc(sizeof('a')*strlen(id));
- strcpy((*st)->id,id);
- (*st)->next_st_bucket = NULL;
- (*st)->all_next = all;
- all = *st;
- for (i = 0; i < 5; ++i)
- (*st)->pos[i] = 0;
- (*st)->pos[where] = 1;
-}
-
- /* The following function moves a bucket to the head of the */
- /* list in which it lies. */
-move_bucket(st, dict_index)
- struct st_bucket
- *st;
- /* pointer to the bucket to */
- /* be moved */
- int dict_index;
- /* index corresponding to */
- /* the list in which the */
- /* bucket lies */
-{
- st->next_st_bucket = dictionary[dict_index];
- dictionary[dict_index] = st;
-}
-
- /* The following function implements Weinberger's hash function. */
-int
-hash_pjw(id)
- char *id;
- /* identifier to be hashed */
-{
- unsigned h,
- g;
-
- for (h = 0; *id != EOS; id++)
- {
- h = (h << HASH1) + (*id);
- if (g = h & HASH2)
- h = h ^ (g >> HASH3) ^ g;
- }
- return(h % DICTSIZE);
-}
-
-
-
-
-
+++ /dev/null
-/****************************************************************/
-/* STHANDLER.H */
-/****************************************************************/
-
-
-extern void init_symbol_table();
-extern void print_all();
-extern int search_bucket();
+++ /dev/null
-all:
- @echo Available targets:
- @echo " forward, backward, compress, clean-forward, clean-backward"
-
-forward:
- time for i in `cat pluto` ; do (cd tmp ; wget -t 1 "http://phd.cs.unibo.it:8081/getxml?format=gz&uri=$$i") ; mkdir -p forward/`dirname $$i | sed "s/cic:\///"` ; zcat tmp/`basename $$i` | METADATA/meta `basename $$i` > forward/`echo $$i | sed "s/cic:\///"` ; rm tmp/`basename $$i` ; done > log 2>&1
- (cd forward ; ../mkindex.sh forward)
-
-backward:
- time for i in `cat pluto` ; do touch/touch.opt $$i ; done
- find forward -type f -exec ./invert.pl {} \;
- find backward -type f -exec ./fix_rdf.pl {} \;
- (cd backward ; ../mkindex.sh backward)
-
-compress:
- find forward -name "*.xml" -exec gzip {} \;
- find backward -name "*.xml" -exec gzip {} \;
- (cd forward ; ../mkindex.sh forward)
- (cd backward ; ../mkindex.sh backward)
-
-clean-forward:
- rm -rf forward/*
-
-clean-backward:
- rm -rf backward/*
-
-.PHONY: all forward backward compress clean-forward clean-backward
+++ /dev/null
-backward
-forward
+++ /dev/null
-meta
-meta_ind
-lex.yy.c
-lex.yy_ind.c
+++ /dev/null
-CC = gcc
-
-all: meta meta_ind
-
-meta: lex.yy.o sthandler.o
- gcc lex.yy.o sthandler.o -lpq -o meta
-
-meta_ind: lex.yy_ind.o sthandler.o
- gcc lex.yy_ind.o sthandler.o -lpq -o meta_ind
-
-lex.yy.c: meta_lex.l sthandler.h
- flex meta_lex.l
-
-lex.yy_ind.c: meta_lex_ind.l sthandler.h
- flex -olex.yy_ind.c meta_lex_ind.l
-
-sthandler.o: sthandler.c sthandler.h
-
-lex.yy.o: lex.yy.c sthandler.h
- gcc -c lex.yy.c
-
-lex.yy_ind.o: lex.yy_ind.c sthandler.h
- gcc -c lex.yy_ind.c
-
-clean:
- -rm *.o
- -rm lex.yy.c lex.yy_ind.c
- -rm meta meta_ind
+++ /dev/null
-Note:
- - LetIn e Variabili con corpo: da pensarci (capita solamente una 30ina
- di volte... per ora!) Per il momento ci mettiamo una pezza.
- - Variabili: non consideriamo l'occorrenza di una variabile come una
- vera occorrenza (perche' puo' essere istanziata). In ogni caso c'e'
- l'attributo @params che fornisce questa informazione.
- - META e IMPLICIT non trattati
- - CAST non considerati ==> di default vado in ricorsione sia sul tipo
- che sul corpo
+++ /dev/null
- /******************************************************************/
- /* Copyright (C) 2000, HELM Team */
- /* */
- /* This file is part of HELM, an Hypertextual, Electronic */
- /* Library of Mathematics, developed at the Computer Science */
- /* Department, University of Bologna, Italy. */
- /* */
- /* HELM 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 */
- /* 2 of the License, or (at your option) any later version. */
- /* */
- /* HELM 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 HELM; if not, write to the Free Software */
- /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, */
- /* MA 02111-1307, USA. */
- /* */
- /* For details, see the HELM World-Wide-Web page, */
- /* http://cs.unibo.it/helm/. */
- /******************************************************************/
-
- /***************************************************************/
- /* META_LEXAN */
- /* Automatic Metadata Extractor */
- /* First draft 11/12/2001, by Andrea Asperti */
- /* more bugs added by domenico lordi on mon 12/17/2001 */
- /***************************************************************/
-
- /***************************************************************/
- /* 1. Inclusion of header files. */
- /***************************************************************/
-
-%{
-#include <string.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <postgresql/libpq-fe.h>
-#include "sthandler.h"
-%}
-
- /***************************************************************/
- /* 2. Constants and Variables Definitions */
- /***************************************************************/
-
-%{
-#define NOWHERE 0
-#define CONST 1
-#define MUTIND 2
-#define MUTCONSTRUCT 3
-#define SORT 4
-
-#define INBODY 0
-#define MAINHYP 1
-#define INHYP 2
-#define INCONCL 3
-#define MAINCONCL 4
-#define INTYPE 5
-#define NOTFOUND 6
-
-#define HERE 0
-#define AFTER 1
-
-
-int where = NOWHERE;
-int found = NOTFOUND;
-int position = INBODY;
-int first_child = HERE;
-int skip = 0; // boolean to skip the insertion of a URI
-int no_open_source = 0;
-int spine_depth = 0;
-int depth = 0;
-int tmp_n;
-char sep = '"';
-char *xpointer = "#xpointer(1/";
-char *uri;
-char *tmp;
-%}
-
- /***************************************************************/
- /* 3. Regular definitions. */
- /***************************************************************/
-
-uri [^"]+
-digits [0-9]+
-value [^"]+
-
- /***************************************************************/
- /* 4. Rules. */
- /***************************************************************/
-
-
-%%
-
-"<Variable"[^>]*">"(" "|\n)*"<body" {
- position = INBODY; // Variables have both a body and a type
- }
-
-"</body>"(" "|\n)*"<type" {
- position = INTYPE; // Variables have both a body and a type
- first_child = HERE;
- no_open_source = 0;
- spine_depth = 0;
- depth = 0;
- }
-
-"<decl" |
-"<def" {
- if (position == INTYPE)
- position = MAINHYP;
- else if (position == MAINHYP)
- { position = INHYP;
- no_open_source++;};
- }
-
-"</decl>" |
-"</def>" {
- if (position == INHYP)
- {
- no_open_source--;
- if (no_open_source == 0)
- {
- position = MAINHYP;
- depth++;
- first_child = HERE;
- }
- }
- else if (position == MAINHYP)
- {
- position = INTYPE;
- spine_depth++;
- depth = 0;
- first_child = HERE;
- }
- /* bug? first_child = HERE; */
- }
-
-
-.|\n {
- }
-
-"<LAMBDA" |
-"<MUTCASE" |
-"<FIX" |
-"<COFIX" {
- first_child = AFTER;
- }
-
-"<REL" {
- if (((position == INTYPE) | (position == MAINHYP)) &&
- (first_child == HERE))
- {
- if (position == INTYPE) /* REL on the spine */
- {
- position = INCONCL;
- search("Rel",first_child,position,spine_depth);
- }
- else search("Rel",first_child,position,depth);
- first_child = AFTER;
- }
- }
-
-"<SORT"(" "|\n)+"value=\""{value} {
- if (((position == INTYPE) | (position == MAINHYP)) &&
- (first_child == HERE))
- {
- tmp=(char *)malloc((sizeof('a')*200));
- strcpy(tmp,yytext);
- strsep(&tmp,&sep);
- if (position == INTYPE) /* SORT on the spine */
- {
- position = INCONCL;
- search(tmp,first_child,position,spine_depth);
- }
- else search(tmp,first_child,position,depth);
- first_child = AFTER;
- }
- }
-
-"<VAR" {
- skip = 1;
- first_child = AFTER;
- }
-
-"<CONST" {
- if (position == INTYPE) /* CONST on the spine */
- position = INCONCL;
- where = CONST;
- }
-
-"<MUTIND" {
- if (position == INTYPE) /* MUTIND on the spine */
- position = INCONCL;
- where = MUTIND;
- }
-
-"<MUTCONSTRUCT" {
- if (position == INTYPE) /* MUTCONSTRUCT on the spine */
- position = INCONCL;
- where = MUTCONSTRUCT;
- }
-
-"uri=\""{uri} {
- if (!skip) {
- uri=(char *)malloc((sizeof('a')*200));
- strcpy(uri,yytext);
- strsep(&uri,&sep);
- if (where == CONST)
- {
- if (position == INCONCL)
- search(uri,first_child,position,spine_depth);
- else search(uri,first_child,position,depth);
- where = NOWHERE;
- first_child = AFTER;
- free(uri);
- };
- } else skip = 0;
- }
-
-"noType=\""{digits} {
- if ((where == MUTIND) || (where == MUTCONSTRUCT))
- { strsep(&yytext,&sep);
- tmp=(char *)malloc((sizeof(sep)*(strlen(yytext)+1)));
- strcpy(tmp,yytext);
- tmp_n = atoi(tmp)+1;
- sprintf(tmp,"%d",tmp_n);
- strcat(uri,"#xpointer(1/");
- strcat(uri,tmp);
- };
- if (where == MUTIND)
- {
- strcat(uri,")");
- if (position == INCONCL)
- search(uri,first_child,position,spine_depth);
- else search(uri,first_child,position,depth);
- free(uri);
- free(tmp);
- where = NOWHERE;
- first_child = AFTER;};
- }
-
-"noConstr=\""{digits} {
- if (where == MUTCONSTRUCT)
- { strsep(&yytext,&sep);
- tmp=(char *)malloc((sizeof(sep)*(strlen(yytext)+1)));
- strcpy(tmp,yytext);
- strcat(uri,"/");
- strcat(uri,tmp);
- strcat(uri,")");
- if (position == INCONCL)
- search(uri,first_child,position,spine_depth);
- else search(uri,first_child,position,depth);
- free(uri);
- free(tmp);
- where = NOWHERE;
- first_child = AFTER;};
- }
-
-
-
-%%
-
- /***************************************************************/
- /* 6. Auxiliary functions. */
- /***************************************************************/
-
-main(int argc, char *argv[])
-{
- struct stat buf;
-
- char *pghost,
- *pgport,
- *pgoptions,
- *pgtty;
- char *dbName;
-
- /* FILE *debug; */
-
- PGconn *conn;
- PGresult *res;
-
- if (argc != 4)
- {
- fprintf(stderr, "Usage: meta <object_uri> <body_file> <type_file>\n");
- exit(1);
- }
-
- /*
- * begin, by setting the parameters for a backend connection if the
- * parameters are null, then the system will try to use reasonable
- * defaults by looking up environment variables or, failing that,
- * using hardwired constants
- */
-
- /* make a connection to the database */
- conn = PQconnectdb("user=helm dbname=mowgli_test");
-
- /*
- * check to see that the backend connection was successfully made
- */
- if (PQstatus(conn) == CONNECTION_BAD)
- {
- fprintf(stderr, "Connection to database '%s' failed.\n", dbName);
- fprintf(stderr, "%s", PQerrorMessage(conn));
- exit_nicely(conn);
- }
-
- /* debug = fopen("/tmp/trace.out","w"); */
- /* PQtrace(conn, debug); */
-
- /* initialize the symbol table */
- init_symbol_table();
-
- // We process the body
- if (!stat(argv[2],&buf))
- {
- yyin = fopen(argv[2], "r");
- position = INBODY;
- yylex();
- fclose(yyin);
- }
-
- // We process the type
- yyin = fopen(argv[3], "r");
- position = INTYPE;
- first_child = HERE;
- no_open_source = 0;
- spine_depth = 0;
- depth = 0;
- yylex();
- fclose(yyin);
- print_all(argv[1],conn);
-
- return 0;
-}
-
-
-search(uri,first_child,position,depth)
-char *uri;
-int first_child;
-int position;
-{
- if (position == MAINHYP)
- {
- if (first_child == HERE)
- found = search_bucket(uri,MAINHYP,depth);
- else
- found = search_bucket(uri,INHYP,0);
- }
- else if (position == INCONCL)
- {
- if (first_child == HERE)
- found = search_bucket(uri,MAINCONCL,depth);
- else
- found = search_bucket(uri,INCONCL,0);
- }
-
- else
- found = search_bucket(uri,position,depth);
- /*
- if (found == NOTFOUND)
- fprintf(stderr,"here = %d, pos = %d, uri = %s\n", first_child,position, uri); */
-}
-/*
- (first_child == HERE)
- {
- if (position == MAINHYP)
- found = search_bucket(uri,MAINHYP,depth);
- else if (position == INCONCL)
- found = search_bucket(uri,MAINCONCL,0);
- else if (position == INHYP)
- found = search_bucket(uri,INHYP,0);
- if (found == NOTFOUND)
- printf( "pos = %d, uri = %s\n", MAINCONCL, uri);
- }
- else if ((position == MAINHYP) && (first_child == AFTER))
- found = search_bucket(uri,INHYP,0);
- else found = search_bucket(uri,position,0);
- if (found == NOTFOUND)
- printf( "pos = %d, uri = %s\n", position, uri);
- } */
-
-int yywrap() {
- return 1;
- }
-
-
-
-
+++ /dev/null
- /******************************************************************/
- /* Copyright (C) 2000, HELM Team */
- /* */
- /* This file is part of HELM, an Hypertextual, Electronic */
- /* Library of Mathematics, developed at the Computer Science */
- /* Department, University of Bologna, Italy. */
- /* */
- /* HELM 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 */
- /* 2 of the License, or (at your option) any later version. */
- /* */
- /* HELM 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 HELM; if not, write to the Free Software */
- /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, */
- /* MA 02111-1307, USA. */
- /* */
- /* For details, see the HELM World-Wide-Web page, */
- /* http://cs.unibo.it/helm/. */
- /******************************************************************/
-
- /***************************************************************/
- /* META_LEXAN */
- /* Automatic Metadata Extractor */
- /* First draft 11/12/2001, by Andrea Asperti */
- /* more bugs added by domenico lordi on mon 12/17/2001 */
- /***************************************************************/
-
- /***************************************************************/
- /* 1. Inclusion of header files. */
- /***************************************************************/
-
-%{
-#include <string.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <postgresql/libpq-fe.h>
-#include "sthandler.h"
-%}
-
- /***************************************************************/
- /* 2. Constants and Variables Definitions */
- /***************************************************************/
-
-%{
-#define NOWHERE 0
-#define CONST 1
-#define MUTIND 2
-#define MUTCONSTRUCT 3
-#define SORT 4
-
-#define INBODY 0
-#define MAINHYP 1
-#define INHYP 2
-#define INCONCL 3
-#define MAINCONCL 4
-#define INTYPE 5
-#define NOTFOUND 6
-
-#define HERE 0
-#define AFTER 1
-
-
-int where = NOWHERE;
-int found = NOTFOUND;
-int position = INBODY;
-int first_child = HERE;
-int skip = 0; // boolean to skip the insertion of a URI
-int no_open_source =0;
-int spine_depth = 0;
-int depth = 0;
-int tmp_n;
-int inductive_type = 0;
-int constructor = 0;
-int deep_type = 0;
-char sep = '"';
-char *xpointer = "#xpointer(1/";
-char *uri;
-char *tmp;
-char *source_uri;
-char *source_uri_prefix;
-PGconn *conn;
-%}
-
- /***************************************************************/
- /* 3. Regular definitions. */
- /***************************************************************/
-
-uri [^"]+
-digits [0-9]+
-value [^"]+
-
- /***************************************************************/
- /* 4. Rules. */
- /***************************************************************/
-
-
-%%
-
-"<InductiveType" {
- /* fprintf(stderr,"uno"); */
- init_symbol_table();
- no_open_source = 0;
- depth = 0;
- spine_depth = 0;
- /* fprintf(stderr,"due"); */
- inductive_type++;
- constructor=0;
- position = INTYPE;
- first_child = HERE;
- }
-
-"</arity>" { tmp = (char *)malloc(sizeof('a')*128);
- strcpy(source_uri,source_uri_prefix);
- sprintf(tmp,"#xpointer(1/%d)", inductive_type);
- strcat(source_uri,tmp);
- /* fprintf(stderr,"cinque"); */
- free(tmp);
- print_all(source_uri,conn);
- /* print_file(); */
- }
-
-"<Constructor" { init_symbol_table();
- no_open_source = 0;
- depth = 0;
- spine_depth = 0;
- constructor++;
- position = INTYPE;
- first_child = HERE;
- }
-
-"</Constructor>" { tmp = (char *)malloc(sizeof('a')*128);
- strcpy(source_uri,source_uri_prefix);
- sprintf(tmp,"#xpointer(1/%d/%d)",inductive_type,constructor);
- strcat(source_uri,tmp);
- free(tmp);
- print_all(source_uri,conn);
- /* print_file(); */
- }
-
-"<decl" |
-"<def" {
- if (position == INTYPE)
- position = MAINHYP;
- else if (position == MAINHYP)
- { position = INHYP;
- no_open_source++;};
- }
-
-"</decl>" |
-"</def>" {
- if (position == INHYP)
- {
- no_open_source--;
- if (no_open_source == 0)
- {
- position = MAINHYP;
- depth++;
- first_child = HERE;
- }
- }
- else if (position == MAINHYP)
- {
- position = INTYPE;
- spine_depth++;
- depth = 0;
- first_child = HERE;
- }
- }
-
-
-.|\n {
- }
-
-"<LAMBDA" |
-"<MUTCASE" |
-"<FIX" |
-"<COFIX" {
- first_child = AFTER;
- }
-
-"<REL" {
- if (((position == INTYPE) | (position == MAINHYP)) &&
- (first_child == HERE))
- {
- if (position == INTYPE) /* REL on the spine */
- {
- position = INCONCL;
- search("Rel",first_child,position,spine_depth);
- }
- else search("Rel",first_child,position,depth);
- first_child = AFTER;
- }
- }
-
-"<SORT"(" "|\n)+"value=\""{value} {
- if (((position == INTYPE) | (position == MAINHYP)) &&
- (first_child == HERE))
- {
- tmp=(char *)malloc((sizeof('a')*200));
- strcpy(tmp,yytext);
- strsep(&tmp,&sep);
- if (position == INTYPE) /* SORT on the spine */
- {
- position = INCONCL;
- search(tmp,first_child,position,spine_depth);
- }
- else search(tmp,first_child,position,depth);
- first_child = AFTER;
- }
- }
-
-"<VAR" {
- skip = 1;
- first_child = AFTER;
- }
-
-"<CONST" {
- if (position == INTYPE) /* CONST on the spine */
- position = INCONCL;
- where = CONST;
- }
-
-"<MUTIND" {
- if (position == INTYPE) /* MUTIND on the spine */
- position = INCONCL;
- where = MUTIND;
- }
-
-"<MUTCONSTRUCT" {
- if (position == INTYPE) /* MUTCONSTRUCT on the spine */
- position = INCONCL;
- where = MUTCONSTRUCT;
- }
-
-"uri=\""{uri} {
- if (!skip) {
- uri=(char *)malloc((sizeof('a')*200));
- strcpy(uri,yytext);
- strsep(&uri,&sep);
- if (where == CONST)
- {
- if (position == INCONCL)
- search(uri,first_child,position,spine_depth);
- else search(uri,first_child,position,depth);
- where = NOWHERE;
- first_child = AFTER;
- free(uri);
- };
- } else skip = 0;
- }
-
-"noType=\""{digits} {
- if ((where == MUTIND) || (where == MUTCONSTRUCT))
- { strsep(&yytext,&sep);
- tmp=(char *)malloc((sizeof(sep)*(strlen(yytext)+1)));
- strcpy(tmp,yytext);
- tmp_n = atoi(tmp)+1;
- sprintf(tmp,"%d",tmp_n);
- strcat(uri,"#xpointer(1/");
- strcat(uri,tmp);
- };
- if (where == MUTIND)
- {
- strcat(uri,")");
- if (position == INCONCL)
- search(uri,first_child,position,spine_depth);
- else search(uri,first_child,position,depth);
- free(uri);
- free(tmp);
- where = NOWHERE;
- first_child = AFTER;};
- }
-
-"noConstr=\""{digits} {
- if (where == MUTCONSTRUCT)
- { strsep(&yytext,&sep);
- tmp=(char *)malloc((sizeof(sep)*(strlen(yytext)+1)));
- strcpy(tmp,yytext);
- strcat(uri,"/");
- strcat(uri,tmp);
- strcat(uri,")");
- if (position == INCONCL)
- search(uri,first_child,position,spine_depth);
- else search(uri,first_child,position,depth);
- free(uri);
- free(tmp);
- where = NOWHERE;
- first_child = AFTER;};
- }
-
-
-
-%%
-
- /***************************************************************/
- /* 6. Auxiliary functions. */
- /***************************************************************/
-
-main(int argc, char *argv[])
-{
- struct stat buf;
-
- char *pghost,
- *pgport,
- *pgoptions,
- *pgtty;
- char *dbName;
-
- /* FILE *debug; */
-
- PGresult *res;
-
- if (argc != 3)
- {
- fprintf(stderr, "Usage: meta_ind <object_uri> <inductive_type_file>\n");
- exit(1);
- }
-
- /*
- * begin, by setting the parameters for a backend connection if the
- * parameters are null, then the system will try to use reasonable
- * defaults by looking up environment variables or, failing that,
- * using hardwired constants
- */
-
- /* make a connection to the database */
- conn = PQconnectdb("user=helm dbname=mowgli");
-
- /*
- * check to see that the backend connection was successfully made
- */
- if (PQstatus(conn) == CONNECTION_BAD)
- {
- fprintf(stderr, "Connection to database '%s' failed.\n", dbName);
- fprintf(stderr, "%s", PQerrorMessage(conn));
- exit_nicely(conn);
- }
-
- /* debug = fopen("/tmp/trace.out","w"); */
- /* PQtrace(conn, debug); */
-
- source_uri = malloc((sizeof('a')*2000));
- source_uri_prefix=argv[1];
- /* fprintf(stderr,"qua"); */
- yyin = fopen(argv[2], "r");
- yylex();
-
- return 0;
-}
-
-search(uri,first_child,position,depth)
-char *uri;
-int first_child;
-int position;
-{
- if (position == MAINHYP)
- {
- if (first_child == HERE)
- found = search_bucket(uri,MAINHYP,depth);
- else
- found = search_bucket(uri,INHYP,0);
- }
- else if (position == INCONCL)
- {
- if (first_child == HERE)
- found = search_bucket(uri,MAINCONCL,depth);
- else
- found = search_bucket(uri,INCONCL,0);
- }
-
- else
- found = search_bucket(uri,position,depth);
- if (found == NOTFOUND)
- printf( "pos = %d, uri = %s\n", position, uri);
-}
-
-
-int yywrap() {
- return 1;
- }
-
-
-
-
+++ /dev/null
-/*********************************************************************/
-/* Copyright (C) 2000, HELM Team */
-/* */
-/* This file is part of HELM, an Hypertextual, Electronic */
-/* Library of Mathematics, developed at the Computer Science */
-/* Department, University of Bologna, Italy. */
-/* */
-/* HELM 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 2 */
-/* of the License, or (at your option) any later version. */
-/* */
-/* HELM 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 HELM; if not, write to the Free Software */
-/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, */
-/* MA 02111-1307, USA. */
-/* */
-/* For details, see the HELM World-Wide-Web page, */
-/* http://cs.unibo.it/helm/. */
- /*********************************************************************/
-
-/****************************************************************/
-/* STHANDLER.C */
-/****************************************************************/
-/* This module supplies routines for symbol table handling. */
-/* - init_symbol_table(): it initializes the symbol table */
-/* to void. */
-/* - search_bucket(): it searches the symbol table for the */
-/* bucket containing a given identifier, and */
-/* inserts it if it is not present; */
-/****************************************************************/
-/* First draft 11/12/2001, by Andrea Asperti */
-/****************************************************************/
-
-/****************************************************************/
-/* 1. Inclusion of header files. */
-/****************************************************************/
-
-#include <stdio.h>
-#include <postgresql/libpq-fe.h>
-#include <malloc.h>
-
-/****************************************************************/
-/* 2. Declarations */
-/****************************************************************/
-
-
-#define DICTSIZE 211
-#define HASH1 4
-#define HASH2 0xf0000000
-#define HASH3 24
-#define EOS '\0'
-
-#define INBODY 0
-#define MAINHYP 1
-#define INHYP 2
-#define INCONCL 3
-#define MAINCONCL 4
-#define INTYPE 5
-#define NOTFOUND 6
-
-/****************************************************************/
-/* 3. Types. */
-/****************************************************************/
-
-struct int_list {
- int val;
- struct int_list *next;
- };
-
-struct st_bucket {
- char *id;
- /* identifier */
- int main_depth;
- struct int_list *depths;
- struct st_bucket *next_st_bucket;
- /* next bucket in the list */
- struct st_bucket *all_next;
- /* all buckets in symbol
- table are linked together */
- int pos[5];
-
- };
-
-struct st_bucket *dictionary[DICTSIZE];
- /* pointers to bucket lists */
-
-/****************************************************************/
-/* 4. Local functions. */
-/****************************************************************/
-struct int_list *add(struct int_list *,int);
-
-/****************************************************************/
-/* 5. Definitions of functions to be exported. */
-/****************************************************************/
-
-struct st_bucket *all;
-
- /* The following function initializes the symbol table to NULL */
-void init_symbol_table()
-{
- struct st_bucket *st;
- int i;
-
- /* initialize the dictionary */
- for (i = 0; i < DICTSIZE; i++)
- dictionary[i] = NULL;
- all = NULL;
-}
-
- /* The following function searches the symbol table for an identifier */
- /* and inserts it if it is not present.
- /* The bucket associated with the given identifier */
- /* becomes the first one in its list. */
-
-search_bucket(id, where, depth)
- char *id;
- /* identifier */
- int where;
- int depth;
-{
- int dict_index;
- /* value returned by the */
- /* hash function */
- struct st_bucket
- *prev,
- *curr;
-
- struct st_bucket *st;
-
- /* apply the hash function */
- dict_index = hash_pjw(id);
- /* fprintf(stderr,"%d\n", dict_index); */
-
- /* scan the bucket list indicated by the hash function */
- prev = curr = dictionary[dict_index];
- while ((curr != NULL) && (strcmp(id, curr->id)))
- {
- prev = curr;
- curr = curr->next_st_bucket;
- }
- if (curr == NULL)
- /* the identifier is not in the list */
- {
- allocate_bucket(&st,id,where);
- if (where == MAINCONCL)
- st->main_depth = depth;
- else if (where == MAINHYP)
- st->depths = add(st->depths,depth);
- move_bucket(st,dict_index);
- return NOTFOUND;
- }
- else
- /*
- printf("uno=%s\n", id);
- printf("st=%s\n", curr->id); fflush(stdout) */
-
- /* the identifier is already in the list */
- {
- /* st = curr; */
- curr->pos[where] = 1;
- if (where >= 1)
- curr->pos[INBODY] = 0; /* it will never be set again to 1 */
- if (where == MAINHYP)
- curr->depths=add(curr->depths,depth);
- else if (where == MAINCONCL)
- curr->main_depth = depth;
- if (prev != curr)
- /* the identifier is not in the first position */
- {
- prev->next_st_bucket = curr->next_st_bucket;
- move_bucket(curr,dict_index);
- };
- return where;
- }
-}
-
-print_all(about,conn)
- char *about;
- PGconn *conn;
-{
-
- int i;
- struct st_bucket *curr;
- curr = all;
- while (curr != NULL)
- {
- for (i = 0; i < 5; ++i)
- if ((curr->pos[i]) == 1)
- {
- if (i == MAINHYP)
- print_mainhyp(about,conn,curr->id,curr->depths);
- else if (i == MAINCONCL)
- print_mainconcl(about,conn,curr->id,curr->main_depth);
- else
- print_one(conn,about,curr->id,i);
- }
- curr = curr->all_next;
- }
-}
-
-
-/****************************************************************/
-/* 5. Definitions of functions local to the module. */
-/****************************************************************/
-
-void exit_nicely(PGconn *conn)
-{
- PQfinish(conn);
- exit(1);
-}
-
-struct int_list *add(l,m)
- struct int_list *l;
- int m;
-{
- struct int_list *curr;
- /* scan the list looking for m */
- curr = l;
- while ((curr != NULL) && (m != (curr->val)))
- curr = curr->next;
- if (curr == NULL)
- /* m is not in the list */
- {
- curr = (struct int_list *)malloc(sizeof(struct int_list));
- curr->val = m;
- curr->next = l;
- return curr;
- }
- else
- return l;
-
-}
-
-print_mainhyp(about,conn,uri,l)
- char *about;
- PGconn *conn;
- char *uri;
- struct int_list *l;
-{
- PGresult *res;
- char *command = (char *)malloc((sizeof('a')*200));
- struct int_list *curr;
- curr = l;
- if (!strcmp(uri,"Rel"))
- {
- /* scan the list */
- while (curr != NULL)
- {
- size_t len = strlen(about) + 1;
- char *qabout = malloc (sizeof(char) * len * 2);
- PQescapeString(qabout,about,len);
- sprintf(command,"INSERT INTO refRel values ('%s', 'http://www.cs.unibo.it/helm/schemas/schema-helm#MainHypothesis', %d)",qabout,curr->val);
- /* fprintf(stderr, "%s\n", command); */
- res = PQexec(conn, command);
- if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
- {
- fprintf(stderr, "BEGIN command failed\n");
- PQclear(res);
- exit_nicely(conn);
- }
- curr = curr->next;
- }
- }
- else if ((!strcmp(uri,"Prop")) || (!strcmp(uri,"Type")) ||
- (!strcmp(uri,"Set")))
- {
- /* scan the list */
- while (curr != NULL)
- {
- size_t len = strlen(about) + 1;
- char *qabout = malloc (sizeof(char) * len * 2);
- PQescapeString(qabout,about,len);
- sprintf(command,"INSERT INTO refSort values ('%s', 'http://www.cs.unibo.it/helm/schemas/schema-helm#MainHypothesis', %d, '%s')",qabout,curr->val,uri);
- /* fprintf(stderr, "%s\n", command); */
- res = PQexec(conn, command);
- if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
- {
- fprintf(stderr, "BEGIN command failed\n");
- PQclear(res);
- exit_nicely(conn);
- }
- curr = curr->next;
- }
- }
- else
- {
- /* scan the list */
- while (curr != NULL)
- {
- size_t len = strlen(about) + 1;
- char *qabout = malloc (sizeof(char) * len * 2);
- char *quri;
- PQescapeString(qabout,about,len);
- len = strlen(uri) + 1;
- quri = malloc (sizeof(char) * len * 2);
- PQescapeString(quri,uri,len);
- sprintf(command,"INSERT INTO refObj values ('%s', '%s', 'http://www.cs.unibo.it/helm/schemas/schema-helm#MainHypothesis', %d)",qabout,quri,curr->val);
- /* fprintf(stderr, "%s\n", command); */
- res = PQexec(conn, command);
- if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
- {
- fprintf(stderr, "BEGIN command failed\n");
- PQclear(res);
- exit_nicely(conn);
- }
- curr = curr->next;
- }
- }
-}
-
-print_mainconcl(about,conn,uri,depth)
- char *about;
- PGconn *conn;
- char *uri;
- int depth;
-
-{
- PGresult *res;
- char *command = (char *)malloc((sizeof('a')*200));
- /* fprintf(stderr,"about = %s\n",about); */
- if (!strcmp(uri,"Rel"))
- {
- size_t len = strlen(about) + 1;
- char *qabout = malloc (sizeof(char) * len * 2);
- PQescapeString(qabout,about,len);
- sprintf(command,"INSERT INTO refRel values ('%s', 'http://www.cs.unibo.it/helm/schemas/schema-helm#MainConclusion', %d)",qabout,depth);
- /* fprintf(stderr, "%s\n", command); */
- res = PQexec(conn, command);
- }
- else if ((!strcmp(uri,"Prop")) || (!strcmp(uri,"Type")) ||
- (!strcmp(uri,"Set")))
- {
- size_t len = strlen(about) + 1;
- char *qabout = malloc (sizeof(char) * len * 2);
- PQescapeString(qabout,about,len);
- sprintf(command,"INSERT INTO refSort values ('%s', 'http://www.cs.unibo.it/helm/schemas/schema-helm#MainConclusion', %d, '%s')",qabout,depth,uri);
- /* fprintf(stderr, "%s\n", command); */
- res = PQexec(conn, command);
- }
- else
- {
- size_t len = strlen(about) + 1;
- char *qabout = malloc (sizeof(char) * len * 2);
- char *quri;
- PQescapeString(qabout,about,len);
- len = strlen(uri) + 1;
- quri = malloc (sizeof(char) * len * 2);
- PQescapeString(quri,uri,len);
- sprintf(command,"INSERT INTO refObj values ('%s', '%s','http://www.cs.unibo.it/helm/schemas/schema-helm#MainConclusion', %d)",qabout,quri,depth);
- /* fprintf(stderr, "%s\n", command); */
- res = PQexec(conn, command);
- }
- if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
- {
- fprintf(stderr, "BEGIN command failed\n");
- PQclear(res);
- exit_nicely(conn);
- }
- /* fprintf(stderr,"FINITO\n"); */
-}
-
-// dome: cambiata per usare il modello con position
-print_one(conn,about,uri,pos)
- PGconn *conn;
- char *about,
- *uri;
- int pos;
-{
- PGresult *res;
- char *command = (char *)malloc((sizeof('a')*200));
- char *position = (char *)malloc((sizeof('a')*20));
- size_t len = strlen(about) + 1;
- char *qabout = malloc (sizeof(char) * len * 2);
- char *quri;
- PQescapeString(qabout,about,len);
- len = strlen(uri) + 1;
- quri = malloc (sizeof(char) * len * 2);
- PQescapeString(quri,uri,len);
- if (pos == INBODY)
- position="InBody";
- else if (pos == MAINHYP)
- position="MainHypothesis"; /* This should never happen */
- else if (pos == INHYP)
- position="InHypothesis";
- else if (pos == INCONCL)
- position="InConclusion";
- else if (pos == MAINCONCL)
- position="MainConclusion"; /* This should never happen */
- sprintf(command,"INSERT INTO refObj values ('%s', '%s', 'http://www.cs.unibo.it/helm/schemas/schema-helm#%s')",qabout,quri,position);
- /* fprintf(stderr, "%s\n", command); */
- res = PQexec(conn, command);
- if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
- {
- fprintf(stderr, "BEGIN command failed\n");
- PQclear(res);
- exit_nicely(conn);
- }
-}
-
- /* The following function allocates a bucket for an identifier. */
-allocate_bucket(st, id, where)
- struct st_bucket
- **st;
- /* pointer to the bucket to be */
- /* allocated */
- char *id;
- /* identifier */
- int where;
-{
- int i;
-
- *st = (struct st_bucket *)malloc(sizeof(struct st_bucket));
- (*st)->id = (char *)malloc(sizeof('a')*(strlen(id) + 1));
- strcpy((*st)->id,id);
- (*st)->main_depth = 0;
- (*st)->depths = NULL;
- (*st)->next_st_bucket = NULL;
- (*st)->all_next = all;
- all = *st;
- for (i = 0; i < 5; ++i)
- (*st)->pos[i] = 0;
- (*st)->pos[where] = 1;
-}
-
- /* The following function moves a bucket to the head of the */
- /* list in which it lies. */
-move_bucket(st, dict_index)
- struct st_bucket
- *st;
- /* pointer to the bucket to */
- /* be moved */
- int dict_index;
- /* index corresponding to */
- /* the list in which the */
- /* bucket lies */
-{
- st->next_st_bucket = dictionary[dict_index];
- dictionary[dict_index] = st;
-}
-
- /* The following function implements Weinberger's hash function. */
-int
-hash_pjw(id)
- char *id;
- /* identifier to be hashed */
-{
- unsigned h,
- g;
-
- for (h = 0; *id != EOS; id++)
- {
- h = (h << HASH1) + (*id);
- if (g = h & HASH2)
- h = h ^ (g >> HASH3) ^ g;
- }
- return(h % DICTSIZE);
-}
-
-
-
-
-
-
+++ /dev/null
-/****************************************************************/
-/* STHANDLER.H */
-/****************************************************************/
-
-
-extern void init_symbol_table();
-extern void print_all(char *, PGconn *);
-extern int search_bucket(char *, int, int);
+++ /dev/null
-/*********************************************************************/
-/* Copyright (C) 2000, HELM Team */
-/* */
-/* This file is part of HELM, an Hypertextual, Electronic */
-/* Library of Mathematics, developed at the Computer Science */
-/* Department, University of Bologna, Italy. */
-/* */
-/* HELM 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 2 */
-/* of the License, or (at your option) any later version. */
-/* */
-/* HELM 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 HELM; if not, write to the Free Software */
-/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, */
-/* MA 02111-1307, USA. */
-/* */
-/* For details, see the HELM World-Wide-Web page, */
-/* http://cs.unibo.it/helm/. */
- /*********************************************************************/
-
-/****************************************************************/
-/* STHANDLER.C */
-/****************************************************************/
-/* This module supplies routines for symbol table handling. */
-/* - init_symbol_table(): it initializes the symbol table */
-/* to void. */
-/* - search_bucket(): it searches the symbol table for the */
-/* bucket containing a given identifier, and */
-/* inserts it if it is not present; */
-/****************************************************************/
-/* First draft 11/12/2001, by Andrea Asperti */
-/****************************************************************/
-
-/****************************************************************/
-/* 1. Inclusion of header files. */
-/****************************************************************/
-
-#include <stdio.h>
-#include <malloc.h>
-
-/****************************************************************/
-/* 2. Declarations */
-/****************************************************************/
-
-
-#define DICTSIZE 211
-#define HASH1 4
-#define HASH2 0xf0000000
-#define HASH3 24
-#define EOS '\0'
-
-#define INBODY 0
-#define MAINHYP 1
-#define INHYP 2
-#define INCONCL 3
-#define MAINCONCL 4
-#define INTYPE 5
-#define NOTFOUND 6
-
-/****************************************************************/
-/* 3. Types. */
-/****************************************************************/
-
-struct int_list {
- int val;
- struct int_list *next;
- };
-
-struct st_bucket {
- char *id;
- /* identifier */
- int main_depth;
- struct int_list *depths;
- struct st_bucket *next_st_bucket;
- /* next bucket in the list */
- struct st_bucket *all_next;
- /* all buckets in symbol
- table are linked together */
- int pos[5];
-
- };
-
-struct st_bucket *dictionary[DICTSIZE];
- /* pointers to bucket lists */
-
-/****************************************************************/
-/* 4. Local functions. */
-/****************************************************************/
-struct int_list *add(struct int_list *,int);
-
-/****************************************************************/
-/* 5. Definitions of functions to be exported. */
-/****************************************************************/
-
-struct st_bucket *all;
-
- /* The following function initializes the symbol table to NULL */
-void init_symbol_table()
-{
- struct st_bucket *st;
- int i;
-
- /* initialize the dictionary */
- for (i = 0; i < DICTSIZE; i++)
- dictionary[i] = NULL;
- all = NULL;
-}
-
- /* The following function searches the symbol table for an identifier */
- /* and inserts it if it is not present.
- /* The bucket associated with the given identifier */
- /* becomes the first one in its list. */
-
-search_bucket(id, where, depth)
- char *id;
- /* identifier */
- int where;
- int depth;
-{
- int dict_index;
- /* value returned by the */
- /* hash function */
- struct st_bucket
- *prev,
- *curr;
-
- struct st_bucket *st;
-
- /* apply the hash function */
- dict_index = hash_pjw(id);
- /* fprintf(stderr,"%d\n", dict_index); fflush(stdout); */
-
- /* scan the bucket list indicated by the hash function */
- prev = curr = dictionary[dict_index];
- while ((curr != NULL) && (strcmp(id, curr->id)))
- {
- prev = curr;
- curr = curr->next_st_bucket;
- }
- if (curr == NULL)
- /* the identifier is not in the list */
- {
- allocate_bucket(&st,id,where);
- if (where == MAINCONCL)
- st->main_depth = depth;
- else if (where == MAINHYP)
- st->depths = add(st->depths,depth);
- move_bucket(st,dict_index);
- return NOTFOUND;
- }
- else
- /*
- fprintf(stderr,"uno=%s\n", id);
- fprintf(stderr,"st=%s\n", curr->id); fflush(stdout) */
-
- /* the identifier is already in the list */
- {
- /* st = curr; */
- curr->pos[where] = 1;
- if (where >= 1)
- curr->pos[INBODY] = 0; /* it will never be set again to 1 */
- if (where == MAINHYP)
- curr->depths=add(curr->depths,depth);
- else if (where == MAINCONCL)
- curr->main_depth = depth;
- if (prev != curr)
- /* the identifier is not in the first position */
- {
- prev->next_st_bucket = curr->next_st_bucket;
- move_bucket(curr,
- dict_index);
- };
- return where;
- }
-}
-
-print_all(about,out,outrel,outsort)
- char *about;
- FILE *out,
- *outrel,
- *outsort;
-{
-
- int i;
- struct st_bucket *curr;
- curr = all;
- while (curr != NULL)
- {
- for (i = 0; i < 5; ++i)
- if ((curr->pos[i]) == 1)
- {
- if (i == MAINHYP)
- print_mainhyp(about,out,outrel,outsort,curr->id,curr->depths);
- else if (i == MAINCONCL)
- print_mainconcl(about,out,outrel,outsort,curr->id,curr->main_depth);
- else
- print_one(out,curr->id,i);
- }
- curr = curr->all_next;
- }
-}
-
-
-/****************************************************************/
-/* 5. Definitions of functions local to the module. */
-/****************************************************************/
-
-struct int_list *add(l,m)
- struct int_list *l;
- int m;
-{
- struct int_list *curr;
- /* scan the list looking for m */
- curr = l;
- while ((curr != NULL) && (m != (curr->val)))
- curr = curr->next;
- if (curr == NULL)
- /* m is not in the list */
- {
- curr = (struct int_list *)malloc(sizeof(struct int_list));
- curr->val = m;
- curr->next = l;
- return curr;
- }
- else
- return l;
-
-}
-
-print_mainhyp(about,out,outrel,outsort,uri,l)
- char *about;
- FILE *out,
- *outrel,
- *outsort;
- char *uri;
- struct int_list *l;
-{
- struct int_list *curr;
- curr = l;
- if (!strcmp(uri,"Rel"))
- {
- /* scan the list */
- while (curr != NULL)
- {
- fprintf(outrel,"\t<h:Object rdf:about=\"");
- fprintf(outrel,"%s",about);
- fprintf(outrel,"\">\n");
- fprintf(outrel,"\t\t<h:refRel rdf:parseType=\"Resource\">");
- fprintf(outrel,"\n\t\t\t\t<h:position rdf:resource=\"&hns;MainHypothesis\"/>");
- fprintf(outrel,"\n\t\t\t\t<h:depth>%d</h:depth>",curr->val);
- fprintf(outrel,"\n\t\t</h:refRel>\n");
- fprintf(outrel,"\t</h:Object>\n");
- curr = curr->next;
- }
- }
- else if ((!strcmp(uri,"Prop")) || (!strcmp(uri,"Type")) ||
- (!strcmp(uri,"Set")))
- {
- /* scan the list */
- while (curr != NULL)
- {
- fprintf(outsort,"\t<h:Object rdf:about=\"");
- fprintf(outsort,"%s",about);
- fprintf(outsort,"\">\n");
- fprintf(outsort,"\t\t<h:refSort rdf:parseType=\"Resource\">");
- fprintf(outsort,"\n\t\t\t\t<h:position rdf:resource=\"&hns;MainHypothesis\"/>");
- fprintf(outsort,"\n\t\t\t\t<h:sort rdf:resource=\"&hns;%s\"/>",uri);
- fprintf(outsort,"\n\t\t\t\t<h:depth>%d</h:depth>",curr->val);
- fprintf(outsort,"\n\t\t</h:refSort>\n");
- fprintf(outsort,"\t</h:Object>\n");
- curr = curr->next;
- }
- }
- else
- {
- /* scan the list */
- while (curr != NULL)
- {
- fprintf(out,"\t\t<h:refObj rdf:parseType=\"Resource\">");
- fprintf(out,"\n\t\t\t\t<h:position rdf:resource=\"&hns;MainHypothesis\"/>");
- fprintf(out,"\n\t\t\t\t<h:depth>%d</h:depth>",curr->val);
- fprintf(out,"\n\t\t\t\t<h:occurrence><h:Object rdf:about=\"%s\"/></h:occurrence>",uri);
- fprintf(out,"\n\t\t</h:refObj>\n");
- curr = curr->next;
- }
- }
-}
-
-print_mainconcl(about,out,outrel,outsort,uri,depth)
- char *about;
- FILE *out,
- *outrel,
- *outsort;
- char *uri;
- int depth;
-
-{
- if (!strcmp(uri,"Rel"))
- {
- fprintf(outrel,"\t<h:Object rdf:about=\"");
- fprintf(outrel,"%s",about);
- fprintf(outrel,"\">\n");
- fprintf(outrel,"\t\t<h:refRel rdf:parseType=\"Resource\">");
- fprintf(outrel,"\n\t\t\t\t<h:position rdf:resource=\"&hns;MainConclusion\"/>");
- fprintf(outrel,"\n\t\t\t\t<h:depth>%d</h:depth>",depth);
- fprintf(outrel,"\n\t\t</h:refRel>\n");
- fprintf(outrel,"\t</h:Object>\n");
- }
- else if ((!strcmp(uri,"Prop")) || (!strcmp(uri,"Type")) ||
- (!strcmp(uri,"Set")))
- {
- fprintf(outsort,"\t<h:Object rdf:about=\"");
- fprintf(outsort,"%s",about);
- fprintf(outsort,"\">\n");
- fprintf(outsort,"\t\t<h:refSort rdf:parseType=\"Resource\">");
- fprintf(outsort,"\n\t\t\t\t<h:position rdf:resource=\"&hns;MainConclusion\"/>");
- fprintf(outsort,"\n\t\t\t\t<h:sort rdf:resource=\"&hns;%s\"/>",uri);
- fprintf(outsort,"\n\t\t\t\t<h:depth>%d</h:depth>",depth);
- fprintf(outsort,"\n\t\t</h:refSort>\n");
- fprintf(outsort,"\t</h:Object>\n");
- }
- else
- {
- fprintf(out,"\t\t<h:refObj rdf:parseType=\"Resource\">");
- fprintf(out,"\n\t\t\t\t<h:position rdf:resource=\"&hns;MainConclusion\"/>");
- fprintf(out,"\n\t\t\t\t<h:depth>%d</h:depth>",depth);
- fprintf(out,"\n\t\t\t\t<h:occurrence><h:Object rdf:about=\"%s\"/></h:occurrence>",uri);
- fprintf(out,"\n\t\t</h:refObj>\n");
- }
-}
-
-// dome: cambiata per usare il modello con position
-print_one(out,uri,pos)
- FILE *out;
- char *uri;
- int pos;
-{
- fprintf(out,"\t\t<h:refObj df:parseType=\"Resource\">");
- fprintf(out,"\n\t\t\t\t<h:position rdf:resource=\"&hns;");
- if (pos == INBODY)
- fprintf(out,"InBody");
- else if (pos == MAINHYP)
- fprintf(out,"MainHypothesis");
- else if (pos == INHYP)
- fprintf(out,"InHypothesis");
- else if (pos == INCONCL)
- fprintf(out,"InConclusion");
- else if (pos == MAINCONCL)
- fprintf(out,"MainConclusion");
- fprintf(out,"\"/>\n\t\t\t\t<h:occurrence><h:Object rdf:about=\"%s\"/></h:occurrence>\n\t\t</h:refObj>\n", uri);
-
-}
-
- /* The following function allocates a bucket for an identifier. */
-allocate_bucket(st, id, where)
- struct st_bucket
- **st;
- /* pointer to the bucket to be */
- /* allocated */
- char *id;
- /* identifier */
- int where;
-{
- int i;
-
- *st = (struct st_bucket *)malloc(sizeof(struct st_bucket));
- (*st)->id = (char *)malloc(sizeof('a')*(strlen(id) + 1));
- strcpy((*st)->id,id);
- (*st)->main_depth = 0;
- (*st)->depths = NULL;
- (*st)->next_st_bucket = NULL;
- (*st)->all_next = all;
- all = *st;
- for (i = 0; i < 5; ++i)
- (*st)->pos[i] = 0;
- (*st)->pos[where] = 1;
-}
-
- /* The following function moves a bucket to the head of the */
- /* list in which it lies. */
-move_bucket(st, dict_index)
- struct st_bucket
- *st;
- /* pointer to the bucket to */
- /* be moved */
- int dict_index;
- /* index corresponding to */
- /* the list in which the */
- /* bucket lies */
-{
- st->next_st_bucket = dictionary[dict_index];
- dictionary[dict_index] = st;
-}
-
- /* The following function implements Weinberger's hash function. */
-int
-hash_pjw(id)
- char *id;
- /* identifier to be hashed */
-{
- unsigned h,
- g;
-
- for (h = 0; *id != EOS; id++)
- {
- h = (h << HASH1) + (*id);
- if (g = h & HASH2)
- h = h ^ (g >> HASH3) ^ g;
- }
- return(h % DICTSIZE);
-}
-
-
-
-
-
-
+++ /dev/null
-/****************************************************************/
-/* STHANDLER.H */
-/****************************************************************/
-
-
-extern void init_symbol_table();
-extern void print_all(char *, FILE *, FILE *, FILE *);
-extern int search_bucket(char *, int, int);
+++ /dev/null
-all:
- @echo Available targets:
- @echo " forward, backward, compress, clean-forward, clean-backward"
-
-forward:
- time for i in `cat tipi_induttivi.txt` ; do (cd tmp ; wget -t 1 -O downloaded.xml.gz "http://mowgli.cs.unibo.it:58081/getxml?format=gz&uri=$$i") ; zcat tmp/downloaded.xml.gz > tmp/inductive_type.xml ; METADATA/meta_ind $$i ; rm -f tmp/downloaded.xml.gz tmp/inductive_type.xml; done > log 2>&1
- time for i in `cat costanti_e_variabili.txt` ; do (cd tmp ; wget -t 1 -O downloaded.xml.gz "http://mowgli.cs.unibo.it:58081/getxml?format=gz&uri=$$i" ; wget -t 1 -O downloaded_body.xml.gz "http://mowgli.cs.unibo.it:58081/getxml?format=gz&uri=$$i.body"); zcat tmp/downloaded.xml.gz > tmp/type.xml ; zcat tmp/downloaded_body.xml.gz > tmp/body.xml ; METADATA/meta $$i ; rm -f tmp/downloaded.xml.gz tmp/downloaded_body.xml.gz tmp/type.xml tmp/body.xml ; done > log 2>&1
-
-backward:
- time for i in `cat all_objects.txt` ; do touch/touch.opt $$i ; done
- find forward -type f -exec ./invert.pl {} \;
- find backward -type f -exec ./fix_rdf.pl {} \;
- (cd backward ; ../mkindex.sh backward)
-
-compress:
- find forward -name "*.xml" -exec gzip {} \;
- find backward -name "*.xml" -exec gzip {} \;
- (cd forward ; ../mkindex.sh forward)
- (cd backward ; ../mkindex.sh backward)
-
-clean-forward:
- rm -rf forward_rel.xml forward_sort.xml forward/*
-
-clean-backward:
- rm -rf backward/*
-
-.PHONY: all forward backward compress clean-forward clean-backward
+++ /dev/null
-#!/usr/bin/perl
-
-$filename = $uri = $ARGV[0];
-$outputfile = $filename.".xml";
-$uri =~ s/^backward/cic:/;
-$uri =~ s/(.*),([^,]*),([^,]*)/$1#xpointer(1\/$2\/$3)/;
-$uri =~ s/(.*),([^,]*)/$1#xpointer(1\/$2)/;
-
-print "Now processing file $filename\n";
-
-open(HEADER,">>$outputfile");
-print HEADER <<EOT;
-<?xml version="1.0" encoding="ISO-8859-1"?>
-
-<!DOCTYPE rdf:RDF [
- <!ENTITY rdfns 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
- <!ENTITY hthns 'http://www.cs.unibo.it/helm/schemas/schema-helmth#'>
- <!ENTITY hns 'http://www.cs.unibo.it/helm/schemas/schema-helm#'>
-
- ]>
-<rdf:RDF xml:lang="en" xmlns:rdf="&rdfns;" xmlns:h="&hns;" xmlns:hth="&hthns;">
- <h:Object rdf:about="$uri">
-EOT
-close(HEADER);
-
-$quotedfilename = $filename;
-$quotedfilename =~ s/'/\\'/g;
-$quotedoutputfile = $outputfile;
-$quotedoutputfile =~ s/'/\\'/g;
-system("cat $quotedfilename >> $quotedoutputfile");
-
-open(FOOTER,">>$outputfile");
-print FOOTER <<EOT;
- </h:Object>
-</rdf:RDF>
-EOT
-close(FOOTER);
-
-unlink $filename;
+++ /dev/null
-</rdf:RDF>
+++ /dev/null
-<?xml version="1.0" encoding="ISO-8859-1"?>
-
-<!DOCTYPE rdf:RDF [
- <!ENTITY rdfns 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
- <!ENTITY hthns 'http://www.cs.unibo.it/helm/schemas/schema-helmth#'>
- <!ENTITY hns 'http://www.cs.unibo.it/helm/schemas/schema-helm#'>
-
- ]>
-<rdf:RDF xml:lang="en" xmlns:rdf="&rdfns;" xmlns:h="&hns;" xmlns:hth="&hthns;">
+++ /dev/null
-#!/usr/bin/perl
-
-my $inputfile = $ARGV[0];
-
-print "Now splitting file $inputfile\n";
-open(IN, "<$inputfile") or die "Error opening file $inputfile";
-my $where;
-while(($where = <IN>) && not ($where =~ /<h:Object/)) {}
-chomp($where);
-$where =~ s/^[^"]*"([^"]*)">$/$1/;
-while(($line1 = <IN>) && not ($line1 =~ /<\/h:Object>/)) { # <h:refObj
- $line2 = <IN>; # <h:position rdf:resource="&hns;value"/>
- $position = $line2;
- chomp($position);
- $position =~ s/^[ \t]*[^"]*"&hns;([^"]*)"\/>/$1/;
- if ($position eq 'MainHypothesis' || $position eq 'MainConclusion') {
- $line3 = <IN>; # <h:depth>value</h:depth>
- }
- $line4 = <IN>; # <h:occurrence><h:Object rdf:about="value"/></h:occurrence>
- $line5 = <IN>; # </h:refObj>
- $uri = $line4;
- chomp($uri);
- $uri =~ s/^[ \t]*<h:occurrence><h:Object rdf:about="([^"]*)"\/><\/h:occurrence>$/$1/;
- $who = $uri;
- $who =~ s/^cic:/backward/;
- $who =~ s/#xpointer\(1\/([^\/]*)\/([^\/]*)\)/,$1,$2/;
- $who =~ s/#xpointer\(1\/([^\/]*)\)/,$1/;
- $line4 =~ s/\Q$uri\E/$where/;
-
- open(OUT, ">>$who") or die "Error opening file $who";
- print OUT "\t\t<h:backPointer rdf:parseType="Resource">\n";
- print OUT $line2;
- if ($position eq 'MainHypothesis' || $position eq 'MainConclusion') {
- print OUT $line3;
- }
- print OUT $line4;
- print OUT "\t\t</h:backPointer>\n";
- close(OUT);
-}
-close(IN);
+++ /dev/null
-#!/bin/bash
-
-echo `find . -name "*.xml"` | ../uris_of_filenames.pl $1 > rdf_index.txt
-echo `find . -name "*.xml.gz"` | ../uris_of_filenames.pl $1 -gz >> rdf_index.txt
+++ /dev/null
-*.cmi *.cmo *.cmx touch touch.opt
+++ /dev/null
-REQUIRES = helm-getter helm-cic str
-PREDICATES =
-OCAMLOPTIONS = -package "$(REQUIRES)" -predicates "$(PREDICATES)"
-OCAMLDEP = ocamldep
-OCAMLFIND = ocamlfind
-OCAMLC = $(OCAMLFIND) ocamlc $(OCAMLOPTIONS)
-OCAMLOPT = $(OCAMLFIND) ocamlopt $(OCAMLOPTIONS)
-
-LIBRARIES = $(shell ocamlfind query -recursive -predicates "byte $(PREDICATES)" -format "%d/%a" $(REQUIRES))
-LIBRARIES_OPT = $(shell ocamlfind query -recursive -predicates "native $(PREDICATES)" -format "%d/%a" $(REQUIRES))
-
-all: touch
-opt: touch.opt
-
-DEPOBJS = touch.ml
-
-TOUCHOBJS = touch.cmo
-
-depend:
- $(OCAMLDEP) $(DEPOBJS) > .depend
-
-touch: $(TOUCHOBJS) $(LIBRARIES)
- $(OCAMLC) -linkpkg -o touch $(TOUCHOBJS)
-
-touch.opt: $(TOUCHOBJS:.cmo=.cmx) $(LIBRARIES_OPT)
- $(OCAMLOPT) -linkpkg -o touch.opt $(TOUCHOBJS:.cmo=.cmx)
-
-.SUFFIXES: .ml .mli .cmo .cmi .cmx
-.ml.cmo: $(LIBRARIES)
- $(OCAMLC) -c $<
-.mli.cmi: $(LIBRARIES)
- $(OCAMLC) -c $<
-.ml.cmx: $(LIBRARIES_OPT)
- $(OCAMLOPT) -c $<
-
-clean:
- rm -f *.cm[iox] *.o touch touch.opt
-
-.PHONY: clean
-
-include .depend
+++ /dev/null
-(* Copyright (C) 2000, HELM Team.
- *
- * This file is part of HELM, an Hypertextual, Electronic
- * Library of Mathematics, developed at the Computer Science
- * Department, University of Bologna, Italy.
- *
- * HELM 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 2
- * of the License, or (at your option) any later version.
- *
- * HELM 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 HELM; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA.
- *
- * For details, see the HELM World-Wide-Web page,
- * http://cs.unibo.it/helm/.
- *)
-
-(******************************************************************************)
-(* *)
-(* PROJECT HELM *)
-(* *)
-(* Claudio Sacerdoti Coen <sacerdot@cs.unibo.it> *)
-(* 03/04/2001 *)
-(* *)
-(* Missing description *)
-(* *)
-(******************************************************************************)
-
-let iteri foo =
- let counter = ref 0 in
- List.iter (function e -> incr counter ; foo e !counter)
-;;
-
-let pathname_of_uri uristring =
- "backward" ^
- Str.replace_first (Str.regexp "^cic:") "" uristring
-;;
-
-let make_dirs dirpath =
- ignore (Unix.system ("mkdir -p \"" ^ dirpath ^ "\""))
-;;
-
-let touch_file rdf_string_uri =
- let module U = UriManager in
- let rdf_uri = U.uri_of_string rdf_string_uri in
- make_dirs (pathname_of_uri (U.buri_of_uri rdf_uri)) ;
- ignore (
- Unix.system
- ("touch \"" ^ (pathname_of_uri rdf_string_uri) ^ "\"")
- )
-;;
-
-let get_obj uri =
- let cicfilename = Getter.getxml uri in
- let res = CicParser.obj_of_xml cicfilename None in
- Unix.unlink cicfilename ;
- res
-;;
-
-let touch_obj string_uri =
- let module U = UriManager in
- let module C = Cic in
- function
- Some (C.InductiveDefinition (itys,_,_)) ->
- iteri
- (fun (_,_,_,cons) n ->
- let sn = string_of_int n in
- touch_file
- (string_uri ^ "," ^ sn) ;
- iteri
- (fun (_,_) m ->
- let sm = string_of_int m in
- touch_file
- (string_uri ^ "," ^ sn ^ "," ^ sm)
- ) cons
- ) itys
- | Some _ -> assert false
- | None ->
- touch_file string_uri
-;;
-
-let touch string_uri =
- let module S = String in
- let module U = UriManager in
- print_endline ("Now touching metadata file for " ^ string_uri) ;
- flush stdout ;
- let uri = U.uri_of_string string_uri in
- let obj =
- if S.sub string_uri (S.length string_uri - 3) 3 = "ind" then
- Some (get_obj uri)
- else
- None
- in
- touch_obj string_uri obj
-;;
-
-let _ =
- let usage_msg = "usage: touch[.opt] URI" in
- let uri = ref "" in
- Arg.parse []
- (fun x ->
- if x = "" then
- begin
- prerr_string "No URI provided.\n" ;
- Arg.usage [] usage_msg ;
- exit (-1)
- end
- else if !uri = "" then
- uri := x
- else
- begin
- prerr_string "More than two arguments provided.\n" ;
- Arg.usage [] usage_msg ;
- exit (-1)
- end
- ) usage_msg ;
- if !uri = "" then
- begin
- prerr_string "No URI provided.\n" ;
- Arg.usage [] usage_msg ;
- exit (-1)
- end ;
- touch !uri
-;;
+++ /dev/null
-#!/usr/bin/perl
-
-while(<STDIN>) {
- chomp;
- split / /;
- for (@_) {
- $GZSUFF = "";
- if (/.gz$/)
- { s/.gz$//; $GZSUFF = " gz" if ($ARGV[1] == "-gz"); }
- s/\./helm:rdf:www.cs.unibo.it\/helm\/rdf\/$ARGV[0]\/\/cic:/;
- s/\.xml//;
- print $_.$GZSUFF."\n";
- }
-}
+++ /dev/null
-upload:
- cat create_dc_tables | psql -h mowgli -U helm helm_mowgli
- cat create_dc_indexes | psql -h mowgli -U helm helm_mowgli
- find dc -name "*.xml" -exec ./upload.pl {} \; | psql -h mowgli -U helm helm_mowgli
-
-download:
- cat drop_dc_tables | psql -h mowgli -U helm helm_mowgli
+++ /dev/null
-create index dccreator_index on dccreator (value);
-create index dcdate_index on dcdate (value);
-create index dcdescription_index on dcdescription (value);
-create index dcformat_index on dcformat (value);
-create index dcidentifier_index on dcidentifier (value);
-create index dclanguage_index on dclanguage (value);
-create index dcpublisher_index on dcpublisher (value);
-create index dcqRelationType_index on dcqRelationType (value);
-create index dcrelation_index on dcrelation (value);
-create index dcrights_index on dcrights (value);
-create index dcsource_index on dcsource (value);
-create index dcsubject_index on dcsubject (value);
-create index dctitle_index on dctitle (value);
-create index hthResourceFormat_index on hthResourceFormat (value);
-create index hthcontact_index on hthcontact (value);
-create index hthfirstVersion_index on hthfirstVersion (value);
-create index hthinstitution_index on hthinstitution (value);
-create index hthmodified_index on hthmodified (value);
-
-create index dccreator_rev_index on dccreator (uri);
-create index dcdate_rev_index on dcdate (uri);
-create index dcdescription_rev_index on dcdescription (uri);
-create index dcformat_rev_index on dcformat (uri);
-create index dcidentifier_rev_index on dcidentifier (uri);
-create index dclanguage_rev_index on dclanguage (uri);
-create index dcpublisher_rev_index on dcpublisher (uri);
-create index dcqRelationType_rev_index on dcqRelationType (uri);
-create index dcrelation_rev_index on dcrelation (uri);
-create index dcrights_rev_index on dcrights (uri);
-create index dcsource_rev_index on dcsource (uri);
-create index dcsubject_rev_index on dcsubject (uri);
-create index dctitle_rev_index on dctitle (uri);
-create index hthResourceFormat_rev_index on hthResourceFormat (uri);
-create index hthcontact_rev_index on hthcontact (uri);
-create index hthfirstVersion_rev_index on hthfirstVersion (uri);
-create index hthinstitution_rev_index on hthinstitution (uri);
-create index hthmodified_rev_index on hthmodified (uri);
+++ /dev/null
-create table dccreator (value varchar, uri varchar);
-create table dcdate (value varchar, uri varchar);
-create table dcdescription (value varchar, uri varchar);
-create table dcformat (value varchar, uri varchar);
-create table dcidentifier (value varchar, uri varchar);
-create table dclanguage (value varchar, uri varchar);
-create table dcpublisher (value varchar, uri varchar);
-create table dcqRelationType (value varchar, uri varchar);
-create table dcrelation (value varchar, uri varchar);
-create table dcrights (value varchar, uri varchar);
-create table dcsource (value varchar, uri varchar);
-create table dcsubject (value varchar, uri varchar);
-create table dctitle (value varchar, uri varchar);
-create table hthResourceFormat (value varchar, uri varchar);
-create table hthcontact (value varchar, uri varchar);
-create table hthfirstVersion (value varchar, uri varchar);
-create table hthinstitution (value varchar, uri varchar);
-create table hthmodified (value varchar, uri varchar);
+++ /dev/null
-drop table dccreator;
-drop table dcdate;
-drop table dcdescription;
-drop table dcformat;
-drop table dcidentifier;
-drop table dclanguage;
-drop table dcpublisher;
-drop table dcqRelationType;
-drop table dcrelation;
-drop table dcrights;
-drop table dcsource;
-drop table dcsubject;
-drop table dctitle;
-drop table hthResourceFormat;
-drop table hthcontact;
-drop table hthfirstVersion;
-drop table hthinstitution;
-drop table hthmodified;
+++ /dev/null
-#!/bin/bash
-
-echo `find . -name "*.xml"` | ../uris_of_filenames.pl $1 > rdf_index.txt
-echo `find . -name "*.xml.gz"` | ../uris_of_filenames.pl $1 -gz >> rdf_index.txt
+++ /dev/null
-#!/usr/bin/perl
-
-use XML::Parser;
-
-$p = new XML::Parser(Handlers => {Start => \&handle_start,
- End => \&handle_end,
- Char => \&handle_char});
-$p->parsefile($ARGV[0]);
-
-
-$skipped = 0;
-$open = 0;
-$content = "";
-$uri = "";
-
-sub handle_start
-{
- my ($expat, $element, @attrs) = @_;
- if ($skipped == 1) {
- $uri = $attrs[1];
- $uri =~ s/'/\\'/g;
- }
- if ($skipped < 2) { $skipped++ ; }
- else {
- $open++;
- $content = "";
- }
-}
-
-sub handle_end
-{
- my ($expat,$element) = @_;
- $open--;
- if ($open >= 0) {
- $content =~ s/'/\\'/g;
- $element =~ s/://g; # dc:pippo ==> dcpippo
- print "insert into $element values ('$content','$uri');\n";
- }
-}
-
-sub handle_char
-{
- my ($expat,$char) = @_;
- if ($open >= 1) {
- chomp($char);
- $char =~ s/ +/ /g;
- $char =~ s/^ //g;
- $char =~ s/ $//g;
- $content .= $char;
- }
-}
+++ /dev/null
-#!/usr/bin/perl
-
-while(<STDIN>) {
- chomp;
- split / /;
- for (@_) {
- $GZSUFF = "";
- if (/.gz$/)
- { s/.gz$//; $GZSUFF = " gz" if ($ARGV[1] == "-gz"); }
- s/\./helm:rdf:www.cs.unibo.it\/helm\/rdf\/dc$ARGV[0]\/\/cic:/;
- s/\.xml//;
- print $_.$GZSUFF."\n";
- }
-}
+++ /dev/null
-forward
-backward
-forward_rel.xml
-forward_sort.xml
-txt
-txt.saved
+++ /dev/null
-CWD=/projects/helm/metadata/postgresql_V7_mowgli_new_schema
-
-txt:
- (cd forward && find . -type d -exec mkdir -p $(CWD)/txt/{} \;)
- (cd forward && find . -name "*.xml" -exec xsltproc --param path '"{}"' -o $(CWD)/txt/{}.txt $(CWD)/metainfo.xsl {} \; -exec echo {} \;)
-
-upload:
- ./upload_rel.pl forward_rel.xml | psql -h mowgli -U helm helm_mowgli_new_schema
- ./upload_sort.pl forward_sort.xml | psql -h mowgli -U helm helm_mowgli_new_schema
- (cd txt && find */* -name "*.txt" > index.txt)
- (cd txt && cat index.txt | ../inserisci.pl)
-
-clean:
- rm -rf txt/*
-
-.PHONY: txt
+++ /dev/null
-* da utente postgres:
-
- $ createuser helm # con permessi minimi (i.e. no create altri database,
- # no create altri utenti)
- $ createdb helm
- $ pg_passwd data/passwords
- # settare una password
-
-* da un utente qualsiasi:
-
- $ psql -h mowgli -U helm helm_mowgli_new_schema
-
- create table registry (uri varchar, id int);
- CREATE INDEX registry_index ON registry (uri);
-
- create table objectName (value varchar, uri varchar);
- CREATE INDEX objectName_index ON objectName (value);
- CREATE INDEX objectName_rev_index ON objectName (uri);
-
- create table hrefRel (uri varchar, position varchar, depth int);
- create table hrefSort (uri varchar, position varchar, sort varchar, depth int);
- CREATE INDEX hrefRel_rev_index ON hrefRel (uri);
- CREATE INDEX hrefSort_rev_index ON hrefSort (uri);
-
-* svuotamento:
- drop table tn;
- delete from registry;
-* svuotamento totale:
- come postgres: dropdb helm
+++ /dev/null
-#!/usr/bin/perl
-
-$max = 0;
-open (OUT, "| psql -U helm helm_mowgli_new_schema");
-while (<STDIN>) {
- open (IN,$_);
- $uri1 = <IN>;
- chomp($uri1);
- print "$uri1:\n";
- $uri1 =~ s/'/\\'/g;
- $max++;
- print OUT "create table t$max (prop_id varchar, position varchar, uri varchar, depth int);";
- print OUT "insert into registry values ('$uri1', $max);";
- while (<IN>) {
- chomp;
- ($dir,$context,$uri2,$depth) = split(/\|/);
- print " Inserisco $dir#$context#$uri2#$depth\n";
- $uri2 =~ s/'/\\'/g;
- print OUT "insert into t$max values ('$dir', '$context', '$uri2', $depth);";
- }
- print "\n";
- close IN;
-}
-close OUT;
+++ /dev/null
-#!/usr/bin/perl
-
-open (OUT, "| psql -h mowgli -U helm helm_mowgli_new_schema");
-while (<STDIN>) {
- chomp;
- ($name,$uri) = split(/\|/);
- print " Inserisco $name#$uri\n";
- $name =~ s/'/\\'/g;
- $uri =~ s/'/\\'/g;
- print OUT "insert into objectName values ('$name', '$uri');";
- print "\n";
-}
-close OUT;
+++ /dev/null
-objectName.txt
+++ /dev/null
-upload:
- cat objectName.txt | ../inserisci_names.pl
+++ /dev/null
-<?xml version="1.0"?>
-
-<!--******************************************************************-->
-<!-- XSLT version 0.1 generating metadata content of pointers -->
-<!-- (backward and forward) -->
-<!-- First draft: May 24 2002, Irene Schena -->
-<!--******************************************************************-->
-
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:h="http://www.cs.unibo.it/helm/schemas/schema-helm#"
- xmlns:hth="http://www.cs.unibo.it/helm/schemas/schema-helmth#">
-
-<xsl:output method="text"/>
-
-<xsl:param name="path"/>
-
-<xsl:template match="/">
- <xsl:apply-templates select="*"/>
- <xsl:apply-templates select="document(concat('backward/',$path))/rdf:RDF/h:Object/*"/>
-</xsl:template>
-
-<!-- to skip blanks -->
-<xsl:template match="*">
- <xsl:apply-templates select="*"/>
-</xsl:template>
-
-<xsl:template match="h:Object">
- <xsl:value-of select="@rdf:about"/>
- <xsl:text>
-</xsl:text>
- <xsl:apply-templates select="*"/>
-</xsl:template>
-
-<xsl:template match="h:refObj|h:backPointer">
- <xsl:choose>
- <xsl:when test="name(.)='h:refObj'">
- <xsl:text>F|</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>B|</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:value-of select="h:position/@rdf:resource"/>
- <xsl:text>|</xsl:text>
- <xsl:value-of select="h:occurrence/h:Object/@rdf:about"/>
- <xsl:text>|</xsl:text>
- <xsl:choose>
- <xsl:when test="h:depth">
- <xsl:value-of select="h:depth"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>null</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:text>
-</xsl:text>
-</xsl:template>
-
-</xsl:stylesheet>
+++ /dev/null
-#!/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:depth..
- $depth = $line3;
- chomp($depth);
- $depth =~ s/^[ \t]*<h:depth>([^<]*)<\/h:depth>$/$1/;
- $line4 = <IN>; # </h:refRel
- $line5 = <IN>; # </h:Object>
-
- $line0 =~ s/'/\\'/g;
- $position =~ s/'/\\'/g;
- $depth =~ s/'/\\'/g;
- print "insert into hrefRel values ('$line0', '$position', $depth);\n\n";
-}
-close(IN);
+++ /dev/null
-#!/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);