簡體   English   中英

從外部SPARQL端點填充OWL本體

[英]Populating an OWL ontology from external SPARQL endpoints

我想使用sparql端點鏈接兩個不同的數據集(比如說http://dbpedia.org/sparqlhttp://pubmed.bio2rdf.org/sparql ),我將從頭創建一個OWL本體,並且然后使用這兩個不同的數據集填充該本體。

我是語義Web和鏈接數據概念的新手。 如果你們給我一些例子/想法來開始這個事情?

您是否要使用SPARQL一次進行兩個本體查詢? 如果那樣的話,這是簡單的方法。 取兩個本體(.OWL文件),然后使用SPARQL(jena-fuseki服務器)對兩個OWL文件的前綴進行查詢。

你能詳細說明這個問題嗎? 您是否需要在端點上使用OWL文件或SPARQL查詢的示例。

在網上很難找到SPARQL技巧。 使用下面的示例,您可以填充您的本體。 我正在回答自己的問題,這讓我感到有些孤獨。

代替使用發布的sparql端點,我使用了gutenberg項目端點。 首先,我使用Protegé創建了一個本體。 這非常簡單直接。 Followinh是有關DBPedia和Gutenberg項目上的Kafka和Twain作品的元數據的示例查詢。

PREFIX gb: <yourOntologyGoesHere.owl#>
  PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
  PREFIX foaf: <http://xmlns.com/foaf/0.1/>
  PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
  PREFIX dbpprop: <http://dbpedia.org/property/>
  PREFIX dc:<http://purl.org/dc/elements/1.1/>
  PREFIX foaf:<http://xmlns.com/foaf/0.1/>
  PREFIX dcterms: <http://purl.org/dc/terms/>
  CONSTRUCT {
  ?book rdf:type gb:Book .
  ?book gb:titled_as ?name.
  gb:Title rdf:type ?name.
  ?book gb:written_by ?author.
  ?author rdf:type gb:Author.
  ?book gb:author_name ?authorName.
  gb:Author rdf:type ?authorName.
  gb:AuthorName rdf:type ?authorName.
  ?book gb:released ?firstPublished.
  ?firstPublished rdf:type gb:PublishDate.
  ?book gb:writtenInCountry ?country .
  ?country rdf:type gb:Country.
  ?book gb:writtenIn ?lang .
  ?lang rdf:type gb:Language.
  ?book gb:summary ?abstract.
  gb:Absratct rdf:type ?abstract.
  ?book gb:identified_with ?isbn .
  gb:ISBN rdf:type ?isbn.
  ?book gb:publish_tpe ?mediaType .
  ?mediaType rdf:type gb:Media .
  ?book gb:has_pagenumber ?pages.
  gb:Pages rdf:type ?pages.
  ?book gb:genre ?genre
  }WHERE{?book rdf:type dbpedia-owl:Book .
   ?book foaf:name ?name.
   OPTIONAL {?book dbpedia-owl:author ?author}
   OPTIONAL {?author dbpprop:name ?authorName}
   OPTIONAL {?book dbpedia-owl:releaseDate ?firstPublished}
   OPTIONAL {?book dbpedia-owl:country ?country}
   OPTIONAL {?book dbpedia-owl:language ?lang}
   OPTIONAL {?book dbpedia-owl:abstract ?abstract}
   OPTIONAL {?book dbpedia-owl:isbn ?isbn}
   OPTIONAL {?book dbpedia-owl:numberOfPages ?pages}
   OPTIONAL {?book dbpedia-owl:mediaType ?mediaType}
   OPTIONAL {?book dbpprop:genre ?genre}
   FILTER ( regex(str(?author), "Franz_Kafka") || regex(str(?author), "Mark_Twain") )
   FILTER (LANG(?abstract)="en")
  }

DBPedia

PREFIX gb: <yourOntologyGoesHere.owl#>
  PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>        
  PREFIX movie: <http://data.linkedmdb.org/resource/movie/>
  PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
  PREFIX dc: <http://purl.org/dc/terms/>
  prefix owl: <http://www.w3.org/2002/07/owl#>
  PREFIX dc:<http://purl.org/dc/elements/1.1/>
  PREFIX foaf:<http://xmlns.com/foaf/0.1/>
  PREFIX dcterms: <http://purl.org/dc/terms/>

  CONSTRUCT {
  ?book rdf:type gb:Book .
  ?book gb:title ?bookTitle .
  ?book gb:written_by ?author.
  ?author rdf:type gb:Author.
  ?book gb:addedToGutenberg ?addedToCatalog.
  ?addedToCatalog rdf:type gb:AddedToGutenberg.
  ?book1 rdf:type gb:Book .
  ?book1 gb:title ?bookTitle1 .
  ?book1 gb:written_by ?author1.
  ?author1 rdf:type gb:Author.
  ?author owl:sameAs <http://dbpedia.org/resource/Franz_Kafka> .
  ?author1 owl:sameAs <http://dbpedia.org/resource/Mark_Twain> .
  <http://wifo5-04.informatik.uni-mannheim.de/gutendata/resource/etext3176> owl:sameAs <http://dbpedia.org/resource/The_Innocents_Abroad>.
  <http://wifo5-04.informatik.uni-mannheim.de/gutendata/resource/etext3177> owl:sameAs <http://dbpedia.org/resource/Roughing_It>.
  <http://wifo5-04.informatik.uni-mannheim.de/gutendata/resource/etext245> owl:sameAs <http://dbpedia.org/resource/Life_on_the_Mississippi>.
  <http://wifo5-04.informatik.uni-mannheim.de/gutendata/resource/etext9009> owl:sameAs <http://dbpedia.org/resource/Life_on_the_Mississippi>.
  <http://wifo5-04.informatik.uni-mannheim.de/gutendata/resource/etext1086> owl:sameAs <http://dbpedia.org/resource/A_Horse's_Tale>.
  <http://wifo5-04.informatik.uni-mannheim.de/gutendata/resource/etext119> owl:sameAs <http://dbpedia.org/resource/A_Tramp_Abroad>.
  <http://wifo5-04.informatik.uni-mannheim.de/gutendata/resource/etext3174> owl:sameAs <http://dbpedia.org/resource/A_Dog's_Tale>.
  <http://wifo5-04.informatik.uni-mannheim.de/gutendata/resource/etext3186> owl:sameAs <http://dbpedia.org/resource/The_Mysterious_Stranger>.
  <http://wifo5-04.informatik.uni-mannheim.de/gutendata/resource/etext3190> owl:sameAs <http://dbpedia.org/resource/1610_(Mark_Twain)>.
  <http://wifo5-04.informatik.uni-mannheim.de/gutendata/resource/etext3251> owl:sameAs <http://dbpedia.org/resource/The_Man_That_Corrupted_Hadleyburg>.
  <http://wifo5-04.informatik.uni-mannheim.de/gutendata/resource/etext91> owl:sameAs <http://dbpedia.org/resource/Tom_Sawyer_Abroad>.
  <http://wifo5-04.informatik.uni-mannheim.de/gutendata/resource/etext93> owl:sameAs <http://dbpedia.org/resource/Tom_Sawyer,_Detective>.
  <http://dbpedia.org/resource/The_Metamorphosis> owl:sameAs <http://wifo5-04.informatik.uni-mannheim.de/gutendata/resource/etext5200> .
  <http://wifo5-04.informatik.uni-mannheim.de/gutendata/resource/etext7849> owl:sameAs <http://dbpedia.org/resource/The_Trial>.
  ?book1 gb:addedToGutenberg ?addedToCatalog1.
  ?addedToCatalog1 rdf:type gb:AddedToGutenberg
  }
  WHERE {
  ?author foaf:name "Kafka, Franz, 1883-1924".
  ?author1 foaf:name "Twain, Mark, 1835-1910".
  ?book dc:creator ?author;
  dc:title ?bookTitle;
  dc:language ?bookLanguage;
  dcterms:created ?addedToCatalog.
  ?book1 dc:creator ?author1;
  dc:title ?bookTitle1;
  dc:language ?bookLanguage1;
  dcterms:created ?addedToCatalog1}

這兩個查詢將填充您創建的本體。 然后,您可以查詢新創建的本體。

使用SPARQL SERVICE,您可以執行以下操作:

CONSTRUCT {
   <dbpedia-value1> a <your-class1> .
   <dbpedia-value1> ?p1 ?o1 .
   <pubmed-value2> a <your-class2> . #or perhaps also <your-class1>
   <pubmed-value2> ?p2 ?o2 .
}
WHERE {
   SERVICE <http://dbpedia.org/sparql> {
      <dbpedia-value1> a <dbp-class1> .
      <dbpedia-value1> ?p1 ?o1 .
   }
   SERVICE <http://pubmed.bio2rdf.org/sparql> {
      <pubmed-value2> a <pubmed-class1> .
      <pubmed-value2> ?p2 ?o2 .
   }
}

這將從每個端點的類中獲取一組實例,並將它們映射到您的本體。 對端點的查詢可能是任意復雜的(SPARQL IN在這里可能有用),但是一般的技術是查詢數據並使用CONSTRUCT將這些值映射到本體中的三元組,然后保存構造的三元組。 (或直接將數據插入到圖形中。)

您還可以使用此模式在源和本體之間映射屬性。 在這種情況下,請在WHERE子句中指定特定屬性

<pubmed-value2> <pubmed-prop1> ?prop1value .

...然后在CONSTRUCT查詢中對其進行轉換:

<pubmed-value2> <your-prop1> ?prop1value .

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM