public List<SemanticType> getSuggestedTypes(OntologyManager ontologyManager, ColumnNode columnNode, SemanticTypeColumnModel columnModel) { ArrayList<SemanticType> suggestedSemanticTypes = new ArrayList<>(); if (columnModel == null) return suggestedSemanticTypes; for (Entry<String, Double> entry : columnModel.getScoreMap().entrySet()) { String key = entry.getKey(); Double confidence = entry.getValue(); if (key == null || key.isEmpty()) continue; String[] parts = key.split("\\|"); if (parts == null || parts.length != 2) continue; String domainUri = parts[0].trim(); String propertyUri = parts[1].trim(); Label domainLabel = ontologyManager.getUriLabel(domainUri); if (domainLabel == null) continue; Label propertyLabel = ontologyManager.getUriLabel(propertyUri); if (propertyLabel == null) continue; SemanticType semanticType = new SemanticType(columnNode.getHNodeId(), propertyLabel, domainLabel, null, false, Origin.TfIdfModel, confidence); logger.info("\t" + propertyUri + " of " + domainUri + ": " + confidence); suggestedSemanticTypes.add(semanticType); } Collections.sort(suggestedSemanticTypes, Collections.reverseOrder()); return suggestedSemanticTypes; }
private static SemanticType readSemanticType(JsonReader reader) throws IOException { String hNodeId = null; Label domain = null; Label type = null; Origin origin = null; Double confidenceScore = null; reader.beginObject(); while (reader.hasNext()) { String key = reader.nextName(); if (key.equals("hNodeId") && reader.peek() != JsonToken.NULL) { hNodeId = reader.nextString(); } else if (key.equals("domain") && reader.peek() != JsonToken.NULL) { domain = readLabel(reader); } else if (key.equals("type") && reader.peek() != JsonToken.NULL) { type = readLabel(reader); } else if (key.equals("origin") && reader.peek() != JsonToken.NULL) { origin = Origin.valueOf(reader.nextString()); } else if (key.equals("confidenceScore") && reader.peek() != JsonToken.NULL) { confidenceScore = reader.nextDouble(); } else { reader.skipValue(); } } reader.endObject(); SemanticType semanticType = new SemanticType(hNodeId, type, domain, null, false, origin, confidenceScore); return semanticType; }
if (propertyLabel == null) continue; SemanticType semanticType = new SemanticType(hNodeId, propertyLabel, domainLabel, null, false, Origin.TfIdfModel, confidence); logger.info("\t" + propertyUri + " of " + domainUri + ": " + confidence); suggestedSemanticTypes.add(semanticType);
public void setLearnedSemanticTypes(List<SemanticType> learnedSemanticTypes) { double sum = 0.0; // normalizing the confidence scores if (learnedSemanticTypes != null) { for (SemanticType st : learnedSemanticTypes) { sum += st.getConfidenceScore() != null ? st.getConfidenceScore().doubleValue() : 0.0; } double confidence; this.learnedSemanticTypes = new ArrayList<>(); for (SemanticType st : learnedSemanticTypes) { confidence = st.getConfidenceScore() != null ? st.getConfidenceScore() : 0.0; SemanticType semType = new SemanticType(st.getHNodeId(), st.getType(), st.getDomain(), st.getDomainId(), st.isProvenance(), st.getOrigin(), confidence / sum); this.learnedSemanticTypes.add(semType); } } if (this.learnedSemanticTypes != null) Collections.sort(this.learnedSemanticTypes, Collections.reverseOrder()); }
type = new SemanticType(hNodeId, typeName, domainName, domainId, false, Origin.User, 1.00); worksheet.getSemanticTypes().addType(type);
type = new SemanticType(hNodeId, typeName, domainName, domainId, false, Origin.User, 1.00); worksheet.getSemanticTypes().addType(type);
private void setUserTypesForColumnNodes() { if (this.graph == null) return; 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) { for (LabeledLink link : incomingLinks) { Node domain = link.getSource(); SemanticType st = new SemanticType(cn.getHNodeId(), link.getLabel(), domain.getLabel(), domain.getId(), false, Origin.User, 1.0); cn.assignUserType(st); } } else logger.debug("The column node " + ((ColumnNode)n).getColumnName() + " does not have any domain or it has more than one domain."); } }
SemanticType newType = new SemanticType(hNodeId, linkLabel, source.getLabel(), source.getId(), isProvenance, SemanticType.Origin.User, 1.0);
SemanticType st = new SemanticType(((ColumnNode)target).getHNodeId(), newLink.getLabel(), source.getLabel(), source.getId(), false,
SemanticType type = new SemanticType(hNode.getId(), propertyLabel, internalNodeLabel, classNode.getId(), false, SemanticType.Origin.User, 1.0); worksheet.getSemanticTypes().addType(type);
newType = new SemanticType(hNodeId, ClassInstanceLink.getFixedLabel(), classNode.getLabel(), classNode.getId(), newType = new SemanticType(hNodeId, DataPropertyOfColumnLink.getFixedLabel(), classInstanceNode.getLabel(), newType = new SemanticType(hNodeId, ObjectPropertySpecializationLink.getFixedLabel(), classInstanceNode.getLabel(), newType = new SemanticType(hNodeId, ColumnSubClassLink.getFixedLabel(), classNode.getLabel(), classNode.getId(), false, SemanticType.Origin.User, 1.0);