Beispiel #1
0
def classes_of_article(article, limit=sys.maxint):
    """
    Given a case-sensitive article title, return the wikipedia classes of
    the article (as a list of strings).
    """
    result = (WikiClass.select().join(ArticleClass).join(Article).where(
        Article.title == article).limit(limit))
    return [x.class_name for x in result]
Beispiel #2
0
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]