SPARQL:在查询中使用过滤器

SPARQL: Using filter in query

我最近开始使用 SPARQL 并进行了一个查询练习,该查询将使我能够获得只有一位歌手作为主唱的歌曲名称?在这种情况下,约翰·列侬是唯一的歌手。

我有一个 beatles.ttl 数据文件,到目前为止我能够 select 所有约翰·列侬主唱的歌曲,但是有些歌曲是他与其他 2 个乐队主唱的成员。

prefix pi:     <http://beatlesExample/ns/playsInstrument/>
prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#>
prefix m:     <http://beatlesExample/ns/musician/>

SELECT ?songTitle
WHERE {
    ?song pi:vocals m:JohnLennon .
    ?song rdfs:label ?songTitle .
}

结果:

在查询结果中出现了约翰·列侬演唱的所有歌曲,但最后两首除了他是歌手之外还有另外2位乐队成员也是该歌曲的歌手。

我试图完成的是一个查询,在该查询中我获得了约翰·列侬是 唯一 歌手的每首歌曲。

数据文件(Beatles.ttl)

 @prefix c:     <http://beatlesExample/ns/class/> .
    @prefix t:     <http://beatlesExample/ns/title/> .
    @prefix pi:     <http://beatlesExample/ns/playsInstrument/> .
    @prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
    @prefix m:     <http://beatlesExample/ns/musician/> .


t:MagicalMysteryTour  a         c:Song ;
        rdfs:label              "Magical Mystery Tour" ;
        pi:acousticrhythmguitar  m:JohnLennon ;
        pi:bass                  m:PaulMcCartney ;
        pi:drums                 m:RingoStarr ;
        pi:leadguitar            m:GeorgeHarrison ;
        pi:percussion            m:RingoStarr , m:NeilAspinall , m:MalEvans , m:GeorgeHarrison , m:JohnLennon ;
        pi:piano                 m:PaulMcCartney ;
        pi:trumpet               m:ElgarHowarth , m:JohnWilbraham , m:DavidMason , m:RoyCopestake ;
        pi:vocals                m:JohnLennon , m:PaulMcCartney , m:GeorgeHarrison .

t:PennyLane  a                  c:Song ;
        rdfs:label              "Penny Lane" ;
        pi:acousticguitar        m:JohnLennon ;
        pi:backingvocals         m:JohnLennon , m:GeorgeHarrison ;
        pi:bassguitar            m:PaulMcCartney ;
        pi:doublebass            m:FrankClarke ;
        pi:drums                 m:RingoStarr ;
        pi:electricguitar        m:JohnLennon ;
        pi:flutesorpiccolos      m:PGoody , m:RaySwinfield , m:MannyWinters , m:DennisWalton ;
        pi:guitar                m:GeorgeHarrison ;
        pi:handclaps             m:GeorgeHarrison , m:JohnLennon , m:PaulMcCartney ;
        pi:harmonium             m:PaulMcCartney ;
        pi:oboesorcoranglais     m:DickMorgan , m:MikeWinfield ;
        pi:piano                 m:JohnLennon , m:PaulMcCartney ;
        pi:tambourine            m:RingoStarr ;
        pi:trumpetsorflugelhorn  m:FreddyClayton , m:LeonCalvert , m:BertCourtley , m:DuncanCampbell , m:DavidMason ;
        pi:tubularbells          m:RingoStarr ;
        pi:vocals                m:PaulMcCartney .

t:NotASecondTime  a             c:Song ;
        rdfs:label              "Not A Second Time" ;
        pi:acousticrhythmguitar  m:JohnLennon ;
        pi:bass                  m:PaulMcCartney ;
        pi:drums                 m:RingoStarr ;
        pi:piano                 m:GeorgeMartin ;
        pi:vocals                m:JohnLennon .

t:Yesterday  a      c:Song ;
        rdfs:label  "Yesterday" ;
        pi:cello     m:FranciscoGabarro ;
        pi:guitar    m:PaulMcCartney ;
        pi:viola     m:KennethEssex ;
        pi:violin    m:TonyGilbert , m:SidneySax ;
        pi:vocals    m:PaulMcCartney .

t:LosParanoias  a         c:Song ;
        rdfs:label        "Los Paranoias" ;
        pi:acousticguitar  m:PaulMcCartney ;
        pi:percussion      m:JohnLennon ;
        pi:shaker          m:RingoStarr ;
        pi:vocals          m:PaulMcCartney .


