cuery.tools.abs#
Higher-level API for extracting entities from texts using one-shot prompts.
Some examples of LLM-based methods:
Evaluating Zero-Shot Multilingual Aspect-Based Sentiment Analysis with Large Language Models https://arxiv.org/abs/2412.12564
Structured Sentiment Analysis with Large Language Models: A Winning Solution for RuOpinionNE-2024 https://dialogue-conf.org/wp-content/uploads/2025/04/VatolinA.104.pdf
Attributes#
Classes#
Represents an aspect with its sentiment and qualified phrase. |
|
Represents a collection of entities with their sentiments and reasons for assignment. |
|
Extract entities with sentiments from texts. |
Module Contents#
- cuery.tools.abs.ABS_PROMPT_SYSTEM = ''#
- cuery.tools.abs.ABS_PROMPT_USER = ''#
- class cuery.tools.abs.AspectEntity(/, **data)#
Bases:
cuery.ResponseRepresents an aspect with its sentiment and qualified phrase.
- Parameters:
data (Any)
- entity: str#
The specific, normalized aspect being evaluated (e.g., ‘ride queues’, ‘food prices’).
- sentiment: Literal['positive', 'negative']#
The sentiment associated with the aspect (positive or negative).
- reason: str#
‘<standardized_adjective> <entity>’ (e.g., ‘long ride queues’).
- Type:
The normalized aspect phrase
- category: str | None = None#
Optional category the entity belongs to (e.g., ‘food’, ‘service’, ‘pricing’).
- class cuery.tools.abs.AspectEntities(/, **data)#
Bases:
cuery.ResponseRepresents a collection of entities with their sentiments and reasons for assignment.
- Parameters:
data (Any)
- entities: list[AspectEntity]#
A list of entities with their sentiments and reasons.
- class cuery.tools.abs.AspectSentimentExtractor(/, **data)#
Bases:
cuery.ToolExtract entities with sentiments from texts.
- Parameters:
data (Any)
- texts: collections.abc.Iterable[str | float | None]#
The texts to extract entities from.
- instructions: str = ''#
Further instructions from the user for the entity extraction task.
- aspect_categories: list[str] | None = None#
Optional list of aspect categories to map entities to (e.g., [‘food’, ‘service’, ‘pricing’]).
- response_model: ClassVar[cuery.ResponseClass]#
Defines the response model for this tool (ClassVar or property).
- classmethod _coerce_na(v)#
Convert pandas NA/NaN values to None so Pydantic accepts them.
- property prompt: cuery.Prompt#
Defines the prompt for this tool (ClassVar or property).
- Return type:
- property context: cuery.AnyContext#
- Return type:
cuery.AnyContext