Example #1
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]
Example #2
0
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]
Example #3
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]
Example #4
0
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]
Example #5
0
 def test_to_dbpedia_class(self):
     self.assertEqual(util.to_dbpedia_class("THing"), "owl:Thing")
Example #6
0
 def test_to_dbpedia_class(self):
     self.assertEqual(util.to_dbpedia_class("THing"), "owl:Thing")