CNLP study materials
CNLP study resources

CNLP practice questions

One question at a time. Build your CNLP understanding.

First 50 of 200 questions. Each one lists the choices, the correct answer, and an explanation. The checker at the top of this page saves progress in this browser when it is available.

Continue in the practice tool above to load more questions, 50 at a time.

Question 1Natural Language Processing Fundamentals

In NLP preprocessing, what does tokenization primarily produce from a raw text string?

  1. A sequence of discrete units such as words or subwords Correct answer.
  2. A dense vector of fixed dimensionality
  3. A probability distribution over the vocabulary
  4. A parse tree of syntactic dependencies

Explanation

Tokenization segments raw text into discrete units (tokens) that later stages can index or embed. It does not itself assign vectors, estimate probabilities, or build syntax trees; those are separate downstream tasks.

Question 2Natural Language Processing Fundamentals

Which text normalization step would convert "Running", "runs", and "ran" to a shared surface form?

  1. Stemming or lemmatization Correct answer.
  2. Part-of-speech tagging
  3. One-hot encoding
  4. Stop-word removal

Explanation

Stemming and lemmatization map inflected word forms back to a common stem or lemma, collapsing variants like running, runs, and ran. The other operations either encode tokens, filter them, or label them without merging surface forms.

Question 3Natural Language Processing Fundamentals

A corpus of 1,000 documents contains the word "neural" in 100 documents. What is the inverse document frequency using the formula log(N/df) with natural log?

  1. About 0.10
  2. About 2.30 Correct answer.
  3. About 0.90
  4. About 10.0

Explanation

IDF = log(N/df) = log(1000/100) = log(10), and the natural logarithm of 10 is approximately 2.30. The ratio 100/1000 is the document frequency fraction, not the IDF itself.

Question 4Natural Language Processing Fundamentals

In a bag-of-words representation of documents, which information is discarded?

  1. The count of each vocabulary term
  2. The total number of tokens per document
  3. Word order and adjacency between tokens Correct answer.
  4. The identity of the vocabulary entries

Explanation

Bag-of-words models keep term frequencies but ignore the positions of words, so order and adjacency are lost. Counts, document lengths, and vocabulary identity are all preserved in the representation.

Question 5Natural Language Processing Fundamentals

Which pair correctly matches an n-gram order to its definition?

  1. Trigram: one token
  2. Bigram: three consecutive tokens
  3. Bigram: two consecutive tokens Correct answer.
  4. Unigram: two consecutive tokens

Explanation

An n-gram is a contiguous sequence of n tokens, so a bigram consists of two consecutive tokens. Unigrams are single tokens and trigrams are sequences of three, making the other pairings inconsistent.

Question 6Natural Language Processing Fundamentals

What does the softmax function output when applied to the logits of a neural language model?

  1. An unnormalized set of integer token IDs
  2. A normalized probability distribution over the vocabulary Correct answer.
  3. A sparse binary vector with one active unit
  4. A fixed-length embedding of the context

Explanation

Softmax exponentiates the logits and divides by their sum, yielding nonnegative values that sum to one over the vocabulary. It does not produce IDs, sparse codes, or context embeddings.

Question 7Natural Language Processing Fundamentals

Which evaluation metric is defined as the fraction of retrieved items that are actually relevant?

  1. F1 score
  2. Accuracy
  3. Precision Correct answer.
  4. Recall

Explanation

Precision measures how many of the retrieved items are relevant, i.e. true positives divided by predicted positives. Recall instead measures coverage of relevant items, and F1 combines the two.

Question 8Natural Language Processing Fundamentals

In a word embedding space, what does the cosine similarity between two word vectors measure?

  1. The rank of the words in the training corpus
  2. The cosine of the angle between them, ignoring magnitude Correct answer.
  3. The dot product scaled by their magnitudes
  4. The Euclidean distance between their endpoints

Explanation

Cosine similarity is the dot product divided by the product of the vector norms, which equals the cosine of the angle and is invariant to vector length. Euclidean distance and raw dot products are different measures that do depend on magnitude.

Question 9Natural Language Processing Fundamentals

A trigram model assigns probability to a sentence by multiplying conditional probabilities. Which factorization does a trigram model use?

  1. P(w_i | w_{i-3}, w_{i-2}, w_{i-1})
  2. P(w_i | w_{i-1}, w_{i+1})
  3. P(w_i | w_{i-2}, w_{i-1}) Correct answer.
  4. P(w_i | w_{i-1})

Explanation

