Package edu.isi.karma.rep.alignment

Examples of edu.isi.karma.rep.alignment.ColumnNode


      Set<String> test = mgr.getPossibleUris("http://example.com/layout/C01_", "http://example.com/layout/C02_");
      for (String s : test) {
        System.out.println(s);
      }
      Alignment al = new Alignment(mgr);
      ColumnNode c1 = al.addColumnNode("h1", "c1", null);
      ColumnNode c2 = al.addColumnNode("h2", "c2", null);
      InternalNode n1 = al.addInternalNode(new Label("http://example.com/layout/C01_"));
      InternalNode n2 = al.addInternalNode(new Label("http://example.com/layout/C02_"));
      al.addDataPropertyLink(n1, c1, new Label("http://example.com/layout/d1"));
      al.addDataPropertyLink(n2, c2, new Label("http://example.com/layout/d2"));
      al.align();
View Full Code Here


        } else {
          n1 = nodes.iterator().next();
        }

        id = new RandomGUID().toString();
        node = new ColumnNode(id, id, "", null);
        if (this.graphBuilder.addNode(node)) {
          n2 = node;
        } else {
          continue;
        }
View Full Code Here

   
    for (Node n : this.graph.vertexSet()) {
     
      if (!(n instanceof ColumnNode)) continue;
     
      ColumnNode cn = (ColumnNode)n;
           
      List<SemanticType> suggestedSemanticTypes =
          new SemanticTypeUtil().getColumnSemanticSuggestions(workspace, worksheet, cn, 4, selection);
      cn.setSuggestedSemanticTypes(suggestedSemanticTypes);
    }
  }
View Full Code Here

   
    for (Node n : this.graph.vertexSet()) {
     
      if (!(n instanceof ColumnNode)) continue;
     
      ColumnNode cn = (ColumnNode)n;
           
      Set<LabeledLink> incomingLinks = this.graph.incomingEdgesOf(n);
      if (incomingLinks != null && incomingLinks.size() == 1) {
        LabeledLink link = incomingLinks.toArray(new LabeledLink[0])[0];
        Node domain = link.getSource();
        SemanticType st = new SemanticType(cn.getHNodeId(), link.getLabel(), domain.getLabel(), Origin.User, 1.0);
        cn.setUserSelectedSemanticType(st);
      } else
        logger.debug("The column node " + ((ColumnNode)n).getColumnName() + " does not have any domain or it has more than one domain.");
    }
  }
View Full Code Here

    for (int i = 0; i < numberOfPossibleSets; i++) {
      HashMap<Node, String> nodeIds = new HashMap<Node,String>();
      NodeIdFactory nodeIdFactory = new NodeIdFactory();
     
      for (Node n : columnNodes) {
        ColumnNode cn = null;
        if (this.mappingToSourceColumns != null &&
            (cn = this.mappingToSourceColumns.get((ColumnNode)n)) != null) {
          nodeIds.put(n, cn.getId());
        } else {
          nodeIds.put(n, n.getId());
        }
      }
     
View Full Code Here

        str += l.getUri();
        str += separator;
      }
     
      if (target instanceof ColumnNode) {
        ColumnNode cn = sm.mappingToSourceColumns.get((ColumnNode)target);
        if (cn == null) return null;
        str += cn.getId();
        str += separator;
      }
     
    }
    return str;
