Question: Task: Define clean _ record as follows: Clean a ( non - raw ) dictionary record. Input: record - A python dictionary as might be
Task: Define cleanrecord as follows:
Clean a nonraw dictionary record.
Input: record A python dictionary as might be produced by getrecord
Return: cleaned A copy of record cleaned as explained below, or None if any required keys are missing.
Requirementssteps: The goal of this task is twofold: Ensure that the record has certain "mandatory" attributes, and simplify the values for certain singlevalue attributes. More specifically, your function should satisfy these requirements.
If the input is missing any of the following keys, return None:id 'title', 'year', 'venue', 'abstract'
For the id and 'year' keys, assume there is only one value in the list and convert it into an integer and store this value.
if there is a 'refs' key, convert each element of its list to an integer and store this list of integers
For any other keys that are present in record, assume there is only one value and store that value asis ie as a string
Return the cleaned dictionary.
Example: A correct implementation should produce, for the deml, the following output:
None
abstract: 'A mathematical model for communicating sequential processes
is given, and a number of its interesting and useful prroperties
'arestated and proved. The possibilities of nondetermimsm are
'fullytaken into account.
'authors': SDBrookes, CARHoare, AW Roscoe',
id:
'refs':
'title': 'A theory of comm sequential processes',
'venue': 'Journal of the ACM JACM
'year':
code:
def cleanrecordrecord: dict dict:
####your code###
pprintcleanrecordrecords #None!
pprintcleanrecordrecords #valid
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
