dbpedia fetch entitites in language other than english

后端 未结 2 1111
离开以前
离开以前 2021-01-14 02:47

I\'m trying to extract entity dictionary contains person name etc. from dbpedia using sparql.

PREFIX owl: 
PREFIX dbpprop         


        
相关标签:
2条回答
  • 2021-01-14 03:26

    You need to filter based on the language of the value of the property. Not every property will have values in different languages, but some properties will. It seems, from your example, that dbpprop:name doesn't have values in every language. You may find more values in other languages if you look on the other language specific DBpediae.

    However, for something like a name, you'll probably get multi-language results if you use the rdfs:label property. For instance, to get the names of Barack Obama, Daniel Webster, and Johnny Cash in Russian, you could do:

    select ?label {
      values ?person { dbpedia:Johnny_Cash dbpedia:Barack_Obama dbpedia:Daniel_Webster }
      ?person rdfs:label ?label .
      filter langMatches(lang(?label),"ru")
    }
    

    SPARQL results

    As an aside, note the use of langMatches rather than equality for matching language tags. This is usually a better approach, because it will correctly handle the different language tags within a language For example (from the SPARQL specification), you can find both of the French literals:

    "Cette Série des Années Soixante-dix"@fr .
    "Cette Série des Années Septante"@fr-BE .
    

    with langMatches(lang(?title),"fr"), but only the first one with lang(?title) = "fr".

    0 讨论(0)
  • 2021-01-14 03:38

    You are looking for rdfs:label for a name, of course all the names are English, you are looking at the English dbpedia.

    PREFIX owl: <http://dbpedia.org/ontology/>
    PREFIX dbpprop: <http://dbpedia.org/property/>
    SELECT distinct *
    WHERE {
        ?person a owl:Person .
        ?person rdfs:label ?name . 
        FILTER(lang(?name) = "fr")
    }
    

    Again, for the second one, if you replace the name with the rdfs: label you can have:

        PREFIX owl: <http://dbpedia.org/ontology/>
        PREFIX dbpprop: <http://dbpedia.org/property/>
        SELECT distinct *
            WHERE {
        ?person a owl:Person .
        ?person rdfs:label ?name .
        ?person dbpprop:language <http://dbpedia.org/resource/English_language>.
    }
    
    0 讨论(0)
提交回复
热议问题