У меня есть строка, которая может быть произвольно длинной, скажем
s = 'Choose from millions of possibilities on Shaadi.com. Create your profile, search&contact; your special one.RegisterFree\xa0\xa0\xa0unsubscribing reply to this mail\xa0\n and 09times and this is limited time offer! and this is For free so you are saving cash'
У меня есть список спам-слов, которые могут быть похожи на
p_words = ['cash', 'for free', 'limited time offer']
Все, что я хочу знать, существует ли шаблон во входном тексте и сколько раз?
Становится просто, когда в нем всего одно слово
import re
p = re.compile(''.join[p_words]) # correct me if I am wrong here
m = p.match(s)
но это может быть bi-gram, tri-gram or n-gram
Как мы подходим к этому?