@SuppressWarnings("unused") private static void getStatistics1(List<SemanticModel> semanticModels) { for (int i = 0; i < semanticModels.size(); i++) { SemanticModel source = semanticModels.get(i); int attributeCount = source.getColumnNodes().size(); int nodeCount = source.getGraph().vertexSet().size(); int linkCount = source.getGraph().edgeSet().size(); int datanodeCount = 0; int classNodeCount = 0; for (Node n : source.getGraph().vertexSet()) { if (n instanceof InternalNode) classNodeCount++; if (n instanceof ColumnNode) datanodeCount++; } System.out.println(attributeCount + "\t" + nodeCount + "\t" + linkCount + "\t" + classNodeCount + "\t" + datanodeCount); List<ColumnNode> columnNodes = source.getColumnNodes(); getStatistics2(columnNodes); } }
for (Node n : model.getGraph().vertexSet()) { sortedNodes.add(n);
private void addInternalNodes(SemanticModel model, Set<InternalNode> addedNodes) { if (model == null || model.getGraph() == null) return; if (addedNodes == null) addedNodes = new HashSet<>(); HashMap<String, Integer> uriCount = new HashMap<>(); for (Node n : model.getGraph().vertexSet()) { if (n instanceof InternalNode) { Integer count = uriCount.get(n.getUri()); if (count == null) uriCount.put(n.getUri(), 1); else uriCount.put(n.getUri(), count.intValue() + 1); } } for (Map.Entry<String, Integer> stringIntegerEntry : uriCount.entrySet()) { int modelNodeCount = stringIntegerEntry.getValue(); Set<Node> matchedNodes = this.graphBuilder.getUriToNodesMap().get(stringIntegerEntry.getKey()); int graphNodeCount = matchedNodes == null ? 0 : matchedNodes.size(); for (int i = 0; i < modelNodeCount - graphNodeCount; i++) { String id = this.nodeIdFactory.getNodeId(stringIntegerEntry.getKey()); Node n = new InternalNode(id, new Label(stringIntegerEntry.getKey())); if (this.graphBuilder.addNode(n)) addedNodes.add((InternalNode)n); } } }
private HashMap<Node,Set<Node>> addInternalNodes(SemanticModel model, Set<InternalNode> addedNodes) { if (model == null || model.getGraph() == null) return null; for (Node n : model.getGraph().vertexSet()) { if (n instanceof InternalNode) { Integer count = uriCount.get(n.getUri()); for (Node n : model.getGraph().vertexSet()) { if (n instanceof InternalNode) { Set<Node> matchedNodes = this.graphBuilder.getUriToNodesMap().get(n.getUri());
public ModelEvaluation evaluate(SemanticModel baseModel, boolean ignoreSemanticTypes, boolean ignoreColumnNodes) { if (baseModel == null || baseModel.getGraph() == null || this.getGraph() == null) return new ModelEvaluation(null, null, null, null); for (Node n : baseModel.getGraph().vertexSet()) { if (n instanceof InternalNode) baseNodeIds.put(n, nodeIdFactory.getNodeId(n.getUri())); Set<String> baseTriples = getTriples(baseModel.getGraph(), baseNodeIds, ignoreSemanticTypes, ignoreColumnNodes); Set<String> targetTriples; List<HashMap<Node,String>> targetNodeIdSets = getPossibleNodeIdSets(); for (HashMap<Node,String> targetNodeIds : targetNodeIdSets) { targetTriples = getTriples(this.getGraph(), targetNodeIds, ignoreSemanticTypes, ignoreColumnNodes); precision = getPrecision(baseTriples, targetTriples); recall = getRecall(baseTriples, targetTriples);
private HashMap<Node,Node> getColumnNodeMapping(SemanticModel model, HashMap<Node,Node> internalNodeMapping) { if (model == null || model.getGraph() == null) return null; for (Node n : model.getGraph().vertexSet()) { if (n instanceof ColumnNode) { ColumnNode c = (ColumnNode)n; Set<LabeledLink> domainLinks = GraphUtil.getDomainLinksInLabeledGraph(model.getGraph(), (ColumnNode)n); if (domainLinks == null || domainLinks.isEmpty()) continue;
private List<HashMap<Node,String>> getPossibleNodeIdSets() { DirectedWeightedMultigraph<Node, LabeledLink> g = this.getGraph(); List<HashMap<Node,String>> nodeIdSets = new ArrayList<>(); if (g == null)
for(Entry<String,SemanticModel> entry : models.entrySet()) { if (entry.getKey() == "1-correct model") { cluster = GraphVizUtil.convertToGraphviz(GraphUtil.asDefaultGraph(entry.getValue().getGraph()), entry.getValue().getMappingToSourceColumns(), false, nodeLabelType, linkLabelType, false, false); } else { cluster = GraphVizUtil.convertToGraphviz(GraphUtil.asDefaultGraph(entry.getValue().getGraph()), entry.getValue().getMappingToSourceColumns(), false, nodeLabelType, linkLabelType, showNodeMetaData, showLinkMetaData);
public SemanticModel(SemanticModel semanticModel) { this.id = semanticModel.getId(); this.name = semanticModel.getName(); this.description = semanticModel.getDescription(); this.graph = semanticModel.getGraph(); this.sourceColumns = semanticModel.getSourceColumns(); this.mappingToSourceColumns = semanticModel.getMappingToSourceColumns(); // this.selection = SuperSelectionManager.DEFAULT_SELECTION; }
HashMap<Node,Set<LabeledLink>> graphNodeDomains) { if (model == null || model.getGraph() == null) return null; for (Node n : model.getGraph().vertexSet()) { if (n instanceof ColumnNode) { Set<LabeledLink> domainLinks = GraphUtil.getDomainLinksInLabeledGraph(model.getGraph(), (ColumnNode)n); if (domainLinks == null || domainLinks.isEmpty()) continue; for (Node n : model.getGraph().vertexSet()) { Set<Node> matches = new HashSet<>(); if (n instanceof ColumnNode) {
for (LabeledLink e : model.getGraph().edgeSet()) { double newW = model.getGraph().getEdgeWeight(e); if (newW < currentW) this.graphBuilder.changeLinkWeight(l, newW); if (!this.graphBuilder.addLink(n1, n2, link, model.getGraph().getEdgeWeight(e))) continue; } else { if (!this.graphBuilder.addLink(n1, n2, link, ModelingParams.PATTERN_LINK_WEIGHT)) continue;
public static void exportSemanticModelToGraphviz( SemanticModel model, GraphVizLabelType nodeLabelType, GraphVizLabelType linkLabelType, boolean showNodeMetaData, boolean showLinkMetaData, String filename) throws IOException { OutputStream out = new FileOutputStream(filename); org.kohsuke.graphviz.Graph graphViz = new org.kohsuke.graphviz.Graph(); graphViz.attr("fontcolor", "blue"); graphViz.attr("remincross", "true"); graphViz.attr("label", model.getName() == null ? "" : model.getName()); // graphViz.attr("page", "8.5,11"); org.kohsuke.graphviz.Graph gViz = convertToGraphviz(GraphUtil.asDefaultGraph(model.getGraph()), model.getMappingToSourceColumns(), false, nodeLabelType, linkLabelType, showNodeMetaData, showLinkMetaData); gViz.attr("label", "model"); gViz.id("cluster"); graphViz.subGraph(gViz); graphViz.writeTo(out); out.close(); }
if (columnNodeMapping != null) mapping.putAll(columnNodeMapping); for (LabeledLink e : model.getGraph().edgeSet()) { if (weightSystem == PatternWeightSystem.OriginalWeights) { double currentW = l.getWeight(); double newW = model.getGraph().getEdgeWeight(e); if (newW < currentW) this.graphBuilder.changeLinkWeight(l, newW); if (!this.graphBuilder.addLink(n1, n2, link, model.getGraph().getEdgeWeight(e))) continue; } else { if (!this.graphBuilder.addLink(n1, n2, link, ModelingParams.PATTERN_LINK_WEIGHT)) continue;
for (LabeledLink e : model.getGraph().edgeSet()) {