0Pricing
NLP Academy · Урок

Перевод в нижний регистр и удаление пробелов

Первые шаги нормализации

«Перевод в нижний регистр и удаление пробелов» — бесплатный урок NLP Academy на CoddyKit. Это урок 2 из 4. Ты можешь прочитать весь урок бесплатно ниже — а потом практиковать его прямо в браузере с встроенным редактором кода и ИИ-репетитором 24/7. Это часть пути обучения NLP Academy, и твой прогресс синхронизируется между веб-версией и приложением CoddyKit. Курс NLP Academy содержит 4 уроков всего.

Части этого урока еще не переведены и отображаются на английском.

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! 🎉

Часто задаваемые вопросы

Урок «Перевод в нижний регистр и удаление пробелов» бесплатный?

Да — полный текст урока «Перевод в нижний регистр и удаление пробелов» бесплатно доступен здесь в веб-версии. Чтобы практиковать его интерактивно (встроенный редактор кода и ИИ-репетитор 24/7) и разблокировать остальной курс NLP Academy, подпишись на CoddyKit PRO. Курс NLP Academy содержит 4 уроков всего.

Чему я научусь в уроке «Перевод в нижний регистр и удаление пробелов»?

Первые шаги нормализации Ты практикуешь NLP Academy с помощью реального кода, который запускаешь прямо в браузере, и ИИ-репетитор 24/7 отвечает на твои вопросы во время урока.

Нужен ли мне опыт, чтобы начать NLP Academy?

Предыдущий опыт не требуется. NLP Academy на CoddyKit структурирован для всех уровней — от новичков до продвинутых, поэтому ты можешь начать отсюда или с самого начала и учиться в своем темпе. Это урок 2 из 4.

Сколько времени занимает урок «Перевод в нижний регистр и удаление пробелов»?

Большинство уроков CoddyKit занимают около 5–10 минут. Каждый из них компактный и интерактивный, поэтому ты постоянно делаешь прогресс и продолжаешь с того же места в веб-версии и приложении.

Можно ли писать и запускать код в этом уроке NLP Academy?

Да. Каждый урок NLP Academy включает встроенный редактор кода, поэтому ты пишешь и запускаешь реальный код прямо в браузере и получаешь моментальную обратную связь от AI — локальная установка не требуется.

Все уроки этого курса

  1. Почему важны регистр и пробелы
  2. Перевод в нижний регистр и удаление пробелов
  3. Стемминг: усечение до корня
  4. Лемматизация: более умные начальные формы
← Назад к NLP Academy