0
0
NLPml~10 mins

Evaluating generated text (BLEU, ROUGE) in NLP - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the BLEU score function from nltk.

NLP
from nltk.translate.bleu_score import [1]
Drag options to blanks, or click blank then click option'
Asentence_bleu
Bbleu_score
Ccorpus_bleu
Dbleu
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'bleu_score' which is the module, not the function.
Using 'corpus_bleu' which is for multiple sentences.
2fill in blank
medium

Complete the code to calculate the BLEU score for a candidate sentence.

NLP
score = sentence_bleu([reference], [1])
Drag options to blanks, or click blank then click option'
Acandidate_tokens
Breferences
Ccandidate_sentence
Dcandidate
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the reference list again instead of candidate.
Using a variable name that does not exist.
3fill in blank
hard

Fix the error in the ROUGE score calculation by completing the missing import.

NLP
from rouge_score import [1]
Drag options to blanks, or click blank then click option'
ARougeScorer
Brouge_scorer
Cscore_rouge
Drouge
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'rouge_scorer' which is a module, not the class.
Using 'score_rouge' which does not exist.
4fill in blank
hard

Fill both blanks to create a ROUGE scorer and calculate scores for two texts.

NLP
scorer = [1](['rouge1', 'rougeL'])
scores = scorer.score([2], generated)
Drag options to blanks, or click blank then click option'
ARougeScorer
Breference_text
Creference
Dscore
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'reference_text' which is not defined.
Using 'score' which is a variable, not a function/class.
5fill in blank
hard

Fill all three blanks to compute BLEU and ROUGE scores and print them.

NLP
bleu = sentence_bleu([reference], [1])
scorer = [2](['rouge1', 'rougeL'])
rouge_scores = scorer.score(reference, [3])
print(f"BLEU: {bleu:.2f}")
print(f"ROUGE-1 F1: {rouge_scores['rouge1'].fmeasure:.2f}")
Drag options to blanks, or click blank then click option'
Acandidate
BRougeScorer
Cgenerated
Dreference
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up reference and generated variables.
Using lowercase 'rougescorer' instead of 'RougeScorer'.