Created
March 30, 2020 20:02
-
-
Save anatoly-scherbakov/49237c959ab008186405fd41b754536d to your computer and use it in GitHub Desktop.
Star Wars expressed in grakn.ai
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
insert | |
$jedi isa order, has name "Jedi"; | |
$sith isa order, has name "Sith"; | |
# Okay, let's start with some Jedi masters we know of. | |
$obi-wan isa human, has name "Obi-Wan Kenobi", has gender "male"; | |
$obi-wan-is-jedi (member: $obi-wan, member-of: $jedi) isa membership; | |
# What do we know about Anakin? | |
$shmi_skywalker isa human, has name "Shmi Skywalker", has gender "female"; | |
$anakin-skywalker isa human, has name "Anakin Skywalker", has gender "male"; | |
$shmi-is-anakins-parent (parent: $shmi_skywalker, child: $anakin-skywalker) isa parentship; | |
$anakin-is-jedi (member: $anakin-skywalker, member-of: $jedi) isa membership; | |
$anakin-padawan-of-obiwan (institution: $jedi, teacher: $obi-wan, apprentice: $anakin-skywalker) isa apprenticeship; | |
# Now, his son | |
$luke-skywalker isa human, has name "Luke Skywalker", has gender "male"; | |
$anakin-is-lukes-parent (parent: $anakin-skywalker, child: $luke-skywalker) isa parentship; | |
$luke-is-jedi (member: $luke-skywalker, member-of: $jedi) isa membership; | |
# Darth Vader is an alter ego of Anakin Skywalker | |
$darth-vader isa human, has name "Darth Vader", has gender "male"; | |
$darth-vader-is-anakin (this: $anakin-skywalker, that: $darth-vader) isa alter-ego; | |
$darth-vader-is-sith (member: $darth-vader, member-of: $sith) isa membership; |
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
define | |
# We will be mostly describing conscious beings; let's define what a person is. | |
being sub entity; | |
name sub attribute, | |
datatype string; | |
gender sub attribute, | |
datatype string, | |
regex "^(male|female)$"; | |
person sub being, | |
has name, | |
has gender, | |
plays parent, | |
plays child; | |
# Star Wars are very conservative: most races have two genders and have two parents. | |
parentship sub relation, | |
relates parent, | |
relates child, | |
relates father as parent, | |
relates mother as parent, | |
relates son as child, | |
relates daughter as child; | |
person-with-a-mother sub entity; | |
person-with-a-father sub entity; | |
genderizeParentships1 | |
when{ | |
(parent: $p, child: $c) isa parentship; | |
$p has gender 'male'; | |
$c has gender 'male'; | |
}, then{ | |
(father: $p, son: $c) isa parentship; | |
}; | |
genderizeParentships2 | |
when{ | |
(parent: $p, child: $c) isa parentship; | |
$p has gender 'male'; | |
$c has gender 'female'; | |
}, then{ | |
(father: $p, daughter: $c) isa parentship; | |
}; | |
genderizeParentships3 | |
when{ | |
(parent: $p, child: $c) isa parentship; | |
$p has gender 'female'; | |
$c has gender 'male'; | |
}, then{ | |
(mother: $p, son: $c) isa parentship; | |
}; | |
genderizeParentships4 | |
when{ | |
(parent: $p, child: $c) isa parentship; | |
$p has gender 'female'; | |
$c has gender 'female'; | |
}, then{ | |
(mother: $p, daughter: $c) isa parentship; | |
}; | |
# We have multiple races in Star Wars. | |
human sub person; | |
wookie sub person; | |
# A person of any race can belong to one of the organizations. | |
organization sub entity, | |
has name, | |
plays member-of; | |
membership sub relation, | |
relates member, | |
relates member-of; | |
person sub being, | |
plays member; | |
# Order is an organization which is powered and defined by the Force. | |
order sub organization, | |
plays institution; | |
# Orders always use the notion of a teacher and an apprentice. | |
apprenticeship sub relation, | |
relates institution, | |
relates teacher, | |
relates apprentice; | |
person sub being, | |
plays teacher, | |
plays apprentice, | |
plays padawan; | |
# Determine when someone is a padawan. | |
padawanship sub relation, | |
relates teacher, | |
relates padawan; | |
apprenticeship-is-padawanship | |
when{ | |
(institution: $i, teacher: $t, apprentice: $a) isa apprenticeship; | |
$i has name "Jedi"; | |
}, then{ | |
(teacher: $t, padawan: $a) isa padawanship; | |
}; | |
# Two persons are actually the same one. | |
alter-ego sub relation, | |
relates this, | |
relates that; | |
person sub being, | |
plays this, | |
plays that; | |
# Alter-egoism does not change parental relationship | |
alter-ego-and-parentship | |
when { | |
(parent: $original, child: $child) isa parentship; | |
(this: $original, that: $alter-ego) isa alter-ego; | |
}, then { | |
(parent: $alter-ego, child: $child) isa parentship; | |
}; |
@crapthings That is an interesting question, I do not know the answer. I am also not sure how soon I could research it. But, I converted this into a Github repo: https://github.com/anatoly-scherbakov/grakn-star-wars
If you are willing to look into this - please feel free to make a PR. :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i have a question about conclusion of "then" from "rule", is it always a grakn "relation"?
can not be an role or entity?
if it can be an role or entity?
could you please add such feature in this schema that make this kinda like a cheatsheet?