Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
536 B
3
Indexable
Never
def labelfromgraph(link):
    response = request.urlopen(link)
    new_url = response.geturl()
    #print(new_url)
    link = new_url.replace("/id/", "/ttl/id/")
    #print(link)
    meanings = []
    g = Graph()
    g.parse(link, format="ttl")
    query ='''prefix ontolex: <http://www.w3.org/ns/lemon/ontolex#> 
SELECT ?meaning WHERE {
  ?stuff ontolex:canonicalForm
  [ ontolex:writtenRep ?meaning ]
}
'''
    resu = g.query(query)
    for el in resu:
        meanings.append(str(el["meaning"]))
    return meanings