A copyright violation detector running on Wikimedia Cloud Services https://tools.wmflabs.org/copyvios/
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 

151 行
9.6 KiB

  1. <%!
  2. from urlparse import parse_qs
  3. from earwigbot.bot import Bot
  4. %>\
  5. <%namespace module="support.copyvios" import="get_results, highlight_delta"/>\
  6. <%namespace module="support.sites" import="get_site, get_sites"/>\
  7. <%namespace module="support.misc" import="urlstrip"/>\
  8. <%
  9. lang = orig_lang = project = name = title = url = None
  10. site = page = result = None
  11. # Parse the query string.
  12. query = parse_qs(environ["QUERY_STRING"])
  13. if "lang" in query:
  14. lang = orig_lang = query["lang"][0].decode("utf8").lower()
  15. if "::" in lang:
  16. lang, name = lang.split("::", 1)
  17. if "project" in query:
  18. project = query["project"][0].decode("utf8").lower()
  19. if "title" in query:
  20. title = query["title"][0].decode("utf8")
  21. if "url" in query:
  22. url = query["url"][0].decode("utf8")
  23. bot = Bot(".earwigbot")
  24. all_langs, all_projects = get_sites(bot)
  25. if lang and project and title:
  26. site = get_site(bot, lang, project, name, all_projects)
  27. if site:
  28. page, result = get_results(bot, site, title, url, query)
  29. %>\
  30. <%include file="/support/header.mako" args="environ=environ, title='Copyvio Detector', add_css=('copyvios.css',), add_js=('copyvios.js',)"/>
  31. <h1>Copyvio Detector</h1>
  32. <p>This tool attempts to detect <a href="//en.wikipedia.org/wiki/WP:COPYVIO">copyright violations</a> 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 also provide a URL, it will not query any search engines and instead display a report comparing the article to that particular webpage, like the <a href="//toolserver.org/~dcoetzee/duplicationdetector/">Duplication Detector</a>. Check out the <a href="//en.wikipedia.org/wiki/User:EarwigBot/Copyvios/FAQ">FAQ</a> for more information and technical details.</p>
  33. <form action="${environ['PATH_INFO']}" method="get">
  34. <table>
  35. <tr>
  36. <td>Site:</td>
  37. <td>
  38. <tt>http://</tt>
  39. <select name="lang">
  40. <% selected_lang = orig_lang if orig_lang else bot.wiki.get_site().lang %>
  41. % for code, name in all_langs:
  42. % if code == selected_lang:
  43. <option value="${code}" selected="selected">${name}</option>
  44. % else:
  45. <option value="${code}">${name}</option>
  46. % endif
  47. % endfor
  48. </select>
  49. <tt>.</tt>
  50. <select name="project">
  51. <% selected_project = project if project else bot.wiki.get_site().project %>
  52. % for code, name in all_projects:
  53. % if code == selected_project:
  54. <option value="${code}" selected="selected">${name}</option>
  55. % else:
  56. <option value="${code}">${name}</option>
  57. % endif
  58. % endfor
  59. </select>
  60. <tt>.org</tt>
  61. </td>
  62. </tr>
  63. <tr>
  64. <td>Page title:</td>
  65. % if page:
  66. <td><input type="text" name="title" size="60" value="${page.title | h}" /></td>
  67. % elif title:
  68. <td><input type="text" name="title" size="60" value="${title | h}" /></td>
  69. % else:
  70. <td><input type="text" name="title" size="60" /></td>
  71. % endif
  72. </tr>
  73. <tr>
  74. <td>URL (optional):</td>
  75. % if url:
  76. <td><input type="text" name="url" size="120" value="${url | h}" /></td>
  77. % else:
  78. <td><input type="text" name="url" size="120" /></td>
  79. % endif
  80. </tr>
  81. % if query.get("nocache") or (result and result.cached):
  82. <tr>
  83. <td>Bypass cache:</td>
  84. % if query.get("nocache"):
  85. <td><input type="checkbox" name="nocache" value="1" checked="checked" /></td>
  86. % else:
  87. <td><input type="checkbox" name="nocache" value="1" /></td>
  88. % endif
  89. </tr>
  90. % endif
  91. <tr>
  92. <td><button type="submit">Submit</button></td>
  93. </tr>
  94. </table>
  95. </form>
  96. % if project and lang and title and not page:
  97. <div class="divider"></div>
  98. <div id="cv-result-yes">
  99. <p>The given site (project=<b><tt>${project}</tt></b>, language=<b><tt>${lang}</tt></b>) doesn't seem to exist. It may also be closed or private. <a href="//${lang}.${project}.org/">Confirm its URL.</a></p>
  100. </div>
  101. % elif project and lang and title and page and not result:
  102. <div class="divider"></div>
  103. <div id="cv-result-yes">
  104. <p>The given page doesn't seem to exist: <a href="${page.url}">${page.title | h}</a>.</p>
  105. </div>
  106. % elif page:
  107. <div class="divider"></div>
  108. <div id="cv-result-${'yes' if result.violation else 'no'}">
  109. % if result.violation:
  110. <h2 id="cv-result-header"><a href="${page.url}">${page.title | h}</a> is a suspected violation of <a href="${result.url | h}">${result.url | urlstrip}</a>.</h2>
  111. % else:
  112. <h2 id="cv-result-header">No violations detected in <a href="${page.url()}">${page.title | h}</a>.</h2>
  113. % endif
  114. <ul id="cv-result-list">
  115. <li><b><tt>${round(result.confidence * 100, 1)}%</tt></b> confidence of a violation.</li>
  116. % if result.cached:
  117. <li>Results are <a id="cv-cached" href="#">cached
  118. <span>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.</span>
  119. </a> from ${result.cache_time} (${result.cache_age} ago). <a href="${environ['REQUEST_URI'].decode("utf8") | h}&amp;nocache=1">Bypass the cache.</a></li>
  120. % else:
  121. <li>Results generated in <tt>${round(result.tdiff, 3)}</tt> seconds using <tt>${result.queries}</tt> queries.</li>
  122. % endif
  123. <li><a id="cv-result-detail-link" href="#cv-result-detail" onclick="copyvio_toggle_details()">Show details:</a></li>
  124. </ul>
  125. <div id="cv-result-detail" style="display: none;">
  126. <ul id="cv-result-detail-list">
  127. <li>Trigrams: <i>Article:</i> <tt>${result.article_chain.size()}</tt> / <i>Source:</i> <tt>${result.source_chain.size()}</tt> / <i>Delta:</i> <tt>${result.delta_chain.size()}</tt></li>
  128. % if result.cached:
  129. % if result.queries:
  130. <li>Retrieved from cache in <tt>${round(result.tdiff, 3)}</tt> seconds (originally generated in <tt>${round(result.original_tdiff, 3)}</tt>s using <tt>${result.queries}</tt> queries; <tt>${round(result.original_tdiff - result.tdiff, 3)}</tt>s saved).</li>
  131. % else:
  132. <li>Retrieved from cache in <tt>${round(result.tdiff, 3)}</tt> seconds (originally generated in <tt>${round(result.original_tdiff, 3)}</tt>s; <tt>${round(result.original_tdiff - result.tdiff, 3)}</tt>s saved).</li>
  133. % endif
  134. % endif
  135. % if result.queries:
  136. <li><i>Fun fact:</i> The Wikimedia Foundation paid Yahoo! Inc. <a href="http://info.yahoo.com/legal/us/yahoo/search/bosspricing/details.html">$${result.queries * 0.0008} USD</a> for these results.</li>
  137. % endif
  138. </ul>
  139. <table id="cv-chain-table">
  140. <tr>
  141. <td>Article: <div class="cv-chain-detail"><p>${highlight_delta(result.article_chain, result.delta_chain)}</p></div></td>
  142. <td>Source: <div class="cv-chain-detail"><p>${highlight_delta(result.source_chain, result.delta_chain)}</p></div></td>
  143. </tr>
  144. </table>
  145. </div>
  146. </div>
  147. % endif
  148. <%include file="/support/footer.mako" args="environ=environ"/>