Skip to content

BUG: German noun capitalization gets lost #196

@mrpi007

Description

@mrpi007

Hello,
When trying your wonderful easy-to-use spellchecker today. I stumbled over this bug:
German noun capitalization is lost on corrections/candidates although case sensitivity is enabled. Try following script:

from spellchecker import SpellChecker

def spellchecker_bug_demo():
    
    # Create German spell checker with case sensitivity enabled
    spell = SpellChecker(language='de', case_sensitive=True)
    
    # Add a custom capitalized German noun
    spell.word_frequency.load_words(['Testwort'])
    
    # Test words
    test_cases = [
        'Stadt',      # Common German noun (should be capitalized)
        'Stsdt',      # same, but with typo
        'Testwort',   # custom sample noun (capitalized) added above
        'Testwprt'    # same, again with typo
    ]
    
    print("Bug Demonstration: German Noun Capitalization")
    print("=" * 50)
    
    for word in test_cases:
        candidates = spell.candidates(word)
        correction = spell.correction(word)
        
        print("Input:      ", word)
        print("Correction: ", correction)
        print("Candidates: ", candidates)
        
        if candidates:
            first_candidate = next(iter(candidates))
             
            # Check if capitalization is preserved
            if word[0].isupper() and first_candidate[0].islower():
                print("❌ BUG: Capitalization lost!")

if __name__ == "__main__":
    spellchecker_bug_demo()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions