prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  LineStrParser: separator behaviour
  I've a question regarding this snippet of code:
  https://github.com/open-mmlab/mmocr/blob/01d8d63be945882fb2d9eaca5e1c1b39cb45f274/mmocr/datasets/utils/parser.py#L33-L36
  
  Is there a particular reason to use these 4 lines of code instead of simply `line_str = line_str.split(self.separator)`?
  
  I'm asking this because for my own use case I have:
  - a TSV file with `filename` and `text` as keys for text recognition task
  - some blank spaces in `filename` e.g. `my cropped image.png`
   
  Hence, LineStrParser is configured as follows:
  ```python
  parser=dict(
              type='LineStrParser',
              keys=['filename', 'text'],
              keys_idx=[0, 1],
              separator='\t'))
  ```
  but with the 4-lines code snippet, the line parsing fails. Instead, with simply `line_str = line_str.split(self.separator)` everything works well.
  
  </issue>
  <code>
  [start of mmocr/datasets/utils/parser.py]
  1 import json
  2 
  3 from mmocr.datasets.builder import PARSERS
  4 
  5 
  6 @PARSERS.register_module()
  7 class LineStrParser:
  8     """Parse string of one line in annotation file to dict format.
  9 
  10     Args:
  11         keys (list[str]): Keys in result dict.
  12         keys_idx (list[int]): Value index in sub-string list
  13             for each key above.
  14         separator (str): Separator to separate string to list of sub-string.
  15     """
  16 
  17     def __init__(self,
  18                  keys=['filename', 'text'],
  19                  keys_idx=[0, 1],
  20                  separator=' '):
  21         assert isinstance(keys, list)
  22         assert isinstance(keys_idx, list)
  23         assert isinstance(separator, str)
  24         assert len(keys) > 0
  25         assert len(keys) == len(keys_idx)
  26         self.keys = keys
  27         self.keys_idx = keys_idx
  28         self.separator = separator
  29 
  30     def get_item(self, data_ret, index):
  31         map_index = index % len(data_ret)
  32         line_str = data_ret[map_index]
  33         for split_key in self.separator:
  34             if split_key != ' ':
  35                 line_str = line_str.replace(split_key, ' ')
  36         line_str = line_str.split()
  37         if len(line_str) <= max(self.keys_idx):
  38             raise Exception(
  39                 f'key index: {max(self.keys_idx)} out of range: {line_str}')
  40 
  41         line_info = {}
  42         for i, key in enumerate(self.keys):
  43             line_info[key] = line_str[self.keys_idx[i]]
  44         return line_info
  45 
  46 
  47 @PARSERS.register_module()
  48 class LineJsonParser:
  49     """Parse json-string of one line in annotation file to dict format.
  50 
  51     Args:
  52         keys (list[str]): Keys in both json-string and result dict.
  53     """
  54 
  55     def __init__(self, keys=[], **kwargs):
  56         assert isinstance(keys, list)
  57         assert len(keys) > 0
  58         self.keys = keys
  59 
  60     def get_item(self, data_ret, index):
  61         map_index = index % len(data_ret)
  62         line_json_obj = json.loads(data_ret[map_index])
  63         line_info = {}
  64         for key in self.keys:
  65             if key not in line_json_obj:
  66                 raise Exception(f'key {key} not in line json {line_json_obj}')
  67             line_info[key] = line_json_obj[key]
  68 
  69         return line_info
  70
  [end of mmocr/datasets/utils/parser.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/mmocr/datasets/utils/parser.py b/mmocr/datasets/utils/parser.py
  --- a/mmocr/datasets/utils/parser.py
  +++ b/mmocr/datasets/utils/parser.py
  @@ -30,10 +30,7 @@
       def get_item(self, data_ret, index):
           map_index = index % len(data_ret)
           line_str = data_ret[map_index]
  -        for split_key in self.separator:
  -            if split_key != ' ':
  -                line_str = line_str.replace(split_key, ' ')
  -        line_str = line_str.split()
  +        line_str = line_str.split(self.separator)
           if len(line_str) <= max(self.keys_idx):
               raise Exception(
                   f'key index: {max(self.keys_idx)} out of range: {line_str}')
  
verification_info: {"golden_diff": "diff --git a/mmocr/datasets/utils/parser.py b/mmocr/datasets/utils/parser.py\n--- a/mmocr/datasets/utils/parser.py\n+++ b/mmocr/datasets/utils/parser.py\n@@ -30,10 +30,7 @@\n     def get_item(self, data_ret, index):\n         map_index = index % len(data_ret)\n         line_str = data_ret[map_index]\n-        for split_key in self.separator:\n-            if split_key != ' ':\n-                line_str = line_str.replace(split_key, ' ')\n-        line_str = line_str.split()\n+        line_str = line_str.split(self.separator)\n         if len(line_str) <= max(self.keys_idx):\n             raise Exception(\n                 f'key index: {max(self.keys_idx)} out of range: {line_str}')\n", "issue": "LineStrParser: separator behaviour\nI've a question regarding this snippet of code:\r\nhttps://github.com/open-mmlab/mmocr/blob/01d8d63be945882fb2d9eaca5e1c1b39cb45f274/mmocr/datasets/utils/parser.py#L33-L36\r\n\r\nIs there a particular reason to use these 4 lines of code instead of simply `line_str = line_str.split(self.separator)`?\r\n\r\nI'm asking this because for my own use case I have:\r\n- a TSV file with `filename` and `text` as keys for text recognition task\r\n- some blank spaces in `filename` e.g. `my cropped image.png`\r\n \r\nHence, LineStrParser is configured as follows:\r\n```python\r\nparser=dict(\r\n            type='LineStrParser',\r\n            keys=['filename', 'text'],\r\n            keys_idx=[0, 1],\r\n            separator='\\t'))\r\n```\r\nbut with the 4-lines code snippet, the line parsing fails. Instead, with simply `line_str = line_str.split(self.separator)` everything works well.\n", "before_files": [{"content": "import json\n\nfrom mmocr.datasets.builder import PARSERS\n\n\n@PARSERS.register_module()\nclass LineStrParser:\n    \"\"\"Parse string of one line in annotation file to dict format.\n\n    Args:\n        keys (list[str]): Keys in result dict.\n        keys_idx (list[int]): Value index in sub-string list\n            for each key above.\n        separator (str): Separator to separate string to list of sub-string.\n    \"\"\"\n\n    def __init__(self,\n                 keys=['filename', 'text'],\n                 keys_idx=[0, 1],\n                 separator=' '):\n        assert isinstance(keys, list)\n        assert isinstance(keys_idx, list)\n        assert isinstance(separator, str)\n        assert len(keys) > 0\n        assert len(keys) == len(keys_idx)\n        self.keys = keys\n        self.keys_idx = keys_idx\n        self.separator = separator\n\n    def get_item(self, data_ret, index):\n        map_index = index % len(data_ret)\n        line_str = data_ret[map_index]\n        for split_key in self.separator:\n            if split_key != ' ':\n                line_str = line_str.replace(split_key, ' ')\n        line_str = line_str.split()\n        if len(line_str) <= max(self.keys_idx):\n            raise Exception(\n                f'key index: {max(self.keys_idx)} out of range: {line_str}')\n\n        line_info = {}\n        for i, key in enumerate(self.keys):\n            line_info[key] = line_str[self.keys_idx[i]]\n        return line_info\n\n\n@PARSERS.register_module()\nclass LineJsonParser:\n    \"\"\"Parse json-string of one line in annotation file to dict format.\n\n    Args:\n        keys (list[str]): Keys in both json-string and result dict.\n    \"\"\"\n\n    def __init__(self, keys=[], **kwargs):\n        assert isinstance(keys, list)\n        assert len(keys) > 0\n        self.keys = keys\n\n    def get_item(self, data_ret, index):\n        map_index = index % len(data_ret)\n        line_json_obj = json.loads(data_ret[map_index])\n        line_info = {}\n        for key in self.keys:\n            if key not in line_json_obj:\n                raise Exception(f'key {key} not in line json {line_json_obj}')\n            line_info[key] = line_json_obj[key]\n\n        return line_info\n", "path": "mmocr/datasets/utils/parser.py"}]}