Package org.wymiwyg.rdf.graphs

Examples of org.wymiwyg.rdf.graphs.Graph


  }
 
  public void testFile9() {
    JenaParameters.disableBNodeUIDGeneration = true;
    for (int i = 0; i < 10; i++) {
      Graph g = getGraphFromResource("test9.rdf");
      Graph gLeanified = makeLean(g);
      Graph doubleLeanifiedGraph = makeLean(gLeanified);
      boolean equals = gLeanified.equals(doubleLeanifiedGraph);
      assertTrue(equals);
   
  }
View Full Code Here


    Resource a = model.createResource();
    Resource b = model.createResource("http://test");
    //modelWithStatements("_:a rdf:rest http://test; http://test rdf:rest _:a");
    model.add(a, RDF.rest, b);
    model.add(b, RDF.rest, a);
    Graph g = JenaUtil.getGraphFromModel(model, true);
    Graph gLeanified = makeLean(g);
    Graph doubleLeanifiedGraph = makeLean(gLeanified);
    boolean equals = gLeanified.equals(doubleLeanifiedGraph);
    assertTrue(equals);
  }
View Full Code Here

  /**
   * @param args
   */
  public static void main(String[] args) {
    Model randomModel = null;
    Graph randomGraph;
    try {
    for (int i = 0; i < 50000; i++) {
      randomModel = ModelCreationUtil.createRandomModel((int) (Math.random()*1000));
      randomGraph = JenaUtil.getGraphFromModel(randomModel, true);
      Graph leanifiedGraph = MoleculeBasedLeanifier.getLeanVersionOf(randomGraph);
      Graph doubleLeanifiedGraph = MoleculeBasedLeanifier.getLeanVersionOf(leanifiedGraph);
      boolean equals = leanifiedGraph.equals(doubleLeanifiedGraph);
      if (!equals) {
        randomModel.write(System.out);
        return;
      }
View Full Code Here

      }
    });
    for (int i = 0; i < files.length; i++) {
      File leanFile = files[i];
      Model leanModel = ModelFactory.createDefaultModel();
      Graph leanGraph = JenaUtil.getGraphFromModel(leanModel, ontology);
      try {
        leanModel.read(leanFile.toURL().toString(), "N3");
      } catch (MalformedURLException e) {
        throw new RuntimeException(e);
      }
      Model leanModelOrig = ModelFactory.createDefaultModel();
      Graph leanGraphOrig = JenaUtil.getGraphFromModel(leanModelOrig,
          ontology);
      try {
        leanModelOrig.read(leanFile.toURL().toString(), "N3");
      } catch (MalformedURLException e) {
        throw new RuntimeException(e);
      }
      leanGraph = makeLean(leanGraph);
      // leanModel.write(System.out, "N3");
      /*
       * if (!leanGraphOrig.equals(leanGraph)) { Map mapping =
       * SubGraphMatcher.getValidMapping(leanGraph, leanGraphOrig);
       * leanGraphOrig.removeAll(org.wymiwyg.rdf.graphs.matcher.GraphMatcher.applyMapping(leanGraph,mapping));
       * JenaUtil.getModelFromGraph(leanGraphOrig).write(System.out,
       * "N3"); }
       */
      // System.out.println("orig:");
      // JenaUtil.getModelFromGraph(leanGraphOrig).write(System.out);
      // System.out.println();
      // System.out.println("lean:");
      // JenaUtil.getModelFromGraph(leanGraph).write(System.out);
      assertTrue("checking" + leanFile + " remains unmodified",
          leanGraphOrig.equals(leanGraph));
    }

  }
View Full Code Here

      try {
        leanifiedModel.read(leanifiedFile.toURL().toString(), "N3");
      } catch (MalformedURLException e) {
        throw new RuntimeException(e);
      }
      Graph leanifiedGraph = JenaUtil.getGraphFromModel(leanifiedModel,
          ontology);
      Model unleanifiedModel = ModelFactory.createDefaultModel();
      try {
        unleanifiedModel.read(unleanifiedFile.toURL().toString(), "N3");
      } catch (MalformedURLException e) {
        throw new RuntimeException(e);
      }
      Graph unleanifiedGraph = JenaUtil.getGraphFromModel(
          unleanifiedModel, ontology);
      unleanifiedGraph = makeLean(unleanifiedGraph);
      assertTrue("comparing leanified model " + unleanifiedFile
          + " with model" + leanifiedFile, unleanifiedGraph
          .equals(leanifiedGraph));
    }

  }
View Full Code Here

  @Test
  public void testNamedUnnamed() {
    Model model = ModelFactory.createDefaultModel();
    model.add(model.createResource("http://foo"), RDFS.seeAlso, model
        .createResource("http://bar"));
    Graph g1 = JenaUtil.getGraphFromModel(model, false);
    g1.size(); // needed to actually copymodel into graph.
    model.add(model.createResource(), RDFS.seeAlso, model.createResource());
    Graph g2 = JenaUtil.getGraphFromModel(model, false);
    Graph g = makeLean(g2);
    assertEquals("remove unnamed resources obsole by named ones", g, g1);
  }
View Full Code Here

 
  @Test
  public void testFile3() {
    JenaParameters.disableBNodeUIDGeneration = true;
    for (int i = 0; i < 1; i++) {
      Graph g = getGraphFromResource("test3-m1.rdf");
      Graph gLean = getGraphFromResource("test3-m1-lean.rdf");
      Graph gLeanified = makeLean(g);
      // JenaUtil.getModelFromGraph(gLeanified).write(System.out, "N3");
      assertEquals(gLeanified, gLean);
    }
  }
View Full Code Here

  @Test
  public void testFile4() {
    JenaParameters.disableBNodeUIDGeneration = true;
    for (int i = 0; i < 1; i++) {
      Graph g = getGraphFromResource("test4.rdf");
      Graph gLean = makeLean(g);
      log.debug("made lean");
      Graph gLeanified = makeLean(gLean);
      log.debug("made lean again");
      assertEquals(gLeanified, gLean);
    }
  }
View Full Code Here

  @Test
  public void testFile5() {
    JenaParameters.disableBNodeUIDGeneration = true;
    for (int i = 0; i < 1; i++) {
      Graph g = getGraphFromResource("test5.rdf");
      Graph gLeanified = makeLean(g);
      Graph doubleLeanifiedGraph = makeLean(gLeanified);
      boolean equals = gLeanified.equals(doubleLeanifiedGraph);
      assertTrue(equals);
    }
  }
View Full Code Here

  @Test
  public void testFile8() {
    JenaParameters.disableBNodeUIDGeneration = true;
    for (int i = 0; i < 10; i++) {
      log.debug("round " + i);
      Graph g = getGraphFromResource("test8.rdf");
      Graph gLeanified = makeLean(g);
      Graph doubleLeanifiedGraph = makeLean(gLeanified);
      boolean equals = gLeanified.equals(doubleLeanifiedGraph);
      assertTrue(equals);
    }
  }
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.