def classes_of_hypernym(hypernym, limit=sys.maxint): """ Given a hypernym from DBpedia (string), return a list of wikipedia classes of that hypernym. Note: use 'thing' instead of 'owl:Thing'. """ hypernym = to_dbpedia_class(hypernym) result = (WikiClass.select().join(Hypernym).join(DbpediaClass).where( DbpediaClass.dbpedia_class == hypernym).limit(limit)) return [x.class_name for x in result]
def articles_of_hypernym_from_db(hypernym, limit=sys.maxint): """ Given a hypernym from DBpedia (string), return a list of articles of that hypernym. Note: use 'thing' instead of 'owl:Thing'. """ hypernym = to_dbpedia_class(hypernym) result = (Article.select().join(ArticleClass).join( Hypernym, on=ArticleClass.c_id).join(DbpediaClass, on=Hypernym.d_id).where( DbpediaClass.dbpedia_class == hypernym).limit(limit)) return [x.title for x in result]
def classes_of_hypernym(hypernym, limit=sys.maxint): """ Given a hypernym from DBpedia (string), return a list of wikipedia classes of that hypernym. Note: use 'thing' instead of 'owl:Thing'. """ hypernym = to_dbpedia_class(hypernym) result = (WikiClass .select() .join(Hypernym) .join(DbpediaClass) .where(DbpediaClass.dbpedia_class == hypernym) .limit(limit)) return [x.class_name for x in result]
def articles_of_hypernym_from_db(hypernym, limit=sys.maxint): """ Given a hypernym from DBpedia (string), return a list of articles of that hypernym. Note: use 'thing' instead of 'owl:Thing'. """ hypernym = to_dbpedia_class(hypernym) result = (Article .select() .join(ArticleClass) .join(Hypernym, on=ArticleClass.c_id) .join(DbpediaClass, on=Hypernym.d_id) .where(DbpediaClass.dbpedia_class == hypernym) .limit(limit)) return [x.title for x in result]
def test_to_dbpedia_class(self): self.assertEqual(util.to_dbpedia_class("THing"), "owl:Thing")