A Python robot that edits Wikipedia and interacts with people over IRC https://en.wikipedia.org/wiki/User:EarwigBot
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

64 líneas
2.8 KiB

  1. # -*- coding: utf-8 -*-
  2. #
  3. # Copyright (C) 2009-2014 Ben Kurtovic <ben.kurtovic@gmail.com>
  4. #
  5. # Permission is hereby granted, free of charge, to any person obtaining a copy
  6. # of this software and associated documentation files (the "Software"), to deal
  7. # in the Software without restriction, including without limitation the rights
  8. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. # copies of the Software, and to permit persons to whom the Software is
  10. # furnished to do so, subject to the following conditions:
  11. #
  12. # The above copyright notice and this permission notice shall be included in
  13. # all copies or substantial portions of the Software.
  14. #
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. # SOFTWARE.
  22. __all__ = ["CopyvioCheckResult"]
  23. class CopyvioCheckResult(object):
  24. """
  25. **EarwigBot: Wiki Toolset: Copyvio Check Result**
  26. A class holding information about the results of a copyvio check.
  27. *Attributes:*
  28. - :py:attr:`violation`: ``True`` if this is a violation, else ``False``
  29. - :py:attr:`confidence`: a float between 0 and 1 indicating accuracy
  30. - :py:attr:`url`: the URL of the violated page
  31. - :py:attr:`queries`: the number of queries used to reach a result
  32. - :py:attr:`time`: the amount of time the check took to complete
  33. - :py:attr:`article_chain`: the MarkovChain of the article text
  34. - :py:attr:`source_chain`: the MarkovChain of the violated page text
  35. - :py:attr:`delta_chain`: the MarkovChainIntersection comparing the two
  36. """
  37. def __init__(self, violation, confidence, url, queries, time, article,
  38. chains):
  39. self.violation = violation
  40. self.confidence = confidence
  41. self.url = url
  42. self.queries = queries
  43. self.time = time
  44. self.article_chain = article
  45. self.source_chain = chains[0]
  46. self.delta_chain = chains[1]
  47. def __repr__(self):
  48. """Return the canonical string representation of the result."""
  49. res = "CopyvioCheckResult(violation={0!r}, confidence={1!r}, url={2!r}, queries={3!r})"
  50. return res.format(self.violation, self.confidence, self.url,
  51. self.queries)
  52. def __str__(self):
  53. """Return a nice string representation of the result."""
  54. res = "<CopyvioCheckResult ({0} with {1} conf)>"
  55. return res.format(self.violation, self.confidence)