You are viewing a single comment's thread. Return to all comments →
In Python 3:
import re num_lines = int(input()) corpus_lines = [input() for _ in range(num_lines)] corpus_text = "\n".join(corpus_lines) num_queries = int(input()) for _ in range(num_queries): query = input() whole_word_pat = re.compile(rf'\b{re.escape(query)}\b') occurrences = len(whole_word_pat.findall(corpus_text)) print(occurrences)
Seems like cookies are disabled on this browser, please enable them to open this website
Find a Word
You are viewing a single comment's thread. Return to all comments →
In Python 3: