pyneql.utils package

Submodules

pyneql.utils.endpoints module

endpoints is part of the project PyNeQL Author: Valérie Hanoka

class pyneql.utils.endpoints.Endpoint(*args, **kwds)

Bases: aenum.Enum

List of the supported endpoints

DEFAULT = <Endpoint.DEFAULT: u'http://dbpedia.org/sparql'>
bnf = <Endpoint.bnf: u'http://data.bnf.fr/sparql'>
dbpedia_fr = <Endpoint.dbpedia_fr: u'http://fr.dbpedia.org/sparql'>
wikidata = <Endpoint.wikidata: u'https://query.wikidata.org/sparql'>
pyneql.utils.endpoints.is_endpoint_multilingual(endpoint)

Some endpoints are multilinguals and requires the language information to be given during a query.

Parameters:endpoint – An endpoint
Returns:True if the endpoint serves multilingual information, False otherwise.

pyneql.utils.enum module

enum.py is part of the project PyNeQL Author: Valérie Hanoka

class pyneql.utils.enum.LanguagesIso6391(*args, **kwds)

Bases: aenum.Enum

List of supported languages with their ISO 639-1:2002 codes.

Abkhazian = <LanguagesIso6391.Abkhazian: 'ab'>
Afar = <LanguagesIso6391.Afar: 'aa'>
Afrikaans = <LanguagesIso6391.Afrikaans: 'af'>
Akan = <LanguagesIso6391.Akan: 'ak'>
Albanian = <LanguagesIso6391.Albanian: 'sq'>
Amharic = <LanguagesIso6391.Amharic: 'am'>
Arabic = <LanguagesIso6391.Arabic: 'ar'>
Aragonese = <LanguagesIso6391.Aragonese: 'an'>
Armenian = <LanguagesIso6391.Armenian: 'hy'>
Assamese = <LanguagesIso6391.Assamese: 'as'>
Avaric = <LanguagesIso6391.Avaric: 'av'>
Avestan = <LanguagesIso6391.Avestan: 'ae'>
Aymara = <LanguagesIso6391.Aymara: 'ay'>
Azerbaijani = <LanguagesIso6391.Azerbaijani: 'az'>
Bambara = <LanguagesIso6391.Bambara: 'bm'>
Bashkir = <LanguagesIso6391.Bashkir: 'ba'>
Basque = <LanguagesIso6391.Basque: 'eu'>
Belarusian = <LanguagesIso6391.Belarusian: 'be'>
Bengali = <LanguagesIso6391.Bengali: 'bn'>
Bihari_languages = <LanguagesIso6391.Bihari_languages: 'bh'>
Bislama = <LanguagesIso6391.Bislama: 'bi'>
Bosnian = <LanguagesIso6391.Bosnian: 'bs'>
Breton = <LanguagesIso6391.Breton: 'br'>
Bulgarian = <LanguagesIso6391.Bulgarian: 'bg'>
Burmese = <LanguagesIso6391.Burmese: 'my'>
Catalan_Valencian = <LanguagesIso6391.Catalan_Valencian: 'ca'>
Central_Khmer = <LanguagesIso6391.Central_Khmer: 'km'>
Chamorro = <LanguagesIso6391.Chamorro: 'ch'>
Chechen = <LanguagesIso6391.Chechen: 'ce'>
Chichewa_Chewa_Nyanja = <LanguagesIso6391.Chichewa_Chewa_Nyanja: 'ny'>
Chinese = <LanguagesIso6391.Chinese: 'zh'>
Chuvash = <LanguagesIso6391.Chuvash: 'cv'>
Cornish = <LanguagesIso6391.Cornish: 'kw'>
Corsican = <LanguagesIso6391.Corsican: 'co'>
Cree = <LanguagesIso6391.Cree: 'cr'>
Croatian = <LanguagesIso6391.Croatian: 'hr'>
Czech = <LanguagesIso6391.Czech: 'cs'>
Danish = <LanguagesIso6391.Danish: 'da'>
Divehi_Dhivehi_Maldivian = <LanguagesIso6391.Divehi_Dhivehi_Maldivian: 'dv'>
Dutch_Flemish = <LanguagesIso6391.Dutch_Flemish: 'nl'>
Dzongkha = <LanguagesIso6391.Dzongkha: 'dz'>
English = <LanguagesIso6391.English: 'en'>
Esperanto = <LanguagesIso6391.Esperanto: 'eo'>
Estonian = <LanguagesIso6391.Estonian: 'et'>
Ewe = <LanguagesIso6391.Ewe: 'ee'>
Faroese = <LanguagesIso6391.Faroese: 'fo'>
Fijian = <LanguagesIso6391.Fijian: 'fj'>
Finnish = <LanguagesIso6391.Finnish: 'fi'>
French = <LanguagesIso6391.French: 'fr'>
Fulah = <LanguagesIso6391.Fulah: 'ff'>
Gaelic_Scottish_Gaelic = <LanguagesIso6391.Gaelic_Scottish_Gaelic: 'gd'>
Galician = <LanguagesIso6391.Galician: 'gl'>
Ganda = <LanguagesIso6391.Ganda: 'lg'>
Georgian = <LanguagesIso6391.Georgian: 'ka'>
German = <LanguagesIso6391.German: 'de'>
Greek_modern = <LanguagesIso6391.Greek_modern: 'el'>
Guarani = <LanguagesIso6391.Guarani: 'gn'>
Gujarati = <LanguagesIso6391.Gujarati: 'gu'>
Haitian_Haitian_Creole = <LanguagesIso6391.Haitian_Haitian_Creole: 'ht'>
Hausa = <LanguagesIso6391.Hausa: 'ha'>
Hebrew = <LanguagesIso6391.Hebrew: 'he'>
Herero = <LanguagesIso6391.Herero: 'hz'>
Hindi = <LanguagesIso6391.Hindi: 'hi'>
Hiri_Motu = <LanguagesIso6391.Hiri_Motu: 'ho'>
Hungarian = <LanguagesIso6391.Hungarian: 'hu'>
Icelandic = <LanguagesIso6391.Icelandic: 'is'>
Ido = <LanguagesIso6391.Ido: 'io'>
Igbo = <LanguagesIso6391.Igbo: 'ig'>
Indonesian = <LanguagesIso6391.Indonesian: 'id'>
Interlingua_IALA = <LanguagesIso6391.Interlingua_IALA: 'ia'>
Interlingue_Occidental = <LanguagesIso6391.Interlingue_Occidental: 'ie'>
Inuktitut = <LanguagesIso6391.Inuktitut: 'iu'>
Inupiaq = <LanguagesIso6391.Inupiaq: 'ik'>
Irish = <LanguagesIso6391.Irish: 'ga'>
Italian = <LanguagesIso6391.Italian: 'it'>
Japanese = <LanguagesIso6391.Japanese: 'ja'>
Javanese = <LanguagesIso6391.Javanese: 'jv'>
Kalaallisut_Greenlandic = <LanguagesIso6391.Kalaallisut_Greenlandic: 'kl'>
Kannada = <LanguagesIso6391.Kannada: 'kn'>
Kanuri = <LanguagesIso6391.Kanuri: 'kr'>
Kashmiri = <LanguagesIso6391.Kashmiri: 'ks'>
Kazakh = <LanguagesIso6391.Kazakh: 'kk'>
Kikuyu_Gikuyu = <LanguagesIso6391.Kikuyu_Gikuyu: 'ki'>
Kinyarwanda = <LanguagesIso6391.Kinyarwanda: 'rw'>
Kirghiz_Kyrgyz = <LanguagesIso6391.Kirghiz_Kyrgyz: 'ky'>
Komi = <LanguagesIso6391.Komi: 'kv'>
Kongo = <LanguagesIso6391.Kongo: 'kg'>
Korean = <LanguagesIso6391.Korean: 'ko'>
Kuanyama_Kwanyama = <LanguagesIso6391.Kuanyama_Kwanyama: 'kj'>
Kurdish = <LanguagesIso6391.Kurdish: 'ku'>
Lao = <LanguagesIso6391.Lao: 'lo'>
Latin = <LanguagesIso6391.Latin: 'la'>
Latvian = <LanguagesIso6391.Latvian: 'lv'>
Limburgan_Limburger_Limburgish = <LanguagesIso6391.Limburgan_Limburger_Limburgish: 'li'>
Lingala = <LanguagesIso6391.Lingala: 'ln'>
Lithuanian = <LanguagesIso6391.Lithuanian: 'lt'>
Luba_Katanga = <LanguagesIso6391.Luba_Katanga: 'lu'>
Luxembourgish_Letzeburgesch = <LanguagesIso6391.Luxembourgish_Letzeburgesch: 'lb'>
Macedonian = <LanguagesIso6391.Macedonian: 'mk'>
Malagasy = <LanguagesIso6391.Malagasy: 'mg'>
Malay = <LanguagesIso6391.Malay: 'ms'>
Malayalam = <LanguagesIso6391.Malayalam: 'ml'>
Maltese = <LanguagesIso6391.Maltese: 'mt'>
Manx = <LanguagesIso6391.Manx: 'gv'>
Maori = <LanguagesIso6391.Maori: 'mi'>
Marathi = <LanguagesIso6391.Marathi: 'mr'>
Marshallese = <LanguagesIso6391.Marshallese: 'mh'>
Mongolian = <LanguagesIso6391.Mongolian: 'mn'>
Nauru = <LanguagesIso6391.Nauru: 'na'>
Navajo_Navaho = <LanguagesIso6391.Navajo_Navaho: 'nv'>
Ndebele_North = <LanguagesIso6391.Ndebele_North: 'nd'>
Ndebele_South = <LanguagesIso6391.Ndebele_South: 'nr'>
Ndonga = <LanguagesIso6391.Ndonga: 'ng'>
Nepali = <LanguagesIso6391.Nepali: 'ne'>
Norwegian = <LanguagesIso6391.Norwegian: 'no'>
Norwegian_Bokmal = <LanguagesIso6391.Norwegian_Bokmal: 'nb'>
Norwegian_Nynorsk = <LanguagesIso6391.Norwegian_Nynorsk: 'nn'>
Occitan = <LanguagesIso6391.Occitan: 'oc'>
Ojibwa = <LanguagesIso6391.Ojibwa: 'oj'>
Oriya = <LanguagesIso6391.Oriya: 'or'>
Oromo = <LanguagesIso6391.Oromo: 'om'>
Ossetian_Ossetic = <LanguagesIso6391.Ossetian_Ossetic: 'os'>
Pali = <LanguagesIso6391.Pali: 'pi'>
Panjabi_Punjabi = <LanguagesIso6391.Panjabi_Punjabi: 'pa'>
Persian = <LanguagesIso6391.Persian: 'fa'>
Polish = <LanguagesIso6391.Polish: 'pl'>
Portuguese = <LanguagesIso6391.Portuguese: 'pt'>
Pushto_Pashto = <LanguagesIso6391.Pushto_Pashto: 'ps'>
Quechua = <LanguagesIso6391.Quechua: 'qu'>
Romanian_Moldavian_Moldovan = <LanguagesIso6391.Romanian_Moldavian_Moldovan: 'ro'>
Romansh = <LanguagesIso6391.Romansh: 'rm'>
Rundi = <LanguagesIso6391.Rundi: 'rn'>
Russian = <LanguagesIso6391.Russian: 'ru'>
Sami_Northern = <LanguagesIso6391.Sami_Northern: 'se'>
Samoan = <LanguagesIso6391.Samoan: 'sm'>
Sango = <LanguagesIso6391.Sango: 'sg'>
Sanskrit = <LanguagesIso6391.Sanskrit: 'sa'>
Sardinian = <LanguagesIso6391.Sardinian: 'sc'>
Serbian = <LanguagesIso6391.Serbian: 'sr'>
Shona = <LanguagesIso6391.Shona: 'sn'>
Sichuan_Yi_Nuosu = <LanguagesIso6391.Sichuan_Yi_Nuosu: 'ii'>
Sindhi = <LanguagesIso6391.Sindhi: 'sd'>
Sinhala_Sinhalese = <LanguagesIso6391.Sinhala_Sinhalese: 'si'>
Slovak = <LanguagesIso6391.Slovak: 'sk'>
Slovenian = <LanguagesIso6391.Slovenian: 'sl'>
Somali = <LanguagesIso6391.Somali: 'so'>
Sotho_Southern = <LanguagesIso6391.Sotho_Southern: 'st'>
Spanish_Castilian = <LanguagesIso6391.Spanish_Castilian: 'es'>
Sundanese = <LanguagesIso6391.Sundanese: 'su'>
Swahili = <LanguagesIso6391.Swahili: 'sw'>
Swati = <LanguagesIso6391.Swati: 'ss'>
Swedish = <LanguagesIso6391.Swedish: 'sv'>
Tagalog = <LanguagesIso6391.Tagalog: 'tl'>
Tahitian = <LanguagesIso6391.Tahitian: 'ty'>
Tajik = <LanguagesIso6391.Tajik: 'tg'>
Tamil = <LanguagesIso6391.Tamil: 'ta'>
Tatar = <LanguagesIso6391.Tatar: 'tt'>
Telugu = <LanguagesIso6391.Telugu: 'te'>
Thai = <LanguagesIso6391.Thai: 'th'>
Tibetan = <LanguagesIso6391.Tibetan: 'bo'>
Tigrinya = <LanguagesIso6391.Tigrinya: 'ti'>
Tonga = <LanguagesIso6391.Tonga: 'to'>
Tsonga = <LanguagesIso6391.Tsonga: 'ts'>
Tswana = <LanguagesIso6391.Tswana: 'tn'>
Turkish = <LanguagesIso6391.Turkish: 'tr'>
Turkmen = <LanguagesIso6391.Turkmen: 'tk'>
Twi = <LanguagesIso6391.Twi: 'tw'>
Uighur_Uyghur = <LanguagesIso6391.Uighur_Uyghur: 'ug'>
Ukrainian = <LanguagesIso6391.Ukrainian: 'uk'>
Urdu = <LanguagesIso6391.Urdu: 'ur'>
Uzbek = <LanguagesIso6391.Uzbek: 'uz'>
Venda = <LanguagesIso6391.Venda: 've'>
Vietnamese = <LanguagesIso6391.Vietnamese: 'vi'>
Volapuk = <LanguagesIso6391.Volapuk: 'vo'>
Walloon = <LanguagesIso6391.Walloon: 'wa'>
Welsh = <LanguagesIso6391.Welsh: 'cy'>
Western_Frisian = <LanguagesIso6391.Western_Frisian: 'fy'>
Wolof = <LanguagesIso6391.Wolof: 'wo'>
Xhosa = <LanguagesIso6391.Xhosa: 'xh'>
Yiddish = <LanguagesIso6391.Yiddish: 'yi'>
Yoruba = <LanguagesIso6391.Yoruba: 'yo'>
Zhuang_Chuang = <LanguagesIso6391.Zhuang_Chuang: 'za'>
Zulu = <LanguagesIso6391.Zulu: 'zu'>

