@@ -131,24 +131,22 @@ def bleu_score(
131131 :rtype: BleuScore
132132
133133 :Example:
134- ::
135134
136- from pythainlp.benchmarks import bleu_score
137-
138- references = ["สวัสดีครับ วันนี้อากาศดีมาก"]
139- hypotheses = ["สวัสดีค่ะ วันนี้อากาศดี"]
140- score = bleu_score(references, hypotheses)
141- print(f"BLEU score: {score['bleu']:.2f}")
142-
143- ::
144-
145- # Multiple references per hypothesis
146- references = [
147- ["สวัสดีครับ", "สวัสดีค่ะ"], # two refs for first hypothesis
148- ["ลาก่อนครับ", "ลาก่อนค่ะ"], # two refs for second hypothesis
149- ]
150- hypotheses = ["สวัสดี", "ลาก่อน"]
151- score = bleu_score(references, hypotheses)
135+ >>> from pythainlp.benchmarks import bleu_score
136+
137+ >>> references = ["สวัสดีครับ วันนี้อากาศดีมาก"]
138+ >>> hypotheses = ["สวัสดีค่ะ วันนี้อากาศดี"]
139+ >>> score = bleu_score(references, hypotheses)
140+ >>> print(f"BLEU score: {score['bleu']:.2f}")
141+ BLEU score: 28.12
142+
143+ >>> # Multiple references per hypothesis
144+ >>> references = [
145+ ... ["สวัสดีครับ", "สวัสดีค่ะ"], # two refs for first hypothesis
146+ ... ["ลาก่อนครับ", "ลาก่อนค่ะ"], # two refs for second hypothesis
147+ ... ]
148+ >>> hypotheses = ["สวัสดี", "ลาก่อน"]
149+ >>> score = bleu_score(references, hypotheses)
152150 """
153151 from pythainlp .tokenize import word_tokenize
154152
@@ -282,16 +280,18 @@ def rouge_score(
282280 :rtype: dict[str, RougeScore]
283281
284282 :Example:
285- ::
286-
287- from pythainlp.benchmarks import rouge_score
288283
289- reference = "สวัสดีครับ วันนี้อากาศดีมาก"
290- hypothesis = "สวัสดีค่ะ วันนี้อากาศดี"
291- scores = rouge_score(reference, hypothesis)
292- print(f"ROUGE-1 F-measure: {scores['rouge1']['fmeasure']:.4f}")
293- print(f"ROUGE-2 F-measure: {scores['rouge2']['fmeasure']:.4f}")
294- print(f"ROUGE-L F-measure: {scores['rougeL']['fmeasure']:.4f}")
284+ >>> from pythainlp.benchmarks import rouge_score
285+
286+ >>> reference = "สวัสดีครับ วันนี้อากาศดีมาก"
287+ >>> hypothesis = "สวัสดีค่ะ วันนี้อากาศดี"
288+ >>> scores = rouge_score(reference, hypothesis)
289+ >>> print(f"ROUGE-1 F-measure: {scores['rouge1']['fmeasure']:.4f}")
290+ ROUGE-1 F-measure: 0.6000
291+ >>> print(f"ROUGE-2 F-measure: {scores['rouge2']['fmeasure']:.4f}")
292+ ROUGE-2 F-measure: 0.2500
293+ >>> print(f"ROUGE-L F-measure: {scores['rougeL']['fmeasure']:.4f}")
294+ ROUGE-L F-measure: 0.6000
295295 """
296296 from pythainlp .tokenize import word_tokenize
297297
@@ -391,14 +391,14 @@ def word_error_rate(
391391 :rtype: float
392392
393393 :Example:
394- ::
395394
396- from pythainlp.benchmarks import word_error_rate
395+ >>> from pythainlp.benchmarks import word_error_rate
397396
398- reference = "สวัสดีครับ วันนี้อากาศดีมาก"
399- hypothesis = "สวัสดีค่ะ วันนี้อากาศดี"
400- wer = word_error_rate(reference, hypothesis)
401- print(f"WER: {wer:.4f}")
397+ >>> reference = "สวัสดีครับ วันนี้อากาศดีมาก"
398+ >>> hypothesis = "สวัสดีค่ะ วันนี้อากาศดี"
399+ >>> wer = word_error_rate(reference, hypothesis)
400+ >>> print(f"WER: {wer:.4f}")
401+ WER: 0.4000
402402 """
403403 from pythainlp .tokenize import word_tokenize
404404
@@ -469,14 +469,14 @@ def character_error_rate(
469469 :rtype: float
470470
471471 :Example:
472- ::
473472
474- from pythainlp.benchmarks import character_error_rate
473+ >>> from pythainlp.benchmarks import character_error_rate
475474
476- reference = "สวัสดีครับ"
477- hypothesis = "สวัสดีค่ะ"
478- cer = character_error_rate(reference, hypothesis)
479- print(f"CER: {cer:.4f}")
475+ >>> reference = "สวัสดีครับ"
476+ >>> hypothesis = "สวัสดีค่ะ"
477+ >>> cer = character_error_rate(reference, hypothesis)
478+ >>> print(f"CER: {cer:.4f}")
479+ CER: 0.3000
480480 """
481481 # Work with characters directly (no tokenization needed)
482482 ref_chars = list (reference )
0 commit comments