An order-3 (trigram) model conditions each word on the previous two words, giving P(w_i | w_{i-2}, w_{i-1}). Conditioning on three previous words would be a 4-gram, and conditioning on one previous word is a bigram.

Question 10Natural Language Processing Fundamentals

Why is add-one (Laplace) smoothing applied to an n-gram language model?

  1. To increase the vocabulary size
  2. To avoid zero probabilities for unseen n-grams Correct answer.
  3. To remove stop words from the corpus
  4. To convert counts into embeddings

Explanation

Add-one smoothing adds a pseudo-count to every n-gram so that unseen events receive nonzero probability and perplexity stays finite. It does not change vocabulary, filter tokens, or create embeddings.

Question 11Natural Language Processing Fundamentals

A Naive Bayes text classifier makes which core independence assumption?

  1. Class labels are uniformly distributed across documents
  2. Documents are independent of their own tokens
  3. All features have identical variance
  4. Features are conditionally independent given the class label Correct answer.

Explanation

Naive Bayes assumes that, conditioned on the class, the presence or count of each feature is independent of the others. This is why the joint likelihood factorizes into a product of per-feature terms.

Question 12Natural Language Processing Fundamentals

In a recurrent neural network language model, what is the role of the hidden state at time step t?

  1. It computes the attention weights for all layers
  2. It normalizes the input embeddings to unit length
  3. It summarizes information from the preceding tokens in the sequence Correct answer.
  4. It stores the full vocabulary as a lookup table

Explanation

The hidden state is updated recursively and acts as a compressed summary of the sequence seen so far. Vocabulary storage, attention computation, and input normalization are handled by other components.

Question 13Natural Language Processing Fundamentals

Which problem motivates gated architectures such as LSTM and GRU over a simple RNN?

  1. Vanishing gradients over long sequences Correct answer.
  2. Lack of a softmax output layer
  3. Excessive vocabulary size
  4. Slow tokenization of input text

Explanation

Gating mechanisms regulate information flow and give gradients a more stable path through time, mitigating vanishing gradients in long sequences. Vocabulary size, tokenization speed, and output layers are unrelated to the gating design.

Question 14Natural Language Processing Fundamentals

In the attention mechanism of a Transformer, what do the query and key vectors jointly determine?

  1. The attention weights assigned to each value Correct answer.
  2. The size of the training corpus
  3. The number of layers in the model
  4. The learning rate schedule

Explanation

Attention scores are computed from the compatibility of queries and keys, then normalized to weight the values. Layer count, corpus size, and learning rate are architectural or training choices unrelated to this computation.

Question 15Natural Language Processing Fundamentals

What does the masked self-attention in a decoder-only language model prevent?

  1. Using more than one attention head
  2. Attending to future tokens during training Correct answer.
  3. Attending to any token at all
  4. Computing gradients for embeddings

Explanation

The causal mask zeroes out attention to positions after the current token so that predicting the next token never uses future information. It still allows attention to past tokens and does not restrict heads or gradients.

Question 16Natural Language Processing Fundamentals

In the original Transformer encoder, why is a positional encoding added to the input embeddings?

  1. It replaces the need for a softmax layer
  2. It reduces the vocabulary size
  3. It makes the embeddings sparse
  4. Self-attention alone is permutation-invariant and encodes no order Correct answer.

Explanation

Without positional information, self-attention treats the input as an unordered set, so position encodings inject sequence order. They do not shrink vocabulary, replace softmax, or enforce sparsity.

Question 17Natural Language Processing Fundamentals

A model achieves 0.8 precision and 0.5 recall on an information extraction task. What is its F1 score?

  1. About 0.65
  2. About 0.40
  3. About 0.62 Correct answer.
  4. About 0.90

Explanation

F1 = 2PR/(P+R) = 2(0.8)(0.5)/(1.3) = 0.8/1.3, which is approximately 0.615, rounding to about 0.62. The arithmetic mean would be 0.65, which is not the F1 formula.

Question 18Natural Language Processing Fundamentals

What does per-token perplexity of a language model represent?

  1. The fraction of tokens that are out of vocabulary
  2. The average number of attention heads per layer
  3. The ratio of training to test tokens
  4. The exponentiated average negative log-likelihood per token Correct answer.

Explanation

Perplexity equals exp of the mean negative log-likelihood per token, so lower values indicate better predictive fit. It is not a vocabulary statistic, an architectural count, or a data split ratio.

Question 19Natural Language Processing Fundamentals