pyneql.utils.namespace module

namespace.py is part of the project PyNeQL Author: Valérie Hanoka

class pyneql.utils.namespace.NameSpace(*args, **kwds)

Bases: aenum.Enum

Common SPARQL prefixes. See also https://prefix.cc/

akt = <NameSpace.akt: u'http://www.aktors.org/ontology/portal#'>
akts = <NameSpace.akts: u'http://www.aktors.org/ontology/support #'>
bd = <NameSpace.bd: u'http://www.bigdata.com/rdf#'>
bds = <NameSpace.bds: u'http://www.bigdata.com/rdf/search#'>
bibo = <NameSpace.bibo: u'http://purl.org/ontology/bibo/'>
bio = <NameSpace.bio: u'http://vocab.org/bio/0.1/'>
bnf_onto = <NameSpace.bnf_onto: u'http://data.bnf.fr/ontology/bnf-onto/'>
bnfroles = <NameSpace.bnfroles: u'http://data.bnf.fr/vocabulary/roles/'>
category_fr = <NameSpace.category_fr: u'http://fr.dbpedia.org/resource/Cat\xe9gorie:'>
dawgt = <NameSpace.dawgt: u'http://www.w3.org/2001/sw/DataAccess/tests/test-dawg#'>
dbc = <NameSpace.dbc: u'http://dbpedia.org/resource/Category:'>
dbo = <NameSpace.dbo: u'http://dbpedia.org/ontology/'>
dbp = <NameSpace.dbp: u'http://dbpedia.org/property/'>
dbpedia_cs = <NameSpace.dbpedia_cs: u'http://cs.dbpedia.org/resource/'>
dbpedia_de = <NameSpace.dbpedia_de: u'http://de.dbpedia.org/resource/'>
dbpedia_el = <NameSpace.dbpedia_el: u'http://el.dbpedia.org/resource/'>
dbpedia_es = <NameSpace.dbpedia_es: u'http://es.dbpedia.org/resource/'>
dbpedia_fr = <NameSpace.dbpedia_fr: u'http://fr.dbpedia.org/resource/'>
dbpedia_it = <NameSpace.dbpedia_it: u'http://it.dbpedia.org/resource/'>
dbpedia_ja = <NameSpace.dbpedia_ja: u'http://ja.dbpedia.org/resource/'>
dbpedia_ko = <NameSpace.dbpedia_ko: u'http://ko.dbpedia.org/resource/'>
dbpedia_nl = <NameSpace.dbpedia_nl: u'http://nl.dbpedia.org/resource/'>
dbpedia_pl = <NameSpace.dbpedia_pl: u'http://pl.dbpedia.org/resource/'>
dbpedia_pt = <NameSpace.dbpedia_pt: u'http://pt.dbpedia.org/resource/'>
dbpedia_ru = <NameSpace.dbpedia_ru: u'http://ru.dbpedia.org/resource/'>
dbr = <NameSpace.dbr: u'http://dbpedia.org/resource/'>
dc = <NameSpace.dc: u'http://purl.org/dc/elements/1.1/'>
dcmi_box = <NameSpace.dcmi_box: u'http://dublincore.org/documents/dcmi-box/'>
dcmitype = <NameSpace.dcmitype: u'http://purl.org/dc/dcmitype/'>
dct = <NameSpace.dct: u'http://purl.org/dc/terms/'>
dul = <NameSpace.dul: u'http://www.ontologydesignpatterns.org/ont/dul/DUL.owl#'>
fabio = <NameSpace.fabio: u'http://purl.org/spar/fabio/'>
fn = <NameSpace.fn: u'http://www.w3.org/2005/xpath-functions/#'>
foaf = <NameSpace.foaf: u'http://xmlns.com/foaf/0.1/'>
frbr_rda = <NameSpace.frbr_rda: u'http://rdvocab.info/uri/schema/FRBRentitiesRDA/'>
freebase = <NameSpace.freebase: u'http://rdf.freebase.com/ns/'>
gas = <NameSpace.gas: u'http://www.bigdata.com/rdf/gas#'>
genremus = <NameSpace.genremus: u'http://data.bnf.fr/vocabulary/musical-genre/'>
geo = <NameSpace.geo: u'http://www.w3.org/2003/01/geo/wgs84_pos#'>
geonames = <NameSpace.geonames: u'http://www.geonames.org/ontology#'>
georss = <NameSpace.georss: u'http://www.georss.org/georss/'>
go = <NameSpace.go: u'http://purl.org/obo/owl/GO#'>
hint = <NameSpace.hint: u'http://www.bigdata.com/queryHints#'>
id = <NameSpace.id: u'http://wordnet.rkbexplorer.com/id/'>
ign = <NameSpace.ign: u'http://data.ign.fr/ontology/topo.owl#'>
insee = <NameSpace.insee: u'http://rdf.insee.fr/geo/'>
isni = <NameSpace.isni: u'http://isni.org/ontology#'>
ldp = <NameSpace.ldp: u'http://www.w3.org/ns/ldp#'>
marcrel = <NameSpace.marcrel: u'http://id.loc.gov/vocabulary/relators/'>
math = <NameSpace.math: u'http://www.w3.org/2000/10/swap/math#'>
mesh = <NameSpace.mesh: u'http://purl.org/commons/record/mesh/'>
mf = <NameSpace.mf: u'http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#'>
mo = <NameSpace.mo: u'http://musicontology.com/'>
nci = <NameSpace.nci: u'http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#'>
obo = <NameSpace.obo: u'http://www.geneontology.org/formats/oboInOwl#'>
ogc = <NameSpace.ogc: u'http://www.opengis.net/'>
ogcgml = <NameSpace.ogcgml: u'http://www.opengis.net/ont/gml#'>
ogcgs = <NameSpace.ogcgs: u'http://www.opengis.net/ont/geosparql#'>
ogcgsf = <NameSpace.ogcgsf: u'http://www.opengis.net/def/function/geosparql/'>
ogcgsr = <NameSpace.ogcgsr: u'http://www.opengis.net/def/rule/geosparql/'>
ogcsf = <NameSpace.ogcsf: u'http://www.opengis.net/ont/sf#'>
opencyc = <NameSpace.opencyc: u'http://sw.opencyc.org/2008/06/10/concept/'>
ore = <NameSpace.ore: u'http://www.openarchives.org/ore/terms/'>
owl = <NameSpace.owl: u'http://www.w3.org/2002/07/owl#'>
p = <NameSpace.p: u'http://www.wikidata.org/prop/'>
pq = <NameSpace.pq: u'http://www.wikidata.org/prop/qualifier/'>
pqn = <NameSpace.pqn: u'http://www.wikidata.org/prop/qualifier/value-normalized/'>
pqv = <NameSpace.pqv: u'http://www.wikidata.org/prop/qualifier/value/'>
pr = <NameSpace.pr: u'http://www.wikidata.org/prop/reference/'>
prn = <NameSpace.prn: u'http://www.wikidata.org/prop/reference/value-normalized/'>
product = <NameSpace.product: u'http://www.buy.com/rss/module/productV2/'>
prop_fr = <NameSpace.prop_fr: u'http://fr.dbpedia.org/property/'>
protseq = <NameSpace.protseq: u'http://purl.org/science/protein/bysequence/'>
prov = <NameSpace.prov: u'http://www.w3.org/ns/prov#'>
prv = <NameSpace.prv: u'http://www.wikidata.org/prop/reference/value/'>
ps = <NameSpace.ps: u'http://www.wikidata.org/prop/statement/'>
psn = <NameSpace.psn: u'http://www.wikidata.org/prop/statement/value-normalized/'>
psv = <NameSpace.psv: u'http://www.wikidata.org/prop/statement/value/'>
rdagroup1elements = <NameSpace.rdagroup1elements: u'http://rdvocab.info/Elements/'>
rdagroup2elements = <NameSpace.rdagroup2elements: u'http://rdvocab.info/ElementsGr2/'>
rdarelationships = <NameSpace.rdarelationships: u'http://rdvocab.info/RDARelationshipsWEMI/'>
rdf = <NameSpace.rdf: u'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
rdfa = <NameSpace.rdfa: u'http://www.w3.org/ns/rdfa#'>
rdfdf = <NameSpace.rdfdf: u'http://www.openlinksw.com/virtrdf-data-formats#'>
rdfs = <NameSpace.rdfs: u'http://www.w3.org/2000/01/rdf-schema#'>
sc = <NameSpace.sc: u'http://purl.org/science/owl/sciencecommons/'>
schemaorg = <NameSpace.schemaorg: u'http://schema.org/'>
scovo = <NameSpace.scovo: u'http://purl.org/NET/scovo#'>
sd = <NameSpace.sd: u'http://www.w3.org/ns/sparql-service-description#'>
sioc = <NameSpace.sioc: u'http://rdfs.org/sioc/ns#'>
skos = <NameSpace.skos: u'http://www.w3.org/2004/02/skos/core#'>
template = <NameSpace.template: u'http://dbpedia.org/resource/Template:'>
template_fr = <NameSpace.template_fr: u'http://fr.dbpedia.org/resource/Template:'>
umbel_ac = <NameSpace.umbel_ac: u'http://umbel.org/umbel/ac/'>
umbel_sc = <NameSpace.umbel_sc: u'http://umbel.org/umbel/sc/'>
units = <NameSpace.units: u'http://dbpedia.org/units/'>
vcard = <NameSpace.vcard: u'http://www.w3.org/2001/vcard-rdf/3.0#'>
vcard2006 = <NameSpace.vcard2006: u'http://www.w3.org/2006/vcard/ns#'>
virtcxml = <NameSpace.virtcxml: u'http://www.openlinksw.com/schemas/virtcxml#'>
virtrdf = <NameSpace.virtrdf: u'http://www.openlinksw.com/schemas/virtrdf#'>
void = <NameSpace.void: u'http://rdfs.org/ns/void#'>
wd = <NameSpace.wd: u'http://www.wikidata.org/entity/'>
wdata = <NameSpace.wdata: u'http://www.wikidata.org/wiki/Special:EntityData/'>
wdno = <NameSpace.wdno: u'http://www.wikidata.org/prop/novalue/'>
wdref = <NameSpace.wdref: u'http://www.wikidata.org/reference/'>
wds = <NameSpace.wds: u'http://www.wikidata.org/entity/statement/'>
wdt = <NameSpace.wdt: u'http://www.wikidata.org/prop/direct/'>
wdt_o = <NameSpace.wdt_o: u'http://www.wikidata.org/ontology#'>
wdv = <NameSpace.wdv: u'http://www.wikidata.org/value/'>
wiki_fr = <NameSpace.wiki_fr: u'http://fr.wikipedia.org/wiki/'>
wikibase = <NameSpace.wikibase: u'http://wikiba.se/ontology#'>
wikicompany = <NameSpace.wikicompany: u'http://dbpedia.openlinksw.com/wikicompany/'>
xf = <NameSpace.xf: u'http://www.w3.org/2004/07/xpath-functions'>
xml = <NameSpace.xml: u'http://www.w3.org/XML/1998/namespace'>
xsd = <NameSpace.xsd: u'http://www.w3.org/2001/XMLSchema#'>
xsl10 = <NameSpace.xsl10: u'http://www.w3.org/XSL/Transform/1.0'>
xsl1999 = <NameSpace.xsl1999: u'http://www.w3.org/1999/XSL/Transform'>
xslwd = <NameSpace.xslwd: u'http://www.w3.org/TR/WD-xsl'>
yago = <NameSpace.yago: u'http://dbpedia.org/class/yago/'>
yago_res = <NameSpace.yago_res: u'http://mpii.de/yago/resource/'>
pyneql.utils.namespace.add_namespace(prefix, url)

