Comparison ¶
A comparison between two corpora: a reference corpus and a comparison corpus.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reference
|
str
|
Name of the reference corpus |
required |
comparison
|
str
|
Name of the comparison corpus |
required |
Methods:
| Name | Description |
|---|---|
alias |
Returns a new |
normalize |
Returns a new |
Attributes:
| Name | Type | Description |
|---|---|---|
exclude |
ComparisonExcluder
|
Namespace for excluding tokens from the reference and comparison corpora. |
score |
Scorer
|
Namespace for scoring comparisons between the reference and comparison corpora. |
Attributes¶
exclude
cached
property
¶
Namespace for excluding tokens from the reference and comparison corpora.
See the available exclusion strategies.
score
cached
property
¶
Namespace for scoring comparisons between the reference and comparison corpora.
See the available scoring methods.
Methods:¶
alias ¶
Returns a new Comparison with the given alias, an internal name for it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name to give to the comparison |
required |
Returns:
| Type | Description |
|---|---|
Comparison
|
A new |
normalize ¶
Returns a new Comparison whose token contributions are normalized onto a common scale.
Example
Each scoring measure produces a per-token contribution \(\delta_\tau\). Normalization divides every contribution by a single constant, either the total difference between the corpora \(\sum_\tau |\delta_\tau|\) or their net difference \(|\sum_\tau \delta_\tau|\), so that scores become interpretable and comparable across measures.
For what each strategy means and how to read a normalized score, see Normalization.
Warning
By default, using this method forces the comparison to be evaluated eagerly rather than
lazily, because validating it requires computing the scores over the full vocabulary.
The eager validation can be skipped using the check_nonzero parameter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
by
|
NormalizeBy
|
The normalization strategy. |
required |
check_nonzero
|
bool
|
Whether to check whether the normalization constant is zero and raise an error. If
|
True
|
Returns:
| Type | Description |
|---|---|
Comparison
|
A new |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
ValueError
|
If the comparison is already normalized by a different strategy. |
ValueError
|
If |
ValueError
|
If |