In a sequence-to-sequence model with beam search, what does a beam width of 5 mean?

  1. The vocabulary is truncated to five tokens
  2. Five epochs of training are performed
  3. Five separate models vote on each token
  4. Five partial hypotheses are kept at each decoding step Correct answer.

Explanation

Beam search maintains the k highest-scoring partial sequences at each step, where k is the beam width. It does not ensemble models, restrict vocabulary, or affect training epochs.

Question 20Natural Language Processing Fundamentals

A sentiment classifier trained on movie reviews performs poorly on product reviews. Which explanation best fits this observation?

  1. The test set has too many tokens
  2. The softmax layer is missing
  3. The model overfits to domain-specific vocabulary and style Correct answer.
  4. The learning rate was too low during training

Explanation

A domain shift means the lexical and stylistic cues learned from movie reviews may not transfer to product reviews, a classic generalization failure. Token counts, missing layers, and learning rate describe other issues that would not specifically cause cross-domain degradation.

Question 21Natural Language Processing Fundamentals

Which statement best describes the difference between stemming and lemmatization?

  1. Stemming applies heuristic suffix stripping; lemmatization uses vocabulary and morphology to return a dictionary form Correct answer.
  2. Stemming returns dictionary forms; lemmatization strips suffixes
  3. Stemming only works on verbs; lemmatization only works on nouns
  4. Stemming requires POS tags; lemmatization never does

Explanation

Stemmers chop affixes by rule and may produce non-words, while lemmatizers consult lexicons and morphological analysis to yield valid lemmas. Neither is restricted to a single part of speech.

Question 22Natural Language Processing Fundamentals

When training word2vec with negative sampling, what is the objective for a center-context pair?

  1. Reconstruct the input one-hot vector exactly
  2. Sort the vocabulary by frequency
  3. Distinguish the true context word from randomly sampled noise words Correct answer.
  4. Minimize the cosine similarity of all word pairs

Explanation

Negative sampling trains a binary classifier to separate observed context words from randomly drawn noise words, which approximates the softmax cheaply. It does not aim at exact reconstruction, global similarity minimization, or frequency sorting.

Question 23Natural Language Processing Fundamentals

A conditional random field (CRF) layer is often placed on top of a BiLSTM for named entity recognition. What does the CRF layer add?

  1. A second embedding matrix for the output
  2. A larger input vocabulary
  3. Modeling of dependencies between adjacent output labels Correct answer.
  4. Faster tokenization of the input

Explanation

A CRF models the joint probability of the label sequence, capturing transition constraints such as I-ORG not following B-PER. It does not alter vocabulary, tokenization, or add an output embedding.

Question 24Natural Language Processing Fundamentals

In BERT-style masked language modeling, why is a fraction of input tokens replaced with a mask token rather than always predicting every token?

  1. It eliminates the need for positional encodings
  2. It creates a denoising objective that forces bidirectional context use without leaking the target Correct answer.
  3. It guarantees the model never sees the original token
  4. It reduces the size of the embedding matrix

Explanation

Masking selected tokens forces the encoder to infer them from both left and right context, giving a bidirectional training signal. Predicting every token from itself would be trivial, so masking creates a meaningful denoising task.

Question 25Natural Language Processing Fundamentals

A retrieval system returns 10 documents, of which 6 are relevant; the corpus contains 20 relevant documents total. What are precision and recall?

  1. Precision 0.60, recall 0.60
  2. Precision 0.50, recall 0.30
  3. Precision 0.30, recall 0.60
  4. Precision 0.60, recall 0.30 Correct answer.

Explanation

Precision is relevant retrieved over retrieved = 6/10 = 0.60, and recall is relevant retrieved over total relevant = 6/20 = 0.30. The two metrics use different denominators, so they need not be equal.

Question 26Natural Language Processing Fundamentals

In a Natural Language Processing pipeline, which operation converts a raw text string into a sequence of tokens before any linguistic annotation is applied?

  1. Tokenization Correct answer.
  2. Stemming
  3. Lemmatization
  4. Part-of-speech tagging

Explanation

Tokenization is the first segmentation step that splits a character stream into tokens such as words, subwords, or punctuation, and it must occur before higher-level annotation. Stemming and lemmatization operate on tokens to reduce inflection, while part-of-speech tagging assigns labels to tokens that have already been segmented.

Question 27Natural Language Processing Fundamentals

