Package org.wymiwyg.rdf.graphs

Examples of org.wymiwyg.rdf.graphs.Graph


  }

  private void createMimimumFailing(int position, Graph[] graphs) {
    SubGraphCreator subGraphCreator = new SubGraphCreator(graphs[position]);
    boolean lastOneFailed; // note that we are looking for failing graphs
    Graph lastFailingGraph = graphs[position];
    // int roundCount = 0;
    for (Graph currentGraph = subGraphCreator.getFirstSubgraph(); currentGraph != null; currentGraph = subGraphCreator
        .getNewSubgraph(lastOneFailed)) {
      graphs[position] = currentGraph;
      lastOneFailed = !getTestResult(graphs);
      if (lastOneFailed) {
        lastFailingGraph = currentGraph;
        System.out.println("Graph " + position + " reduced to "
            + lastFailingGraph.size());
        // if (roundCount++ % 100 ==0){
        // try {
        // JenaUtil.getModelFromGraph(currentGraph).write(new
        // FileWriter("g1-"+roundCount),"N-TRIPLES");
        // } catch (IOException e) {
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

          .getFileFormat());
    } catch (MalformedURLException e) {
      throw new RuntimeException(e);
    }
    if (arguments.isPedantic()) {
      Graph graph = JenaUtil.getGraphFromModel(model, false);
      GraphLeanifier.makeLean(graph);
      model = JenaUtil.getModelFromGraph(graph);
      model.write(System.out, arguments.getFileFormat());
    } else {
      File ontologyFile = arguments.getModelOntologyPath();
      Graph source;
      if (ontologyFile != null) {
        Model ontology = ModelFactory.createDefaultModel();
        try {
          ontology.read(ontologyFile.toURL().toString(), arguments
              .getFileFormat());
        } catch (MalformedURLException e) {
          throw new RuntimeException(e);
        }
        source = JenaUtil.getGraphFromModel(model, ontology, arguments.getUseDefaultOntology());   
      } else {
        source = JenaUtil.getGraphFromModel(model, arguments.getUseDefaultOntology());
      }
      Graph result = MoleculeBasedLeanifier.getLeanVersionOf(source);
      JenaUtil.getModelFromGraph(result).write(System.out, arguments.getFileFormat());
    }

  }
View Full Code Here

   *            the graph to be leanified
   * @return a lean graph expressing the same content
   */
  public static Graph getLeanVersionOf(Graph graph) {
    graph = new AnonymizedGraph(graph);
    Graph result = getLeanVersionWithoutAnonymizing(graph);
    return new DeAnonymizedGraph(result);
  }
View Full Code Here

      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());
View Full Code Here

        leanifiedMolecules.add(currentGraph);
      }
      contextualMolecules = new HashSet<MaximumContextualMolecule>();
      for (Iterator<Graph> iter = leanifiedMolecules.iterator(); iter
          .hasNext();) {
        Graph current = iter.next();
        if (!isSubgrapgOfOther(current, leanifiedMolecules)) {
          ContextualMoleculeImpl contextualMolecule = new ContextualMoleculeImpl();
          contextualMolecule.addAll(current);
          contextualMolecule.markFinalized();
          contextualMolecules.add(contextualMolecule);
        } else {
          iter.remove();
        }
      }
    }
    Map<FunctionallyGroundedNode, FunctionallyGroundedNode> fgNodeMap = new HashMap<FunctionallyGroundedNode, FunctionallyGroundedNode>();
    for (FunctionallyGroundedNode fgNode : refDec
        .getFunctionallyGroundedNodes()) {
      fgNodeMap.put(fgNode, fgNode);
    }
   
    fgNodeMap = FgNodeMerger.mergeFgNodes(fgNodeMap);

    boolean nodeReplaced = false;
    Set<TerminalMolecule> terminalMolecules = refDec.getTerminalMolecules();
    //TODO iterate over molecules
    for (Entry<FunctionallyGroundedNode, FunctionallyGroundedNode> entry : fgNodeMap
        .entrySet()) {
      FunctionallyGroundedNode orig = entry.getKey();
      FunctionallyGroundedNode current = entry.getValue();
      if (!current.equals(orig)) {
        Set<MaximumContextualMolecule> newContextualModelcules = new HashSet<MaximumContextualMolecule>();
        for (MaximumContextualMolecule maximumContextualMolecule : contextualMolecules) {
          try {
            ContextualMoleculeImpl replacement = new ContextualMoleculeImpl();
            new GraphUtil<MaximumContextualMolecule>()
View Full Code Here

   */
  private static boolean isSubgrapgOfOther(Graph current,
      Set<Graph> leanifiedMolecules) {
    for (Iterator<Graph> iter = leanifiedMolecules.iterator(); iter
        .hasNext();) {
      Graph other = iter.next();
      if (current == other) {
        continue;
      }
      if (SubGraphMatcher.getValidMapping(current, other) != null) {
        return true;
View Full Code Here

   

  }

  public static void serialize(Graph graph, OutputStream out) {
    Graph labelableGraph = getLabelableGraph(graph);
   
  }
View Full Code Here

   * @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

        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
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.