Examples of SimpleGraph


Examples of org.wymiwyg.rdf.graphs.impl.SimpleGraph

       * 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

Examples of org.wymiwyg.rdf.graphs.impl.SimpleGraph

   * @param tripleSet
   */
  private <T extends Collection<? extends Triple>> SimpleGraph replaceNode(
      Node currentAfgn, Node afgn, T tripleSet) {
    try {
      return new GraphUtil<SimpleGraph>().replaceNode(tripleSet, currentAfgn, afgn, new SimpleGraph());
    } catch (SourceNodeNotFoundException e) {
      SimpleGraph result = new SimpleGraph();
      result.addAll(tripleSet);
     
      return result;
    }
    /*
     * Set<Triple> result = new HashSet<Triple>(); for (Triple triple :
View Full Code Here

Examples of org.wymiwyg.rdf.graphs.impl.SimpleGraph

      log.debug("Anonymized graph: ");
      log.debug(stringWriter);
    }
    ReferenceGroundedDecomposition refDec = new ReferenceGroundedDecompositionImpl(graph);
    ReferenceGroundedDecomposition leanifiedDec = getLeanVersionWithoutAnonymizing(refDec);
    Graph nonNaturalGraph = new SimpleGraph();
    for (Iterator<MaximumContextualMolecule> iter = leanifiedDec
        .getContextualMolecules().iterator(); iter.hasNext();) {
      nonNaturalGraph.addAll(iter.next());
    }
    for (Iterator<TerminalMolecule> iter = leanifiedDec.getTerminalMolecules()
        .iterator(); iter.hasNext();) {
      nonNaturalGraph.addAll(iter.next());
    }

    try {
      SimpleGraph result = new NaturalizedGraph(nonNaturalGraph, leanifiedDec
          .getFunctionallyGroundedNodes());
      result.markFinalized();
      /*System.out.println("DEBUG not anonymized:");
      JenaUtil.getModelFromGraph(result).write(System.out, "N3");*/
      return result;
    } catch (NoReplacementFoundException ex) {
      log.error(ex.toString());
View Full Code Here

Examples of org.wymiwyg.rdf.graphs.impl.SimpleGraph

      for (Iterator<MaximumContextualMolecule> iter = contextualMolecules
          .iterator(); iter.hasNext();) {
        MaximumContextualMolecule current = (MaximumContextualMolecule) iter
            .next();
        // test, why does it takes sooo much longer with molecule?
        SimpleGraph currentGraph = new SimpleGraph();
        currentGraph.addAll(current);
        GraphLeanifier.makeLean(currentGraph);
        currentGraph.markFinalized();
        leanifiedMolecules.add(currentGraph);
      }
      contextualMolecules = new HashSet<MaximumContextualMolecule>();
      for (Iterator<Graph> iter = leanifiedMolecules.iterator(); iter
          .hasNext();) {
View Full Code Here

Examples of org.wymiwyg.rdf.graphs.impl.SimpleGraph

   * @param graph
   * @return
   */
  private static Graph getLabelableGraph(Graph graph) {
    Map<Node, LabelableNode> nodeMap = new HashMap<Node, LabelableNode>();
    Graph labelableGraph = new SimpleGraph();
    for (Triple triple : graph) {
      labelableGraph.add(getLabelableTriple(triple, nodeMap));
    }
    return labelableGraph;
  }
View Full Code Here

Examples of org.wymiwyg.rdf.graphs.impl.SimpleGraph

      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

Examples of org.wymiwyg.rdf.graphs.impl.SimpleGraph

        StringBuffer moleculePath = new StringBuffer(relativePath);
        moleculePath.append(Util.createRandomString(8));
        moleculePath.append(".rdf");
        ZipEntry entry = new ZipEntry(moleculePath.toString());
        zipOut.putNextEntry(entry);
        Graph graph = new SimpleGraph();
        Node naturalNode = naturalizer.naturalize(fgNode, graph);
        Graph addition;
        try {
          addition = new GraphUtil<Graph>().replaceNode(molecule,
              fgNode, naturalNode, new SimpleGraph());
        } catch (SourceNodeNotFoundException e) {
          // this is in fact the normal case of non-self-referencing
          // fg-nodes (x mbox [mbox "foo"]. x mbox "foo")
          addition = molecule;
        }
        try {
          addition = new GraphUtil<Graph>().replaceNode(addition,
              NonTerminalMolecule.GROUNDED_NODE, naturalNode,
              new SimpleGraph());
        } catch (SourceNodeNotFoundException e) {
          // this is a bit strange ...
          throw new RuntimeException(e);
        }
        graph.addAll(addition);
        /*
         * graph.addAll(molecule); graph.add(new
         * TripleImp(naturalizer.naturalize(fgNode, null), new
         * PropertyNodeImpl(MODELDIFF.functionallyGroundedIn .getURI()),
         * namedNode));
 
View Full Code Here

Examples of org.wymiwyg.rdf.graphs.impl.SimpleGraph

*/
public class FgNodeMergerTest {

  @Test
  public void simple() {
    SimpleGraph graph = new SimpleGraph();
    Node nanmedNode = new NamedNodeImpl("http://1.example.org/");
    graph.add(new TripleImpl(new NodeImpl(),
        new InverseFunctionalPropertyNodeImpl(
            "http://example.org/functional"), nanmedNode));
    Node fg2 = new NodeImpl();
    graph.add(new TripleImpl(fg2, new InverseFunctionalPropertyNodeImpl(
        "http://example.org/functional"), nanmedNode));
    graph.add(new TripleImpl(fg2, new InverseFunctionalPropertyNodeImpl(
        "http://example.org/f2"), new NamedNodeImpl(
        "http://2.example.org/")));
    ReferenceGroundedDecomposition dec = new ReferenceGroundedDecompositionImpl(
        graph);
    Set<FunctionallyGroundedNode> functionallyGroundedNodes = dec
View Full Code Here

Examples of org.wymiwyg.rdf.graphs.impl.SimpleGraph

    }
    return true;
  }

  public static Graph applyMapping(Graph graph, Map mapping) {
    SimpleGraph result = new SimpleGraph();
    for (Iterator iter = graph.iterator(); iter.hasNext();) {
      Triple triple = (Triple) iter.next();
      Node subject = triple.getSubject();
      PropertyNode predicate = triple.getPredicate();
      Node object = triple.getObject();
      if (!(subject instanceof GroundedNode)) {
        subject = (Node) mapping.get(subject);
      }
      if (!(object instanceof GroundedNode)) {
        object = (Node) mapping.get(object);
      }
      Triple mappedTriple = new TripleImpl(subject, predicate, object);
      result.add(mappedTriple);
    }
    result.markFinalized();
    return result;
  }
View Full Code Here

Examples of org.wymiwyg.rdf.graphs.impl.SimpleGraph

    ReferenceGroundedDecomposition recDec = new ReferenceGroundedDecompositionImpl(
        prob1GraphRec);
    // ReferenceGroundedUtil.print(recDec, new PrintWriter(System.out));
    Graph recDecRec2 = new NaturalizedGraph(ReferenceGroundedUtil
        .reconstructGraph(recDec));
    Graph recDecRec = new NaturalizedGraph(new SimpleGraph(), recDec
        .getFunctionallyGroundedNodes());
    // System.out.println(recDecRec2.equals(recDecRec));
    // JenaUtil.getModelFromGraph(recDecRec).write(System.out);
    Graph recDecRecLean = MoleculeBasedLeanifier
        .getLeanVersionOf(recDecRec);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.