Package edu.isi.karma.modeling.alignment.learner

Examples of edu.isi.karma.modeling.alignment.learner.CandidateSteinerSets


    for (Node n : steinerNodes)
      if (n instanceof ColumnNode)
        columnNodes.add((ColumnNode)n);
   
    logger.info("finding candidate steiner sets ... ");
    CandidateSteinerSets candidateSteinerSets = getCandidateSteinerSets(steinerNodes, useCorrectTypes, numberOfCandidates, addedNodes);

    if (candidateSteinerSets == null ||
        candidateSteinerSets.getSteinerSets() == null ||
        candidateSteinerSets.getSteinerSets().isEmpty()) {
      logger.error("there is no candidate set of steiner nodes.");
     
      DirectedWeightedMultigraph<Node, LabeledLink> tree =
          new DirectedWeightedMultigraph<Node, LabeledLink>(LabeledLink.class);
     
      for (Node n : steinerNodes)
        tree.addVertex(n);
     
      SemanticModel sm = new SemanticModel(new RandomGUID().toString(), tree);
      SortableSemanticModel sortableSemanticModel = new SortableSemanticModel(sm, null);
      sortableSemanticModels.add(sortableSemanticModel);
      return sortableSemanticModels;
    }
   
    logger.info("graph nodes: " + this.graphBuilder.getGraph().vertexSet().size());
    logger.info("graph links: " + this.graphBuilder.getGraph().edgeSet().size());

    logger.info("number of steiner sets: " + candidateSteinerSets.numberOfCandidateSets());

//    logger.info("updating weights according to training data ...");
//    long start = System.currentTimeMillis();
//    this.updateWeights();
//    long updateWightsElapsedTimeMillis = System.currentTimeMillis() - start;
//    logger.info("time to update weights: " + (updateWightsElapsedTimeMillis/1000F));
   
    logger.info("computing steiner trees ...");
    int number = 1;
    for (SteinerNodes sn : candidateSteinerSets.getSteinerSets()) {
      if (sn == null) continue;
      logger.debug("computing steiner tree for steiner nodes set " + number + " ...");
      logger.debug(sn.getScoreDetailsString());
      number++;
//      logger.info("START ...");
View Full Code Here


    if (steinerNodes == null || steinerNodes.isEmpty())
      return null;

    int maxNumberOfSteinerNodes = steinerNodes.size() * 2;
    CandidateSteinerSets candidateSteinerSets = new CandidateSteinerSets(maxNumberOfSteinerNodes);

    if (addedNodes == null)
      addedNodes = new HashSet<Node>();

    Set<SemanticTypeMapping> tempSemanticTypeMappings;
    HashMap<ColumnNode, List<SemanticType>> columnSemanticTypes = new HashMap<ColumnNode, List<SemanticType>>();
    HashMap<String, Integer> semanticTypesCount = new HashMap<String, Integer>();
    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.getDomainNode() != null) {
          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);
      logger.debug("number of candidate steiner sets after update: " + candidateSteinerSets.getSteinerSets().size());
    }

    for (Node n : steinerNodes) {
      if (n instanceof InternalNode) {
        candidateSteinerSets.updateSteinerSets((InternalNode)n);
      }
    }
   
    //    System.out.println("number of possible mappings: " + numOfMappings);
    logger.info("number of possible mappings: " + numOfMappings);
View Full Code Here

TOP

Related Classes of edu.isi.karma.modeling.alignment.learner.CandidateSteinerSets

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.