Add an element to NameSpace enumeration, and returns it.

Parameters:
  • prefix – The name of the NameSpace to be added
  • url – The url of the NameSpace to be added
Returns:

The added NameSpace element

pyneql.utils.namespace.decompose_prefix(prefix)

Decomposes a prefix in its parts.

Example:

gn: <http://www.geonames.org/ontology#> will be decomposed in:

  • the abbreviation gn
  • the url http://www.geonames.org/ontology#
Parameters:prefix – A well-formed SPARQL prefix
Returns:A parsed SPARQL prefix: (abbreviation, url)
Raises:NameSpaceException – The prefix is ill-formed
pyneql.utils.namespace.get_consistent_namespace(abbreviation, namespace)

Given an abbreviation (e.g.: “foaf”) and a namespace (e.g.: “http://xmlns.com/foaf/0.1/”) we check that the mapping abbreviation: namespace is in the vocabulary. This function raises a NameSpaceException if (at least) one of the element is in the vocabulary but the other does not corresponds to what is given in the vocabulary. Returns the corresponding NameSpace if it exists or None.

Parameters:
  • abbreviation – A SPARQL PREFIX abbreviation (e.g.: “foaf”)
  • namespace – A SPARQL PREFIX namespace (e.g.: “http://xmlns.com/foaf/0.1/”)
Returns:

The corresponding NameSpace if it exists or None

Raises:

NameSpaceException – The prefix cannot be dynamically added to the vocabulary

pyneql.utils.namespace.get_expended_uri(uri)

Return the expanded form of a short URI if the namespace is known.

>>> get_expended_uri("foaf:surname")
>>> "http://xmlns.com/foaf/0.1/surname"
Parameters:uri – the URI to expand.
Returns:the long URI if it exists, else None
pyneql.utils.namespace.get_shortened_uri(uri)

Return a shortened URI if the namespace is known.

>>> get_shortened_uri("http://xmlns.com/foaf/0.1/surname")
>>> "foaf:surname"

pyneql.utils.utils module

utils.py is part of the project PyNeQL Author: Valérie Hanoka

exception pyneql.utils.utils.NameSpaceException

Bases: pyneql.utils.utils.QueryException

exception pyneql.utils.utils.QueryException

Bases: exceptions.Exception

pyneql.utils.utils.contains_a_date(s)

Detects if a string contains a date.

Parameters:s – a string
Returns:True if s contains a date, False otherwise.
pyneql.utils.utils.is_listlike(element)

Identify objects that acts like lists (list, tuple, set, …) but are not strings.

pyneql.utils.utils.merge_two_dicts_in_lists(x, y)

Given two dicts (with string keys), merge them into a new dict as a deep copy. In cases of duplicate keys, values are appended in lists.

>>> dic_y = {'both': {'both_y_diff' : 'bar', 'both_same': 'same_y'}, 'only_y': 'only_y'}
>>> dic_x = {'both': {'both_x_diff' : 'foo', 'both_same': 'same_x'}, 'only_x': {'only_x' : 'baz'}}
>>> merge_two_dicts(dic_x, dic_y)
>>> {'both': {
>>>      'both_same': ['same_x', 'same_y'],
>>>      'both_x_diff': 'foo',
>>>      'both_y_diff': 'bar'},
>>>  'only_x': {'only_x': 'baz'},
>>>  'only_y': 'only_y'}
Parameters:
  • x – First dictionary
  • y – Second dictionary
Returns:

The recursive merge of x and y, appending values in list in case of duplicate keys.

pyneql.utils.utils.merge_two_dicts_in_sets(x, y)

Given two dicts (with string keys), merge them into a new dict as a deep copy. In cases of duplicate keys, values are added into a set.

>>> dic_y = {'both': {'both_y_diff' : 'bar', 'both_same': 'same_y'}, 'only_y': 'only_y'}
>>> dic_x = {'both': {'both_x_diff' : 'foo', 'both_same': 'same_x'}, 'only_x': {'only_x' : 'baz'}}
>>> merge_two_dicts(dic_x, dic_y)
>>> {'both': {
>>>      'both_same': set(['same_x', 'same_y']),
>>>      'both_x_diff': 'foo',
>>>      'both_y_diff': 'bar'},
>>>  'only_x': {'only_x': 'baz'},
>>>  'only_y': 'only_y'}
Parameters:
  • x – First dictionary
  • y – Second dictionary
Returns:

The recursive merge of x and y, appending values in list in case of duplicate keys.

pyneql.utils.utils.normalize_str(s)

Remove leading and trailing and multiple whitspaces from a string s.

Parameters:s – a string or unicode
Returns:the unicode normalised version of s
pyneql.utils.utils.parse_literal_with_language(literal_with_language_str)

At some point, literals in the result set are formated as follow: “literal _(@lang)”. This function parses this string if possible, and returns a couple (litteral, language). :param literal_with_language_str: The string of the form “literal _(@lang)” :return: a couple (literal, lang) if the language is detected, (literal, None) otherwise.

pyneql.utils.utils.pretty_print_utf8(result_dataset)

For debug & documentation purpose

pyneql.utils.utils.recursive_pretty_print(element)

pyneql.utils.vocabulary module

vocabulary.py is part of the project PyNeQL Author: Valérie Hanoka

pyneql.utils.wikidataproperties module

pyneql.utils.wikidataproperties.translate_to_legible_wikidata_properties(wikidata_property)

Translates a wikidata property code into a legible property.

>>>print translate_to_legible_wikidata_properties(u’P214’) >>>’VIAF_ID_(P214)’

Module contents