def predict_retention(words): if not words: return 0 duration = words[-1]["end"] - words[0]["start"] score = 100 # too long → drop-off risk if duration > 30: score -= 30 # too short → no engagement if duration < 6: score -= 20 # weak opening signal if "..." in words[0]["text"]: score -= 10 return max(0, score)