Which statement best characterizes the difference between the bag-of-words representation and a continuous bag-of-words (CBOW) word2vec model?

  1. Bag-of-words produces low-dimensional embeddings, whereas CBOW produces sparse high-dimensional count vectors.
  2. Bag-of-words counts term occurrences in a document, whereas CBOW learns dense vectors by predicting a center word from its surrounding context. Correct answer.
  3. Bag-of-words preserves word order, whereas CBOW discards all positional information.
  4. Bag-of-words requires a neural network, whereas CBOW is a purely count-based method.

Explanation

Bag-of-words is a sparse count representation of a document that ignores order, while CBOW is a neural prediction model that learns low-dimensional word vectors by using context words to predict a target word. The two differ in both representation density and training objective.

Question 28Natural Language Processing Fundamentals

A corpus contains only the two sentences "the cat sat" and "the dog sat". Using a bigram model with add-one (Laplace) smoothing over the vocabulary {the, cat, sat, dog}, what is the smoothed probability P(cat | the)?

  1. 1/3
  2. 1/5
  3. 2/7
  4. 1/6 Correct answer.

Explanation

With add-one smoothing, P(cat | the) = (count(the, cat) + 1) / (count(the) + |V|). The bigram "the cat" occurs once, "the" occurs twice as a bigram history, and the vocabulary size is four, so the result is (1+1)/(2+4) = 2/6 = 1/3.

Question 29Natural Language Processing Fundamentals

A named entity recognition system is evaluated on a test set. It correctly identifies 40 entities, labels 10 non-entities as entities, and misses 20 true entities. What are the precision and recall of the system?

  1. Precision = 0.80, Recall = 0.80
  2. Precision = 0.67, Recall = 0.80
  3. Precision = 0.50, Recall = 0.67
  4. Precision = 0.80, Recall = 0.67 Correct answer.

Explanation

Precision is true positives divided by all predicted positives: 40 / (40 + 10) = 0.80. Recall is true positives divided by all gold positives: 40 / (40 + 20) ≈ 0.67.

Question 30Natural Language Processing Fundamentals

A decoder-only Transformer language model is trained with causal (masked) self-attention. During autoregressive generation, why is the attention mask still applied at inference time?

  1. To prevent the model from attending to padding tokens in the prompt.
  2. To preserve the same conditional factorization used in training, so each position attends only to earlier positions. Correct answer.
  3. To reduce the quadratic cost of self-attention to linear time.
  4. To force the model to assign equal probability to all vocabulary items.

Explanation

Causal masking enforces the left-to-right factorization p(x_t | x_<t) that the model was trained on. Removing the mask at inference would let a position see future tokens, creating a mismatch with the training objective and breaking autoregressive generation.

Question 31Text Preprocessing and Feature Engineering

In a classical NLP pipeline, which operation converts the raw string "The cats are running" into the token sequence ["The", "cat", "be", "run"]?

  1. Lemmatization combined with tokenization Correct answer.
  2. Byte-pair encoding
  3. One-hot encoding
  4. Character n-gram extraction

Explanation

Tokenization splits the string into units, and lemmatization then maps each token to its dictionary base form, so "cats" becomes "cat", "are" becomes "be", and "running" becomes "run". The result is a sequence of lemmas rather than raw surface forms.

Question 32Text Preprocessing and Feature Engineering

A corpus contains 1,000 documents. The token "data" appears in 300 of them. What is the inverse document frequency of "data" under the standard formula idf = log(N / df)?

  1. log(1000 / 700)
  2. log(300)
  3. log(1000 / 300) Correct answer.
  4. log(300 / 1000)

Explanation

The inverse document frequency uses the total number of documents N in the numerator and the number of documents containing the term, df, in the denominator. With N = 1000 and df = 300, idf = log(1000/300), which is positive because the term does not occur in every document.

Question 33Text Preprocessing and Feature Engineering

Which preprocessing step most directly reduces the vocabulary size by mapping "organize", "organizing", and "organization" to a single shared string?

  1. Stemming Correct answer.
  2. Stop-word removal
  3. Case folding
  4. Sentence segmentation

Explanation

Stemming strips affixes so that morphologically related word forms collapse to one stem, such as "organ", thereby shrinking the feature space. It is a crude heuristic that may produce non-words, but it unifies the three forms.

Question 34Text Preprocessing and Feature Engineering

What does the bag-of-words representation of a document deliberately discard?

  1. The order in which the tokens appear Correct answer.
  2. The presence of rare terms
  3. The counts of each vocabulary term
  4. The size of the vocabulary

Explanation

