Obtaining object in a particular language

11 views
Skip to first unread message

anoga...@gmail.com

unread,
Mar 22, 2015, 2:21:58 PM3/22/15
to rdfli...@googlegroups.com
Hello I am working with UDC the schema is like

<skos:Concept rdf:about="http://udcdata.info/078887">
<skos:inScheme rdf:resource="http://udcdata.info/udc-schema"/>
<skos:notation rdf:datatype="http://udcdata.info/UDCnotation">----</skos:notation>
<skos:prefLabel xml:lang="af">HOOFTABELLE</skos:prefLabel>
<skos:prefLabel xml:lang="be">АСНОЎНЫЯ ТАБЛІЦЫ</skos:prefLabel>
<skos:prefLabel xml:lang="bg">ОСНОВНА ТАБЛИЦА</skos:prefLabel>
<skos:prefLabel xml:lang="bn">প্রধান সারণিসমূহ</skos:prefLabel>
<skos:prefLabel xml:lang="ca">TAULES PRINCIPALS</skos:prefLabel>
<skos:prefLabel xml:lang="cs">Hlavní tabulky</skos:prefLabel>
<skos:prefLabel xml:lang="de">HAUPTTAFELN</skos:prefLabel>
<skos:prefLabel xml:lang="el">ΚΥΡΙΟΙ ΠΙΝΑΚΕΣ</skos:prefLabel>
<skos:prefLabel xml:lang="en">MAIN TABLES</skos:prefLabel>
...

I want to obtain only the concept in English. What I have to do?
g.add( (None, skos.prefLavel, None) )

Will give me all the objtects not only the one in English

Thank you.

Niklas Lindström

unread,
Mar 22, 2015, 6:16:27 PM3/22/15
to rdfli...@googlegroups.com
Hi,

In general, you can do:

    from rdflib.namespace import SKOS

    for o in g.objects(URIRef("http://udcdata.info/078887"), SKOS.prefLabel):
        if o.language == 'en':
            print o

There is also a utility function for getting labels (skos:prefLabel and similar) and filtering on language:

    for p, o in g.preferredLabel(URIRef("http://udcdata.info/078887"), lang='en'):
        print o

Cheers,
Niklas

 

Thank you.

--
http://github.com/RDFLib
---
You received this message because you are subscribed to the Google Groups "rdflib-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rdflib-dev+...@googlegroups.com.
To post to this group, send email to rdfli...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rdflib-dev/1f5d53ee-3d3b-46fc-b933-81d11e6ee9fc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages