Question
We have shown in the course how to generate a document x term matrix in Python (with the support of different packages). Our solution was
We have shown in the course how to generate a document x term matrix in Python (with the support of different packages). Our solution was based on a list of (tokenized) documents and a list of terms as shown below. >>> dtm = np.array(corpus2dtm(list_docs, voc)) >>> print(f" matrix with " ... f"|D| = {dtm.shape[0]} documents and " ... f"|V| = {dtm.shape[1]} words.") matrix with |D| = 498 documents and |V| = 48046 words.
Based on the document x term matrix representation (or the variable dtm in our example), your first task is to write a Python function to return a list of terms with an occurrence frequency larger than or equal to 20. Your second task is to write a Python function to return a list of terms present in more than 10 documents.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started