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.

ไทย

คำที่พบบ่อยที่สุด

หาคำโปรดของข้อความหนึ่งๆ

ทำเป็นสามขั้นตอน: ทำความสะอาด: ลบเครื่องหมายวรรคตอนด้วย .replace() และเปลี่ยนเป็นตัวพิมพ์เล็กทั้งหมดด้วย .lower(). นับ: .split() ข้อความเป็นคำและนับ它们在 dictionary ด้วย counts.get(word, 0) + 1. เลือก: ท่องผ่านคำตามลำดับเดิมและเปลี่ยนเป็นคำใหม่ก็ต่อเมื่อจำนวนนับมากกว่าเดิมอย่างชัดเจนเท่านั้น เพื่อให้งานที่เท่ากันเป็นคำที่ปรากฏก่อนหน้า

Log in or create account · ⁨เข้าสู่ระบบหรือสร้างบัญชี⁩

IGCSE, A-Level & AP