Skip to content
TheChatArchiveThe Chat Archive
o4-mini-2025-04-16· OpenAIHugging Face LMArena Human Preference 140K

in qgis i have column SLAD and SLAD2. I want to update SLAD2, so that it equals SLAD,…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Metallama-4-maverick-03-26-experimental’s answer.
  1. User

    in qgis i have column SLAD and SLAD2. I want to update SLAD2, so that it equals SLAD, but change every letter (including polish characters) to small caps, if previous char is not a digit

  2. Assistant

    Here’s one way to do it in QGIS’s Field Calculator by using a small Python‐snippet.

    What we want

    • Read each character of SLAD
    • If it’s a letter (including Polish letters) and the previous character is not a digit (or it’s the very first character), we convert it to “small-caps” (or lowercase if no small-caps glyph exists)
    • Otherwise leave it as is
    • Write the result into SLAD2

    1) Prepare a small-caps mapping (ASCII only)

    Unicode defines a handful of “Small Capital” codepoints for A–Z. Polish diacritics don’t have true small-caps, so we’ll fall back to lowercase for them.

    smallcaps_map = {
      'A':'ᴀ','B':'ʙ','C':'ᴄ','D':'ᴅ','E':'ᴇ','F':'ꜰ','G':'ɢ',
      'H':'ʜ','I':'ɪ','J':'ᴊ','K':'ᴋ','L':'ʟ','M':'ᴍ','N':'ɴ',
      'O':'ᴏ','P':'ᴘ','Q':'ꞯ','R':'ʀ','S':'s','T':'ᴛ','U':'ᴜ',
      'V':'ᴠ','W':'ᴡ','X':'x','Y':'ʏ','Z':'ᴢ'
    }
    

    Note: S/X are typically the same as lowercase because true small-caps don’t exist in Unicode.


    2) The Python snippet

    1. Open Field Calculator
    2. Set Output field name to SLAD2
    3. Check “Expression” → Use Python eval (in QGIS ≥3.16 you can choose the “@python” evaluator)
    4. Paste in something like this:
    # ─────────────────────────────────────────────────
    # PYTHON EVALUATOR SNIPPET FOR QGIS FIELD CALCULATOR
    # ─────────────────────────────────────────────────
    
    # 1) your small-caps map
    smallcaps_map = {
      'A':'ᴀ','B':'ʙ','C':'ᴄ','D':'ᴅ','E':'ᴇ','F':'ꜰ','G':'ɢ',
      'H':'ʜ','I':'ɪ','J':'ᴊ','K':'ᴋ','L':'ʟ','M':'ᴍ','N':'ɴ',
      'O':'ᴏ','P':'ᴘ','Q':'ꞯ','R':'ʀ','S':'s','T':'ᴛ','U':'ᴜ',
      'V':'ᴠ','W':'ᴡ','X':'x','Y':'ʏ','Z':'ᴢ'
    }
    
    # 2) fetch the source text
    s = @feature['SLAD']  # or just "SLAD" depending on your QGIS version
    
    # 3) build the output
    out = []
    for i, ch in enumerate(s):
        prev = s[i-1] if i>0 else None
    
        # if this character is a letter AND previous char is not a digit
        if ch.isalpha() and (prev is None or not prev.isdigit()):
            # if there's a smallcaps glyph, use it
            up = ch.upper()
            sc = smallcaps_map.get(up)
            if sc:
                out.append(sc)
            else:
                # fallback to lowercase (preserves Polish diacritics)
                out.append(ch.lower())
        else:
            # otherwise keep the original
            out.append(ch)
    
    # 4) return the new string
    "".join(out)
    

    3) Click “OK”

    QGIS will evaluate that for every feature and populate SLAD2 exactly as you asked: any letter (ASCII or Polish) whose preceding character is not a digit (or it’s the first character) will become a small-cap (or lowercase when no small-cap exists). All other characters stay untouched.

    😊 Let me know if you hit any snags!

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.