Zamiana na małe litery i usuwanie białych znaków
Pierwsze kroki normalizacji
Zamiana na małe litery i usuwanie białych znaków to bezpłatna lekcja NLP Academy na CoddyKit. To lekcja 2 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej NLP Academy, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs NLP Academy zawiera 4 lekcji w sumie.
Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.
Your First Two Steps
The simplest normalization is folding case and trimming spaces. Master these two and you already remove most of the noise that splits your word counts. ✨
Lowercasing in One Call
Python strings carry a built-in lower method. It returns a fresh copy with every letter folded to lowercase, leaving the original untouched.
text = 'The QUICK Fox'
print(text.lower())Now They Match
Once both sides are lowercased, the case difference vanishes and the comparison finally returns True. That is the whole point of case folding.
print('Paris'.lower() == 'paris')Trimming the Edges
The strip method removes whitespace from both ends of a string. Leading and trailing spaces, tabs, and newlines all disappear in one call.
messy = ' hello world '
print(messy.strip())One-Sided Trims
Sometimes you only want one edge cleaned. Use lstrip for the left side and rstrip for the right when you need that control.
print(' hi'.lstrip())
print('hi '.rstrip())Spaces in the Middle
Strip only touches the ends. To squash repeated spaces inside text, split on whitespace and rejoin, which collapses every gap to a single space.
text = 'too many spaces'
print(' '.join(text.split()))Why Split Then Join
Calling split with no argument breaks on any run of whitespace and drops the empties. Rejoining with one space gives you clean, even spacing.
Chain Them Together
Because each method returns a string, you can chain them. Here you lowercase and strip a value in a single readable pipeline.
raw = ' CoddyKit '
print(raw.lower().strip())Strings Are Immutable
These methods never change the original; they hand back a new string. Always capture the result in a variable or you lose the cleaned value.
s = 'HELLO'
s.lower()
print(s)Normalize a Whole List
Apply your two steps to every token at once with a comprehension. Now each word is lowercase and trimmed, ready for counting.
words = [' Cat ', 'DOG', 'Cat']
print([w.lower().strip() for w in words])Counts Finally Agree
After folding case, the three messy entries for cat collapse into one matching token, so your frequency table tells the truth. 📊
Quick Check
Let's confirm how to clean spacing.
Recap
You learned to fold case with lower and trim edges with strip, then collapse inner gaps with split and join. Your tokens now match cleanly. Nice work! 🎉
Często zadawane pytania
Czy lekcja „Zamiana na małe litery i usuwanie białych znaków” jest bezpłatna?
Tak — pełny tekst „Zamiana na małe litery i usuwanie białych znaków” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu NLP Academy, przejdź na CoddyKit PRO. Kurs NLP Academy zawiera 4 lekcji w sumie.
Co nauczysz się w „Zamiana na małe litery i usuwanie białych znaków”?
Pierwsze kroki normalizacji Ćwiczysz NLP Academy z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.
Czy potrzebuję doświadczenia, aby zacząć NLP Academy?
Nie wymagamy żadnego doświadczenia. NLP Academy w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 2 z 4.
Ile czasu zajmuje lekcja „Zamiana na małe litery i usuwanie białych znaków”?
Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.
Czy mogę pisać i uruchamiać kod w tej lekcji NLP Academy?
Tak. Każda lekcja NLP Academy zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.
Wszystkie lekcje w tym kursie
- Dlaczego wielkość liter i odstępy mają znaczenie
- Zamiana na małe litery i usuwanie białych znaków
- Stemming: skracanie do rdzenia
- Lematyzacja: inteligentniejsze formy podstawowe