Transcript Document
Una piattaforma inferenziale per il Web Semantico: Jena2 Roma, 2006 Web Semantico How to deploy a simple document reconciliation engine with Jena2 M. Missikoff – F. Taglino LEKS, IASI-CNR Order Processing Buyer Process according to AIDIMA Supplier Process according to UBL Sending RFQ RFQ Evaluating Quotation Quot. Issuing PO Receiving Goods Paying Invoice BUYER Processing RFQ Processing PO Purchase Order OrdConf Invoice Fulfilling PO Delivering Goods Invoicing SUPPLIER2 The steps 4 the deployment of a reasoner Preliminary analysis of the (paper) documents to identify the conflicts Create the RDFS files with the formal description of the two documents Identify the conflicting elements in the RDFS files Create the reconciliation rules for each identified conflict Configure the inference engine by register the namespaces used in the rdf(s) files register the new functors specify the reasoning mode load the Reconciliation Rules Acquire (create) the instance RDF document to be processed Launch the reasoner, with the RDF doc instance in input 3 Preliminary analysis of the two documents A sketchy Purchase Order inspired by the AIDIMA format OrderNum 5796 Date: 11-08-05 Seller Info Product Code Buyer Info PERMASA Group Pedro Texeira, 8 28020 – Madrid Ph. 913301003 Fax. 913301005 Email: [email protected] Tax number: G12345678 Contact: John Smith GREBECO – Calle Sol, 23 18003 – Granada (Spain) Ph. 958203734 Fax. 558282885 Email: [email protected] Description Quantity ProdUnitCost(€) A sketchy Purchase Order inspired by the UBL standard GREBECO – Calle Sol, 23 18003 – Granada (Spain) Ph. 958203734 Fax. 558282885 Email: [email protected] Buyer Party PERMASA Group Pedro Texeira, 8 28020 – Madrid Ph. 913301003 Fax. 913301005 Email: [email protected] Catalogue Indicator Description Qty BuyerOrderNum:5796 IssueDate: 11-08-2005 TaxID: G12345678 Contact: John Smith Item Price(€) Line Price(€) ON229 Wardrobe 49*99 2 78.00 ON229 Wardrobe 49*99 2 OP328 Sheft unit panel 60*175 1 59.00 OP328 Sheft unit panel 60*175 1 59.00 59.00 OP481 Rear panel 2 20.00 OP481 Rear panel 2 20.00 40.00 OP873 Bunk bed ladder 1 21.00 OP873 Bunk bed ladder 1 21.00 21.00 OP874 Upper bed for a youth bedroom 1 65.00 OP874 Upper bed for a youth bedroom 1 65.00 65.00 Total(€) 341.00 78.00 156.00 TotalAmount (€) 341.00 4 Create the RDFS files with the formal description of the two documents AIDIMA <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" > <rdf:Description rdf:ID="Order"> <rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/> </rdf:Description> <rdf:Description rdf:ID=“orderHeader"> <rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/> </rdf:Description> <rdf:Description rdf:ID="has_orderHeader"> <rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Property"/> <rdfs:domain rdf:resource="#Order"/> <rdfs:range rdf:resource="#orderHeader"/> </rdf:Description> … UBL <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" > <rdf:Description rdf:about="#Order"> <rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/> </rdf:Description> <rdf:Description rdf:about="#has_BuyerParty"> <rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Property"/> <rdfs:domain rdf:resource="#Order"/> <rdfs:range rdf:resource="#BuyerParty"/> </rdf:Description> … 5 Identify the RDFS conflicting elements AIDIMA … orgName supplier info order order header header Order order order buyer buyer info info … org org info info name name address details … Contact Contact Party Telephone … … description UBL Buyer Buyer Party buyerOrderNum productCode product record … … LastName LastName contact contact person person orderNumber products info Attribute FirstName FirstName Granularity … Structure Organiz andCatalogue Naming Indicator quantity … <rdf:Description rdf:ID="Order"> <rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/> </rdf:Description> … <rdf:Description rdf:ID=“OrderHeader"> <rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/> </rdf:Description> <rdf:Description rdf:ID="#has_orderNumber"> <rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Property"/> <rdfs:domain rdf:resource="#OrderHeader"/> <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/> </rdf:Description> Order Address … Item LineItem OrderLine … Quantity <rdf:Description rdf:ID="Order"> <rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class"/> </rdf:Description> <rdf:Description rdf:ID="#has_buyerOrderNum"> <rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Property"/> <rdfs:domain rdf:resource="#Order"/> <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/> </rdf:Description> 6 Create the reconciliation rules [R1: ] … (?x1 (?x1 (?x2 (?x2 -> (?x1 (?x1 rdf:type AIDIMA:Order) AIDIMA:has_orderHeader ?x2) rdf:type AIDIMA:orderHeader) AIDIMA:has_orderNumber ?x3) rdf:type UBL:Order) UBL:has_buyerOrderNum ?x3) The rule for reconciliating the order number 7 Configure the inference engine to obtain a specific reasoner Registrare i propri namespace … // Register the namespace used in the rdf(s) files String aidimaURI = "http://www.aidima.es/#"; PrintUtil.registerPrefix(“aidima", aidimaURI); String ublURI = "http://www.ubl.com/#"; PrintUtil.registerPrefix(“ubl", ublURI); utilizzati nei file rdf(s) // Register the functors BuiltinRegistry.theRegistry.register( new Split() ); Registrare i nuovi funtori // Create an (RDF) specification of a forward reasoner with Specificare la modalità di reasoning // AIDIMA2UBL rules. Model m = ModelFactory.createDefaultModel(); Resource configuration = m.createResource(); configuration.addProperty(ReasonerVocabulary.PROPruleMode, “forward"); configuration.addProperty(ReasonerVocabulary.PROPruleSet, “AIDIMA2UBL.rules"); … Specificare il file delle regole 8 Acquire (create) the instance RDF document to be processed <?xml version="1.0"?> <!DOCTYPE rdf:RDF [ <!ENTITY rdf 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'> <!ENTITY AIDIMA 'http://aidima.es/AIDIMA#'> <!ENTITY rdfs 'http://www.w3.org/2000/01/rdf-schema#'> ]> <rdf:RDF xmlns:rdf="&rdf;" xmlns:AIDIMA="&AIDIMA;" xmlns:rdfs="&rdfs;" xml:base="&AIDIMA;"> <AIDIMA:Order rdf:about="&AIDIMA;AIDIMA_Instance_0“ <AIDIMA:has_orderHeader rdf:resource="&AIDIMA;AIDIMA_Instance_100"/> … </AIDIMA:Order> <AIDIMA:orderHeader rdf:about="&AIDIMA;AIDIMA_Instance_100"> <AIDIMA:has_orderNumber>OP874</AIDIMA:has_orderNumber> … </AIDIMA:orderHeader> … 9 Launch the reasoner, with the RDF doc instance in input … // Launch the reasoner Model aidimaData = ModelLoader.loadModel("file:aidima.rdf"); InfModel infmodel = ModelFactory.createInfModel(reasoner, aidimaData); // Get the Results Model deductionsModel = infmodel.getDeductionsModel(); StmtIterator i = deductionsModel.listStatements(); while (i.hasNext()) {System.out.println(" - " + PrintUtil.print(i.nextStatement()));} … 10 Implementing and using a reasoner (the Java code) // Register a namespace used in the rdf(s) files Registrare i propri namespace String aidimaURI = "http://www.aidima.es/#"; utilizzati nei file rdf(s) PrintUtil.registerPrefix(“aidima", aidimaURI); String ublURI = "http://www.ubl.com/#"; PrintUtil.registerPrefix(“ubl", ublURI); // Register the functors Registrare i funtori BuiltinRegistry.theRegistry.register( new Split() ); // Create an (RDF) specification of a forward reasoner with Modificare il nome del file // AIDIMA2UBL rules. Model m = ModelFactory.createDefaultModel(); per utilizzare le proprie Resource configuration = m.createResource(); regole configuration.addProperty(ReasonerVocabulary.PROPruleMode, “forward"); configuration.addProperty(ReasonerVocabulary.PROPruleSet, “AIDIMA2UBL.rules"); // Create an instance of such a reasoner Reasoner reasoner = GenericRuleReasonerFactory.theInstance().create(configuration); // Launch the reasoner Modificare il nome del file Model aidimaData = ModelLoader.loadModel("file:aidima.rdf"); per utilizzare i propri dati InfModel infmodel = ModelFactory.createInfModel(reasoner, aidimaData); // Get the Results Model deductionsModel = infmodel.getDeductionsModel(); StmtIterator i = deductionsModel.listStatements(); 11 while (i.hasNext()) {System.out.println(" - " + PrintUtil.print(i.nextStatement()));}