Counts¤
Counts
pydantic-model
¤
Bases: BaseCalculator
A calculator for counting patterns in rolling windows.
Config:
default:validation_config
Fields:
-
patterns(Optional[list | str]) -
windows(Optional[Windows]) -
mode(Optional[bool | str]) -
case_sensitive(Optional[bool]) -
alignment_mode(Optional[str]) -
model(Optional[str]) -
nlp(Optional[Language]) -
data(Optional[list])
Source code in lexos/rolling_windows/calculators/counts.py
alignment_mode: Optional[str] = 'strict'
pydantic-field
¤
Whether to snap searches to token boundaries. Values are 'strict', 'contract', and 'expand'.
case_sensitive: Optional[bool] = False
pydantic-field
¤
Whether to make searches case-sensitive.
data: Optional[list] = []
pydantic-field
¤
A container for the calculated data.
metadata: dict
property
¤
Return metadata for the calculator.
mode: Optional[bool | str] = 'exact'
pydantic-field
¤
The search method to use ('regex', 'spacy_rule', 'multi_token', 'multi_token_exact').
model: Optional[str] = 'xx_sent_ud_sm'
pydantic-field
¤
The language model to be used for searching spaCy tokens/spans.
n
property
¤
Get the number of units per window.
nlp: Optional[Language] = None
pydantic-field
¤
The spaCy nlp object.
patterns: Optional[list | str] = None
pydantic-field
¤
A pattern or list of patterns to search in windows.
regex_flags
property
¤
Return regex flags based on case_sensitive setting.
window_type
property
¤
Get the type of units in the windows.
windows: Optional[Windows] = None
pydantic-field
¤
A Windows object containing the windows to search.
__call__(patterns: Optional[list | str] = None, windows: Optional[Windows] = None, mode: Optional[bool | str] = None, case_sensitive: Optional[bool] = None, alignment_mode: Optional[str] = None, model: Optional[str] = None)
¤
Call the calculator.
Source code in lexos/rolling_windows/calculators/counts.py
to_df(show_spacy_rules: Optional[bool] = False) -> pd.DataFrame
¤
Convert the data to a pandas dataframe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
show_spacy_rules
|
Optional[bool]
|
If True, use full spaCy rules for labels; otherwise use only the string pattern. |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: A pandas DataFrame. |
Source code in lexos/rolling_windows/calculators/counts.py
__call__(patterns: Optional[list | str] = None, windows: Optional[Windows] = None, mode: Optional[bool | str] = None, case_sensitive: Optional[bool] = None, alignment_mode: Optional[str] = None, model: Optional[str] = None)
¤
Call the calculator.
Source code in lexos/rolling_windows/calculators/counts.py
to_df(show_spacy_rules: Optional[bool] = False) -> pd.DataFrame
¤
Convert the data to a pandas dataframe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
show_spacy_rules
|
Optional[bool]
|
If True, use full spaCy rules for labels; otherwise use only the string pattern. |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: A pandas DataFrame. |