public SemanticModel getBaseModel() { return new SemanticModel(this); }
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; }
public static void main(String[] args) throws Exception { List<SemanticModel> semanticModels = null; try { semanticModels = importSemanticModelsFromJsonFiles(Params.MODEL_DIR, Params.MODEL_MAIN_FILE_EXT); if (semanticModels != null) { for (SemanticModel sm : semanticModels) { sm.print(); sm.writeGraphviz(Params.GRAPHVIS_DIR + sm.getName() + Params.GRAPHVIS_MAIN_FILE_EXT, true, true); } } } catch (IOException e) { e.printStackTrace(); } }
public SemanticModel(String id, DirectedWeightedMultigraph<Node, LabeledLink> graph) { this.id = id; this.graph = graph; // this.selection = SuperSelectionManager.DEFAULT_SELECTION; // this.setLearnedTypesForColumnNodes(); this.setUserTypesForColumnNodes(); this.sourceColumns = this.getColumnNodes(); this.mappingToSourceColumns = new HashMap<>(); for (ColumnNode c : this.sourceColumns) this.mappingToSourceColumns.put(c, c); }
SemanticModel semanticModel = new SemanticModel(workspace, worksheet, worksheetName, alignment.getSteinerTree(), selection); semanticModel.setName(worksheetName); try { semanticModel.writeJson(contextParameters.getParameterValue(ContextParameter.JSON_MODELS_DIR) + semanticModel.getName() + ".model.json"); } catch (Exception e) { semanticModel.writeGraphviz(contextParameters.getParameterValue(ContextParameter.GRAPHVIZ_MODELS_DIR) + semanticModel.getName() + ".model.dot", false, false); } catch (Exception e) {
reader.beginArray(); while (reader.hasNext()) { ColumnNode cn = readSourceColumn(reader); if (cn != null) { sourceColumns.add(cn); reader.beginArray(); while (reader.hasNext()) { oneEntryMapping = readMappingToSourceColumn(reader); if (oneEntryMapping != null && oneEntryMapping.size() == 1) mappingToSourceColumnsIds.putAll(oneEntryMapping); SemanticModel semanticModel = new SemanticModel(id, GraphUtil.asLabeledGraph(graph), sourceColumns, mappingToSourceColumns); semanticModel.setName(name); semanticModel.setDescription(description);
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(); if (targetNodeIdSets == null) return null; for (HashMap<Node,String> targetNodeIds : targetNodeIdSets) { targetTriples = getTriples(this.getGraph(), targetNodeIds, ignoreSemanticTypes, ignoreColumnNodes); precision = getPrecision(baseTriples, targetTriples); recall = getRecall(baseTriples, targetTriples); jaccard = getJaccard(baseTriples, targetTriples); fmeasure = 2 * precision * recall / (precision + recall); if (fmeasure > bestFMeasure) {
private void writeModel(JsonWriter writer) throws IOException { String nullStr = null; writer.beginObject(); writer.name("id").value(this.getId()); writer.name("name").value(this.getName()); writer.name("description").value(this.getDescription()); writer.name("sourceColumns"); if (this.sourceColumns == null) writer.value(nullStr); writer.beginArray(); for (ColumnNode cn : this.sourceColumns) { writeSourceColumn(writer, cn); writer.beginArray(); for (Entry<ColumnNode, ColumnNode> mapping : this.mappingToSourceColumns.entrySet()) { writeMappingToSourceColumn(writer, mapping);
public ModelEvaluation evaluate_old(SemanticModel baseModel) { if (baseModel == null || baseModel.getGraph() == null || this.getGraph() == null) return new ModelEvaluation(null, null, null, null); Double distance = getDistance(baseModel); Integer count; for (GraphPath gp : basePaths) { pathStr = getPathString(baseModel, gp); count = visitedPaths.get(pathStr); if (count == null) count = 1; else count++; pathStr = getPathString(this, gp); count = visitedPaths.get(pathStr); if (count == null) count = 1; else count++; Double precision = getPrecision(basePathString, modelPathString); Double recall = getRecall(basePathString, modelPathString);
public void print() { logger.info("id: " + this.getId()); logger.info("name: " + this.getName()); logger.info("description: " + this.getDescription()); logger.info(GraphUtil.labeledGraphToString(this.graph)); }
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(); }
return null; String modelId = model.getId(); if (this.graphBuilder.getModelIds().contains(modelId)) { logger.debug(model.getId() + " --> number of mappings: " + mappings.size()); 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;
logger.info(newSource.getName() + "(#attributes:" + newSource.getColumnNodes().size() + ")"); System.out.println(newSource.getName() + "(#attributes:" + newSource.getColumnNodes().size() + ")"); logger.info("======================================================"); resultsArray[0].append(newSource.getName() + "(" + newSource.getColumnNodes().size() + ")" + "\t" + " " + "\t" + " "); if (resultsArray[1].length() > 0) resultsArray[1].append(" \t "); resultsArray[1].append("p \t r \t t"); List<ColumnNode> columnNodes = correctModel.getColumnNodes(); graphPath + semanticModels.get(newSourceIndex).getName() + Params.GRAPH_JSON_FILE_EXT : graphPath + semanticModels.get(newSourceIndex).getName() + ".knownModels=" + numberOfKnownModels + Params.GRAPH_JSON_FILE_EXT; outputPath + semanticModels.get(newSourceIndex).getName() + Params.GRAPHVIS_OUT_DETAILS_FILE_EXT : outputPath + semanticModels.get(newSourceIndex).getName() + ".knownModels=" + numberOfKnownModels + Params.GRAPHVIS_OUT_DETAILS_FILE_EXT; newSource.getName(), outName, GraphVizLabelType.LocalId,
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);
@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); } }
public SemanticModel getModel() { if (this.semanticModel == null) try { this.learn(); } catch (Exception e) { logger.error("error in learing the semantic model for the source " + ((this.semanticModel == null) ? "" : this.semanticModel.getId())); e.printStackTrace(); } return this.semanticModel; }
public ModelEvaluation evaluate(SemanticModel baseModel) { return evaluate(baseModel, false, false); }
public SemanticModel(String id, DirectedWeightedMultigraph<Node, LabeledLink> graph, boolean suggestSemanticTypes) { this.id = id; this.graph = graph; this.sourceColumns = this.getColumnNodes(); this.mappingToSourceColumns = new HashMap<>(); for (ColumnNode c : this.sourceColumns) this.mappingToSourceColumns.put(c, c); }