コード例 #1
0
ファイル: query.py プロジェクト: infolab-csail/wikithingsdb
def hypernyms_of_class(w_class):
    """
    Given a wikipedia class, return a list of hypernyms (as a list of strings)
    from DBpedia's Ontology Classes.
    """

    result = get_hypernyms(w_class)
    return [from_dbpedia_class(x) for x in result]
コード例 #2
0
def hypernyms_of_class(w_class):
    """
    Given a wikipedia class, return a list of hypernyms (as a list of strings)
    from DBpedia's Ontology Classes.
    """

    result = get_hypernyms(w_class)
    return [from_dbpedia_class(x) for x in result]
コード例 #3
0
def hypernyms_of_article_from_db(article, limit=sys.maxint):
    """
    Given a case-sensitive article title, return all hypernyms of
    that article (as a list of strings) from DBpedia's Ontology
    Classes.
    """
    result = (DbpediaClass.select().join(Hypernym).join(
        ArticleClass,
        on=Hypernym.c_id).join(Article, on=ArticleClass.a_id).where(
            Article.title == article, ).limit(limit))
    return [from_dbpedia_class(x.dbpedia_class) for x in result]
コード例 #4
0
def hypernyms_of_class_from_db(w_class, limit=sys.maxint):
    """
    Given a wikipedia class, return a list of hypernyms (as a list of strings)
    from DBpedia's Ontology Classes.

    Deprecated: uses the database, resulting in slow, unordered
    results. Use hypernyms_of_class() instead.
    """

    w_class = to_wikipedia_class(w_class)
    result = (DbpediaClass.select().join(Hypernym).join(WikiClass).where(
        WikiClass.class_name == w_class).limit(limit))
    return [from_dbpedia_class(x.dbpedia_class) for x in result]
コード例 #5
0
ファイル: query.py プロジェクト: infolab-csail/wikithingsdb
def hypernyms_of_article_from_db(article, limit=sys.maxint):
    """
    Given a case-sensitive article title, return all hypernyms of
    that article (as a list of strings) from DBpedia's Ontology
    Classes.
    """
    result = (DbpediaClass
              .select()
              .join(Hypernym)
              .join(ArticleClass, on=Hypernym.c_id)
              .join(Article, on=ArticleClass.a_id)
              .where(
                  Article.title == article,
              )
              .limit(limit))
    return [from_dbpedia_class(x.dbpedia_class) for x in result]
コード例 #6
0
ファイル: query.py プロジェクト: infolab-csail/wikithingsdb
def hypernyms_of_class_from_db(w_class, limit=sys.maxint):
    """
    Given a wikipedia class, return a list of hypernyms (as a list of strings)
    from DBpedia's Ontology Classes.

    Deprecated: uses the database, resulting in slow, unordered
    results. Use hypernyms_of_class() instead.
    """

    w_class = to_wikipedia_class(w_class)
    result = (DbpediaClass
              .select()
              .join(Hypernym)
              .join(WikiClass)
              .where(WikiClass.class_name == w_class)
              .limit(limit))
    return [from_dbpedia_class(x.dbpedia_class) for x in result]
コード例 #7
0
ファイル: test_util.py プロジェクト: words16/wikithingsdb
 def test_from_dbpedia_class(self):
     self.assertEqual(util.from_dbpedia_class("owl:Thing"), "thing")
コード例 #8
0
 def test_from_dbpedia_class(self):
     self.assertEqual(util.from_dbpedia_class("owl:Thing"), "thing")