小文字化と空白の除去
最初に行う正規化のステップ
「小文字化と空白の除去」はCoddyKit上の無料NLP Academyレッスンです。 これはレッスン2/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これは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時間対応のAIチューター)、NLP Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 NLP Academyコースには全4レッスンが含まれています。
「小文字化と空白の除去」で何を学びますか?
最初に行う正規化のステップ ブラウザで直接実行するハンズオンコードでNLP Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
NLP Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのNLP Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン2/4です。
「小文字化と空白の除去」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このNLP Academyレッスンでコードを書いて実行できますか?
はい。すべてのNLP Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。