当前位置: 首页>>代码示例>>Java>>正文


Java DTNode类代码示例

本文整理汇总了Java中org.nodes.DTNode的典型用法代码示例。如果您正苦于以下问题:Java DTNode类的具体用法?Java DTNode怎么用?Java DTNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DTNode类属于org.nodes包,在下文中一共展示了DTNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import org.nodes.DTNode; //导入依赖的package包/类
private void init(RDFDataSet dataset, List<Resource> instances, List<Statement> blackList) {	
	Set<Statement> stmts = RDFUtils.getStatements4Depth(dataset, instances, depth, inference);
	stmts.removeAll(blackList);
	graph = RDFUtils.statements2Graph(stmts, RDFUtils.REGULAR_LITERALS, instances, true);

	StringTree st = new StringTree();
	for (DTNode<String,String> node : graph.getGraph().nodes()) {
		st.store(node.label());
	}
	for (DTLink<String,String> link : graph.getGraph().links()) {
		st.store(link.tag());
	}

	

}
 
开发者ID:Data2Semantics,项目名称:mustard,代码行数:17,代码来源:RDFURIPrefixWrapperFeatureVectorKernel.java

示例2: countLabelTagPairs

import org.nodes.DTNode; //导入依赖的package包/类
/**
 * Create a hubmap from a graph
 * 
 * @param graph
 * @return
 */
public static Map<LabelTagPair<String,String>, Integer> countLabelTagPairs(SingleDTGraph graph) {
	Map<LabelTagPair<String,String>, Integer> edgeCounts = new HashMap<LabelTagPair<String,String>, Integer>();
	Set<DTNode<String,String>> iNodes = new HashSet<DTNode<String,String>>(graph.getInstances());

	for (DTLink<String,String> link : graph.getGraph().links()) {
		if (!iNodes.contains(link.from())) { // instance nodes should not be hubs
			LabelTagPair<String,String> heOut = new LabelTagPair<String,String>(link.from().label(), link.tag(), LabelTagPair.DIR_OUT);
			if (!edgeCounts.containsKey(heOut)) {
				edgeCounts.put(heOut, 0);
			}
			edgeCounts.put(heOut, edgeCounts.get(heOut)+1);	
		}
		if (!iNodes.contains(link.to())) {
			LabelTagPair<String,String> heIn = new LabelTagPair<String,String>(link.to().label(), link.tag(), LabelTagPair.DIR_IN);
			if (!edgeCounts.containsKey(heIn)) {
				edgeCounts.put(heIn, 0);
			}
			edgeCounts.put(heIn, edgeCounts.get(heIn)+1);
		}		
	}
	return edgeCounts;
}
 
开发者ID:Data2Semantics,项目名称:mustard,代码行数:29,代码来源:HubUtils.java

示例3: getSubTreesApproxStringLabel

import org.nodes.DTNode; //导入依赖的package包/类
public static GraphList<DTGraph<ApproxStringLabel,ApproxStringLabel>> getSubTreesApproxStringLabel(DTGraph<String,String> graph, List<DTNode<String,String>> instances, int depth) {
	List<DTGraph<ApproxStringLabel,ApproxStringLabel>> subTrees = new ArrayList<DTGraph<ApproxStringLabel,ApproxStringLabel>>();
	List<Pair<DTNode<String,String>,DTNode<ApproxStringLabel,ApproxStringLabel>>> searchNodes, newSearchNodes;

	for (DTNode<String,String> startNode : instances) {
		DTGraph<ApproxStringLabel,ApproxStringLabel> newGraph = new LightDTGraph<ApproxStringLabel,ApproxStringLabel>();
		searchNodes = new ArrayList<Pair<DTNode<String,String>,DTNode<ApproxStringLabel,ApproxStringLabel>>>();

		// root gets index 0
		searchNodes.add(new Pair<DTNode<String,String>,DTNode<ApproxStringLabel,ApproxStringLabel>>(startNode, newGraph.add(new ApproxStringLabel(startNode.label(), depth))));

		for (int i = 0; i < depth; i++) {
			newSearchNodes = new ArrayList<Pair<DTNode<String,String>,DTNode<ApproxStringLabel,ApproxStringLabel>>>();
			for (Pair<DTNode<String,String>,DTNode<ApproxStringLabel,ApproxStringLabel>> nodePair : searchNodes) {				
				for (DTLink<String,String> link : nodePair.first().linksOut()) {
					DTNode<ApproxStringLabel,ApproxStringLabel> n2 = newGraph.add(new ApproxStringLabel(link.to().label(), depth - (i+1)));
					newSearchNodes.add(new Pair<DTNode<String,String>,DTNode<ApproxStringLabel,ApproxStringLabel>>(link.to(),n2));					
					nodePair.second().connect(n2, new ApproxStringLabel(link.tag(),depth - (i+1)));
				}
			}
			searchNodes = newSearchNodes;
		}
		subTrees.add(newGraph);
	}
	return new GraphList<DTGraph<ApproxStringLabel,ApproxStringLabel>>(subTrees);
}
 