Bag-of-words records only term frequencies and treats the document as an unordered multiset of tokens, so positional information is lost. Two documents with the same word counts but different word order receive identical vectors.

Question 35Text Preprocessing and Feature Engineering

Which pair of strings would a rule-based English stop-word list most likely remove while keeping the meaningful content word?

  1. "the" and "is", keeping "engineer" Correct answer.
  2. "engineer" and "the", keeping "is"
  3. "running" and "quickly", keeping "the"
  4. "database" and "query", keeping "is"

Explanation

Stop-word lists typically contain high-frequency function words such as articles, prepositions, and auxiliary verbs. "The" and "is" are such function words, whereas "engineer" is a content word that carries topical meaning and is normally retained.

Question 36Text Preprocessing and Feature Engineering

In a hashing trick (feature hashing) vectorizer, what determines the index at which a token's feature is stored?

  1. The alphabetical order of the token
  2. A hash function applied to the token string Correct answer.
  3. The token's frequency rank in the corpus
  4. The length of the token in characters

Explanation

Feature hashing applies a fixed hash function to each token and reduces the result modulo the chosen number of buckets, so no explicit vocabulary dictionary is needed. Collisions occur when distinct tokens map to the same bucket.

Question 37Text Preprocessing and Feature Engineering

A character trigram extractor processes the string "abcd". Which set of trigrams does it produce?

  1. ["abcd"]
  2. ["ab", "bc", "cd"]
  3. ["abc", "bcd"] Correct answer.
  4. ["a", "b", "c", "d"]

Explanation

A character n-gram of size three takes every contiguous window of three characters, yielding "abc" from positions 1-3 and "bcd" from positions 2-4. The total count for a string of length L is L - n + 1 when no padding is used.

Question 38Text Preprocessing and Feature Engineering

Why do many text classifiers apply sublinear term-frequency scaling, replacing raw count tf with 1 + log(tf)?

  1. To make the vector entries integers
  2. To guarantee that all document vectors have unit norm
  3. To remove stop words automatically
  4. To dampen the influence of very frequent terms within a document Correct answer.

Explanation

Raw counts let a term occurring fifty times dominate a term occurring five times, even though the marginal information gain is small. The logarithm compresses high counts so that repeated occurrences contribute progressively less, balancing term influence.

Question 39Text Preprocessing and Feature Engineering

A document contains the token "bank" used in both a financial and a river context. Which representation would best distinguish these two senses as separate features?

  1. Unigram bag-of-words over the whole document
  2. A single binary indicator for the word "bank"
  3. Bigram features that capture adjacent context words Correct answer.
  4. Character unigrams of the word "bank"

Explanation

Bigrams pair the ambiguous token with its neighboring words, so "bank account" and "river bank" become distinct features carrying disambiguating context. Unigram and character-level representations collapse both senses into the same feature.

Question 40Text Preprocessing and Feature Engineering

When building a subword vocabulary with byte-pair encoding, what operation is repeated at each training iteration?

  1. Sorting the vocabulary by descending token length
  2. Merging the most frequent adjacent symbol pair into a new symbol Correct answer.
  3. Splitting every word into individual characters once
  4. Deleting the least frequent token from the corpus

Explanation

BPE starts from a character-level vocabulary and iteratively merges the most frequent adjacent pair across the corpus, adding the merged symbol to the vocabulary. This greedy procedure builds frequent subwords first, and the number of merges controls the final vocabulary size.

Question 41Text Preprocessing and Feature Engineering

A vectorizer is fit on the training corpus and then applied to the test corpus. Why must the vocabulary and idf values be learned only from the training data?

  1. Because test documents are always shorter than training documents
  2. Because idf values must be identical for every document
  3. Because the test corpus contains no unknown words
  4. Because using test statistics leaks information and inflates evaluation scores Correct answer.

Explanation

Fitting on the test set lets the model observe the distribution it will be evaluated on, which is a form of data leakage that produces optimistic and unreliable metrics. The correct practice is to fit the vectorizer on training data and transform test data with those frozen statistics.

Question 42Text Preprocessing and Feature Engineering

Which normalization step would convert the full-width characters "ABC123" into "ABC123"?

  1. Porter stemming
  2. Unicode NFKC normalization Correct answer.
  3. Lowercasing
  4. Sentence tokenization

Explanation

NFKC is a compatibility normalization form that maps full-width variants to their standard-width equivalents, so full-width Latin letters and digits become ASCII. Lowercasing or stemming would not change character width.

