<jupyter_start><jupyter_text>演習問題<jupyter_code># 強調したい単語
emph = ['you', 'your', 'yours']

# 英文の入力
sentence = input("英文を入力してください: ")

# 単語に分解
words = sentence.split(" ")

# 先頭を大文字にする
converted = list(map(lambda x: x.upper() if x in emph else x, words))
# for文を使う場合はこうする
converted = []
for x in words:
    if x in emph:
        converted.append(x.upper())
    else:
        converted.append(x)

# 連結して元に戻す
print(" ".join(converted))<jupyter_output>英文を入力してください:  A problem is a chance for you to do your best<jupyter_text>発展問題<jupyter_code># 英文の入力（全部小文字に変換しておく）
sentence = input("英文を入力してください: ").lower()

# 単語に分解
words = sentence.split(" ")
# 空文字は除去
excludes = ['']
words = list(filter(lambda x: not x in excludes, words))
# 区切り文字は除去
import re
words = list(map(lambda x: re.sub(r'^(.*)[\.,!?]', r'\1', x), words))

# 単語の出現回数
import collections
counts = collections.Counter(words)

print("英文の長さ: {}".format(len(sentence)))
print("単語の数: {}".format(len(words)))
print("単語の出現回数:")
for k,v in counts.items():
    print(" {}: {}回".format(k, v))<jupyter_output>英文を入力してください:  A problem is a chance for you to do your best.
{'fraction_non_alphanumeric': 0.17281728172817282, 'fraction_numerical': 0.0009000900090009, 'mean_word_length': 4.914893617021277, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '573711', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 548, 'n_tokens_neox': 549, 'n_words': 106, 'path': 'exe04.ipynb', 'repo_name': 'pman0214/qu-kikan-prog-2020-enshu-answers', 'size': '1111'}