开发者ID:Data2Semantics,项目名称:mustard,代码行数:27,代码来源:RDFUtils.java

示例4: blankLabels

import org.nodes.DTNode; //导入依赖的package包/类
public static SingleDTGraph blankLabels(SingleDTGraph graph) {
	Map<DTNode<String,String>, Integer> ns = new HashMap<DTNode<String,String>,Integer>();
	DTGraph<String,String> newGraph = new LightDTGraph<String,String>();
	List<DTNode<String,String>> newIN = new ArrayList<DTNode<String,String>>();

	for (int i = 0; i < graph.getInstances().size(); i++) {
		ns.put(graph.getInstances().get(i), i);
		newIN.add(null);
	}

	for (DTNode<String,String> n : graph.getGraph().nodes()) {
		if (ns.containsKey(n)) {
			newIN.set(ns.get(n), newGraph.add(""));
		} else {
			newGraph.add("");
		}
	}
	for (DTLink<String,String> l : graph.getGraph().links()) {
		newGraph.nodes().get(l.from().index()).connect(newGraph.nodes().get(l.to().index()), "");
	}
	return new SingleDTGraph(newGraph, newIN);
}
 
开发者ID:Data2Semantics,项目名称:mustard,代码行数:23,代码来源:RDFUtils.java

示例5: simplifyInstanceNodeLabels

import org.nodes.DTNode; //导入依赖的package包/类
public static DTGraph<String,String> simplifyInstanceNodeLabels(DTGraph<String,String> oldGraph, List<DTNode<String,String>> instanceNodes) {
	String rootLabel = KernelUtils.ROOTID;
	Map<DTNode<String,String>, Integer> ns = new HashMap<DTNode<String,String>,Integer>();
	DTGraph<String,String> graph = new LightDTGraph<String,String>();

	for (int i = 0; i < instanceNodes.size(); i++) {
		ns.put(instanceNodes.get(i), i);
	}

	for (DTNode<String,String> n : oldGraph.nodes()) {
		if (ns.containsKey(n)) {
			instanceNodes.set(ns.get(n), graph.add(rootLabel));
		} else {
			graph.add(n.label());
		}
	}
	for (DTLink<String,String> l : oldGraph.links()) {
		graph.nodes().get(l.from().index()).connect(graph.nodes().get(l.to().index()), l.tag());
	}
	return graph;
}
 
开发者ID:Data2Semantics,项目名称:mustard,代码行数:22,代码来源:RDFUtils.java

示例6: statements2Graph

import org.nodes.DTNode; //导入依赖的package包/类
/**
 * Convert a set of RDF statements into a DTGraph. 
 * There are three possible ways to treat literals, as regular nodes (REGULAR_LITERALS), as unique nodes (i.e. one for each literal even if they are equal) (REPEAT_LITERALS),
 * or ignore them (NO_LITERALS)
 * 
 * @param stmts
 * @param literalOption
 * @return
 */
