skip to Main Content
The smarter way
to do assignments.

Please note that this is just a preview of a school assignment posted on our website by one of our clients. If you need assistance with this question too, please click on the Order button at the bottom of the page to get started.

I’m working on a Python question and need a sample draft to help me understand better.Please write a logic inferencing program using Python which can handle family relationship. The input files are (t60,t61,t69) given below. Each input file contains lines of facts (each ended with period “.”) of family relationships and lines of questions (each ended with question mark “?”) about family relationships in any order. The questions should be answered based on all “previous” facts in the same file. The facts always have the format “’s is ”, e.g., “Martha’s husband is John”. The questions always have the format “Who is ’s ?”, e.g., “Who is John’s father?” Since some names can be either female or male, so you cannot infer the gender of a person by her/his name, instead, you need to infer gender by the family relationship. All the possible relationships are mother, father, husband, wife, son, daughter, brother, and sister. Assume each one has at most 1 mother and/or 1 father, and each one has at most one spouse (husband or wife), but one can have any number of siblings.Here is the pseudocode for the functions. For each test case, call relation(f), and relation() needs to call propagate before answering every query.genders = {‘mother’:’F’, ‘father’:’M’, ‘son’:’M’, ‘daughter’:’F’, ‘brother’:’M’,’sister’:’F’, ‘husband’:’M’, ‘wife’:’F’}reverses = {‘mother’:’child’, ‘father’:’child’, ‘son’:’parent’, ‘daughter’:’parent’,’brother’:’sibling’, ‘sister’:’sibling’, ‘husband’:’spouse’, ‘wife’:’spouse’}supers = {‘mother’:’parent’, ‘father’:’parent’, ‘son’:’child’, ‘daughter’:’child’,’brother’:’sibling’, ‘sister’:’sibling’, ‘husband’:’spouse’, ‘wife’:’spouse’}def propogate(hash): for all person, add each person’s child’s siblings as the person’s children for all person, add each person’s spouse’s children as the person’s children for all person, add each person’s parent’s spouse as a person’s parent for all person, add each person’s sibling’s parents as a person’s parentdef relation(f):hash = {}hash[“gender”] = {}hash[“parent”] = {}hash[“spouse”] = {}hash[“child”] = {}hash[“sibling”] = {}print(f, ‘:’)for each line from input file f:if line ends with ‘.’: # handle factadd ‘super’ relationship (refer supers dict above)check if conflict genders, if no, set gender, otherwise, return errorhandle relationship of wife/husband by checking genders andset genders for spouseadd ‘reverse’ relationship (refer reverses dict above)elif line ends with ‘?’: # handle querycall propogate(hash)if supers[relationship] of the queried person match the gender:output answerselse:output ‘Unknown’else:return(“ERROR”)else:return(“ERROR”)The t69 is an illegal test data, so you need report error and handle the next file is exists. Both t60.dat and t61.dat is legal tests, and t61.dat also test for whitespace convention. For t60.dat, you should answer the first questions with “Martha” and the second question with “Edward”. For t60.dat, you should answer “Martha” and “Unknown”.t60 Edward’s son is David.John’s daughter is Mary.Martha’s husband is John.Mary’s sister is Catherine.Who is Catherine’s mother?David’s brother is John.Edward’s wife is Jennifer.Who is John’s father?t 61Edward’s son is David.John’s daughter is Mary. Martha’s husband is John . Mary’s sister is Catherine.Who is Catherine’s mother ?Edward’s wife is Jennifer. Who is John’s father?t69123 Edward’s son is David.John’s daughter is Mary. Martha’s husband is John.Mary’s uncle Catherine.Catherine’s mother?David’s brother is John.Edward’s wife is Jennifer.Who is John’s father?

GET HELP WITH THIS ASSIGNMENT TODAY

Clicking on this button will take you to our custom assignment page. Here you can fill out all the additional details for this particular paper (grading rubric, academic style, number of sources etc), after which your paper will get assigned to a course-specific writer. If you have any issues/concerns, please don’t hesitate to contact our live support team or email us right away.

How It Works        |        About Us       |       Contact Us

© 2018 | Intelli Essays Homework Service®