t:LikeDreamersDo  a     c:Song ;
        rdfs:label      "Like Dreamers Do" ;
        pi:bass          m:PaulMcCartney ;
        pi:drums         m:PeteBest ;
        pi:leadguitar    m:GeorgeHarrison ;
        pi:rhythmguitar  m:JohnLennon ;
        pi:vocals        m:PaulMcCartney .

t:IGotToFindMyBaby  a   c:Song ;
        rdfs:label      "I Got To Find My Baby" ;
        pi:bass          m:PaulMcCartney ;
        pi:drums         m:RingoStarr ;
        pi:harmonica     m:JohnLennon ;
        pi:leadguitar    m:GeorgeHarrison ;
        pi:rhythmguitar  m:JohnLennon ;
        pi:vocals        m:JohnLennon .

t:Revolution1  a          c:Song ;
        rdfs:label        "Revolution 1" ;
        pi:Hammondorgan    m:PaulMcCartney ;
        pi:acousticguitar  m:JohnLennon ;
        pi:backingvocals   m:FrancieSchwartz , m:GeorgeHarrison , m:PaulMcCartney ;
        pi:bass            m:PaulMcCartney ;
        pi:drums           m:RingoStarr ;
        pi:leadguitar      m:GeorgeHarrison , m:JohnLennon ;
        pi:piano           m:PaulMcCartney ;
        pi:trombone        m:JPower , m:DonLang , m:BillPovey , m:RexMorris ;
        pi:trumpet         m:FreddyClayton , m:DerekWatkins ;
        pi:vocals          m:JohnLennon .

t:DizzyMissLizzy  a                  c:Song ;
        rdfs:label                   "Dizzy Miss Lizzy" ;
        pi:Hammondorgan               m:JohnLennon ;
        pi:HohnerPianetelectricpiano  m:PaulMcCartney ;
        pi:bass                       m:PaulMcCartney ;
        pi:cowbell                    m:RingoStarr ;
        pi:double-trackedleadguitar   m:GeorgeHarrison ;
        pi:drums                      m:RingoStarr ;
        pi:rhythmguitar               m:JohnLennon ;
        pi:vocals                     m:JohnLennon .

t:YesItIs  a                    c:Song ;
        rdfs:label              "Yes It Is" ;
        pi:acousticrhythmguitar  m:JohnLennon ;
        pi:bass                  m:PaulMcCartney ;
        pi:drums                 m:RingoStarr ;
        pi:harmonyvocals         m:GeorgeHarrison , m:PaulMcCartney ;
        pi:leadguitar            m:GeorgeHarrison ;
        pi:tambourine            m:RingoStarr ;
        pi:vocals                m:JohnLennon .

t:IWannaBeYourMan  a     c:Song ;
        rdfs:label       "I Wanna Be Your Man" ;
        pi:Hammondorgan   m:GeorgeMartin ;
        pi:backingvocals  m:PaulMcCartney , m:JohnLennon ;
        pi:bass           m:PaulMcCartney ;
        pi:drums          m:RingoStarr ;
        pi:leadguitar     m:GeorgeHarrison ;
        pi:maracas        m:RingoStarr ;
        pi:rhythmguitar   m:JohnLennon ;
        pi:vocals         m:RingoStarr .

t:ThingsWeSaidToday  a          c:Song ;
        rdfs:label              "Things We Said Today" ;
        pi:acousticrhythmguitar  m:JohnLennon ;
        pi:bass                  m:PaulMcCartney ;
        pi:drums                 m:RingoStarr ;
        pi:leadguitar            m:GeorgeHarrison ;
        pi:piano                 m:JohnLennon ;
        pi:tambourine            m:RingoStarr ;
        pi:vocals                m:PaulMcCartney .

t:HallelujahILoveHerSo
        a           c:Song ;
        rdfs:label  "Hallelujah, I Love Her So" ;
        pi:bass      m:StuartSutcliffe ;
        pi:guitar    m:GeorgeHarrison , m:PaulMcCartney , m:JohnLennon ;
        pi:vocals    m:PaulMcCartney .

