簡體   English   中英

SPARQL查詢DBLP

[英]SPARQL query DBLP

我正在運行此查詢

SELECT *
WHERE
{
?s dc:creator ?name .
?s rdf:type swrc:Article .
FILTER regex(str(?name), "Jeffrey", "D.", "Ullman") .
}

我收到的錯誤是:

Encountered " "," ", "" at line 16, column 41.
Was expecting one of:
    <LANGTAG> ...
    <INTEGER_POSITIVE> ...
    <DECIMAL_POSITIVE> ...

有什么問題,我不符合准則嗎? 我搜索了一下,我在各種帖子中找到了相同的語法。

編輯:

當我要求的時候

SELECT * WHERE { ?s rdf:type swrc:Article . ?s dc:creator ?name . }

我回去: s name <http://dblp.l3s.de/d2r/resource/publications/conf/www/BeszteriV07> [http] <http://dblp.l3s.de/d2r/resource/authors/Istvan_Beszteri> [http]在一個單一的線路,其中拳頭URI是?s ,第二個?name

現在我知道有一個名為“Jeffrey D. Ullman”的作者,我查詢:

SELECT * WHERE { ?s rdf:type swrc:Article . ?s dc:creator ?name . FILTER regex(str(?name), "Jeffrey") } LIMIT 10 SELECT * WHERE { ?s rdf:type swrc:Article . ?s dc:creator ?name . FILTER regex(str(?name), "Jeffrey") } LIMIT 10

然后我回來例如: s name <http://dblp.l3s.de/d2r/resource/publications/conf/www/LimWPVA07> [http] <http://dblp.l3s.de/d2r/resource/authors/Jeffrey_Scott_Vitter> [http]

所以這里的問題是我如何能夠匹配“Jeffrey D. Ullman”並查看他撰寫的所有文章。

您的正則表達式函數語法不正確請參閱SPARQL1.1規范 請注意, 正則表達式正好采用兩個或三個參數,第一個是文本,第二個是模式,最后一個是包含標志的可選字符串。

17.4.3.14 REGEX

 xsd:boolean REGEX (string literal text, simple literal pattern) xsd:boolean REGEX (string literal text, simple literal pattern, simple literal flags) 

關於SPARQL的一些背景研究是一個非常好的主意。 只是為了指出這里的確切問題,正則表達式匹配正則表達式的字符串。 所以以下內容:

FILTER regex(str(?name), "Jeffrey D\\. Ullman") .

......將匹配“Jeffrey D. Ullman”。 下列:

FILTER regex(str(?name), "Ullman") .

...將匹配“Jeffrey D. Ullman”以及任何帶有“Ullman”的?name 這個過濾器:

FILTER regex(str(?name), "Ullman$") .

...將匹配任何以“Ullman”結尾的字符串。 而這個過濾器:

FILTER regex(str(?name), "^Jeffrey.*Ullman$") .

...將匹配以“Jeffrey”開頭的任何字符串,以“Ullman”結尾,其間包含任何字符。

等等...

暫無
暫無

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

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