001package conexp.fx.core.dl.deprecated; 002 003/* 004 * #%L 005 * Concept Explorer FX 006 * %% 007 * Copyright (C) 2010 - 2019 Francesco Kriegel 008 * %% 009 * This program is free software: you can redistribute it and/or modify 010 * it under the terms of the GNU General Public License as 011 * published by the Free Software Foundation, either version 3 of the 012 * License, or (at your option) any later version. 013 * 014 * This program is distributed in the hope that it will be useful, 015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 017 * GNU General Public License for more details. 018 * 019 * You should have received a copy of the GNU General Public 020 * License along with this program. If not, see 021 * <http://www.gnu.org/licenses/gpl-3.0.html>. 022 * #L% 023 */ 024 025@Deprecated 026public class DescriptionGraphBuilder { 027 028// public final static DescriptionGraph fromRDFGraph(final File file) throws RepositoryException, RDFParseException, 029// IOException, MalformedQueryException { 030// final DescriptionGraph graph = new DescriptionGraph(); 031// final Repository repository = new SailRepository(new MemoryStore()); 032// repository.initialize(); 033// final RepositoryConnection connection = repository.getConnection(); 034// connection.add(file, null, RDFFormat.forFileName(file.getName(), RDFFormat.RDFXML)); 035// connection.commit(); 036// connection.prepareQuery(QueryLanguage.SPARQL, ""); 037// 038// connection.close(); 039// return graph; 040// } 041// 042// public final static void testDDT() throws RepositoryException { 043// final DescriptionGraph graph = new DescriptionGraph(); 044// System.out.println("loading data"); 045// TTD_Example.TripleStore.initRepository(); 046// System.out.println("done"); 047// final RepositoryConnection c = TTD_Example.TripleStore.repository.getConnection(); 048// final RepositoryResult<Statement> s = c.getStatements(null, null, null, false); 049// int i = 0; 050// while (s.hasNext()) { 051// final Statement n = s.next(); 052// System.out.println(n); 053// if (n.getPredicate().equals(RDF.TYPE)) 054// graph.nodes.add( 055// graph.df.getOWLNamedIndividual(IRI.create(n.getSubject().stringValue())), 056// graph.df.getOWLClass(IRI.create(n.getObject().stringValue()))); 057// else { 058// final OWLObjectProperty key = graph.df.getOWLObjectProperty(IRI.create(n.getPredicate().stringValue())); 059// if (!graph.edges.containsKey(key)) 060// graph.edges.put(key, new MatrixContext<OWLNamedIndividual, OWLNamedIndividual>(true)); 061// graph.edges.get(key).add( 062// graph.df.getOWLNamedIndividual(IRI.create(n.getSubject().stringValue())), 063// graph.df.getOWLNamedIndividual(IRI.create(n.getObject().stringValue()))); 064// } 065// if (i++ > 1000) 066// break; 067// } 068// s.close(); 069// c.close(); 070// System.out.println(graph.nodes); 071// System.out.println(graph.edges); 072// } 073// 074// public final static Interpretation2 testDDT_() throws RepositoryException { 075// final Interpretation2 in = new Interpretation2(10000, 10000, 10000); 076// System.out.println("interpretation created"); 077// TTD_Example.TripleStore.initRepository(); 078// final RepositoryConnection c = TTD_Example.TripleStore.repository.getConnection(); 079// final RepositoryResult<Statement> s = c.getStatements(null, null, null, false); 080// int i = 0; 081// while (s.hasNext()) { 082// final Statement n = s.next(); 083//// System.out.println(n); 084// if (n.getPredicate().equals(RDF.TYPE)) { 085// in.addIndividual(n.getSubject().stringValue()); 086// in.addConcept(n.getObject().stringValue()); 087// in.addConceptAssertion(n.getSubject().stringValue(), n.getObject().stringValue()); 088// } else { 089// in.addIndividual(n.getSubject().stringValue()); 090// in.addIndividual(n.getObject().stringValue()); 091// in.addRole(n.getPredicate().stringValue()); 092// in.addRoleAssertion(n.getSubject().stringValue(), n.getPredicate().stringValue(), n.getObject().stringValue()); 093// } 094//// if (i++ > 1000) 095//// break; 096// } 097// s.close(); 098// c.close(); 099// return in; 100// } 101// 102// public final static DescriptionGraph test57() { 103// final DescriptionGraph graph = new DescriptionGraph(); 104// final MatrixContext<OWLNamedIndividual, OWLNamedIndividual> cxt = 105// new MatrixContext<OWLNamedIndividual, OWLNamedIndividual>(true); 106// for (String s : new String[] { "Kirk", "Luann", "Milhouse", "Clancy", "Jackie", "Selma" }) { 107// final OWLNamedIndividual i = graph.df.getOWLNamedIndividual(IRI.create(s)); 108// graph.nodes.rowHeads().add(i); 109// cxt.rowHeads().add(i); 110// } 111// for (String s : new String[] { "Male", "Female", "Father", "Mother" }) 112// graph.nodes.colHeads().add(graph.df.getOWLClass(IRI.create(s))); 113// graph.nodes.add(graph.df.getOWLNamedIndividual(IRI.create("Kirk")), graph.df.getOWLClass(IRI.create("Male"))); 114// graph.nodes.add(graph.df.getOWLNamedIndividual(IRI.create("Kirk")), graph.df.getOWLClass(IRI.create("Father"))); 115// graph.nodes.add(graph.df.getOWLNamedIndividual(IRI.create("Clancy")), graph.df.getOWLClass(IRI.create("Male"))); 116// graph.nodes.add(graph.df.getOWLNamedIndividual(IRI.create("Clancy")), graph.df.getOWLClass(IRI.create("Father"))); 117// graph.nodes.add(graph.df.getOWLNamedIndividual(IRI.create("Luann")), graph.df.getOWLClass(IRI.create("Female"))); 118// graph.nodes.add(graph.df.getOWLNamedIndividual(IRI.create("Luann")), graph.df.getOWLClass(IRI.create("Mother"))); 119// graph.nodes.add(graph.df.getOWLNamedIndividual(IRI.create("Jackie")), graph.df.getOWLClass(IRI.create("Female"))); 120// graph.nodes.add(graph.df.getOWLNamedIndividual(IRI.create("Jackie")), graph.df.getOWLClass(IRI.create("Mother"))); 121// graph.nodes.add(graph.df.getOWLNamedIndividual(IRI.create("Selma")), graph.df.getOWLClass(IRI.create("Female"))); 122// graph.nodes.add(graph.df.getOWLNamedIndividual(IRI.create("Milhouse")), graph.df.getOWLClass(IRI.create("Male"))); 123// cxt.add(graph.df.getOWLNamedIndividual(IRI.create("Kirk")), graph.df.getOWLNamedIndividual(IRI.create("Milhouse"))); 124// cxt 125// .add( 126// graph.df.getOWLNamedIndividual(IRI.create("Luann")), 127// graph.df.getOWLNamedIndividual(IRI.create("Milhouse"))); 128// cxt.add(graph.df.getOWLNamedIndividual(IRI.create("Clancy")), graph.df.getOWLNamedIndividual(IRI.create("Selma"))); 129// cxt.add(graph.df.getOWLNamedIndividual(IRI.create("Jackie")), graph.df.getOWLNamedIndividual(IRI.create("Selma"))); 130// graph.edges.put(graph.df.getOWLObjectProperty(IRI.create("child")), cxt); 131// System.out.println(graph.nodes); 132// System.out.println(graph.edges); 133// return graph; 134// } 135// 136// public final static Interpretation2 test57_() { 137// final Interpretation2 in = new Interpretation2(6, 4, 1); 138// for (String s : new String[] { "Kirk", "Luann", "Milhouse", "Clancy", "Jackie", "Selma" }) 139// in.addIndividual(s); 140// for (String s : new String[] { "Male", "Female", "Father", "Mother" }) 141// in.addConcept(s); 142// in.addRole("child"); 143// in.addConceptAssertion("Kirk", "Male"); 144// in.addConceptAssertion("Kirk", "Father"); 145// in.addConceptAssertion("Clancy", "Male"); 146// in.addConceptAssertion("Clancy", "Father"); 147// in.addConceptAssertion("Luann", "Female"); 148// in.addConceptAssertion("Luann", "Mother"); 149// in.addConceptAssertion("Jackie", "Female"); 150// in.addConceptAssertion("Jackie", "Mother"); 151// in.addConceptAssertion("Milhouse", "Male"); 152// in.addConceptAssertion("Selma", "Female"); 153// in.addRoleAssertion("Kirk", "child", "Milhouse"); 154// in.addRoleAssertion("Luann", "child", "Milhouse"); 155// in.addRoleAssertion("Clancy", "child", "Selma"); 156// in.addRoleAssertion("Jackie", "child", "Selma"); 157// return in; 158// } 159// 160// public static void main(String[] args) { 161// final DescriptionGraph graph = test57(); 162// final MatrixContext<OWLNamedIndividual, OWLClassExpression> logicalContext = graph.toLogicalContext(40); 163// logicalContext.colHeads().forEach(new Consumer<OWLClassExpression>() { 164// 165// @Override 166// public void accept(OWLClassExpression t) { 167// System.out.println(t); 168// } 169// }); 170// System.out.println(logicalContext); 171// 172// final Interpretation2 in = test57_(); 173// final MatrixContext<OWLNamedIndividual, OWLClassExpression> lcxt = in.toLogicalContext(2, DescriptionLogic.EL); 174// lcxt.colHeads().forEach(new Consumer<OWLClassExpression>() { 175// 176// @Override 177// public void accept(OWLClassExpression t) { 178// System.out.println(t); 179// } 180// }); 181// System.out.println(lcxt); 182// 183// final Result<OWLNamedIndividual, OWLClassExpression> base = NextClosures6.compute(lcxt, true); 184// for (Entry<?, ?> e : base.implications.entrySet()) 185// System.out.println(e.getKey() + " ==> " + e.getValue()); 186// 187// try { 188// final Interpretation2 inDDT = testDDT_(); 189// System.out.println("creating logical scaling"); 190// final MatrixContext<OWLNamedIndividual, OWLClassExpression> lcxt2 = 191// inDDT.toLogicalContext(0, DescriptionLogic.EL); 192// System.out.println("done"); 193// System.out.println(lcxt2); 194// } catch (RepositoryException e1) { 195// // TODO Auto-generated catch block 196// e1.printStackTrace(); 197// } 198// 199//// try { 200//// testDDT(); 201//// } catch (RepositoryException e) { 202//// // TODO Auto-generated catch block 203//// e.printStackTrace(); 204//// } 205// } 206}