-
-
Save civic/ddc4e68b22d9dcacc027cddf0d233b8c to your computer and use it in GitHub Desktop.
あたえられた文字列中に含まれる単語の個数を単語ごとにカウントするpython
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import collections | |
import re | |
text = "I have a pen. I have a apple. oh!! Apple pen! I have a pen. I have a pineapple. oh!! Pineapple pen! Apple pen. Pineapplepen. Pen pineapple apple pen." | |
collections.Counter(s.lower() for s in re.split(r'[^\w]+',text)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment