Package edu.isi.karma.rep.alignment

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


    if (n == null)
      return null;

    List<SemanticType> types = new ArrayList<>();

    SemanticType userSelectedType = n.getUserSelectedSemanticType();
    if (useCorrectType && userSelectedType != null) {
      double probability = 1.0;
      SemanticType newType = new SemanticType(
          userSelectedType.getHNodeId(),
          userSelectedType.getType(),
          userSelectedType.getDomain(),
          userSelectedType.getOrigin(),
          probability
View Full Code Here


      return;

    int numberOfAttributesWhoseTypeIsFirstCRFType = 0;
    int numberOfAttributesWhoseTypeIsInCRFTypes = 0;
    for (ColumnNode cn : columnNodes) {
      SemanticType userSelectedType = cn.getUserSelectedSemanticType();
      List<SemanticType> top4Suggestions = cn.getTopKSuggestions(4);

      for (int i = 0; i < top4Suggestions.size(); i++) {
        SemanticType st = top4Suggestions.get(i);
        if (userSelectedType != null &&
            st.getModelLabelString().equalsIgnoreCase(userSelectedType.getModelLabelString())) {
          if (i == 0) numberOfAttributesWhoseTypeIsFirstCRFType ++;
          numberOfAttributesWhoseTypeIsInCRFTypes ++;
          break;
        }
      }
View Full Code Here

      Node obj = uri2Classes.get(objStr);
      if (obj == null) {
        if (objStr.startsWith(attPrefix)) {
          id = new RandomGUID().toString();
          obj = new ColumnNode(id, objStr, objStr, null);
          SemanticType semanticType = new SemanticType(((ColumnNode)obj).getHNodeId(),
              new Label(predicateStr),
              subj.getLabel(),
              Origin.User,
              1.0);
          ((ColumnNode)obj).setUserSelectedSemanticType(semanticType);
View Full Code Here

    String columnName = null;
    Label rdfLiteralType = null;
    Label datatype = null;
    String value = null;
    boolean isUri = false;
    SemanticType userSelectedSemanticType = null;
    List<SemanticType> suggestedSemanticTypes = null;
    Set<String> modelIds = null;
   
    reader.beginObject();
      while (reader.hasNext()) {
        String key = reader.nextName();
      if (key.equals("id") && reader.peek() != JsonToken.NULL) {
        id = reader.nextString();
      } else if (key.equals("label") && reader.peek() != JsonToken.NULL) {
        label = readLabel(reader);
      } else if (key.equals("type") && reader.peek() != JsonToken.NULL) {
        type = NodeType.valueOf(reader.nextString());
      } else if (key.equals("hNodeId") && reader.peek() != JsonToken.NULL) {
        hNodeId = reader.nextString();
      } else if (key.equals("columnName") && reader.peek() != JsonToken.NULL) {
        columnName = reader.nextString();
      } else if (key.equals("datatype") && reader.peek() != JsonToken.NULL) {
        datatype = readLabel(reader);
      } else if (key.equals("value") && reader.peek() != JsonToken.NULL) {
        value = reader.nextString();
      } else if (key.equals("isUri") && reader.peek() != JsonToken.NULL) {
        isUri = Boolean.parseBoolean(reader.nextString());
      } else if (key.equals("rdfLiteralType") && reader.peek() != JsonToken.NULL) {
        rdfLiteralType = readLabel(reader);
      } else if (key.equals("userSelectedSemanticType") && reader.peek() != JsonToken.NULL) {
        userSelectedSemanticType = readSemanticType(reader);
      } else if (key.equals("suggestedSemanticTypes") && reader.peek() != JsonToken.NULL) {
        suggestedSemanticTypes = new ArrayList<SemanticType>();
        reader.beginArray();
          while (reader.hasNext()) {
            SemanticType semanticType = readSemanticType(reader);
            suggestedSemanticTypes.add(semanticType);
        }
          reader.endArray();       
      } else if (key.equals("modelIds") && reader.peek() != JsonToken.NULL) {
        modelIds = readModelIds(reader);
View Full Code Here

        reader.skipValue();
      }
    }
      reader.endObject();
     
      SemanticType semanticType = new SemanticType(hNodeId, type, domain, origin, confidenceScore);
      return semanticType; 
    }
View Full Code Here

     
      this.getGraphBuilder().addLink(source, target, newLink); // returns false if link already exists
      tree.addEdge(source, target, newLink);
           
      if (target instanceof ColumnNode) {
        SemanticType st = new SemanticType(((ColumnNode)target).getHNodeId(),
            newLink.getLabel(), source.getLabel(), SemanticType.Origin.User, 1.0);
        semanticTypes.add(st);
      }
     
    }
View Full Code Here

      if (columnNodeIncomingLinks == null || columnNodeIncomingLinks.isEmpty()) { // SemanticType not yet assigned
        Label propertyLabel = new Label(ns + columnName, ns, "karma");
        alignment.addDataPropertyLink(classNode, columnNode, propertyLabel);
       
        // Create a semantic type object
        SemanticType type = new SemanticType(hNode.getId(), propertyLabel, internalNodeLabel, SemanticType.Origin.User, 1.0);
        worksheet.getSemanticTypes().addType(type);
        columnNode.setUserSelectedSemanticType(type);
      } else {
        // User-defined: do nothing
      }
View Full Code Here

        String nodeId = node.getId();

        writer.object();

        // Check if a semantic type exists for the HNode
        SemanticType type = types.getSemanticTypeForHNodeId(nodeId);
        if (type != null && type.getConfidenceLevel() != SemanticType.ConfidenceLevel.Low) {
          writer.key(JsonKeys.HNodeId.name())
              .value(type.getHNodeId())
              .key(JsonKeys.SemanticTypesArray.name()).array();
         
          ColumnNode alignmentColumnNode = hNodeIdTocolumnNodeMap.get(type.getHNodeId());
          InternalNode domainNode = hNodeIdToDomainNodeMap.get(type.getHNodeId());
         
          if (alignmentColumnNode == null || domainNode == null) {
            logger.error("Column node or domain node not found in alignment." +
                " (This should not happen conceptually!):" + type);
            continue;
          }
         
          // Add the primary semantic type
          writer.object()
              .key(JsonKeys.Origin.name())
              .value(type.getOrigin().name())
              .key(JsonKeys.ConfidenceLevel.name())
              .value(type.getConfidenceLevel().name())
              .key(JsonKeys.isPrimary.name())
              .value(true);
         
          // Add the RDF literal type to show in the text box
          String rdfLiteralType = alignmentColumnNode.getRdfLiteralType() == null? "" :
            alignmentColumnNode.getRdfLiteralType().getDisplayName();
          writer.key(JsonKeys.rdfLiteralType.name())
            .value(rdfLiteralType);
         
//          String domainDisplayLabel = (domainNode.getLabel().getPrefix() != null && (!domainNode.getLabel().getPrefix().equals(""))) ?
//              (domainNode.getLabel().getPrefix() + ":" + domainNode.getLocalId()) : domainNode.getLocalId();
          if (!type.isClass()) {
            writer
              .key(JsonKeys.FullType.name()).value(type.getType().getUri())
              .key(JsonKeys.DisplayLabel.name()).value(type.getType().getDisplayName())
              .key(JsonKeys.DomainId.name()).value(domainNode.getId())
              .key(JsonKeys.DomainUri.name()).value(domainNode.getUri())
              .key(JsonKeys.DisplayDomainLabel.name()).value(domainNode.getDisplayId());
          } else {
            writer
              .key(JsonKeys.FullType.name()).value(domainNode.getId())
              .key(JsonKeys.DisplayLabel.name()).value(domainNode.getDisplayId())
              .key(JsonKeys.DomainId.name()).value("")
              .key(JsonKeys.DomainUri.name()).value("")
              .key(JsonKeys.DisplayDomainLabel.name())
              .value("");
          }
         
          // Mark the special properties
          writer
            .key(JsonKeys.isMetaProperty.name())
            .value(isMetaProperty(type.getType(), alignmentColumnNode));
         
         
          writer.endObject();

          // Iterate through the synonym semantic types
View Full Code Here

TOP

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

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.