查找基于多个主题的三元组 (SANSA-STACK)
Finding triples based on multiple subjects (SANSA-STACK)
我有一个使用主题查找三元组的代码,所以我正在使用三元组的查找方法并提供必要的信息,如下所示:
import net.sansa_stack.rdf.spark.model._
val node1 = NodeFactory.createURI("http://dbpedia.org/resource/Charles_Dickens")
val result: RDD[graph.Triple] = triplesRdd.find(Some(node1), None, None)
但是我怎样才能找到可以传递多个主题节点的结果?
val node1 = NodeFactory.createURI("http://dbpedia.org/resource/Charles_Dickens")
val node2 = NodeFactory.createURI("http://dbpedia.org/resource/Henry_James")
val nodes = List(node1, node2)
//Here I want to pass list of Subject notes
val result = triplesRdd.find(Some(node2),None,None)
尝试此代码并检查是否有帮助,
val node1 = NodeFactory.createURI("http://dbpedia.org/resource/Charles_Dickens")
val node2 = NodeFactory.createURI("http://dbpedia.org/resource/Henry_James")
val nodes = List(node1, node2)
//Just use filter instead of find ,it will create new RDD containing only items matching those provided subjects
val result = tripleRDD.filter(triple => nodes.contains(triple.getSubject))
result.toDF().show(1000,truncate = false)
我有一个使用主题查找三元组的代码,所以我正在使用三元组的查找方法并提供必要的信息,如下所示:
import net.sansa_stack.rdf.spark.model._
val node1 = NodeFactory.createURI("http://dbpedia.org/resource/Charles_Dickens")
val result: RDD[graph.Triple] = triplesRdd.find(Some(node1), None, None)
但是我怎样才能找到可以传递多个主题节点的结果?
val node1 = NodeFactory.createURI("http://dbpedia.org/resource/Charles_Dickens")
val node2 = NodeFactory.createURI("http://dbpedia.org/resource/Henry_James")
val nodes = List(node1, node2)
//Here I want to pass list of Subject notes
val result = triplesRdd.find(Some(node2),None,None)
尝试此代码并检查是否有帮助,
val node1 = NodeFactory.createURI("http://dbpedia.org/resource/Charles_Dickens")
val node2 = NodeFactory.createURI("http://dbpedia.org/resource/Henry_James")
val nodes = List(node1, node2)
//Just use filter instead of find ,it will create new RDD containing only items matching those provided subjects
val result = tripleRDD.filter(triple => nodes.contains(triple.getSubject))
result.toDF().show(1000,truncate = false)