Repository: tatuylonen/wiktextract

Issue:
Spanish verb conjugations: `*-person` tags for imperative forms are shifted by one
## Description

All imperative forms of verbs in Spanish have wrong person tags. And they are shifted exactly by one cell: 2nd is replaced by 1st, 3rd by 2nd, and 1st (plural) by 3rd.

Example for "[pasar](https://es.wiktionary.org/wiki/pasar)":

```json
    {
      "form": "pasa^(tú)",
      "tags": [
        "affirmative",
        "singular",
        "first-person"
      ]
    },
    {
      "form": "pasáᵛᵒˢ",
      "tags": [
        "affirmative",
        "singular",
        "first-person"
      ]
    },
    {
      "form": "pase",
      "tags": [
        "affirmative",
        "singular",
        "second-person"
      ]
    },
    {
      "form": "pasemos",
      "tags": [
        "affirmative",
        "singular",
        "third-person"
      ]
    },
```

- "pasa" and "pasá" should have a "second-person" tag instead of "first-person"
- "pase" should have a "third-person" tag instead of "second-person"
- and so on...

However, note that numbers are correct.

## Possible reason

I believe this happens because the template has an empty header cell for 1st person singular in the section for imperative forms:

<img width="1028" alt="Screenshot 2025-01-03 at 18 40 56" src="https://github.com/user-attachments/assets/c0039e77-bc65-4f9a-bab5-5684ccd7e93c" />

## Possible solution

My guess is that in this code should do `col_header_index += colspan` even for empty cells (right now there is only `continue` on line 81):

https://github.com/tatuylonen/wiktextract/blob/f889f659cd5690d0f50741810e77a03e8a7e3d1a/src/wiktextract/extractor/es/conjugation.py#L80-L82

Currently, empty cells result in `col_header_index` being off by one, which I suspect somehow is translated to the `*-person` tags.

However, I don't see why this doesn't also affect number tags. These are probably added somewhere else based on the text inside cells, but I couldn't find it.

Discussion:
@xxyzz: Thanks for the detailed bug report!@scriptin: Thank you for such a quick response and fix!

Solution patch:
diff --git a/src/wiktextract/extractor/es/conjugation.py b/src/wiktextract/extractor/es/conjugation.py
index 0883637a..b393c575 100644
--- a/src/wiktextract/extractor/es/conjugation.py
+++ b/src/wiktextract/extractor/es/conjugation.py
@@ -86,6 +86,7 @@ def process_es_v_conj_template(
                     )
                 else:
                     row_header = cell_text
+                    col_cell_index += colspan - 1
                 col_header_index += colspan
             else:
                 for line in cell_text.splitlines():


Test patch:
diff --git a/tests/test_es_conj.py b/tests/test_es_conj.py
index 46aba34c..ad16add0 100644
--- a/tests/test_es_conj.py
+++ b/tests/test_es_conj.py
@@ -69,7 +69,10 @@ segunda conjugación,&nbsp;irregular</span>
 || [[ves|ves]]<sup><sup>tú</sup></sup><br/>[[ves|ves]]<sup><sup>vos</sup></sup>||[[ve|ve]]|| [[vemos]]
 || [[veis|veis]]
 || [[ven|ven]]
-|}""",  # noqa: E501
+|-
+! colspan="2" style="background:#e4d4c0; color:#000; padding-left:5px"|Afirmativo
+|| [[ve|ve]]<sup><sup>tú</sup></sup><br/>[[ve|ve]]<sup><sup>vos</sup></sup>
+|}""",
         )
         root = self.wxr.wtp.parse("{{es.v.conj.ver|v}}")
         word_entry = WordEntry(
@@ -103,5 +106,13 @@ segunda conjugación,&nbsp;irregular</span>
                     "tags": ["present", "plural", "second-person"],
                 },
                 {"form": "ven", "tags": ["present", "plural", "third-person"]},
+                {
+                    "form": "ve^(tú)",
+                    "tags": ["affirmative", "singular", "second-person"],
+                },
+                {
+                    "form": "veᵛᵒˢ",
+                    "tags": ["affirmative", "singular", "second-person"],
+                },
             ],
         )