Skip to content · ⁨Bỏ qua nội dung⁩

Most common word · ⁨Từ phổ biến nhất⁩

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.

Tiếng Việt

Từ phổ biến nhất

Tìm từ yêu thích của một đoạn văn bản.

Thực hiện theo ba giai đoạn. Làm sạch: loại bỏ dấu câu bằng .replace() và chuyển toàn bộ về chữ thường bằng .lower(). Đếm: .split() văn bản thành các từ và đếm chúng trong một bảng từ bằng counts.get(word, 0) + 1. Chọn: duyệt qua các từ theo thứ tự ban đầu và chỉ chuyển sang từ mới khi số đếm của nó lớn hơn()(strictly) strictly, để trường hợp ngang điểm thuộc về từ xuất hiện trước đó.

Log in or create account · ⁨Đăng nhập hoặc tạo tài khoản⁩

IGCSE, A-Level & AP