t:OldBrownShoe  a        c:Song ;
        rdfs:label       "Old Brown Shoe" ;
        pi:backingvocals  m:JohnLennon , m:PaulMcCartney ;
        pi:bass           m:GeorgeHarrison ;
        pi:drums          m:RingoStarr ;
        pi:guitar         m:GeorgeHarrison , m:PaulMcCartney ;
        pi:organ          m:GeorgeHarrison ;
        pi:piano          m:PaulMcCartney ;
        pi:vocals         m:GeorgeHarrison .

t:GoodNight  a           c:Song ;
        rdfs:label       "Good Night" ;
        pi:12violins      m:Uncredited ;
        pi:backingvocals  m:MikeRedway , m:PatWhitmore , m:FredLucas , m:ValStockwell , m:IreneKing , m:IngridThomas , m:KenBarrie , m:RossGilmour ;
        pi:celesta        m:GeorgeMartin ;
        pi:clarinet       m:Uncredited ;
        pi:doublebass     m:Uncredited ;
        pi:harp           m:Uncredited ;
        pi:horn           m:Uncredited ;
        pi:threecellos    m:Uncredited ;
        pi:threeflutes    m:Uncredited ;
        pi:threeviolas    m:Uncredited ;
        pi:vibraphone     m:Uncredited ;
        pi:vocals         m:RingoStarr .

t:MemphisTennessee  a   c:Song ;
        rdfs:label      "Memphis, Tennessee" ;
        pi:bass          m:PaulMcCartney ;
        pi:drums         m:RingoStarr ;
        pi:leadguitar    m:GeorgeHarrison ;
        pi:rhythmguitar  m:JohnLennon ;
        pi:vocals        m:JohnLennon .

t:TicketToRide  a                   c:Song ;
        rdfs:label                  "Ticket To Ride" ;
        pi:bass                      m:PaulMcCartney ;
        pi:double-trackedleadvocals  m:JohnLennon ;
        pi:drums                     m:RingoStarr ;
        pi:handclaps                 m:RingoStarr ;
        pi:harmonyvocals             m:PaulMcCartney ;
        pi:leadguitar                m:PaulMcCartney ;
        pi:rhythmguitar              m:GeorgeHarrison , m:JohnLennon ;
        pi:tambourine                m:RingoStarr .

t:Ob-La-DiOb-La-Da  a      c:Song ;
        rdfs:label         "Ob-La-Di, Ob-La-Da" ;
        pi:acousticguitar   m:GeorgeHarrison ;
        pi:backingvocals    m:JohnLennon , m:GeorgeHarrison ;
        pi:bass             m:PaulMcCartney ;
        pi:bongo            m:RingoStarr ;
        pi:drums            m:RingoStarr ;
        pi:handclaps        m:JohnLennon , m:PaulMcCartney , m:GeorgeHarrison , m:RingoStarr ;
        pi:percussion       m:RingoStarr ;
        pi:piano            m:JohnLennon ;
        pi:threesaxophones  m:Uncredited ;
        pi:vocals           m:PaulMcCartney .

t:LetItBe  a              c:Song ;
        rdfs:label        "Let It Be" ;
        pi:backingvocals   m:JohnLennon , m:LindaMcCartney , m:PaulMcCartney , m:GeorgeHarrison ;
        pi:bassguitar      m:PaulMcCartney ;
        pi:cello           m:Uncredited ;
        pi:drums           m:RingoStarr ;
        pi:electricpiano   m:BillyPreston ;
        pi:leadguitar      m:GeorgeHarrison ;
        pi:maracas         m:PaulMcCartney ;
        pi:organ           m:BillyPreston ;
        pi:piano           m:PaulMcCartney ;
        pi:tenorsaxophone  m:Uncredited ;
        pi:twotrombones    m:Uncredited ;
        pi:twotrumpets     m:Uncredited ;
        pi:vocals          m:PaulMcCartney .


t:IGotAWoman  a         c:Song ;
        rdfs:label      "I Got A Woman" ;
        pi:bass          m:PaulMcCartney ;
        pi:drums         m:RingoStarr ;
        pi:leadguitar    m:GeorgeHarrison ;
        pi:rhythmguitar  m:JohnLennon ;
        pi:vocals        m:JohnLennon .

