Question: Hello, can someone help me with this function please. Write a function (not a method, so it should be outside the class) named compare_dictionaries(d1, d2).
Hello, can someone help me with this function please.
Write a function (not a method, so it should be outside the class) named compare_dictionaries(d1, d2). It should take two feature dictionaries d1 and d2 as inputs, and it should compute and return their log similarity score. Here is some pseudocode for what you will need to do:
Start the score at zero.
Let total be the total number of words in d1 not only distinct items, but all of the repetitions of all the items as well. (For example, total for our example shakespeare_dict would be 100.)
For each item in d2:
Check if the item is in d1.
If so, add the log of the probability that the item would be chosen at random from everything in d1, multiplied by the number of times it appears in d2.
If not, add the log of the default probability (0.5 / total), multiplied by the number of times the item appears in d2.
Return the resulting score.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
