简体   繁体   English

SPARQL:过滤字符串和整数?

[英]SPARQL: filter on both string and integer?

I'm testing SPARQL with Protégé on this data file https://raw.githubusercontent.com/miranda-zhang/cloud-computing-schema/master/example/sparql-generate/result/gcloud_vm.ttl我正在此数据文件上使用 Protégé 测试 SPARQL https://raw.githubusercontent.com/miranda-zhang/cloud-computing-schema/master/example/sparql-generate/result/gcloud_vm.ttl

Validated the following works:验证了以下工作:

PREFIX cocoon: <https://raw.githubusercontent.com/miranda-zhang/cloud-computing-schema/master/ontology_dev/cocoon.ttl>

SELECT ?VM ?cores
WHERE {
    ?VM a cocoon:VM ;
        cocoon:numberOfCores ?cores .

}

For example, it returns something like:例如,它返回如下内容:

https://w3id.org/cocoon/data/vm/gcloud/CP-COMPUTEENGINE-VMIMAGE-N1-ULTRAMEM-80-PREEMPTIBLE  "80"@   
https://w3id.org/cocoon/data/vm/gcloud/CP-COMPUTEENGINE-VMIMAGE-N1-HIGHCPU-64-PREEMPTIBLE   "64"@   
https://w3id.org/cocoon/data/vm/gcloud/CP-COMPUTEENGINE-VMIMAGE-N1-STANDARD-2   "2"@    
https://w3id.org/cocoon/data/vm/gcloud/CP-COMPUTEENGINE-VMIMAGE-F1-MICRO    "shared"@   
https://w3id.org/cocoon/data/vm/gcloud/CP-COMPUTEENGINE-VMIMAGE-N1-HIGHCPU-8-PREEMPTIBLE    "8"@    
https://w3id.org/cocoon/data/vm/gcloud/CP-COMPUTEENGINE-VMIMAGE-N1-HIGHCPU-32   "32"@   
https://w3id.org/cocoon/data/vm/gcloud/CP-COMPUTEENGINE-VMIMAGE-N1-HIGHMEM-16-PREEMPTIBLE   "16"@   
https://w3id.org/cocoon/data/vm/gcloud/CP-COMPUTEENGINE-VMIMAGE-N1-STANDARD-96-PREEMPTIBLE  "96"@   
https://w3id.org/cocoon/data/vm/gcloud/CP-COMPUTEENGINE-VMIMAGE-N1-STANDARD-4   "4"@

I'm not sure if I can apply a filter on ?cores , I tried the following, but they returned nothing:我不确定是否可以在?cores上应用过滤器,我尝试了以下操作,但它们什么也没返回:

cocoon:numberOfCores "shared" .

Or或者

FILTER(?cores = "4") .

I'd also like to apply filter on ?cores (ie > 4 and < 8 ), so I have to make it an xsd:integer ?我还想在?cores上应用过滤器(即> 4< 8 ),所以我必须将其设为xsd:integer But then I have to get rid of shared which is about < 1 core但是后来我必须摆脱大约< 1 coreshared

Thanks AKSW , impressive knowledge about Protégé.感谢AKSW ,对 Protégé 的了解令人印象深刻。

In the end, I changed my data type to xsd:decimal .最后,我将数据类型更改为xsd:decimal Seems to be enough for now.目前看来已经足够了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM