prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  [wiktionary] Relax case sensitivity a bit?
  Looking up anything other than the exact capitalization in Wiktionary's database appears to fail. It might be worthwhile, for user experience, to always try the all-lowercase version of a query if no results are returned for it as entered.
  
  That said, the MediaWiki API would allow querying automatically for several variants (using `action=query&titles=variant1|Variant2|etc.`) and then fetching the first one that exists for display, if making multiple requests is OK in the plugin.
  
  </issue>
  <code>
  [start of sopel/modules/wiktionary.py]
  1 # coding=utf-8
  2 """
  3 wiktionary.py - Sopel Wiktionary Module
  4 Copyright 2009, Sean B. Palmer, inamidst.com
  5 Licensed under the Eiffel Forum License 2.
  6 
  7 https://sopel.chat
  8 """
  9 from __future__ import unicode_literals, absolute_import, print_function, division
  10 
  11 import re
  12 import requests
  13 from sopel import web
  14 from sopel.module import commands, example
  15 
  16 uri = 'https://en.wiktionary.org/w/index.php?title=%s&printable=yes'
  17 r_sup = re.compile(r'<sup[^>]+>.+</sup>')  # Superscripts that are references only, not ordinal indicators, etc...
  18 r_tag = re.compile(r'<[^>]+>')
  19 r_ul = re.compile(r'(?ims)<ul>.*?</ul>')
  20 
  21 
  22 def text(html):
  23     text = r_sup.sub('', html)  # Remove superscripts that are references from definition
  24     text = r_tag.sub('', text).strip()
  25     text = text.replace('\n', ' ')
  26     text = text.replace('\r', '')
  27     text = text.replace('(intransitive', '(intr.')
  28     text = text.replace('(transitive', '(trans.')
  29     text = web.decode(text)
  30     return text
  31 
  32 
  33 def wikt(word):
  34     bytes = requests.get(uri % web.quote(word)).text
  35     bytes = r_ul.sub('', bytes)
  36 
  37     mode = None
  38     etymology = None
  39     definitions = {}
  40     for line in bytes.splitlines():
  41         if 'id="Etymology"' in line:
  42             mode = 'etymology'
  43         elif 'id="Noun"' in line:
  44             mode = 'noun'
  45         elif 'id="Verb"' in line:
  46             mode = 'verb'
  47         elif 'id="Adjective"' in line:
  48             mode = 'adjective'
  49         elif 'id="Adverb"' in line:
  50             mode = 'adverb'
  51         elif 'id="Interjection"' in line:
  52             mode = 'interjection'
  53         elif 'id="Particle"' in line:
  54             mode = 'particle'
  55         elif 'id="Preposition"' in line:
  56             mode = 'preposition'
  57         elif 'id="Prefix"' in line:
  58             mode = 'prefix'
  59         elif 'id="Suffix"' in line:
  60             mode = 'suffix'
  61         # 'id="' can occur in definition lines <li> when <sup> tag is used for references;
  62         # make sure those are not excluded (see e.g., abecedarian).
  63         elif ('id="' in line) and ('<li>' not in line):
  64             mode = None
  65 
  66         elif (mode == 'etmyology') and ('<p>' in line):
  67             etymology = text(line)
  68         elif (mode is not None) and ('<li>' in line):
  69             definitions.setdefault(mode, []).append(text(line))
  70 
  71         if '<hr' in line:
  72             break
  73     return etymology, definitions
  74 
  75 
  76 parts = ('preposition', 'particle', 'noun', 'verb',
  77          'adjective', 'adverb', 'interjection',
  78          'prefix', 'suffix')
  79 
  80 
  81 def format(result, definitions, number=2):
  82     for part in parts:
  83         if part in definitions:
  84             defs = definitions[part][:number]
  85             result += u' — {}: '.format(part)
  86             n = ['%s. %s' % (i + 1, e.strip(' .')) for i, e in enumerate(defs)]
  87             result += ', '.join(n)
  88     return result.strip(' .,')
  89 
  90 
  91 @commands('wt', 'define', 'dict')
  92 @example('.wt bailiwick')
  93 def wiktionary(bot, trigger):
  94     """Look up a word on Wiktionary."""
  95     word = trigger.group(2)
  96     if word is None:
  97         bot.reply('You must tell me what to look up!')
  98         return
  99 
  100     _etymology, definitions = wikt(word)
  101     if not definitions:
  102         bot.say("Couldn't get any definitions for %s." % word)
  103         return
  104 
  105     result = format(word, definitions)
  106     if len(result) < 150:
  107         result = format(word, definitions, 3)
  108     if len(result) < 150:
  109         result = format(word, definitions, 5)
  110 
  111     if len(result) > 300:
  112         result = result[:295] + '[...]'
  113     bot.say(result)
  114
  [end of sopel/modules/wiktionary.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/sopel/modules/wiktionary.py b/sopel/modules/wiktionary.py
  --- a/sopel/modules/wiktionary.py
  +++ b/sopel/modules/wiktionary.py
  @@ -99,8 +99,11 @@
   
       _etymology, definitions = wikt(word)
       if not definitions:
  -        bot.say("Couldn't get any definitions for %s." % word)
  -        return
  +        # Cast word to lower to check in case of mismatched user input
  +        _etymology, definitions = wikt(word.lower())
  +        if not definitions:
  +            bot.say("Couldn't get any definitions for %s." % word)
  +            return
   
       result = format(word, definitions)
       if len(result) < 150:
  
verification_info: {"golden_diff": "diff --git a/sopel/modules/wiktionary.py b/sopel/modules/wiktionary.py\n--- a/sopel/modules/wiktionary.py\n+++ b/sopel/modules/wiktionary.py\n@@ -99,8 +99,11 @@\n \n     _etymology, definitions = wikt(word)\n     if not definitions:\n-        bot.say(\"Couldn't get any definitions for %s.\" % word)\n-        return\n+        # Cast word to lower to check in case of mismatched user input\n+        _etymology, definitions = wikt(word.lower())\n+        if not definitions:\n+            bot.say(\"Couldn't get any definitions for %s.\" % word)\n+            return\n \n     result = format(word, definitions)\n     if len(result) < 150:\n", "issue": "[wiktionary] Relax case sensitivity a bit?\nLooking up anything other than the exact capitalization in Wiktionary's database appears to fail. It might be worthwhile, for user experience, to always try the all-lowercase version of a query if no results are returned for it as entered.\r\n\r\nThat said, the MediaWiki API would allow querying automatically for several variants (using `action=query&titles=variant1|Variant2|etc.`) and then fetching the first one that exists for display, if making multiple requests is OK in the plugin.\n", "before_files": [{"content": "# coding=utf-8\n\"\"\"\nwiktionary.py - Sopel Wiktionary Module\nCopyright 2009, Sean B. Palmer, inamidst.com\nLicensed under the Eiffel Forum License 2.\n\nhttps://sopel.chat\n\"\"\"\nfrom __future__ import unicode_literals, absolute_import, print_function, division\n\nimport re\nimport requests\nfrom sopel import web\nfrom sopel.module import commands, example\n\nuri = 'https://en.wiktionary.org/w/index.php?title=%s&printable=yes'\nr_sup = re.compile(r'<sup[^>]+>.+</sup>')  # Superscripts that are references only, not ordinal indicators, etc...\nr_tag = re.compile(r'<[^>]+>')\nr_ul = re.compile(r'(?ims)<ul>.*?</ul>')\n\n\ndef text(html):\n    text = r_sup.sub('', html)  # Remove superscripts that are references from definition\n    text = r_tag.sub('', text).strip()\n    text = text.replace('\\n', ' ')\n    text = text.replace('\\r', '')\n    text = text.replace('(intransitive', '(intr.')\n    text = text.replace('(transitive', '(trans.')\n    text = web.decode(text)\n    return text\n\n\ndef wikt(word):\n    bytes = requests.get(uri % web.quote(word)).text\n    bytes = r_ul.sub('', bytes)\n\n    mode = None\n    etymology = None\n    definitions = {}\n    for line in bytes.splitlines():\n        if 'id=\"Etymology\"' in line:\n            mode = 'etymology'\n        elif 'id=\"Noun\"' in line:\n            mode = 'noun'\n        elif 'id=\"Verb\"' in line:\n            mode = 'verb'\n        elif 'id=\"Adjective\"' in line:\n            mode = 'adjective'\n        elif 'id=\"Adverb\"' in line:\n            mode = 'adverb'\n        elif 'id=\"Interjection\"' in line:\n            mode = 'interjection'\n        elif 'id=\"Particle\"' in line:\n            mode = 'particle'\n        elif 'id=\"Preposition\"' in line:\n            mode = 'preposition'\n        elif 'id=\"Prefix\"' in line:\n            mode = 'prefix'\n        elif 'id=\"Suffix\"' in line:\n            mode = 'suffix'\n        # 'id=\"' can occur in definition lines <li> when <sup> tag is used for references;\n        # make sure those are not excluded (see e.g., abecedarian).\n        elif ('id=\"' in line) and ('<li>' not in line):\n            mode = None\n\n        elif (mode == 'etmyology') and ('<p>' in line):\n            etymology = text(line)\n        elif (mode is not None) and ('<li>' in line):\n            definitions.setdefault(mode, []).append(text(line))\n\n        if '<hr' in line:\n            break\n    return etymology, definitions\n\n\nparts = ('preposition', 'particle', 'noun', 'verb',\n         'adjective', 'adverb', 'interjection',\n         'prefix', 'suffix')\n\n\ndef format(result, definitions, number=2):\n    for part in parts:\n        if part in definitions:\n            defs = definitions[part][:number]\n            result += u' \u2014 {}: '.format(part)\n            n = ['%s. %s' % (i + 1, e.strip(' .')) for i, e in enumerate(defs)]\n            result += ', '.join(n)\n    return result.strip(' .,')\n\n\n@commands('wt', 'define', 'dict')\n@example('.wt bailiwick')\ndef wiktionary(bot, trigger):\n    \"\"\"Look up a word on Wiktionary.\"\"\"\n    word = trigger.group(2)\n    if word is None:\n        bot.reply('You must tell me what to look up!')\n        return\n\n    _etymology, definitions = wikt(word)\n    if not definitions:\n        bot.say(\"Couldn't get any definitions for %s.\" % word)\n        return\n\n    result = format(word, definitions)\n    if len(result) < 150:\n        result = format(word, definitions, 3)\n    if len(result) < 150:\n        result = format(word, definitions, 5)\n\n    if len(result) > 300:\n        result = result[:295] + '[...]'\n    bot.say(result)\n", "path": "sopel/modules/wiktionary.py"}]}