Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
flippedAben committed Apr 28, 2019
2 parents c2d8500 + 560fa5c commit 0dfa658
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions scripts/process_question.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ def process_question(q):
q=q.lower()
form=r'(who )?(is )?(?P<character>.*)(oldest|youngest)?(living|dead|alive)? +(?P<relation>'+relation_regex+r') *\??$'
match=re.match(form, q)
#print("0",match)
if not match:
form=r'(who )?(is )?(the )?(oldest|youngest)?(living|dead|alive)? *(?P<relation>'+relation_regex+r') *of (?P<character>.*)\??$'
match=re.match(form, q)
#print("1",match)
if not match:
form=r'(who )?(is )?(?P<character>.*)(?P<relation>)?\??$'
match=re.match(form, q)
#print("2",match)
if match:
#print(match)
char=match.group('character')
Expand All @@ -35,3 +41,5 @@ def process_question(q):
process_question("Who is the Mother of dragons?")
process_question("Who is Peter Dinklage?")
process_question("Who is Peter Dinklage's grandfather?")
process_question("Who is the daughter of Lady Catelyn and Lord Eddard Stark?")
process_question("Who is the daughter of Lady Catelyn?")
2 changes: 2 additions & 0 deletions scripts/relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def get_relatives(names, relation):
rel_type="-[:IS_SIBLING_OF]-"
elif relation == "child":
names=get_relatives(names,"spouse").union(names) #ex: robin arryn
print("Finding child of both:", names)
rel_type="<-[:IS_CHILD_OF]-"
elif relation == "parent":
rel_type="-[:IS_CHILD_OF]->"
Expand Down Expand Up @@ -132,3 +133,4 @@ def get_relatives(names, relation):

print("**** ", resolve_relation(["Arya Stark"], "brother"))
print("**** ", resolve_relation(["Arya Stark"], "sister"))
print("**** ", resolve_relation(["Eddard Stark"], "daughter"))

0 comments on commit 0dfa658

Please sign in to comment.