public static DTGraph<String,String> statements2Graph(Set<Statement> stmts, int literalOption) {
	DTGraph<String,String> graph = new LightDTGraph<String,String>();	
	Map<String, DTNode<String,String>> nodeMap = new HashMap<String, DTNode<String,String>>();
	
	for (Statement s : stmts) {
		if (s.getObject() instanceof Literal && literalOption != NO_LITERALS) {
			if (literalOption == REGULAR_LITERALS) {
				addStatement(graph, s, false, false, nodeMap);
			}
			if (literalOption == REGULAR_SPLIT_LITERALS) {
				addStatement(graph, s, false, true, nodeMap);
			}
			if (literalOption == REPEAT_LITERALS) {
				addStatement(graph, s, true, false, nodeMap);
			}
			if (literalOption == REPEAT_SPLIT_LITERALS) {
				addStatement(graph, s, true, true, nodeMap);
			}
		} else if (!(s.getObject() instanceof Literal)){
			addStatement(graph, s, false, false, nodeMap);
		}
	}	
	return graph;
}
 
开发者ID:Data2Semantics,项目名称:mustard,代码行数:34,代码来源:RDFUtils.java

示例7: computeFVs

import org.nodes.DTNode; //导入依赖的package包/类
/**
 * The computation of the feature vectors assumes that each edge and vertex is only processed once. We can encounter the same
 * vertex/edge on different depths during computation, this could lead to multiple counts of the same vertex, possibly of different
 * depth labels.
 * 
 * @param graph
 * @param instances
 * @param weight
 * @param featureVectors
 */
private void computeFVs(DTGraph<PathStringLabel,PathStringLabel> graph, List<DTNode<PathStringLabel,PathStringLabel>> instances, SparseVector[] featureVectors, int lastIndex, int currentIt) {
	int index, depth;
	Map<DTNode<PathStringLabel,PathStringLabel>, Integer> vertexIndexMap;

	for (int i = 0; i < instances.size(); i++) {
		featureVectors[i].setLastIndex(lastIndex);

		vertexIndexMap = instanceVertexIndexMap.get(instances.get(i));
		for (DTNode<PathStringLabel,PathStringLabel> vertex : vertexIndexMap.keySet()) {
			depth = vertexIndexMap.get(vertex);
			if (depth == this.depth) {
				for (String path : vertex.label().getPaths()) {
					index = pathDict.get(path);
					featureVectors[i].setValue(index, featureVectors[i].getValue(index) + 1.0);
				}
			}
		}
	}
}
 
开发者ID:Data2Semantics,项目名称:mustard,代码行数:30,代码来源:DTGraphRootWalkCountIDEQApproxKernel.java

示例8: computeFVs

import org.nodes.DTNode; //导入依赖的package包/类
/**
 * The computation of the feature vectors assumes that each edge and vertex is only processed once. We can encounter the same
 * vertex/edge on different depths during computation, this could lead to multiple counts of the same vertex, possibly of different
 * depth labels.
 * 
 * @param graph
 * @param instances
 * @param weight
 * @param featureVectors
 */
private void computeFVs(DTGraph<MapLabel,MapLabel> graph, List<DTNode<MapLabel,MapLabel>> instances, double weight, SparseVector[] featureVectors, int lastIndex) {
	int index;
	Map<DTNode<MapLabel,MapLabel>, Integer> vertexIndexMap;
	Map<DTLink<MapLabel,MapLabel>, Integer> edgeIndexMap;

	for (int i = 0; i < instances.size(); i++) {
		featureVectors[i].setLastIndex(lastIndex);

		vertexIndexMap = instanceVertexIndexMap.get(instances.get(i));
		for (DTNode<MapLabel,MapLabel> vertex : vertexIndexMap.keySet()) {
			if (!vertex.label().getSameAsPrev(vertexIndexMap.get(vertex))) {
				index = Integer.parseInt(vertex.label().get(vertexIndexMap.get(vertex)).toString());
				featureVectors[i].setValue(index, featureVectors[i].getValue(index) + weight);
			}
		}
		edgeIndexMap = instanceEdgeIndexMap.get(instances.get(i));
		for (DTLink<MapLabel,MapLabel> edge : edgeIndexMap.keySet()) {
			if (!edge.tag().getSameAsPrev(edgeIndexMap.get(edge))) {
				index = Integer.parseInt(edge.tag().get(edgeIndexMap.get(edge)).toString());
				featureVectors[i].setValue(index, featureVectors[i].getValue(index) + weight);
			}
		}
	}
}
 
开发者ID:Data2Semantics,项目名称:mustard,代码行数:35,代码来源:DTGraphWLSubTreeKernel.java

示例9: computeFVs

import org.nodes.DTNode; //导入依赖的package包/类
/**
 * @param graph
 * @param instances
 * @param weight
 * @param featureVectors
 */
private void computeFVs(DTGraph<ApproxStringLabel,ApproxStringLabel> graph, List<DTNode<ApproxStringLabel,ApproxStringLabel>> instances, double weight, SparseVector[] featureVectors, int lastIndex, int currentIt) {
	int index;
	List<Pair<DTNode<ApproxStringLabel,ApproxStringLabel>, Integer>> vertexIndexMap;
	List<Pair<DTLink<ApproxStringLabel,ApproxStringLabel>, Integer>> edgeIndexMap;

	for (int i = 0; i < instances.size(); i++) {
		featureVectors[i].setLastIndex(lastIndex);

		vertexIndexMap = instanceVertexIndexMap.get(instances.get(i));
		for (Pair<DTNode<ApproxStringLabel,ApproxStringLabel>, Integer> vertex : vertexIndexMap) {
			if ((!noDuplicateSubtrees || vertex.getFirst().label().getSameAsPrev() == 0)  && ((vertex.getSecond() * 2) >= currentIt)) {
				index = Integer.parseInt(vertex.getFirst().label().toString());
				featureVectors[i].setValue(index, featureVectors[i].getValue(index) + weight);
			}
		}
		edgeIndexMap = instanceEdgeIndexMap.get(instances.get(i));
		for (Pair<DTLink<ApproxStringLabel,ApproxStringLabel>, Integer> edge : edgeIndexMap) {
			if ((!noDuplicateSubtrees || edge.getFirst().tag().getSameAsPrev() == 0) && (((edge.getSecond() * 2)+1) >= currentIt)) {
				index = Integer.parseInt(edge.getFirst().tag().toString());
				featureVectors[i].setValue(index, featureVectors[i].getValue(index) + weight);
			}
		}
	}
}
 
开发者ID:Data2Semantics,项目名称:mustard,代码行数:31,代码来源:DTGraphTreeWLSubTreeIDEQApproxKernel.java

示例10: computeFVs

import org.nodes.DTNode; //导入依赖的package包/类
/**
 * The computation of the feature vectors assumes that each edge and vertex is only processed once. We can encounter the same
 * vertex/edge on different depths during computation, this could lead to multiple counts of the same vertex, possibly of different
 * depth labels.
 * 
 * @param graph
 * @param instances
 * @param weight
 * @param featureVectors
 */
private void computeFVs(DTGraph<ApproxStringLabel,ApproxStringLabel> graph, List<DTNode<ApproxStringLabel,ApproxStringLabel>> instances, double weight, SparseVector[] featureVectors, int lastIndex, int currentIt) {
	int index, depth;
	Map<DTNode<ApproxStringLabel,ApproxStringLabel>, Integer> vertexIndexMap;

	for (int i = 0; i < instances.size(); i++) {
		featureVectors[i].setLastIndex(lastIndex);

		vertexIndexMap = instanceVertexIndexMap.get(instances.get(i));
		for (DTNode<ApproxStringLabel,ApproxStringLabel> vertex : vertexIndexMap.keySet()) {
			depth = vertexIndexMap.get(vertex);
			if (depth == this.depth && vertex.label().getSameAsPrev() == 0) {
				index = Integer.parseInt(vertex.label().toString());
				featureVectors[i].setValue(index, featureVectors[i].getValue(index) + weight);
			}
		}
	}
}
 