t:TheSaints  a          c:Song ;
        rdfs:label      "The Saints" ;
        pi:bass          m:PaulMcCartney ;
        pi:drums         m:PeteBest ;
        pi:leadguitar    m:TonySheridan , m:GeorgeHarrison ;
        pi:rhythmguitar  m:JohnLennon ;
        pi:vocals        m:TonySheridan .

t:LendMeYourComb  a     c:Song ;
        rdfs:label      "Lend Me Your Comb" ;
        pi:bass          m:PaulMcCartney ;
        pi:drums         m:RingoStarr ;
        pi:leadguitar    m:GeorgeHarrison ;
        pi:rhythmguitar  m:JohnLennon ;
        pi:vocals        m:GeorgeHarrison , m:PaulMcCartney , m:JohnLennon .

t:BesameMucho  a        c:Song ;
        rdfs:label      "Besame Mucho" ;
        pi:bass          m:PaulMcCartney ;
        pi:drums         m:PeteBest ;
        pi:leadguitar    m:GeorgeHarrison ;
        pi:rhythmguitar  m:JohnLennon ;
        pi:vocals        m:PaulMcCartney .

Beatles2.ttl

@prefix c:     <http://beatlesExample/ns/class/> .
@prefix t:     <http://beatlesExample/ns/title/> .
@prefix pi:     <http://beatlesExample/ns/playsInstrument/> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
@prefix m:     <http://beatlesExample/ns/musician/> .

c:Singer rdfs:subClassOf c:Musician.
c:Guitarist rdfs:subClassOf c:Musician.
c:Drummer rdfs:subClassOf c:Musician.
c:Flutist rdfs:subClassOf c:Musician.      
c:Trumpeter rdfs:subClassOf c:Musician.
c:Cellist rdfs:subClassOf c:Musician.
c:Percussionist rdfs:subClassOf c:Musician.
c:Harpist rdfs:subClassOf c:Musician.

c:Guitar rdfs:subClassOf c:Instrument.
c:Piano rdfs:subClassOf c:Instrument.
c:Drums rdfs:subClassOf c:Instrument.
c:Vocals rdfs:subClassOf c:Instrument.
c:Violin rdfs:subClassOf c:Instrument.
c:Viola rdfs:subClassOf c:Instrument.
c:Cello rdfs:subClassOf c:Instrument.
c:Trombone rdfs:subClassOf c:Instrument.
c:Trumpet rdfs:subClassOf c:Instrument.
c:Flute rdfs:subClassOf c:Instrument.
c:Vibraphone rdfs:subClassOf c:Instrument.
c:Bell rdfs:subClassOf c:Instrument.
c:Harp rdfs:subClassOf c:Instrument.
c:Shaker rdfs:subClassOf c:Instrument.
c:Hands rdfs:subClassOf c:Instrument.

t:piano  a   c:Instrument ;
        rdfs:label  "piano" .

t:celesta  a   c:Instrument ;
        rdfs:label  "celesta" .

t:celesta
        a c:Piano;
            a   c:Instrument ;
        pi:playedBy c:Pianist .

t:electricpiano  a   c:Instrument ;
        rdfs:label  "electric piano" .

t:electricpiano
        a c:Piano;
            a   c:Instrument ;
        pi:playedBy c:Pianist .

t:Hammondorgan  a   c:Instrument ;
        rdfs:label  "Hammondorgan" .

t:Hammondorgan
        a c:Piano;
            a   c:Instrument ;
        pi:playedBy c:Pianist .

t:harmonium  a   c:Instrument ;
        rdfs:label  "harmonium" .

t:harmonium
        a c:Piano;
            a   c:Instrument ;
        pi:playedBy c:Pianist .

t:guitar  a   c:Instrument ;
        rdfs:label  "guitar" .

t:acousticguitar  a  
   c:Instrument ;
        rdfs:label  "acoustic guitar" .

t:acousticguitar
        a c:Guitar;
            a   c:Instrument ;
        pi:playedBy c:Guitarist .

t:bass  a   c:Instrument ;
        rdfs:label  "bass" .

t:bass
        a c:Guitar;
            a   c:Instrument ;
        pi:playedBy c:Guitarist .

t:bassguitar  a   c:Instrument ;
        rdfs:label  "bass guitar" .

t:bassguitar
        a c:Guitar;
            a   c:Instrument ;
        pi:playedBy c:Guitarist .

t:doublebass  a   c:Instrument ;
        rdfs:label  "double bass" .

