フレーズの数を取得しようとしているファイルがあります。特定のテキスト行で数える必要のあるフレーズは約100個あります。簡単な例として、次のようなものがあります。
phrases = """hello
name
john doe
"""
text1 = 'id=1: hello my name is john doe. hello hello. how are you?'
text2 = 'id=2: I am good. My name is Jane. Nice to meet you John Doe'
header = ''
for phrase in phrases.splitlines():
header = header+'|'+phrase
header = 'id'+header
次のような出力ができるようにしたいと思います。
id|hello|name|john doe
1|3|1|1
2|0|1|1
ヘッダーが下にあります。各フレーズを数え、出力を追加する方法がわかりません。