Skip to content · ⁨コンテンツへスキップ⁩

Most common word

English

Most common word

Find the favourite word of a piece of text.

Work in three stages. Clean: remove the punctuation with .replace() and make everything lowercase with .lower(). Count: .split() the text into words and count them in a dictionary with counts.get(word, 0) + 1. Choose: walk through the words in their original order and switch to a word only when its count is strictly bigger, so that a tie goes to the earlier word.

日本語

最も頻出する単語

テキストの中で最も好まれる(出現回数の多い)単語を見つけてください。

3つの工程で行います。クリーニング: .replace() で句読点を削除し、.lower() で全てを小文字にします。カウント: .split() でテキストを単語に分割し、counts.get(word, 0) + 1 で辞書内に個々の単語の数を数えます。選択: 単語を元の順序で巡回し、出現数がより大きくなった場合にのみ更新します。同点の場合は最初の単語が選ばれます。

Log in or create account · ⁨ログインまたはアカウント作成⁩

IGCSE, A-Level & AP