Package org.wymiwyg.rdf.graphs

Examples of org.wymiwyg.rdf.graphs.Node


  private void addFgNodesToCommons(Set<? extends Molecule> molecules) {
    for (Molecule currentMolecule : molecules) {
      for (Triple currentTriple : currentMolecule) {
        // check if subject is mappable
        Node subject = currentTriple.getSubject();
        if (subject instanceof FunctionallyGroundedNode) {
          commonFgNodesInDiffMolecules
              .add((FunctionallyGroundedNode) subject);
        }
        Node object = currentTriple.getObject();
        if (object instanceof FunctionallyGroundedNode) {
          commonFgNodesInDiffMolecules
              .add((FunctionallyGroundedNode) object);
        }
View Full Code Here


    return getFgNodeFromPathNode(zipFile, pathNode, describingResource);
  }
 
  private FunctionallyGroundedNode getFgNodeFromPathNode(ZipFile zipFile,
      PathNode pathNode, NamedNode describingResource) throws IOException {
    Node afgn = null;
    FunctionallyGroundedNodeImpl result = functionallyGroundedBuilder.createFGNode();
    descriptionPathToFgNode.put(describingResource, result);
    for (String moleculeNodeName : pathNode.list()) {
      PathNode moleculePathNode = pathNode.getSubPath(moleculeNodeName);
      Model model = ModelFactory.createDefaultModel();
      model
          .read(moleculePathNode.getInputStream(),
              ReferencingNaturalizer.rootURL
                  + moleculePathNode.getPath());
      /*
       * StmtIterator specialStmtIter = model.listStatements(null,
       * 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
View Full Code Here

   * @param n2
   * @return
   */
  private static boolean containsNoOtherAnon(Triple statement,
      Node node) {
    Node subject = statement.getSubject();
    if (!(subject instanceof GroundedNode) && (!subject.equals(node))) {
      return true;
    }
    Node object = statement.getObject();
    if (!(subject instanceof GroundedNode) && (!object.equals(node))) {
      return true;
    }
    return false;
  }
View Full Code Here

  private static Set<Triple> getPropertySet(Graph graph, Node node) {
    Set<Triple> result = new HashSet<Triple>();
    Iterator stmtIter = graph.iterator();
      while (stmtIter.hasNext()) {
        Triple statement = (Triple) stmtIter.next();
        Node subject = statement.getSubject();
        if ((node.hashCode() == subject.hashCode()) && subject.equals(node)) {
          result.add(statement);
          continue;
        }
        Node object = statement.getObject();
        if ((node.hashCode() == object.hashCode()) && object.equals(node)) {
          result.add(statement);
        }

      }
    return result;
View Full Code Here

  private static Node geNewCandidateImplicated(Graph graph, Set<Node> exclude,
      Node currentCandidateImplicator) {
    Iterator stmtIter = graph.iterator();
    while (stmtIter.hasNext()) {
      Triple statement = (Triple) stmtIter.next();
      Node subject = statement.getSubject();
      if ((!(subject instanceof GroundedNode))
          && !exclude.contains(subject)
          && !subject.equals(currentCandidateImplicator)) {
        return subject;
      }
      Node object = statement.getObject();
      if ((!(object instanceof GroundedNode))
          && !exclude.contains(object)
          && !object.equals(currentCandidateImplicator)) {
        return object;
      }

    }
View Full Code Here

   */
  private static Node getNewCandidateImplicator(Graph graph, Set<Node> exclude) {
    Iterator stmtIter = graph.iterator();
    while (stmtIter.hasNext()) {
      Triple statement = (Triple) stmtIter.next();
      Node subject = statement.getSubject();
      if (!exclude.contains(subject)) {
        return subject;
      }
      Node object = statement.getObject();
      if (!exclude.contains(object)) {
        return object;
      }

    }
View Full Code Here

  /* (non-Javadoc)
   * @see org.wymiwyg.rdf.graphs.fgnodes.impl.Naturalizer#naturalize(org.wymiwyg.rdf.graphs.fgnodes.FunctionallyGroundedNode, org.wymiwyg.rdf.graphs.Graph)
   */
  public Node naturalize(FunctionallyGroundedNode fgNode, Graph graph) {
    Node anonNode = map.get(fgNode);
    if (anonNode == null) {
      anonNode = new NodeImpl();
      map.put(fgNode,anonNode);
    }
    for (Molecule molecule : fgNode.getGroundingMolecules()) {
View Full Code Here

   */
  // TODO should object/subject be shifted?
  private int getBlankNodeBlindHash(Triple triple,
      List<FunctionallyGroundedNode> callers) {
    int hash = triple.getPredicate().hashCode();
    Node subject = triple.getSubject();
    if (subject instanceof FunctionallyGroundedNodeImpl) {
      hash ^= ((FunctionallyGroundedNodeImpl) subject)
          .computeHash(callers);
    } else {
      if ((subject instanceof GroundedNode)) {// && (!(subject instanceof
        // FunctionallyGroundedNode))){
        hash ^= subject.hashCode();// >> 1;
      }
    }
    Node object = triple.getObject();
    if (object instanceof FunctionallyGroundedNodeImpl) {
      hash ^= ((FunctionallyGroundedNodeImpl) object)
          .computeHash(callers);
    } else {
      if ((object instanceof GroundedNode)) {// && (!(object instanceof
        // FunctionallyGroundedNode))){
        hash ^= object.hashCode();// << 1;
      }
    }
    /*
     * log.debug("GRAPH: computed BlankNodeBlindHash triple hash " + hash + "
     * for predicate " + triple.getPredicate());
View Full Code Here

  /** adoptd subject and/or object if functionally grounded
   * @param triple
   * @return
   */
  private Triple adopt(Triple triple) {
    Node subject = triple.getSubject();
    boolean modified =  false;
    if (subject instanceof FunctionallyGroundedNode) {
      subject = adopt((FunctionallyGroundedNode)subject);
      modified = true;
    }
    Node object = triple.getObject();
    if (object instanceof FunctionallyGroundedNode) {
      object = adopt((FunctionallyGroundedNode)object);
      modified = true;
    }
    if (modified) {
View Full Code Here

          .warn("Leanifying graph with more than 1000 triples, consider decomposition strategy.");
    }
    Set<Node> fullyCheckedCandidateImplicators = new HashSet<Node>();
    Set<Node> checkedCandidateImplicatedForCurrentCandidateImplicator = new HashSet<Node>();
    // MultiMap otherChecked = new MultiHashMap();
    Node currentCandidateImplicator = null;
    Set<Node[]> knownNotImplying = new HashSet<Node[]>();
    while (true) {
      if (currentCandidateImplicator == null) {
        currentCandidateImplicator = getNewCandidateImplicator(graph,
            fullyCheckedCandidateImplicators);
      }
      if (currentCandidateImplicator == null) {
        return;
      }

      Node currentCandidateImplicated = geNewCandidateImplicated(
          graph,
          checkedCandidateImplicatedForCurrentCandidateImplicator,
          currentCandidateImplicator);
      if (currentCandidateImplicated == null) {
        fullyCheckedCandidateImplicators
View Full Code Here

TOP

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

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.