This repository has been archived by the owner on Nov 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve clarity of diagnosis example (#117)
## What is the goal of this PR? Reformat the diagnosis example to make it as clear as possible to users how they can build their own KGCN. ## What are the changes implemented in this PR? - Move main parameters to be easily visible - Move out generic util methods for retrieving types and roles - Improved docstrings - Some outdated format docstrings updated to Google format
- Loading branch information
Showing
8 changed files
with
176 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
load("@io_bazel_rules_python//python:python.bzl", "py_library") | ||
load("@pypi_dependencies//:requirements.bzl", "requirement") | ||
|
||
|
||
py_library( | ||
name = "type", | ||
srcs = [ | ||
'type.py', | ||
], | ||
visibility=['//visibility:public'] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
|
||
|
||
def get_thing_types(tx): | ||
""" | ||
Get all schema types, excluding those for implicit attribute relations and base types | ||
Args: | ||
tx: Grakn transaction | ||
Returns: | ||
Grakn types | ||
""" | ||
schema_concepts = tx.query( | ||
"match $x sub thing; " | ||
"not {$x sub @has-attribute;}; " | ||
"not {$x sub @key-attribute;}; " | ||
"get;") | ||
thing_types = [schema_concept.get('x').label() for schema_concept in schema_concepts] | ||
[thing_types.remove(el) for el in ['thing', 'relation', 'entity', 'attribute']] | ||
return thing_types | ||
|
||
|
||
def get_role_types(tx): | ||
""" | ||
Get all schema roles, excluding those for implicit attribute relations, the base role type | ||
Args: | ||
tx: Grakn transaction | ||
Returns: | ||
Grakn roles | ||
""" | ||
schema_concepts = tx.query( | ||
"match $x sub role; " | ||
"not{$x sub @key-attribute-value;}; " | ||
"not{$x sub @key-attribute-owner;}; " | ||
"not{$x sub @has-attribute-value;}; " | ||
"not{$x sub @has-attribute-owner;};" | ||
"get;") | ||
role_types = ['has'] + [role.get('x').label() for role in schema_concepts] | ||
role_types.remove('role') | ||
return role_types |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters