Natural Language Processing · 免费预览

词、语料库与词频

词元与类型、型例比、齐夫定律、独词及希普斯定律,用 NumPy 在小型语料库上统计。

1. Words, Corpora, and Word Frequency

Words, Corpora, and Word Frequency

2. Word frequencies follow two empirical laws

Word frequencies follow two empirical laws

3. Counting a corpus in a dozen lines

Counting a corpus in a dozen lines

4. Tokens and types in a sentence

Count word tokens and word types in this sentence (split on spaces, ignore punctuation): "the ferry waits, the mast waits, and the ferry waits again."

5. Type-token ratio

A toy corpus contains these 23 tokens:

"pilot mast harbour dusk wake wake mast pilot dusk sail harbour pilot mast pilot wake wake sail pilot harbour wake sail dusk mast"

Compute the type-token ratio, rounded to three decimal places.

6. Zipf's law interpolation

In a large corpus the most frequent type occurs 22,000 times. Zipf's law predicts the frequency of the type at rank 4 as f(r)=k/rf(r) = k/r. How many occurrences does it predict for rank 4?

7. Share of the most frequent type

The three most frequent types in a corpus occur 3,120, 1,560, and 520 times, and the long tail of remaining types accounts for 3,000 tokens. What fraction of all tokens does the single most frequent type account for? Round to three decimal places.

8. Heaps' law extrapolation

A corpus of 600,000 tokens has a vocabulary of 50,000 types. Assume Heaps' law ∣V∣=k nβ|V| = k\,n^{\beta} with β=0.56\beta = 0.56. Predict the vocabulary size at 1,200,000 tokens.

进入交互式练习

免费注册 · 即时批改 · 自动安排间隔复习。

免费开始这门课