meteor.doctest 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. .. Copyright (C) 2001-2020 NLTK Project
  2. .. For license information, see LICENSE.TXT
  3. .. -*- coding: utf-8 -*-
  4. =============
  5. METEOR tests
  6. =============
  7. No Allignment test
  8. ------------------
  9. >>> from nltk.translate import meteor
  10. If the candidate has no alignment to any of the references, the METEOR score is 0.
  11. >>> round(meteor(
  12. ... ['The candidate has no alignment to any of the references'],
  13. ... 'John loves Mary'
  14. ... ),4)
  15. 0.0
  16. Tests based on wikipedia examples
  17. ---------------------------------
  18. Testing on `wikipedia examples <https://en.wikipedia.org/wiki/METEOR#Examples>`_
  19. >>> same_res = round(meteor(
  20. ... ['The cat sat on the mat'],
  21. ... 'The cat sat on the mat'
  22. ... ),4)
  23. >>> abs(same_res - 0.9977) < 1e-2
  24. True
  25. >>> meteor(
  26. ... ['The cat sat on the mat'],
  27. ... 'on the mat sat the cat'
  28. ... )
  29. 0.5
  30. >>> round(meteor(
  31. ... ['The cat sat on the mat'],
  32. ... 'The cat was sat on the mat'
  33. ... ),4)
  34. 0.9654