Package org.wymiwyg.rdf.graphs.fgnodes

Examples of org.wymiwyg.rdf.graphs.fgnodes.FunctionallyGroundedNode


   *
   * @see com.hp.hpl.jena.gvs.storage.MoleculeStore#getFunctionallyGroundedNode(org.wymiwyg.rdf.graphs.NamedNode)
   */
  public FunctionallyGroundedNode getFunctionallyGroundedNode(
      NamedNode functionallyGroundedNodeRef) {
    FunctionallyGroundedNode result = null;
    result = currentlyBeingAdded.getKey(functionallyGroundedNodeRef);
    if (result != null) {
      return result;
    }
    Resource fgRes = indexModel.getResource(functionallyGroundedNodeRef
View Full Code Here


        Set<NamedNode> fgNodeRefs = metaStore.getAsserted(sources,
            moment, METAMODEL.FunctionallyGroundedNode);

        Set<FunctionallyGroundedNode> unmergedFGNodes = new HashSet<FunctionallyGroundedNode>();
        for (NamedNode fgNodeRef : fgNodeRefs) {
          FunctionallyGroundedNode fgNode = moleculeStore
              .getFunctionallyGroundedNode(fgNodeRef);
          unmergedFGNodes.add(fgNode);
        }
        fgNodeMap = new HashMap<FunctionallyGroundedNode, FunctionallyGroundedNode>();
        for (FunctionallyGroundedNode fgNode : unmergedFGNodes) {
View Full Code Here

            cMolecules.add(cMolecule);

          }
          for (Entry<FunctionallyGroundedNode, FunctionallyGroundedNode> entry : fgNodeMap
              .entrySet()) {
            FunctionallyGroundedNode orig = entry.getKey();
            FunctionallyGroundedNode current = entry.getValue();
            if (!current.equals(orig)) {
              Set<MaximumContextualMolecule> originalContextualMolecules = cMolecules;
              cMolecules = new HashSet<MaximumContextualMolecule>();
              for (MaximumContextualMolecule molecule : originalContextualMolecules) {
                try {
                  SimpleContextualMolecule replacement = new GraphUtil<SimpleContextualMolecule>()
View Full Code Here

                .getTerminalMolecule(tMoleculesRef);
            tMolecules.add(tMolecule);
          }
          for (Entry<FunctionallyGroundedNode, FunctionallyGroundedNode> entry : fgNodeMap
              .entrySet()) {
            FunctionallyGroundedNode orig = entry.getKey();
            FunctionallyGroundedNode current = entry.getValue();
            if (!current.equals(orig)) {
              Set<TerminalMolecule> originalTerminalMolecules = tMolecules;
              tMolecules = new HashSet<TerminalMolecule>();
              for (TerminalMolecule molecule : originalTerminalMolecules) {
                try {
                  SimpleTerminalMolecule replacement = new GraphUtil<SimpleTerminalMolecule>()
View Full Code Here

  private static void serialize(FunctionallyGroundedNode node,
      ArrayList<FunctionallyGroundedNode> visitedFgNodes,
      StringWriter writer) {
    writer.write("[");
    for (int i = 0; i < visitedFgNodes.size(); i++) {
      FunctionallyGroundedNode visitedFgNode = visitedFgNodes.get(i);
      // TODO deal with the case they are not the same instance
      if (visitedFgNode == node) {
        writer.write(Integer.toString(i));
        writer.write("]");
        return;
View Full Code Here

    }
    if (!(obj instanceof FunctionallyGroundedNode)) {
      return false;
    }

    FunctionallyGroundedNode other = (FunctionallyGroundedNode) obj;
    /*if (!isFinalized() || !other.isFinalized()) {
      return false;
    }*/
    byte[] otherStronhHash = other.strongHashCode();
    return Arrays.equals(strongHashCode(), otherStronhHash);
  }
View Full Code Here

  public static <T> Map<T, FunctionallyGroundedNode> mergeFgNodes(
      Map<T, FunctionallyGroundedNode> originalNodeMap) {
    Map<FunctionallyGroundedNode, Set<T>> nodes2Keys = new HashMap<FunctionallyGroundedNode, Set<T>>();
    for (Map.Entry<T, FunctionallyGroundedNode> entry : originalNodeMap
        .entrySet()) {
      final FunctionallyGroundedNode value = entry.getValue();
      Set<T> keySet = nodes2Keys.get(value);
      if (keySet == null) {
        keySet = new HashSet<T>();
        nodes2Keys.put(value, keySet);
      }
      keySet.add(entry.getKey());
    }
    int sizeBeforeMerging = nodes2Keys.size();
    if (log.isDebugEnabled()) {
      log.debug("Size before merging: " + sizeBeforeMerging);
      log.debug(nodes2Keys.keySet());
    }
    mergeFgNodes(nodes2Keys);
    while (nodes2Keys.size() < sizeBeforeMerging) {
      sizeBeforeMerging = nodes2Keys.size();
      if (sizeBeforeMerging > 1)
        mergeFgNodes(nodes2Keys);
    }
    if (log.isDebugEnabled()) {
      log.debug("Size after merging: " + sizeBeforeMerging);
      log.debug(nodes2Keys.keySet());
    }
    Map<T, FunctionallyGroundedNode> result = new HashMap<T, FunctionallyGroundedNode>();
    for (Map.Entry<FunctionallyGroundedNode, Set<T>> nodes2KeyEntry : nodes2Keys
        .entrySet()) {
      FunctionallyGroundedNode node = nodes2KeyEntry.getKey();
      for (T key : nodes2KeyEntry.getValue()) {
        result.put(key, node);

      }
    }
View Full Code Here

    out.println();
    out.println("Functionally grounded nodes only in 1: "
        + fgNodesOnlyIn1.size());
    for (Iterator<FunctionallyGroundedNode> iter = fgNodesOnlyIn1
        .iterator(); iter.hasNext();) {
      FunctionallyGroundedNode current = iter.next();
      out.print("-");
      out.println(current);
    }
    out.println();
    out.println("Functionally grounded nodes only in 2: "
        + fgNodesOnlyIn2.size());
    for (Iterator<FunctionallyGroundedNode> iter = fgNodesOnlyIn2
        .iterator(); iter.hasNext();) {
      FunctionallyGroundedNode current = iter.next();
      out.print("-");
      out.println(current);
    }
    out.println();
    out.println("Common functionally grounded nodes used in diff-molecules/fg-nodes: "
        + commonFgNodes.size());
    for (Iterator<FunctionallyGroundedNode> iter = commonFgNodes
        .iterator(); iter.hasNext();) {
      FunctionallyGroundedNode current = iter.next();
      out.print("-");
      out.println(current);
    }

    out.println("Maximum contextual molecules only in 1: " + contextualMoleculesOnlyIn1.size());
View Full Code Here

      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 {
View Full Code Here

        dec1.getFunctionallyGroundedNodes());
    Set<FunctionallyGroundedNode> fgNodes2 = new HashSet<FunctionallyGroundedNode>(
        dec2.getFunctionallyGroundedNodes());
    // commonFgNodes = new HashSet<FunctionallyGroundedNode>();
    for (Iterator iter = fgNodes1.iterator(); iter.hasNext();) {
      FunctionallyGroundedNode current = (FunctionallyGroundedNode) iter
          .next();
      if (fgNodes2.contains(current)) {
        // commonFgNodes.add(current);
        iter.remove();
        fgNodes2.remove(current);
      }
    }
    Map<FunctionallyGroundedNode, CrossGraphFgNode> fgNodes12CrossGraphFgNodes = new HashMap<FunctionallyGroundedNode, CrossGraphFgNode>();
    Map<FunctionallyGroundedNode, CrossGraphFgNode> fgNodes22CrossGraphFgNodes = new HashMap<FunctionallyGroundedNode, CrossGraphFgNode>();
    for (Iterator iter = fgNodes1.iterator(); iter.hasNext();) {
      FunctionallyGroundedNode fgnode1 = (FunctionallyGroundedNode) iter
          .next();
      CrossGraphFgNode matching = new CrossGraphFgNode();
      matching.getNodesIn1().add(fgnode1);

      boolean fgNodeInCrossGraph = false;
      for (Iterator iterator = fgnode1.getGroundingMolecules().iterator(); iterator
          .hasNext();) {
        NonTerminalMolecule current = (NonTerminalMolecule) iterator
            .next();
        FunctionallyGroundedNode fgnode2 = getFgNodeWith(fgNodes2,
            current);
        if (fgnode2 != null) {
          fgNodeInCrossGraph = true;
          matching.getNodesIn2().add(fgnode2);
          fgNodes22CrossGraphFgNodes.put(fgnode2, matching);
        }
      }
      if (!fgNodeInCrossGraph) {
        fgNodesOnlyIn1.add(fgnode1);
      } else {
        fgNodes12CrossGraphFgNodes.put(fgnode1, matching);
        //TODO ensure later finalization
        crossGraphFgNodes.add(matching);
      }
    }
    for (Iterator<FunctionallyGroundedNode> iter = fgNodes2.iterator(); iter
        .hasNext();) {
      FunctionallyGroundedNode fgnode2 = iter.next();
      boolean fgNodeInCrossGraph = false;
      for (Iterator iterator = fgnode2.getGroundingMolecules().iterator(); iterator
          .hasNext();) {
        NonTerminalMolecule current = (NonTerminalMolecule) iterator
            .next();
        FunctionallyGroundedNode fgnode1 = getFgNodeWith(fgNodes1,
            current);
        if (fgnode1 != null) {
          fgNodeInCrossGraph = true;
          // check if there is already an OverlappingNodes with
          // fgnode1 and 2
          CrossGraphFgNode crossNodeWith2 = fgNodes22CrossGraphFgNodes
              .get(fgnode2);
          if (crossNodeWith2 == null) {
            // graph is not lean
            for (NonTerminalMolecule molecule : fgnode2
                .getGroundingMolecules()) {
              FunctionallyGroundedNode fgnode2alt = getFgNodeWith(
                  fgNodes2, molecule);
              if ((fgnode2alt != null)
                  && (!fgnode2.equals(fgnode2alt))) {
                crossNodeWith2 = fgNodes22CrossGraphFgNodes
                    .get(fgnode2alt);
View Full Code Here

TOP

Related Classes of org.wymiwyg.rdf.graphs.fgnodes.FunctionallyGroundedNode

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.