Package org.wymiwyg.rdf.graphs

Examples of org.wymiwyg.rdf.graphs.Graph


   * @param g2
   */
  private void createMimimumFailingG2( Graph g2) {
    SubGraphCreator subGraphCreator = new SubGraphCreator(g2);
    boolean lastOneFailed; //note that we are looking for failing graphs
    Graph lastFailingGraph = g2; //we don't verify
//    int roundCount = 0;
    for (Graph currentGraph = subGraphCreator.getFirstSubgraph(); currentGraph != null; currentGraph = subGraphCreator.getNewSubgraph(lastOneFailed)) {
      lastOneFailed = !diffPathTest(minimumFailingG1, true, currentGraph, false);
      if (lastOneFailed) {
        lastFailingGraph = currentGraph;
View Full Code Here


      diff.serialize(new FileOutputStream(file));
      MoleculeDiff diffRec =  LeanDiffPatch.deserializeDiff(file);
      ReferenceGroundedDecomposition dec2rec = diffRec
          .patch(new ReferenceGroundedDecompositionImpl(
              (g1)));
      Graph g2rec = ReferenceGroundedUtil.reconstructGraph(dec2rec);
      //TODO find out why test 20 fails without this line
      g2rec = JenaUtil.getGraphFromModel(JenaUtil.getModelFromGraph(g2rec), true);
      g2rec = MoleculeBasedLeanifier.getLeanVersionOf(g2rec);
      Model m2 = JenaUtil.getModelFromGraph(g2);
      Model m2rec = JenaUtil.getModelFromGraph(g2rec);
      System.out.println(g2.size());
      System.out.println(g2rec.size());
      System.out.println(m2.size());
      System.out.println(m2rec.size());
      //m2rec = LeanDiffPatch.leanify(m2rec);
      return m2.isIsomorphicWith(m2rec);
    } catch (Exception e) {
View Full Code Here

    //m2.read(new File("problematic-model2.nt").toURL().toString(), "N-TRIPLE");
    m1.read(MinimumFailingGraphDetector.class.getResource("test14-1.nt").toString(), "N-TRIPLE");
    m2.read(MinimumFailingGraphDetector.class.getResource("test14-2.nt").toString(), "N-TRIPLE");
    m1 = LeanDiffPatch.leanify(m1);
    m2 = LeanDiffPatch.leanify(m2);
    Graph g1 = new JenaModelGraph(m1, true);
    Graph g2 = new JenaModelGraph(m2, true);
    MinimumFailingGraphDetector detector = new MinimumFailingGraphDetector(g1, g2);
    System.out.println("minimum failing g1 (of size "+detector.minimumFailingG1.size()+") :");
    JenaUtil.getModelFromGraph(
        detector.minimumFailingG1).write(
        System.out, "N-TRIPLE");
View Full Code Here

      }
      return getNextSubGraph();
    }
    private Graph getNextSubGraph() {
      int count  = 0;
      Graph currentGraph = new SimpleGraph();
      for (TripleInfo info : tripleInfos) {
        switch (info.status) {
        case undefined:
          if (count < omitUndefined) {
            count++;
            break;
          } else {
            currentGraph.add(info.triple);
          }
          ;
          break;
        case needed:
          currentGraph.add(info.triple);
        }
      }
      if (count == 0) {
        return null;
      }
      System.out.println("returning subgraph of size "+currentGraph.size());
      return currentGraph;
    }
View Full Code Here

*
*/
public class ReferenceGroundedUtil {

  public static Graph reconstructGraph(ReferenceGroundedDecomposition dec) {
    Graph graph = new SimpleGraph();
    for (TerminalMolecule terminalMolecule : dec.getTerminalMolecules()) {
      graph.addAll(terminalMolecule);
    }
    for (ContextualMolecule contextualMolecule : dec.getContextualMolecules()) {
      graph.addAll(contextualMolecule);
    }
    return new NaturalizedGraph(graph, dec.getFunctionallyGroundedNodes());
  }
View Full Code Here

   *
   * @param graph
   * @param naturalizer
   */
  public NaturalizedGraph(Graph graph, Naturalizer naturalizer) {
    Graph fgNodesGraph = new SimpleGraph();
    Map<Set<NonTerminalMolecule>, Node> replacementMap = new HashMap<Set<NonTerminalMolecule>, Node>();
    addGraphTriples(graph, true, naturalizer, replacementMap, fgNodesGraph);
   
    while (fgNodesGraph.size() > 0) {
      //add the triples of the fg-nodes graph and repeat if new triples result from fg-nodes replacemnets
      //withing these triples
      Graph addingFgNodesGraph = fgNodesGraph;
      fgNodesGraph = new SimpleGraph();
      addGraphTriplesaddingFgNodesGraph, true, naturalizer, replacementMap, fgNodesGraph);
    }
    markFinalized();
  }
View Full Code Here

   * @param addReferencedFgNodes if false an exception is thrown if graph contians an fg-node which is not in fgNodes
   */
  public NaturalizedGraph(Graph graph,
      Collection<FunctionallyGroundedNode> fgNodes, boolean addReferencedFgNodes) {
    Map<Set<NonTerminalMolecule>, Node> replacementMap = new HashMap<Set<NonTerminalMolecule>, Node>();
    Graph fgNodesGraph = new SimpleGraph();
    for (Iterator<FunctionallyGroundedNode> iter = fgNodes.iterator(); iter
        .hasNext();) {
      FunctionallyGroundedNode fgNode = iter.next();
      // fg2NormalNodeMap.put(fgNode, fgNode.getOriginalNode());
      Node replacementNode = addFgNodeMolecules(fgNode, new DefaultNaturalizer(), fgNodesGraph);
      //rehashing necessary as long unfinalized nodes come
      replacementMap.put(new HashSet<NonTerminalMolecule>(fgNode.getGroundingMolecules()), replacementNode);
    }
    Naturalizer naturalizer;
    if (addReferencedFgNodes) {
      naturalizer = new DefaultNaturalizer();
    } else {
      naturalizer = null;
    }
    addGraphTriples(graph, addReferencedFgNodes, naturalizer, replacementMap, fgNodesGraph);
    while (fgNodesGraph.size() > 0) {
      //add the triples of the fg-nodes graph and repeat if new triples result from fg-nodes replacemnets
      //withing these triples
      Graph addingFgNodesGraph = fgNodesGraph;
      fgNodesGraph = new SimpleGraph();
      addGraphTriples(addingFgNodesGraph, addReferencedFgNodes, naturalizer, replacementMap, fgNodesGraph);
    }
    markFinalized();
  }
View Full Code Here

      throws IOException {
    PathNode moleculePathNode = dirPathNode.getSubPath(name);
    Model model = ModelFactory.createDefaultModel();
    model.read(moleculePathNode.getInputStream(),
        ReferencingNaturalizer.rootURL + moleculePathNode.getPath());
    Graph graph = JenaUtil.getGraphFromModel(model, false);
    SimpleGraph simpleGraph = new SimpleGraph();
    //Collection<Node> origFgNodes = new HashSet<Node>();
    Map<Node, NamedNode> node2descriptionDocMap = new HashMap<Node, NamedNode>();
    //NamedNode descriptionDoc = null;
    for (Triple triple : graph) {
View Full Code Here

       * MODELDIFF.functionallyGroundedIn, (Resource)null); Statement
       * specialStmt = specialStmtIter.nextStatement();
       * specialStmtIter.close(); Resource groundedNodedRes =
       * specialStmt.getSubject(); specialStmt.remove();
       */
      Graph graph = JenaUtil.getGraphFromModel(model, false);
      Graph tripleSet = new SimpleGraph();
      Node currentAfgn = null;
      Map<Node, FunctionallyGroundedNode> innerReplacements = new HashMap<Node, FunctionallyGroundedNode>();
      for (Triple triple : graph) {
        if (triple.getPredicate().equals(
            new PropertyNodeImpl(MODELDIFF.functionallyGroundedIn
                .getURI()))) {
          Node subject = triple.getSubject();
          if (!describingResource.equals(triple.getObject())) {
            // throw new RuntimeException("invalid diff");
            // now legal as fg-nodes may reference to others in
            // their nt-molecules
            //infinite recursion by cache
            FunctionallyGroundedNode replacement = getFgNodeFromDescribingNode(zipFile,
                (NamedNode) triple.getObject());
            innerReplacements.put(subject, replacement);
           
          } else {
            currentAfgn = subject;
          }
        } else {
          tripleSet.add(triple);
        }
      }
      if (afgn == null) {
        afgn = currentAfgn;
      } else {
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

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.