def __init__(self, db, mapping_db): self.mime_types = dict( [('html', 'text/html'), ('pretty-xml', 'application/rdf+xml'), ('turtle', 'text/turtle'), ('nt', 'text/plain'), ('json-ld', 'application/ld+json'), ('sparql', 'application/sparql-results+xml' ), ('json-sparql', 'application/sparql-results+json')]) self.mime_ext = dict( [('html','.html'), ('pretty-xml', '.rdf'), ('turtle', '.ttl'), ('nt', '.nt')]) self.wordnet_context = WNRDF.WNRDFContext(db, mapping_db) self.header = open(resolve("header")).read() self.footer = open(resolve("footer")).read()
def test_synset(self): context = WNRDF.WNRDFContext("wordnet_3.1+.db") graph = WNRDF.synset(context, 100001740) print graph.serialize() assert (graph)
def test_sample(self): context = WNRDF.WNRDFContext("wordnet_3.1+.db") graph = WNRDF.synset(context, 100003993) serialization = graph.serialize() assert ("American shopkeeper" in serialization)
def test_fail(self): context = WNRDF.WNRDFContext("wordnet_3.1+.db") graph = WNRDF.synset(context, 0) assert (graph is None)
def test_morphs(self): context = WNRDF.WNRDFContext("wordnet_3.1+.db") graph = WNRDF.entry(context, "abhor", "v") serialization = graph.serialize() assert ("abhorred" in serialization) assert ("abhorring" in serialization)
def test_adjposition(self): context = WNRDF.WNRDFContext("wordnet_3.1+.db") graph = WNRDF.entry(context, "inclined", "a") serialization = graph.serialize() assert ("adjposition" in serialization)
def test_entry(self): context = WNRDF.WNRDFContext("wordnet_3.1+.db") graph = WNRDF.entry(context, "cat", "n") print graph.serialize() assert (graph)