Write a function named make_phrases(my_tags_dictionary) which takes a tags dictionary as a parameter and generates and prints a number of phrases using the content of the dictionary. Note: You can assume that the parameter tags dictionary only contains three tags (i.e. "DT", "JJ" and "NN").
We can generate a meaningful phrase if we start a phrase with a word which is classed as an article (i.e. a word with a 'DT' tag) followed by an adjective (i.e. a word with a 'JJ' tag) and end with a noun (i.e. a word with an 'NN' tag). For example: if the tags dictionary contains the following tag-words_list pairs:
{'JJ': ['brown'], 'NN': ['grass', 'summer'], 'DT': ['the']}
The phrases printed would be:
the brown grass the brown summer
For example:
| Test | Result |
|---|---|
tags = {'JJ': ['brown'], 'NN': ['grass', 'summer'], 'DT': ['the']}
make_phrases(tags
|
the brown grass the brown summer |
tags ={'JJ': ['brown', 'hot'], 'NN': ['bushes', 'days', 'grass', 'shrubs', 'summer', 'trees'], 'DT': ['the']}
make_phrases(tags) |
the brown bushes the brown days the brown grass the brown shrubs the brown summer the brown trees the hot bushes the hot days the hot grass the hot shrubs the hot summer the hot trees |
def make_phrases(my_tags_dictionary):
for noun in my_tags_dictionary['DT']:
for adjective in my_tags_dictionary['JJ']:
for article in my_tags_dictionary['NN']:
print(noun, adjective, article)
Write a function named make_phrases(my_tags_dictionary) which takes a tags dictionary as a parameter and generates and...
help
Question 12 (20 points) Write a function named inverse that takes a single parameter, a dictionary. In this key is a student, represented by a string. The value of each key is a list of courses, each represented by a string, in which the student is enrolled. dictionary each The function inverse should compute and return a dictionary in which each key is a course and the associated value is a list of students enrolled in that course For...