开发者ID:Data2Semantics,项目名称:mustard,代码行数:28,代码来源:DTGraphRootWLSubTreeIDEQApproxKernel.java

示例11: computeFVs

import org.nodes.DTNode; //导入依赖的package包/类
/**
 * The computation of the feature vectors assumes that each edge and vertex is only processed once. We can encounter the same
 * vertex/edge on different depths during computation, this could lead to multiple counts of the same vertex, possibly of different
 * depth labels.
 * 
 * @param graph
 * @param instances
 * @param weight
 * @param featureVectors
 */
private void computeFVs(DTGraph<MapLabel,MapLabel> graph, List<DTNode<MapLabel,MapLabel>> instances, double weight, SparseVector[] featureVectors, int lastIndex) {
	int index;
	Map<DTNode<MapLabel,MapLabel>, Integer> vertexIndexMap;
	for (int i = 0; i < instances.size(); i++) {
		featureVectors[i].setLastIndex(lastIndex);

		vertexIndexMap = instanceVertexIndexMap.get(instances.get(i));
		for (DTNode<MapLabel,MapLabel> vertex : vertexIndexMap.keySet()) {
		if (vertexIndexMap.get(vertex) == depth) {
				index = Integer.parseInt(vertex.label().get(vertexIndexMap.get(vertex)).toString());
				featureVectors[i].setValue(index, featureVectors[i].getValue(index) + weight);
			}
		}
	}
}
 
开发者ID:Data2Semantics,项目名称:mustard,代码行数:26,代码来源:DTGraphRootWLSubTreeKernel.java

示例12: computeFVs

import org.nodes.DTNode; //导入依赖的package包/类
/**
 * @param graph
 * @param instances
 * @param weight
 * @param featureVectors
 */
private void computeFVs(DTGraph<MapLabel,MapLabel> graph, List<DTNode<MapLabel,MapLabel>> instances, double weight, SparseVector[] featureVectors, int lastIndex) {
	int index;
	List<Pair<DTNode<MapLabel,MapLabel>, Integer>> vertexIndexMap;
	List<Pair<DTLink<MapLabel,MapLabel>, Integer>> edgeIndexMap;

	for (int i = 0; i < instances.size(); i++) {
		featureVectors[i].setLastIndex(lastIndex);

		vertexIndexMap = instanceVertexIndexMap.get(instances.get(i));
		for (Pair<DTNode<MapLabel,MapLabel>, Integer> vertex : vertexIndexMap) {
			if (!vertex.getFirst().label().getSameAsPrev(vertex.getSecond())) {
				index = Integer.parseInt(vertex.getFirst().label().get(vertex.getSecond()).toString());
				featureVectors[i].setValue(index, featureVectors[i].getValue(index) + weight);
			}
		}
		edgeIndexMap = instanceEdgeIndexMap.get(instances.get(i));
		for (Pair<DTLink<MapLabel,MapLabel>, Integer> edge : edgeIndexMap) {
			if (!edge.getFirst().tag().getSameAsPrev(edge.getSecond())) {
				index = Integer.parseInt(edge.getFirst().tag().get(edge.getSecond()).toString());
				featureVectors[i].setValue(index, featureVectors[i].getValue(index) + weight);
			}
		}
	}
}
 
开发者ID:Data2Semantics,项目名称:mustard,代码行数:31,代码来源:DTGraphTreeWLSubTreeKernel.java

示例13: compute

