diff --git a/copyvios/checker.py b/copyvios/checker.py index 091c024..ddf968a 100644 --- a/copyvios/checker.py +++ b/copyvios/checker.py @@ -9,7 +9,10 @@ from earwigbot import exceptions from .misc import Query, get_cache_db from .sites import get_site, get_sites -__all__ = ["do_check"] +__all__ = ["do_check", "T_POSSIBLE", "T_SUSPECT"] + +T_POSSIBLE = 0.3 +T_SUSPECT = 0.6 def do_check(): query = Query() @@ -60,7 +63,8 @@ def _get_results(query, follow=True): if not query.nocache: query.result = _get_cached_results(page, conn, query) if not query.result: - query.result = page.copyvio_check(max_queries=10, max_time=45) + query.result = page.copyvio_check( + min_confidence=T_SUSPECT, max_queries=10, max_time=45) query.result.cached = False _cache_result(page, query.result, conn) @@ -108,7 +112,7 @@ def _get_cached_results(page, conn, query): return result def _do_copyvio_compare(query, page, url): - result = page.copyvio_compare(url, max_time=30) + result = page.copyvio_compare(url, min_confidence=T_SUSPECT, max_time=30) if result.source_chain is not page.EMPTY: return result query.error = "timeout" if result.time > 30 else "no data" diff --git a/static/style.css b/static/style.css index 25720a4..405bbbf 100644 --- a/static/style.css +++ b/static/style.css @@ -126,6 +126,11 @@ div.green-box { border: 1px solid #7F7; } +div.yellow-box { + background-color: #FFE; + border: 1px solid #FF7; +} + div.red-box { background-color: #FEE; border: 1px solid #F77; diff --git a/templates/index.mako b/templates/index.mako index d4e8e39..6f92c3a 100644 --- a/templates/index.mako +++ b/templates/index.mako @@ -1,5 +1,6 @@ <%! from flask import g, request %>\ <%include file="/support/header.mako" args="title='Earwig\'s Copyvio Detector'"/> +<%namespace module="copyvios.checker" import="T_POSSIBLE, T_SUSPECT"/>\ <%namespace module="copyvios.highlighter" import="highlight_delta"/>\ <%namespace module="copyvios.misc" import="httpsfix, urlstrip"/>\ % if query.project and query.lang and (query.title or query.oldid): @@ -111,12 +112,13 @@ % if result: <% hide_comparison = "CopyviosHideComparison" in g.cookies and g.cookies["CopyviosHideComparison"].value == "True" %>
-
- % if result.violation: +
+ % if result.confidence >= T_POSSIBLE: + <% vio_type = "suspected" if result.confidence >= T_SUSPECT else "possible" %> % if query.oldid: -

${query.page.title | h} @${query.oldid | h} is a suspected violation of ${result.url | urlstrip, h}.

+

${query.page.title | h} @${query.oldid | h} is a ${vio_type} violation of ${result.url | urlstrip, h}.

% else: -

${query.page.title | h} is a suspected violation of ${result.url | urlstrip, h}.

+

${query.page.title | h} is a ${vio_type} violation of ${result.url | urlstrip, h}.

% endif % else: % if query.oldid: @@ -126,7 +128,7 @@ % endif % endif