答案
你只需要添加三元组
?transx lrppi:propertyType ?propertytype .
到您的查询。例如,这是基于您的查询:
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX lrppi: <http://landregistry.data.gov.uk/def/ppi/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX lrcommon: <http://landregistry.data.gov.uk/def/common/>
SELECT ?propertytype ?paon ?saon ?street ?town ?county ?locality ?district ?postcode ?amount ?date
WHERE {
?transx lrppi:pricePaid ?amount ;
lrppi:transactionDate ?date ;
lrppi:propertyAddress ?addr ;
lrppi:propertyType ?propertytype .
?addr lrcommon:district "MALVERN HILLS"^^xsd:string .
OPTIONAL {?addr lrcommon:county ?county .}
OPTIONAL {?addr lrcommon:paon ?paon .}
OPTIONAL {?addr lrcommon:saon ?saon .}
OPTIONAL {?addr lrcommon:street ?street .}
OPTIONAL {?addr lrcommon:town ?town .}
OPTIONAL {?addr lrcommon:locality ?locality .}
OPTIONAL {?addr lrcommon:postcode ?postcode .}
}
ORDER BY ?postcode ?amount
LIMIT 10
您可以将其复制并粘贴到端点并获取结果。(不幸的是,似乎没有办法直接链接到结果。)
寻找答案
这是我如何找到该属性的。端点有一些示例查询,其中之一是“列出正在使用的 RDF 类型”:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
# Get labels for types used in the data.
SELECT ?type ?name
WHERE {
?type rdfs:label ?name .
FILTER EXISTS { ?something rdf:type ?type . }
}
该查询的结果包括
---------------------------------------------------------------------------------------------------------------------------------------------
| type | name |
=============================================================================================================================================
| <http://landregistry.data.gov.uk/def/common/PropertyTypeConcept> | "Property type concept"@en |
---------------------------------------------------------------------------------------------------------------------------------------------
由于我们现在关于类型<http://landregistry.data.gov.uk/def/common/PropertyTypeConcept>
,我们可以询问它的实例:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?x
WHERE { ?x a <http://landregistry.data.gov.uk/def/common/PropertyTypeConcept> }
LIMIT 10
----------------------------------------------------------------
| x |
================================================================
| <http://landregistry.data.gov.uk/def/common/detached> |
| <http://landregistry.data.gov.uk/def/common/semi-detached> |
| <http://landregistry.data.gov.uk/def/common/flat-maisonette> |
| <http://landregistry.data.gov.uk/def/common/terraced> |
----------------------------------------------------------------
现在我们可以看到与其中之一相关的内容,以及与哪些属性相关的内容。例如
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?x ?y
WHERE { ?x ?y <http://landregistry.data.gov.uk/def/common/detached> }
LIMIT 10
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
| x | y |
======================================================================================================================================================================
| <http://landregistry.data.gov.uk/data/ppi/transaction/C7AE071D-242D-4825-9162-97BBF3B71840/2009-02-27233> | <http://landregistry.data.gov.uk/def/ppi/propertyType> |
| <http://landregistry.data.gov.uk/data/ppi/transaction/D0CDBC03-5147-4D93-BCE5-176AF007E391/2009-02-10191> | <http://landregistry.data.gov.uk/def/ppi/propertyType> |
| <http://landregistry.data.gov.uk/data/ppi/transaction/E37CAA33-CEF5-4162-8E07-918394B3C8AF/2009-02-00643> | <http://landregistry.data.gov.uk/def/ppi/propertyType> |
| <http://landregistry.data.gov.uk/data/ppi/transaction/E37CAA33-CEF5-4162-8E07-918394B3C8AF/2009-03-32825> | <http://landregistry.data.gov.uk/def/ppi/propertyType> |
| <http://landregistry.data.gov.uk/data/ppi/transaction/22276002-0030-4748-A7F6-C20F125DAC1C/2009-02-47264> | <http://landregistry.data.gov.uk/def/ppi/propertyType> |
| <http://landregistry.data.gov.uk/data/ppi/transaction/FA525F65-CC8E-4617-A682-F8B267319445/2009-02-38989> | <http://landregistry.data.gov.uk/def/ppi/propertyType> |
| <http://landregistry.data.gov.uk/data/ppi/transaction/3BFA438C-47AE-4B47-87AD-5DC365977619/2009-02-37729> | <http://landregistry.data.gov.uk/def/ppi/propertyType> |
| <http://landregistry.data.gov.uk/data/ppi/transaction/A5BED22B-F54B-4459-9BF9-18920B8CDBAA/2009-02-21721> | <http://landregistry.data.gov.uk/def/ppi/propertyType> |
| <http://landregistry.data.gov.uk/data/ppi/transaction/DDAAE7E0-B07F-49FF-AAB6-A2B96D8D4DE3/2009-02-11020> | <http://landregistry.data.gov.uk/def/ppi/propertyType> |
| <http://landregistry.data.gov.uk/data/ppi/transaction/5168D986-FAA2-42E8-B2C8-A04981C8BD0F/2009-02-09080> | <http://landregistry.data.gov.uk/def/ppi/propertyType> |
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
我们看到我们想要的属性是<http://landregistry.data.gov.uk/def/ppi/propertyType>
,可以将其缩短为lrppi:propertyType
使用您定义的前缀。它似乎将交易与属性类型相关联,并且由于您查询中的交易是?transx
,我们添加
?transx lrppi:propertyType ?propertyType