Click4Ai

223.

Medium

Implement a function to calculate the probability of a sentence using an N-gram language model. **Example:** Given a sentence 'I love this' and an N-gram model, calculate the probability. **Constraints:** The sentence and N-gram model will be provided as input.

Test Cases

Test Case 1
Input: 'I love this', {'I love': 0.5, 'love this': 0.3}
Expected: 0.15
Test Case 2
Input: 'This is a test', {'This is': 0.2, 'is a': 0.4, 'a test': 0.1}
Expected: 0.008
+ 3 hidden test cases