sCAKE¤
SCake
pydantic-model
¤
Bases: TopWords
Extracts keyterms using the sCAKE (Semantic Connectivity Aware Keyword Extraction) algorithm.
Config:
default:validation_config
Fields:
-
doc(str | Doc) -
normalize(Optional[Literal['orth', 'lower', 'lemma']]) -
include_pos(Optional[str | Collection[str]]) -
topn(Optional[int | float]) -
keyterms(list[tuple[str, float]] | None)
Source code in lexos/topwords/keyterms/scake.py
doc: str | Doc
pydantic-field
¤
The raw text or spaCy doc to analyze.
include_pos: Optional[str | Collection[str]] = ('NOUN', 'PROPN', 'ADJ')
pydantic-field
¤
POS tags to include for candidate selection.
normalize: Optional[Literal['orth', 'lower', 'lemma']] = 'lemma'
pydantic-field
¤
How to normalize tokens for candidate selection.
topn: Optional[int | float] = 10
pydantic-field
¤
The number of top keyterms to return (int or float ratio of candidates).
__init__(**kwargs) -> None
¤
Initialize the SCake object and extract keyterms.
Source code in lexos/topwords/keyterms/scake.py
to_df()
¤
scake(doc: Doc | str, *, normalize: Literal['orth', 'lower', 'lemma'] | None = 'lemma', include_pos: Optional[str | Collection[str]] = ('NOUN', 'PROPN', 'ADJ'), topn: int | float = 10) -> list[tuple[str, float]]
¤
Extract key terms from a document using the sCAKE algorithm.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
doc
|
Doc | str
|
spaCy |
required |
normalize
|
Literal['orth', 'lower', 'lemma'] | None
|
If "lemma", lemmatize
terms; if "lower", lowercase terms; if None, use the orthographic forms
that appear in |
'lemma'
|
include_pos
|
str | Collection[str] | None
|
One or more POS tags with which
to filter for good candidate keyterms. If |
('NOUN', 'PROPN', 'ADJ')
|
topn
|
int | float
|
Number of top-ranked terms to return as key terms.
If an integer, represents the absolute number; if a float, value
must be in the interval (0.0, 1.0], which is converted to an int by
|
10
|
Returns:
| Type | Description |
|---|---|
list[tuple[str, float]]
|
list[tuple[str, float]]: Sorted list of top |
Notes
- Normalize the arguments
- Then make the co-occurrence matrix.
- Make a graph based on the matrix.
- Compute the scores based on the graph.
- Get the key phrases and return topn.