Package org.wymiwyg.rdf.graphs

Examples of org.wymiwyg.rdf.graphs.Graph


      }
      previousResource.addProperty(FOAF.mbox, model
          .createResource("mailto:foo"));
    }
    // model.write(System.out);
    Graph graph = JenaUtil.getGraphFromModel(model, true);
    ReferenceGroundedDecomposition dec = new ReferenceGroundedDecompositionImpl(
        graph);
    Set<FunctionallyGroundedNode> functionallyGroundedNodes = dec
        .getFunctionallyGroundedNodes();
    // System.out.println(functionallyGroundedNodes.size());
View Full Code Here


  public void fileTest4() {
    for (int i = 0; i < 1; i++) {
      Model origM = ModelFactory.createDefaultModel();
      origM.read(getClass().getResource("test4.rdf").toString());

      Graph graph = new AnonymizedGraph(JenaUtil.getGraphFromModel(origM,
          true));
      ReferenceGroundedDecomposition ref = new ReferenceGroundedDecompositionImpl(
          graph);
      Set<FunctionallyGroundedNode> fgNodes = ref
          .getFunctionallyGroundedNodes();
      //Map<Object, FunctionallyGroundedNode> map = map(fgNodes);
      boolean firtsRound = true;
      Graph lastReconstructedGraph = null;
      for (int j = 0; j < 10; j++) {
        Map<Object, FunctionallyGroundedNode> map = map(fgNodes);
        Map<Object, FunctionallyGroundedNode> mergedMap = FgNodeMerger.mergeFgNodes(map);
        final Set<FunctionallyGroundedNode> mergedFGnodes = new HashSet<FunctionallyGroundedNode>(mergedMap.values());
        if (!firtsRound) {
          assertEquals(fgNodes, mergedFGnodes);
        }
        fgNodes = mergedFGnodes;
        ReferenceGroundedDecomposition referenceGroundedDecomposition = new ReferenceGroundedDecomposition() {

          public Set<MaximumContextualMolecule> getContextualMolecules() {
            return new HashSet<MaximumContextualMolecule>();
          }

          public Set<FunctionallyGroundedNode> getFunctionallyGroundedNodes() {
            return new HashSet<FunctionallyGroundedNode>(new ArrayList<FunctionallyGroundedNode>(mergedFGnodes));
          }

          public Set<TerminalMolecule> getTerminalMolecules() {
            return new HashSet<TerminalMolecule>();
          }
         
        };
        Graph reconstructedGraph = ReferenceGroundedUtil.reconstructGraph(referenceGroundedDecomposition);
        Graph reconstructedGraph2 = ReferenceGroundedUtil.reconstructGraph(referenceGroundedDecomposition);
        assertEquals(reconstructedGraph, reconstructedGraph2);
        reconstructedGraph = new DeAnonymizedGraph(reconstructedGraph);
        assertEquals(reconstructedGraph, new DeAnonymizedGraph(reconstructedGraph2));
        if (!firtsRound) {
          assertEquals(lastReconstructedGraph, reconstructedGraph);
View Full Code Here

        previousResource = resource;
      }
      previousResource.addProperty(FOAF.mbox, model
          .createResource("mailto:foo"));
    }
    Graph graph = JenaUtil.getGraphFromModel(model, true);
    ReferenceGroundedDecomposition dec = new ReferenceGroundedDecompositionImpl(
        new AnonymizedGraph(graph));
    /*System.out.println(dec.getContextualMolecules().size() + " - "
        + dec.getFunctionallyGroundedNodes().size() + " - "
        + dec.getTerminalMolecules().size());*/
 
View Full Code Here

        .isIsomorphicWith(m2reconstructed));
  }

  public void testDecomposition() {
    Model firstModel = null;
    Graph firstGraph = null;
    for (int i = 0; i < 3; i++) {
      Model m = ModelFactory.createDefaultModel();
      /*
       * m.read(getClass().getResource("test4-2.nt").toString(),
       * "N-TRIPLE");
       */
      m.read(getClass().getResource("test-decomposition.nt").toString(),
          "N-TRIPLE");
      m = LeanDiffPatch.leanify(m);
      if (firstModel == null) {
        firstModel = m;
      } else {
        if (m.isIsomorphicWith(firstModel)) {
          System.out.println("same again");
        } else {
          System.out.println("different");
        }
      }
      Graph g = JenaUtil.getGraphFromModel(m, true);
      if (firstGraph == null) {
        firstGraph = g;
      } else {
        if (g.equals(firstGraph)) {
          System.out.println("same again");
        } else {
          System.out.println("different graph");
        }
      }
      ReferenceGroundedDecomposition dec = new ReferenceGroundedDecompositionImpl(
          g);
      Graph gRec = ReferenceGroundedUtil.reconstructGraph(dec);
      assertTrue("same opinion", g.equals(gRec) == JenaUtil
          .getModelFromGraph(g).isIsomorphicWith(
              JenaUtil.getModelFromGraph(gRec)));
      /*
       * if (!g.equals(gRec)) { ReferenceGroundedDecomposition dec2 = new
View Full Code Here

public class UtilTest extends TestCase {

  public void testConversion() throws FileNotFoundException {
    Model orig = ModelFactory.createDefaultModel();
    orig.read(getClass().getResource("OWLManifest.rdf").toString());
    Graph graph = JenaUtil.getGraphFromModel(orig, false);
    Model convertedBack = JenaUtil.getModelFromGraph(graph);
    Graph graph1 = JenaUtil.getGraphFromModel(convertedBack, false);
    graph1.size();
    assertTrue("Converting back and forward (testing on graph)",
        GraphMatcher.getValidMapping(graph, graph1) != null);
    // fails because of literal-identity bug
    // assertTrue("Converting back and forward",
    // orig.isIsomorphicWith(convertedBack));
View Full Code Here

  public static MoleculeDiff deserializeDiff(File file) throws IOException {
    return new MoleculeDiffDeserialized(file);
  }
 
  public static Model leanify(Model m) {
    Graph source = JenaUtil.getGraphFromModel(m, ontology,
        useDefaultOntology);
    Graph result = MoleculeBasedLeanifier.getLeanVersionOf(source);
    return JenaUtil.getModelFromGraph(result);
  }
View Full Code Here

   */
  private void assertIsomorphic(String message, Model model1, Model model2) {
    long startTime = System.currentTimeMillis();
    assertTrue("Jena isomorphism", model1.isIsomorphicWith(model2));
    //System.out.println(message+" took with jena "+(System.currentTimeMillis()-startTime));
    Graph g1 = new JenaModelGraph(model1, false);
    Graph g2 = new JenaModelGraph(model2, false);
    startTime = System.currentTimeMillis();
    assertNotNull(message, GraphMatcher.getValidMapping(g1, g2));
    //System.out.println(message+" took "+(System.currentTimeMillis()-startTime));
   
  }
View Full Code Here

 
  private void assertNotIsomorphic(String message, Model model1, Model model2) {
    long startTime = System.currentTimeMillis();
    assertFalse("Jena isomorphism", model1.isIsomorphicWith(model2));
    System.out.println(message+" took with jena "+(System.currentTimeMillis()-startTime));
    Graph g1 = new JenaModelGraph(model1, false);
    Graph g2 = new JenaModelGraph(model2, false);
    startTime = System.currentTimeMillis();
    assertNull(message, GraphMatcher.getValidMapping(g1, g2));
    System.out.println(message+" took "+(System.currentTimeMillis()-startTime));
   
  }
View Full Code Here

   */
  public void testDoubleIFP() {
    Model origM = ModelFactory.createDefaultModel();
    origM.read(getClass().getResource("double-ifp.n3.noauto").toString(),
        "N3");
    Graph orgigG = JenaUtil.getGraphFromModel(origM, ontology);
    Model leanM = ModelFactory.createDefaultModel();
    leanM.read(getClass().getResource("double-ifp-leanified.n3.noauto")
        .toString(), "N3");
    //leanM.write(System.out);
    Graph leanG = JenaUtil.getGraphFromModel(leanM, ontology);
    Graph leanifiedG = makeLean(orgigG);
    //JenaUtil.getModelFromGraph(leanifiedG).write(System.out);
    assertEquals(leanG, leanifiedG);
  }
View Full Code Here

  public void testNamedUnnamedIFP() {
    Model origM = ModelFactory.createDefaultModel();
    origM.read(
        getClass().getResource("named-unnamed.n3.noauto").toString(),
        "N3");
    Graph orgigG = JenaUtil.getGraphFromModel(origM, ontology);
    Model leanM = ModelFactory.createDefaultModel();
    leanM.read(getClass().getResource("named-unnamed-leanified.n3.noauto")
        .toString(), "N3");
    //leanM.write(System.out);
    Graph leanG = JenaUtil.getGraphFromModel(leanM, ontology);
    Graph leanifiedG = makeLean(orgigG);
    //JenaUtil.getModelFromGraph(leanifiedG).write(System.out);
    assertEquals(leanG, leanifiedG);
  }
View Full Code Here

TOP

Related Classes of org.wymiwyg.rdf.graphs.Graph

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.