t:doublebass
        a c:Guitar;
            a   c:Instrument ;
        pi:playedBy c:Guitarist .

t:drums  a   c:Instrument ;
        rdfs:label  "drums" .

t:drums
        a c:Drums;
            a   c:Instrument ;
        pi:playedBy c:Drummer .

t:tambourine  a   c:Instrument ;
        rdfs:label  "tambourine" .

t:tambourine
        a c:Drums;
            a   c:Instrument ;
        pi:playedBy c:Drummer .

t:snaredrum
        a c:Drums;
            a   c:Instrument ;
        pi:playedBy c:Drummer .

t:vibraphone  a   c:Instrument ;
        rdfs:label  "vibraphone" .

t:vibraphone
        a c:Bell;
            a   c:Instrument ;
        pi:playedBy c:Percussionist .

t:tubularbells  a   c:Instrument ;
        rdfs:label  "tubular bells" .

t:tubularbells
        a c:Vibraphone;
            a   c:Instrument ;
        pi:playedBy c:Percussionist .

t:handclaps  a   c:Instrument ;
        rdfs:label  "hand claps" .

t:handclaps
        a c:Hands;
            a   c:Instrument ;
        pi:playedBy c:Percussionist .

t:cello  a   c:Instrument ;
        rdfs:label  "cello" .

t:cello
        a c:Cello;
            a   c:Instrument ;
        pi:playedBy c:Cellist .

t:backingvocals  a   c:Instrument ;
        rdfs:label  "backing vocals" .

t:backingvocals
        a c:Vocals;
            a   c:Instrument ;
        pi:playedBy c:Singer .

t:double-trackedleadvocals  a   c:Instrument ;
        rdfs:label  "doubletracked lead vocals" .

t:double-trackedleadvocals
        a c:Vocals;
            a   c:Instrument ;
        pi:playedBy c:Singer .

t:trumpetsorflugelhorn  a   c:Instrument ;
        rdfs:label  "trumpets or flugelhorn" .

t:trumpetsorflugelhorn
        a c:Trumpet;
            a   c:Instrument ;
        pi:playedBy c:Trumpeter .

t:oboesorcoranglais  a   c:Instrument ;
        rdfs:label  "oboe or coranglais" .

t:oboesorcoranglais
        a c:Flute;
            a   c:Instrument ;
        pi:playedBy c:Flutist .

t:trumpet  a   c:Instrument ;
        rdfs:label  "trumpet" .

t:trumpet
        a c:Trumpet;
            a   c:Instrument ;
        pi:playedBy c:Trumpeter .

t:tenorsaxophone  a   c:Instrument ;
        rdfs:label  "tenor saxophone" .

t:tenorsaxophone
        a c:Trumpet;
            a   c:Instrument ;
        pi:playedBy c:Trumpeter .

t:harp  a   c:Instrument ;
        rdfs:label  "harp" .

t:harp
        a c:Harp;
            a   c:Instrument ;
        pi:playedBy c:Harpist .

t:horn  a   c:Instrument ;
        rdfs:label  "horn" .

t:clarinet
        a c:Trumpet;
            a   c:Instrument ;
        pi:playedBy c:Trumpeter .

t:clarinet  a   c:Instrument ;
        rdfs:label  "clarinet" .

t:clarinet
        a c:Flute;
            a   c:Instrument ;
        pi:playedBy c:Flutist .

t:trombone  a   c:Instrument ;
        rdfs:label  "trombone" .

t:trombone
        a c:Trombone;
            a   c:Instrument ;
        pi:playedBy c:Trumpeter .

t:threecellos  a   c:Instrument ;
        rdfs:label  "three cellos" .

t:threecellos
        a c:Cello;
            a   c:Instrument ;
        pi:playedBy c:Cellist .

t:threeflutes  a   c:Instrument ;
        rdfs:label  "three flutes" .

t:threeflutes
        a c:Flute;
            a   c:Instrument ;
        pi:playedBy c:Flutist .

t:threeviolas  a   c:Instrument ;
        rdfs:label  "three violas" .

t:threeviolas
        a c:Viola;
            a   c:Instrument ;
        pi:playedBy c:Guitarist .

t:12violins  a   c:Instrument ;
        rdfs:label  "12 violins" .

