edu.isi.karma.modeling.alignment.Alignment类的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(13.7k)|赞(0)|评价(0)|浏览(106)

本文整理了Java中edu.isi.karma.modeling.alignment.Alignment类的一些代码示例,展示了Alignment类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Alignment类的具体详情如下:
包路径:edu.isi.karma.modeling.alignment.Alignment
类名称:Alignment

Alignment介绍

暂无

代码示例

代码示例来源:origin: usc-isi-i2/Web-Karma

System.out.println(s);
  Alignment al = new Alignment(mgr);
  ColumnNode c1 = al.addColumnNode("h1", "c1", null, null);
  ColumnNode c2 = al.addColumnNode("h2", "c2", null, null);
  InternalNode n1 = al.addInternalNode(new Label("http://example.com/layout/C01_"));
  InternalNode n2 = al.addInternalNode(new Label("http://example.com/layout/C02_"));
  al.addDataPropertyLink(n1, c1, new Label("http://example.com/layout/d1"), false);
  al.addDataPropertyLink(n2, c2, new Label("http://example.com/layout/d2"), false);
  al.align();
  System.out.println(GraphUtil.labeledGraphToString(al.getSteinerTree()));
} else {
  logger.info("No directory for preloading ontologies exists.");

代码示例来源:origin: usc-isi-i2/Web-Karma

public Set<LabeledLink> getCurrentIncomingLinksToNode(String nodeId) {
  Node node = this.getNodeById(nodeId);
  if (node == null)
    return null;
  
  return this.graphBuilder.getIncomingLinksMap().get(nodeId);
}

代码示例来源:origin: usc-isi-i2/Web-Karma

if(alignment == null || alignment.isEmpty()) {
  logger.error("Alignment cannot be null before calling this command since the alignment is created while " +
      "setting the semantic types.");
oldAlignment = alignment.getAlignmentClone();
oldGraph = (DirectedWeightedMultigraph<Node, DefaultLink>)alignment.getGraph().clone();
Set<LabeledLink> currentLinks = alignment.getCurrentIncomingLinksToNode(LinkIdFactory.getLinkTargetId(edgeId));
if (currentLinks != null && !currentLinks.isEmpty()) {
  for (LabeledLink currentLink: currentLinks) {
      alignment.changeLinkStatus(currentLink.getId(), LinkStatus.Normal);
alignment.changeLinkStatus(edgeId, LinkStatus.ForcedByUser);
if(!this.isExecutedInBatch())
  alignment.align();

代码示例来源:origin: usc-isi-i2/Web-Karma

public void deleteForcedInternalNode(String nodeId) {
    Node node = getNodeById(nodeId);
    if(node != null) {
      this.removeNode(nodeId);
//            if (this.graphBuilder.removeNode(node))
//                this.steinerTree.removeVertex(node);
    }
  }

代码示例来源:origin: usc-isi-i2/Web-Karma

private void addProvenaceLinks(Alignment alignment, Label linkLabel, LiteralNode targetNode) {
  String targetId = targetNode.getId();
  Set<Node> internalNodes = alignment.getNodesByType(NodeType.InternalNode);
  String edgeUri = linkLabel.getUri();
  
  for(Node internalNode : internalNodes) {
    String nodeId = internalNode.getId();
    Set<LabeledLink> inLinks = alignment.getIncomingLinksInTree(nodeId);
    Set<LabeledLink> outLinks = alignment.getOutgoingLinksInTree(nodeId);
    if((inLinks != null && inLinks.size() > 0) 
        || (outLinks != null && outLinks.size() > 0)) {
      String linkId = LinkIdFactory.getLinkId(edgeUri, nodeId, targetId);
      LabeledLink link = alignment.getLinkById(linkId);
      if(link == null) {
        link = alignment.addObjectPropertyLink(internalNode,
            targetNode, linkLabel);
        alignment.changeLinkStatus(linkId, LinkStatus.ForcedByUser);
        link.setProvenance(true, false);
      }
    }
  }
}

代码示例来源:origin: usc-isi-i2/Web-Karma

@SuppressWarnings("unchecked")
@Override
public UpdateContainer doIt(Workspace workspace) throws CommandException {
  logCommand(logger, workspace);

  Alignment alignment = AlignmentManager.Instance().getAlignment(
      alignmentId);
  // Save the original alignment for undo
  oldAlignment = alignment.getAlignmentClone();
  oldGraph = (DirectedWeightedMultigraph<Node, DefaultLink>) alignment
      .getGraph().clone();
  try {
    alignment.deleteForcedInternalNode(nodeId);
    if(!this.isExecutedInBatch())
      alignment.align();
  } catch (JSONException e) {
    logger.error("Error adding Internal Node:" , e);
  }
  return WorksheetUpdateFactory.createSemanticTypesAndSVGAlignmentUpdates(worksheetId, workspace);
}

代码示例来源:origin: usc-isi-i2/Web-Karma

Alignment alignment = AlignmentManager.Instance().getAlignment(alignmentId);
if (alignment == null) {
  alignment = new Alignment(ontMgr);
  AlignmentManager.Instance().addAlignmentToMap(alignmentId, alignment);
oldAlignment = alignment.getAlignmentClone();
oldGraph = (DirectedWeightedMultigraph<Node, DefaultLink>)alignment.getGraph().clone();
ColumnNode columnNode = alignment.getColumnNodeByHNodeId(hNodeId);
columnNode.setRdfLiteralType(rdfLiteralType);
columnNode.setLanguage(language);
List<LabeledLink> columnNodeIncomingLinks = alignment.getGraphBuilder().getIncomingLinks(columnNode.getId());
if (columnNodeIncomingLinks != null) { 
  for(LabeledLink oldIncomingLinkToColumnNode : columnNodeIncomingLinks) {
    Node oldDomainNode = oldIncomingLinkToColumnNode.getSource();
    alignment.removeLink(oldIncomingLinkToColumnNode.getId());
    if (alignment.isNodeIsolatedInTree(oldDomainNode.getId()))
      alignment.removeNode(oldDomainNode.getId());
      Set<Node> internalNodes = alignment.getNodesByType(NodeType.InternalNode);
      if(internalNodes != null) {
        for(Node internalNode : internalNodes) {
          String nodeId = internalNode.getId();
          Set<LabeledLink> inLinks = alignment.getIncomingLinksInTree(nodeId);
          Set<LabeledLink> outLinks = alignment.getOutgoingLinksInTree(nodeId);
          if((inLinks != null && inLinks.size() > 0) 
              || (outLinks != null && outLinks.size() > 0)) {

代码示例来源:origin: usc-isi-i2/Web-Karma

alignmentId);
if (alignment == null) {
  alignment = new Alignment(ontMgr);
  AlignmentManager.Instance().addAlignmentToMap(alignmentId, alignment);
oldAlignment = alignment.getAlignmentClone();
oldGraph = (DirectedWeightedMultigraph<Node, DefaultLink>) alignment
    .getGraph().clone();
ColumnNode columnNode = alignment.getColumnNodeByHNodeId(hNodeId);
columnNode.setRdfLiteralType(rdfLiteralType);
columnNode.setLanguage(language);
List<LabeledLink> columnNodeIncomingLinks = alignment.getGraphBuilder().getIncomingLinks(columnNode.getId());
if (columnNodeIncomingLinks != null) { 
  for(LabeledLink oldIncomingLinkToColumnNode : columnNodeIncomingLinks) {
    Node oldDomainNode = oldIncomingLinkToColumnNode.getSource();
    alignment.removeLink(oldIncomingLinkToColumnNode.getId());
    if (alignment.isNodeIsolatedInTree(oldDomainNode.getId()))
      alignment.removeNode(oldDomainNode.getId());
  Node classNode = alignment.getNodeById(metaPropertyId);
    classNode = alignment.addInternalNode((InternalNode)classNode);
  LabeledLink newLink = alignment.addClassInstanceLink(classNode, columnNode,
      LinkKeyInfo.UriOfInstance);
  alignment.changeLinkStatus(newLink.getId(),
      LinkStatus.ForcedByUser);

代码示例来源:origin: usc-isi-i2/Web-Karma

initialAlignment = alignment.getAlignmentClone();
  initialGraph = (DirectedWeightedMultigraph<Node, DefaultLink>)alignment.getGraph().clone();
        continue;
      ColumnNode cn = alignment.getColumnNodeByHNodeId(hNodeId);
  alignment.setGraph(initialGraph);
  if(!this.isExecutedInBatch())
    alignment.align();
  AlignmentManager.Instance().addAlignmentToMap(alignmentId, alignment);
steinerNodes = alignment.computeSteinerNodes();
ModelLearner modelLearner;
  modelLearner = new ModelLearner(alignment.getGraphBuilder(), steinerNodes);
else
  modelLearner = new ModelLearner(ontologyManager, alignment.getLinksByStatus(LinkStatus.ForcedByUser), steinerNodes);
alignment.updateAlignment(model, semanticTypes);
logger.info(GraphUtil.labeledGraphToString(alignment.getSteinerTree()));

代码示例来源:origin: usc-isi-i2/Web-Karma

oldAlignment = alignment.getAlignmentClone();
oldGraph = (DirectedWeightedMultigraph<Node, DefaultLink>)alignment.getGraph().clone();
ColumnNode columnNode = alignment.getColumnNodeByHNodeId(hNodeId);
Set<LabeledLink> alignmentEdges = alignment.getCurrentIncomingLinksToNode(hNodeId);
for(LabeledLink edge: alignmentEdges) {
  String linkId = edge.getId();
  columnNode.setForced(false);
  LabeledLink currentLink = alignment.getLinkById(linkId);
  alignment.removeLink(linkId);
  Node domain = currentLink.getSource();
  if (domain != null) {
    String domainId = domain.getId();
    if (alignment.isNodeIsolatedInTree(domainId))
      alignment.removeNode(domainId);
  alignment.align();

代码示例来源:origin: usc-isi-i2/Web-Karma

oldAlignment = alignment.getAlignmentClone();
oldGraph = (DirectedWeightedMultigraph<Node, DefaultLink>) alignment
    .getGraph().clone();
OntologyManager ontMgr = workspace.getOntologyManager();
    nodeId = nodeUri + (alignment.getLastIndexOfNodeUri(nodeUri) + 1);
  Node addedNode = alignment.addInternalNode(node);
  if (addedNode != null)
    alignment.addToForcedNodes(addedNode);
  if(!this.isExecutedInBatch())
    alignment.align();

代码示例来源:origin: usc-isi-i2/Web-Karma

Alignment alignment = AlignmentManager.Instance().getAlignment(alignmentId);
if (alignment == null) {
  alignment = new Alignment(ontMgr);
  AlignmentManager.Instance().addAlignmentToMap(alignmentId, alignment);
Node classNode = alignment.addInternalNode(internalNodeLabel);
for (HNode hNode : sortedLeafHNodes){
  String columnName = hNode.getColumnName().trim().replaceAll(" ", "_");
  ColumnNode columnNode = alignment.getColumnNodeByHNodeId(hNode.getId());
  List<LabeledLink> columnNodeIncomingLinks = alignment.getGraphBuilder().getIncomingLinks(columnNode.getId());
  if (columnNodeIncomingLinks == null || columnNodeIncomingLinks.isEmpty()) { // SemanticType not yet assigned
    Label propertyLabel = new Label(ns + columnName, ns, "karma");
    alignment.addDataPropertyLink(classNode, columnNode, propertyLabel, false);
  alignment.align();

代码示例来源:origin: usc-isi-i2/Web-Karma

if (alignment != null && !alignment.isEmpty()) {
  for (Node node: alignment.getSteinerTree().vertexSet()) {
    if (node.getType() == NodeType.InternalNode) {
      steinerTreeNodeIds.add(node.getId());
      clazzLocalNameWithPrefix = domainURI.getUri() + "/" + domainURI.getLocalName();
    int graphLastIndex = alignment.getLastIndexOfNodeUri(domainURI.getUri());
    if (graphLastIndex == -1) { // No instance present in the graph
      insertSemanticTypeSuggestion(arr, clazzLocalNameWithPrefix + "1 (add)", 
            hasLastNodeFromSteinerTree = true;
        } else {
          Node graphNode = alignment.getNodeById(domainURI.getUri() + i);
          if (graphNode != null)
            insertSemanticTypeSuggestion(arr, clazzLocalNameWithPrefix + i + " (add)", 
    int graphLastIndex = alignment.getLastIndexOfNodeUri(typeURI.getUri());
    if (graphLastIndex == -1) { // No instance present in the graph
      insertSemanticTypeSuggestion(arr, "", "", "", clazzLocalNameWithPrefix + "1 (add)", 
              typeURI.getUri(), typeURI.getUri() + i, probability);
        } else {
          Node graphNode = alignment.getNodeById(typeURI.getUri() + i);
          if (graphNode != null)
            insertSemanticTypeSuggestion(arr, "", "", "", clazzLocalNameWithPrefix + i + " (add)",

代码示例来源:origin: usc-isi-i2/Web-Karma

private Map<Node,Boolean> getClassesInModel(Workspace workspace) {
  final Alignment alignment = AlignmentManager.Instance().getAlignment(
      workspace.getId(), worksheetId);
  Map<Node,Boolean> nodeSet = new HashMap<>();
  Set<Node> treeNodes = alignment.getSteinerTree().vertexSet();
  if (treeNodes != null) {
    for (Node n : treeNodes) {
      nodeSet.put(n, true);
    }
  }
  return nodeSet;
}

代码示例来源:origin: usc-isi-i2/Web-Karma

if (alignment != null && !alignment.isEmpty()) {
  for (Node node: alignment.getSteinerTree().vertexSet()) {
    if (node.getType() == NodeType.InternalNode) {
      steinerTreeNodeIds.add(node.getId());
    graphLastIndex = alignment.getLastIndexOfNodeUri(nodeUri);
    Set<Node> graphNodes = alignment.getNodesByUri(nodeUri);
    if (graphNodes != null && !graphNodes.isEmpty()) {
      for (Node graphNode: graphNodes) {

代码示例来源:origin: usc-isi-i2/Web-Karma

@SuppressWarnings("unchecked")
@Override
public UpdateContainer doIt(Workspace workspace) throws CommandException {
  Alignment alignment = AlignmentManager.Instance().getAlignment(
      alignmentId);
  OntologyManager ontMgr = workspace.getOntologyManager();
  // Save the original alignment for undo
  oldAlignment = alignment.getAlignmentClone();
  oldGraph = (DirectedWeightedMultigraph<Node, DefaultLink>) alignment
      .getGraph().clone();
  UpdateContainer uc = this.deleteLink(alignment, ontMgr, edge);
  if(!this.isExecutedInBatch())
    alignment.align();
  uc.append(this.computeAlignmentAndSemanticTypesAndCreateUpdates(workspace));
  return uc;
}

代码示例来源:origin: usc-isi-i2/Web-Karma

oldAlignment = alignment.getAlignmentClone();
oldGraph = (DirectedWeightedMultigraph<Node, DefaultLink>) alignment
    .getGraph().clone();
    final LiteralNode ln = alignment.addLiteralNode(literalValue, literalType, language, isUri);
    nodeId = ln.getId();
    alignment.updateLiteralNode(nodeId, literalValue, literalType, language, isUri);
    alignment.align();

代码示例来源:origin: usc-isi-i2/Web-Karma

Alignment alignment = AlignmentManager.Instance().getAlignment(workspace.getId(), worksheetId);
Set<String> steinerTreeNodeIds = new HashSet<>();
if (alignment != null && !alignment.isEmpty()) {
  DirectedWeightedMultigraph<Node, LabeledLink> steinerTree = alignment.getSteinerTree(); 
  for (Node node: steinerTree.vertexSet()) {
    if (node.getType() == NodeType.InternalNode) {
  temp = alignment.getLinksByType(LinkType.DataPropertyLink);
  if (temp != null) specializedLinks.addAll(temp);
  for (LabeledLink link:steinerTree.edgeSet()) 
properties.addAll(alignment.suggestAlternativeLinks(linkId));

代码示例来源:origin: usc-isi-i2/Web-Karma

if (alignment.getSteinerTree() != null) {
  for (LabeledLink link : alignment.getSteinerTree().edgeSet()) {
    if ((link.getStatus() == LinkStatus.Normal || link.getStatus() == LinkStatus.PreferredByUI) && (link.getType() == LinkType.ObjectPropertyLink)) {
      links.add(link);
Set<Node> nodes = alignment.getSteinerTree().vertexSet();
boolean linksRemoved = false;
for (Node node:nodes) {
  if (node instanceof InternalNode) {
    Set<LabeledLink> outLinks = alignment.getOutgoingLinksInTree(node.getId());
    if(outLinks != null && outLinks.size() > 0) {
      boolean hasProvLink = false;
          alignment.removeLink(linkId);
          linksRemoved = true;
SemanticModel semanticModel = new SemanticModel(workspace, worksheet, worksheetName, alignment.getSteinerTree(), selection);
semanticModel.setName(worksheetName);
try {

代码示例来源:origin: usc-isi-i2/Web-Karma

Node n = this.getNodeById(nodeId);
if (n == null) {
  logger.error("could not find the node " + nodeId + " in the model.");
currentIncomingLinks = this.getIncomingLinksInTree(nodeId);
currentOutgoingLinks = this.getOutgoingLinksInTree(nodeId);
if (currentIncomingLinks != null) 
  for (LabeledLink l : currentIncomingLinks)
for (LabeledLink e : this.steinerTree.edgeSet()) {
  LabeledLink l = this.getLinkById(e.getId());

相关文章