diff --git a/pages/copyvios.mako b/pages/copyvios.mako index c77dab5..2506d88 100644 --- a/pages/copyvios.mako +++ b/pages/copyvios.mako @@ -12,7 +12,7 @@ from earwigbot import bot, exceptions import oursql - def get_results(lang, project, title, query): + def get_results(lang, project, title, url, query): bot = bot.Bot(".earwigbot") try: site = bot.wiki.get_site(lang=lang, project=project) @@ -22,13 +22,15 @@ except exceptions.APIError: return None, None - page = site.get_page(title) - conn = open_sql_connection(bot) - """if not query.get("nocache"): - result = get_cached_results(page, conn) - if query.get("nocache") or not result: - result = get_fresh_results(page, conn) - """ + page = site.get_page(title) # TODO: what if the page doesn't exist? + # if url: + # result = get_url_specific_results(page, url) + # else: + # conn = open_sql_connection(bot) + # if not query.get("nocache"): + # result = get_cached_results(page, conn) + # if query.get("nocache") or not result: + # result = get_fresh_results(page, conn) mc1 = __import__("earwigbot").wiki.copyvios.MarkovChain(page.get()) mc2 = __import__("earwigbot").wiki.copyvios.MarkovChain("This is some random textual content for a page.") mci = __import__("earwigbot").wiki.copyvios.MarkovChainIntersection(mc1, mc2) @@ -36,6 +38,12 @@ True, 0.67123, "http://example.com/", 7, mc1, (mc2, mci)) return page, result + def get_url_specific_results(page, url): + t_start = time() + result = page.copyvio_compare(url) + result.tdiff = time() - t_start + return result + def open_sql_connection(bot): conn_args = bot.config.wiki["_toolserverSQLCache"] if "read_default_file" not in conn_args and "user" not in conn_args and "passwd" not in conn_args: @@ -47,7 +55,7 @@ return oursql.connect(**conn_args) def get_cached_results(page, conn): - query1 = "DELETE FROM cache WHERE cache_time < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 DAY)" + query1 = "DELETE FROM cache WHERE cache_time < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 3 DAY)" query2 = "SELECT cache_url, cache_time, cache_queries, cache_process_time FROM cache WHERE cache_id = ? AND cache_hash = ?" pageid = page.pageid() hash = sha256(page.get()).hexdigest() @@ -184,14 +192,15 @@ lang = query["lang"][0] project = query["project"][0] title = query["title"][0] + url = query.get("url", [None])[0] except (KeyError, IndexError): page = None else: - page, result = get_results(lang, project, title, query) + page, result = get_results(lang, project, title, url, query) %>\ <%include file="/support/header.mako" args="environ=environ, title='Copyvio Detector', add_css=('copyvios.css',), add_js=('copyvios.js',)"/>

Copyvio Detector

-

This tool attempts to detect copyright violations in Wikipedia articles.

+

This tool attempts to detect copyright violations in articles. Simply give the title of the page you want to check and hit Submit. The tool will then search for its content elsewhere on the web and display a report if a similar webpage is found. If you provide a URL, it will not query any search engines and instead display a report comparing the article to that particular webpage, like the Duplication Detector. Check out the FAQ for more information and technical details.

@@ -208,9 +217,17 @@ % if page: - + % else: - + + % endif + + + + % if url: + + % else: + % endif % if query.get("nocache") or page: @@ -240,7 +257,7 @@
  • ${round(result.confidence * 100, 1)}% confidence of a violation.
  • % if result.cached:
  • Results are cached - To save time (and money), this tool will retain the results of checks for up to 24 hours. This includes the URL of the "violated" source, but neither its content nor the content of the article. Future checks on the same page (assuming it remains unchanged) will not involve additional search queries, but a fresh comparison against the source URL will be made. + To save time (and money), this tool will retain the results of checks for up to 72 hours. This includes the URL of the "violated" source, but neither its content nor the content of the article. Future checks on the same page (assuming it remains unchanged) will not involve additional search queries, but a fresh comparison against the source URL will be made. If the page is modified, a new check will be run. from ${result.cache_time} (${result.cache_age} ago). Bypass the cache.
  • % else:
  • Results generated in ${round(result.tdiff, 3)} seconds using ${result.queries} queries.
  • @@ -249,7 +266,7 @@
    Page title:
    URL: