Skip to content

Commit

Permalink
enable P31 for type by default - best scores on SemTab 2022
Browse files Browse the repository at this point in the history
  • Loading branch information
NoYo25 committed Oct 20, 2022
1 parent 2e75a77 commit 7055262
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion services/Wikidata_Proxy/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# endpoint for cache server
# None for local, SQlite-based cache
CACHE_ENDPOINT = 'https://jentab-01.fmi.uni-jena.de/cache'
CACHE_ENDPOINT = None #'https://jentab-01.fmi.uni-jena.de/cache'
# credentials
CACHE_USERNAME = 'YourCacheUserName'
CACHE_PASSWORD = 'YourCachePassword'
Expand Down
49 changes: 25 additions & 24 deletions services/Wikidata_Proxy/inc/api_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ async def get_ancestors_for_lst(entities):
aka simulate a reasoner and get all classes of the given entities
"""
# P31
# res = await runQuerySingleKey(cacheAncestors, entities, """
# SELECT ?base ?type
# WHERE {
# VALUES ?base { %s } .
# ?base wdt:P31 ?type .
# }
# """)
res = await runQuerySingleKey(cacheAncestors, entities, """
SELECT ?base ?type
WHERE {
VALUES ?base { %s } .
?base wdt:P31 ?type .
}
""")

# multiple hops
# res = await runQuerySingleKey(cacheAncestors, entities, """
# SELECT ?base ?type
Expand All @@ -65,23 +66,23 @@ async def get_ancestors_for_lst(entities):
# disabled for now: ?base (wdt:P31/wdt:P279*)|wdt:P279+ ?type .

# 2 hops including if entity == class
res = await runQuerySingleKey(cacheAncestors, entities, """
SELECT DISTINCT ?base ?type
WHERE
{
{
VALUES ?base { %s } .
{ ?base wdt:P31 ?type. } # direct instanceOf P31 (most fine-grained type)
UNION
{
?base wdt:P31 ?t.
?t wdt:P279 ?type . # parent of the instanceOf P279 (next fine-grained type)
}
UNION
{ ?base wdt:P279 ?type .} # if base is a class then retrieves its parent directly P279
}
}
""",printIt=False)
# res = await runQuerySingleKey(cacheAncestors, entities, """
# SELECT DISTINCT ?base ?type
# WHERE
# {
# {
# VALUES ?base { %s } .
# { ?base wdt:P31 ?type. } # direct instanceOf P31 (most fine-grained type)
# UNION
# {
# ?base wdt:P31 ?t.
# ?t wdt:P279 ?type . # parent of the instanceOf P279 (next fine-grained type)
# }
# UNION
# { ?base wdt:P279 ?type .} # if base is a class then retrieves its parent directly P279
# }
# }
# """,printIt=False)
# filtered result placeholder
f_res = {}
# get rid of excludedClasses
Expand Down

0 comments on commit 7055262

Please sign in to comment.