View Full Code Here

   
    // Adding the nodes to the maps
    for (Node n : mainModel.graph.vertexSet()) {
      if (n instanceof InternalNode) key = n.getLabel().getUri();
      else if (n instanceof ColumnNode) {
        ColumnNode cn = mainModel.mappingToSourceColumns.get(n);
        if (cn == null) continue; else key = cn.getId();
      }
      else continue;
     
      count = mainNodes.get(key);
      if (count == null) mainNodes.put(key, 1);
      else mainNodes.put(key, ++count);
    }
    for (Node n : targetModel.graph.vertexSet()) {
      if (n instanceof InternalNode) key = n.getLabel().getUri();
      else if (n instanceof ColumnNode) {
        ColumnNode cn = targetModel.mappingToSourceColumns.get(n);
        if (cn == null) continue; else key = cn.getId();
      }
      else continue;
     
      count = targetNodes.get(key);
      if (count == null) targetNodes.put(key, 1);
      else targetNodes.put(key, ++count);
    }
   
    // Adding the links to the maps
    Node source, target;
    for (LabeledLink l : mainModel.graph.edgeSet()) {     
      source = l.getSource();
      target = l.getTarget();
     
      if (!(source instanceof InternalNode)) continue;
     
      sourceStr = source.getLabel().getUri();
      linkStr = l.getLabel().getUri();
      if (target instanceof InternalNode) targetStr = target.getLabel().getUri();
      else if (target instanceof ColumnNode) {
        ColumnNode cn = mainModel.mappingToSourceColumns.get(target);
        if (cn == null) continue; else targetStr = cn.getId();
      }
      else continue;
     
      key = sourceStr + linkStr + targetStr;
      count = mainLinks.get(key);
      if (count == null) mainLinks.put(key, 1);
      else mainLinks.put(key, ++count);
     
      Set<String> links = mainNodePairToLinks.get(sourceStr + targetStr);
      if (links == null) { links = new HashSet<String>(); mainNodePairToLinks.put(sourceStr + targetStr, links); }
      links.add(linkStr);
    }
    for (LabeledLink l : targetModel.graph.edgeSet()) {
      source = l.getSource();
      target = l.getTarget();
     
      if (!(source instanceof InternalNode)) continue;
     
      sourceStr = source.getLabel().getUri();
      linkStr = l.getLabel().getUri();
      if (target instanceof InternalNode) targetStr = target.getLabel().getUri();
      else if (target instanceof ColumnNode) {
        ColumnNode cn = targetModel.mappingToSourceColumns.get(target);
        if (cn == null) continue; else targetStr = cn.getId();
      }
      else continue;
     
      key = sourceStr + linkStr + targetStr;
      count = targetLinks.get(key);
View Full Code Here

    List<SemanticType> candidateSemanticTypes;
    String domainUri = "", propertyUri = "";

    for (Node n : steinerNodes) {

      ColumnNode cn = null;
      if (n instanceof ColumnNode)
        cn = (ColumnNode)n;
      else
        continue;
       
      candidateSemanticTypes = getCandidateSemanticTypes(cn, useCorrectTypes, numberOfCandidates);
      columnSemanticTypes.put(cn, candidateSemanticTypes);

      for (SemanticType semanticType: candidateSemanticTypes) {

        if (semanticType == null ||
            semanticType.getDomain() == null ||
            semanticType.getType() == null) continue;

        domainUri = semanticType.getDomain().getUri();
        propertyUri = semanticType.getType().getUri();

        Integer count = semanticTypesCount.get(domainUri + propertyUri);
        if (count == null) semanticTypesCount.put(domainUri + propertyUri, 1);
        else semanticTypesCount.put(domainUri + propertyUri, count.intValue() + 1);
      }
    }

    long numOfMappings = 1;
   
    for (Node n : steinerNodes) {

      if (n instanceof InternalNode)
        continue;
     
      ColumnNode cn = null;
      if (n instanceof ColumnNode)
        cn = (ColumnNode)n;
      else
        continue;
     
      candidateSemanticTypes = columnSemanticTypes.get(n);
      if (candidateSemanticTypes == null) continue;

      logger.info("===== Column: " + cn.getColumnName());

      Set<SemanticTypeMapping> semanticTypeMappings = new HashSet<SemanticTypeMapping>();
      for (SemanticType semanticType: candidateSemanticTypes) {

        logger.info("\t" + semanticType.getConfidenceScore() + " :" + semanticType.getModelLabelString());

        if (semanticType == null ||
            semanticType.getDomain() == null ||
            semanticType.getType() == null) continue;

        domainUri = semanticType.getDomain().getUri();
        propertyUri = semanticType.getType().getUri();
        Integer countOfSemanticType = semanticTypesCount.get(domainUri + propertyUri);
        logger.debug("count of semantic type: " +  countOfSemanticType);

       
        if (cn.hasUserType()) {
          SemanticTypeMapping mp = new SemanticTypeMapping(cn, semanticType, cn.getDomainNode(), cn.getDomainLink(), cn);
          semanticTypeMappings.add(mp);
        } else {

          tempSemanticTypeMappings = findSemanticTypeInGraph(cn, semanticType, semanticTypesCount, addedNodes);
          logger.debug("number of matches for semantic type: "
             + (tempSemanticTypeMappings == null ? 0 : tempSemanticTypeMappings.size()));
 
          if (tempSemanticTypeMappings != null)
            semanticTypeMappings.addAll(tempSemanticTypeMappings);
 
          int countOfMatches = tempSemanticTypeMappings == null ? 0 : tempSemanticTypeMappings.size();
  //        if (countOfMatches < countOfSemanticType)
          if (countOfMatches == 0) // No struct in graph is matched with the semantic type, we add a new struct to the graph
          {
            SemanticTypeMapping mp = addSemanticTypeStruct(cn, semanticType, addedNodes);
            if (mp != null)
              semanticTypeMappings.add(mp);
          }
        }
      }
      //      System.out.println("number of matches for column " + n.getColumnName() +
      //          ": " + (semanticTypeMappings == null ? 0 : semanticTypeMappings.size()));
      logger.debug("number of matches for column " + cn.getColumnName() +
          ": " + (semanticTypeMappings == null ? 0 : semanticTypeMappings.size()));
      numOfMappings *= (semanticTypeMappings == null || semanticTypeMappings.isEmpty() ? 1 : semanticTypeMappings.size());

      logger.debug("number of candidate steiner sets before update: " + candidateSteinerSets.getSteinerSets().size());
      candidateSteinerSets.updateSteinerSets(semanticTypeMappings);
View Full Code Here

      } else if (key.equals("sourceColumns") && reader.peek() != JsonToken.NULL) {
        sourceColumns = new LinkedList<ColumnNode>();
        sourceColumnIds = new HashMap<String, ColumnNode>();
        reader.beginArray();
          while (reader.hasNext()) {
            ColumnNode cn = readSourceColumn(reader);
            if (cn != null) {
              sourceColumns.add(cn);
              sourceColumnIds.put(cn.getId(), cn);
            }
        }
          reader.endArray();       
      } else if (key.equals("mappingToSourceColumns") && reader.peek() != JsonToken.NULL) {
        mappingToSourceColumnsIds = new HashMap<String, String>();
        Map <String, String> oneEntryMapping;
        reader.beginArray();
          while (reader.hasNext()) {
            oneEntryMapping = readMappingToSourceColumn(reader);
            if (oneEntryMapping != null && oneEntryMapping.size() == 1)
              mappingToSourceColumnsIds.putAll(oneEntryMapping);
        }
          reader.endArray();       
      } else if (key.equals("graph") && reader.peek() != JsonToken.NULL) {
        graph = GraphUtil.readGraph(reader);
      } else {
        reader.skipValue();
      }
    }
      reader.endObject();
     
    Map<ColumnNode, ColumnNode> mappingToSourceColumns = new HashMap<ColumnNode, ColumnNode>();
    if (graph != null && mappingToSourceColumnsIds != null && !mappingToSourceColumnsIds.isEmpty()) {
      for (Node n : graph.vertexSet()) {
        if (n instanceof ColumnNode) {
          ColumnNode cn = (ColumnNode)n;
          String sourceColumnId = mappingToSourceColumnsIds.get(cn.getId());
          if (sourceColumnId != null) {
            ColumnNode sourceColumn = sourceColumnIds.get(sourceColumnId);
            if (sourceColumn != null)
              mappingToSourceColumns.put(cn, sourceColumn);
          }
        }
      }
View Full Code Here

          }
        }


        String nodeId = new RandomGUID().toString();
        ColumnNode target = new ColumnNode(nodeId, nodeId, sourceColumn.getColumnName(), null);
        if (!this.graphBuilder.addNode(target)) continue;;
        addedNodes.add(target);

        String linkId = LinkIdFactory.getLinkId(propertyUri, source.getId(), target.getId())
        LabeledLink link = new DataPropertyLink(linkId, new Label(propertyUri));
        if (!this.graphBuilder.addLink(source, target, link)) continue;;

        SemanticTypeMapping mp = new SemanticTypeMapping(sourceColumn, semanticType, (InternalNode)source, link, target);
        mappings.add(mp);
View Full Code Here

TOP

Related Classes of edu.isi.karma.rep.alignment.ColumnNode

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.