import org.nodes.DTNode; //导入依赖的package包/类
public double[][] compute(SingleDTGraph data) {
	List<DTNode<String,String>> iNodes = data.getInstances();
	double[][] kernel = KernelUtils.initMatrix(iNodes.size(), iNodes.size());
	Tree tree;
		
	DTGraph<String,String> newG = toIntGraph(data.getGraph(),iNodes);
		
	long tic = System.currentTimeMillis();
	
	for (int i = 0; i < iNodes.size(); i++) {
		for (int j = i; j < iNodes.size(); j++) {
			tree = computeIntersectionTree(newG, iNodes.get(i), iNodes.get(j));
			kernel[i][j] = subTreeScore(tree.getRoot(), discountFactor);
			kernel[j][i] = kernel[i][j];
		}
	}
	
	compTime = System.currentTimeMillis() - tic;

	if (normalize) {
		return KernelUtils.normalize(kernel);
	} else {		
		return kernel;
	}
}
 
开发者ID:Data2Semantics,项目名称:mustard,代码行数:26,代码来源:DTGraphIntersectionSubTreeKernel.java

示例14: computeFVs

import org.nodes.DTNode; //导入依赖的package包/类
/**
 * Compute feature vector for the graphs based on the label dictionary created in the previous two steps
 * 
 * @param graphs
 * @param featureVectors
 * @param startLabel
 * @param currentLabel
 */
private void computeFVs(List<DTGraph<StringLabel,StringLabel>> graphs, SparseVector[] featureVectors, double weight, int lastIndex) {
	int index;
	for (int i = 0; i < graphs.size(); i++) {
		featureVectors[i].setLastIndex(lastIndex);

		// for each vertex, use the label as index into the feature vector and do a + 1,
		for (DTNode<StringLabel,StringLabel> vertex : graphs.get(i).nodes()) {
			if (!vertex.label().isSameAsPrev()) {
				index = Integer.parseInt(vertex.label().toString());	
				featureVectors[i].setValue(index, featureVectors[i].getValue(index) + weight);
			}
		}

		for (DTLink<StringLabel,StringLabel> edge : graphs.get(i).links()) {
			if (!edge.tag().isSameAsPrev()) {
				index = Integer.parseInt(edge.tag().toString());
				featureVectors[i].setValue(index, featureVectors[i].getValue(index) + weight);
			}
		}
	}
}
 
开发者ID:Data2Semantics,项目名称:mustard,代码行数:30,代码来源:WLSubTreeKernel.java

示例15: copyGraphs

import org.nodes.DTNode; //导入依赖的package包/类
private List<DTGraph<ApproxStringLabel,ApproxStringLabel>> copyGraphs(List<DTGraph<ApproxStringLabel,ApproxStringLabel>> oldGraphs) {
	List<DTGraph<ApproxStringLabel,ApproxStringLabel>> newGraphs = new ArrayList<DTGraph<ApproxStringLabel,ApproxStringLabel>>();	

	maxDepth = 0;
	for (DTGraph<ApproxStringLabel,ApproxStringLabel> graph : oldGraphs) {
		LightDTGraph<ApproxStringLabel,ApproxStringLabel> newGraph = new LightDTGraph<ApproxStringLabel,ApproxStringLabel>();
		for (DTNode<ApproxStringLabel,ApproxStringLabel> vertex : graph.nodes()) {
			newGraph.add(new ApproxStringLabel(vertex.label().toString(), vertex.label().getDepth()));
			maxDepth = Math.max(maxDepth, vertex.label().getDepth());
		}
		for (DTLink<ApproxStringLabel,ApproxStringLabel> edge : graph.links()) {
			newGraph.nodes().get(edge.from().index()).connect(newGraph.nodes().get(edge.to().index()), new ApproxStringLabel(edge.tag().toString(), edge.tag().getDepth())); // ?
			maxDepth = Math.max(maxDepth, edge.tag().getDepth());
		}
		newGraphs.add(newGraph);
	}
	return newGraphs;
}
 
开发者ID:Data2Semantics,项目名称:mustard,代码行数:19,代码来源:WLSubTreeApproxKernel.java


注:本文中的org.nodes.DTNode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。