Question 43Text Preprocessing and Feature Engineering

A document-term matrix built with a 20,000-word vocabulary has rows of mostly zeros because each document uses only a few hundred distinct words. What property does this matrix exhibit?

  1. Sparsity Correct answer.
  2. High density
  3. Perfect collinearity
  4. Low dimensionality

Explanation

Sparsity means the vast majority of matrix entries are zero, which is typical when vocabulary size greatly exceeds the number of distinct terms per document. Sparse representations store only nonzero entries to save memory and computation.

Question 44Text Preprocessing and Feature Engineering

Which tokenizer behavior is required to correctly segment the English contraction "don't" into its component parts for downstream normalization?

  1. Splitting only on whitespace, keeping "don't" intact
  2. Lowercasing the string before splitting on whitespace
  3. Treating the apostrophe as a word-internal character and then splitting the clitic Correct answer.
  4. Removing all punctuation before any splitting

Explanation

Contraction handling requires recognizing the apostrophe as part of the token first, then separating the clitic so that "do" and "n't" (or "not") emerge as distinct units. Whitespace-only splitting or premature punctuation removal loses the internal boundary.

Question 45Text Preprocessing and Feature Engineering

A feature engineer adds a binary feature that is 1 for every document in the training set. What is the practical consequence for a linear model trained on this feature?

  1. It increases the rank of the design matrix
  2. It removes the need for regularization
  3. It perfectly separates the classes
  4. It carries no discriminative information and only shifts the intercept Correct answer.

Explanation

A constant feature has zero variance across documents, so it cannot help distinguish classes and is collinear with the intercept term. Its weight is therefore unidentifiable on its own and merely absorbs part of the bias.

Question 46Text Preprocessing and Feature Engineering

In a term-document matrix, a term appears in exactly one of 5,000 documents. Under idf = log(N/df), how does its weight compare with a term appearing in 2,500 documents?

  1. Both terms receive identical idf weights
  2. The rare term has a much higher idf weight Correct answer.
  3. The rare term receives an idf of exactly zero
  4. The common term has a much higher idf weight

Explanation

Because df is in the denominator, smaller document frequency yields a larger ratio and thus a larger idf. The term in one document gets log(5000) while the term in 2,500 documents gets log(2), so rarity is strongly rewarded.

Question 47Text Preprocessing and Feature Engineering

Why is lemmatization often preferred over stemming when interpretable features are required for a downstream model?

  1. Lemmatization produces valid dictionary words using part-of-speech information Correct answer.
  2. Lemmatization increases the vocabulary size deliberately
  3. Lemmatization removes more stop words than stemming
  4. Lemmatization always runs faster than stemming

Explanation

A lemmatizer uses morphological analysis and part-of-speech context to return a real base form such as "be" for "was", so the resulting features are linguistically valid and human-readable. Stemmers apply crude affix stripping that can yield non-words like "studi".

Question 48Text Preprocessing and Feature Engineering

A Naive Bayes text classifier is trained on raw counts but performs poorly on long documents. Which feature transformation most directly addresses the imbalance between long and short documents?

  1. Removing all rare terms from the vocabulary
  2. Increasing the n-gram order to four
  3. Adding more stop words to the list
  4. Applying L2 normalization to each document vector Correct answer.

Explanation

L2 normalization rescales each document vector to unit length, so the total magnitude of counts no longer dominates the decision. This puts long and short documents on a comparable scale while preserving the relative term proportions.

Question 49Text Preprocessing and Feature Engineering

In a fixed-window word-context co-occurrence matrix, what does the entry for row word w and column context c typically store?

  1. The cosine similarity between w and c
  2. The edit distance between w and c
  3. The part of speech shared by w and c
  4. The number of times c appears within the window around w Correct answer.

Explanation

A co-occurrence matrix counts how often a context word appears inside a defined window around each target word, capturing distributional context. Similarity measures are computed from these counts afterward rather than stored directly.

Question 50Text Preprocessing and Feature Engineering

A pipeline applies lowercasing, then removes punctuation, then tokenizes on whitespace. What problem arises for the input "U.S.A."?

  1. The token is incorrectly lemmatized to "use"
  2. The token becomes "usa", losing the internal period boundaries Correct answer.
  3. The token is treated as a numeric value
  4. The token is split into four separate tokens

Explanation

Removing punctuation before tokenization deletes the periods that mark abbreviation boundaries, fusing the string into "usa". If tokenization had run first, the periods could have been preserved as part of the abbreviation or used as split points.