t:12violins
        a c:Violin;
            a   c:Instrument ;
        pi:playedBy c:Cellist .

t:viola  a   c:Instrument ;
        rdfs:label  "viola" .

t:viola
        a c:Viola;
            a   c:Instrument ;
        pi:playedBy c:Guitarist .

t:violin  a   c:Instrument ;
        rdfs:label  "violin" .

t:violin
        a c:Violin;
            a   c:Instrument ;
        pi:playedBy c:Cellist .

t:shaker  a   c:Instrument ;
        rdfs:label  "shaker" .

t:shaker
        a c:Shaker;
            a   c:Instrument ;
        pi:playedBy c:Percussionist .

m:PeteBest a c:Musician;
        rdfs:label  "Pete Best" .

m:TonySheridan a c:Musician;
        rdfs:label  "Tony Sheridan" .

m:LindaMcCartney a c:Musician;
        rdfs:label  "Linda McCartney" .

m:BillyPreston a c:Musician;
        rdfs:label  "Billy Preston" .

m:MikeRedway a c:Musician;
        rdfs:label  "Mike Redway" .

m:PatWhitmore a c:Musician;
        rdfs:label  "Pat Whitmore" .

m:FredLucas a c:Musician;
        rdfs:label  "Fred Lucas" .

m:ValStockwell a c:Musician;
        rdfs:label  "Val Stockwell" .

m:IreneKing a c:Musician;
        rdfs:label  "Irene King" .

m:IngridThomas a c:Musician;
        rdfs:label  "Ingrid Thomas" .

m:KenBarrie a c:Musician;
        rdfs:label  "Ken Barrie" .

m:RossGilmour a c:Musician;
        rdfs:label  "Ross Gilmour" .

m:StuartSutcliffe a c:Musician;
        rdfs:label  "Stuart Sutcliffe" .

m:JPower a c:Musician;
        rdfs:label  "JPower" .

m:FrancieSchwartz a c:Musician;
        rdfs:label  "Francie Schwartz" .

m:DonLang a c:Musician;
        rdfs:label  "Don Lang" .

m:BillPovey a c:Musician;
        rdfs:label  "Bill Povey" .

m:RexMorris a c:Musician;
        rdfs:label  "Rex Morris" .

m:DerekWatkins a c:Musician;
        rdfs:label  "Derek Watkins" .

m:FranciscoGabarro a c:Musician;
        rdfs:label  "Francisco Gabarro" .

m:TonyGilbert a c:Musician;
        rdfs:label  "Tony Gilbert" .

m:SidneySax a c:Musician;
        rdfs:label  "Sidney Sax" .

m:GeorgeMartin a c:Musician;
        rdfs:label  "George Martin" .

m:FrankClarke a c:Musician;
        rdfs:label  "Frank Clarke" .

m:PGoody a c:Musician;
        rdfs:label  "P Goody" .

m:MikeWinfield a c:Musician;
        rdfs:label  "Mike Winfield" .

m:RaySwinfield a c:Musician;
        rdfs:label  "Ray Swinfield" .

m:MannyWinters a c:Musician;
        rdfs:label  "Manny Winters" .

m:DennisWalton a c:Musician;
        rdfs:label  "Dennis Walton" .

m:DickMorgan a c:Musician;
        rdfs:label  "Dick Morgan" .

m:LeonCalvert a c:Musician;
        rdfs:label  "Leon Calvert" .

m:BertCourtley a c:Musician;
        rdfs:label  "Bert Courtley" .

m:DuncanCampbell a c:Musician;
        rdfs:label  "Duncan Campbell" .

m:DavidMason a c:Musician;
        rdfs:label  "David Mason" .

m:MalEvans a c:Musician;
        rdfs:label  "Mal Evans" .

m:RoyCopestake a c:Musician;
        rdfs:label  "Roy Copestake" .

m:JohnWilbraham a c:Musician;
        rdfs:label  "John Wilbraham" .

m:ElgarHowarth a c:Musician;
        rdfs:label  "Elgar Howarth" .

诀窍在于意识到您可以将 "John Lennon is the only vocalist" 改写为 "none of the vocalists are anyone other than John Lennon"。然后你可以使用 FILTER NOT EXISTS,像这样:

FILTER NOT EXISTS { 
      ?song pi:vocals ?other 
      FILTER(?other != m:JohnLennon)
}