EntityExtraction.h header
#include <ew/app/EntityExtraction.h>
Namespace ew::app
ExtractedEntity struct
struct ew::app::ExtractedEntity
One worldbuilding entity an AI proposed from a manuscript: a suggested name, a suggested codex category ("Characters", "Locations", "Items", "Organizations", "Events", or "Other"), and a one-sentence summary grounded in the prose. The desktop review UI turns the ones the writer accepts into codex entities. Backs DESIGN §4.8 "generate a codex from a manuscript".
Members
QString ew::app::ExtractedEntity::name
The proposed entity name.
QString ew::app::ExtractedEntity::category
The suggested category label (one of the fixed set; "Other" when the model is unsure).
QString ew::app::ExtractedEntity::summary
A one-sentence description drawn from the manuscript.
bool operator==(const ExtractedEntity &, const ExtractedEntity &)=default
Extracted entities compare equal when every field matches.
Functions
AiRequest ew::app::buildEntityExtractionRequest(const QString &manuscriptText, const QStringList &existingNames)
Builds an AI request that asks the model to extract the worldbuilding entities mentioned in manuscriptText – characters, locations, items, organizations, events – as a strict JSON array for parseEntityExtractionResponse, excluding any whose name is already in existingNames (so it proposes only what the codex is missing). Pure (assembles the prompt only); the caller fills the model from settings and sends it via an AiProvider, then parses the reply. The model name is left empty for the caller to set.
std::vector< ExtractedEntity > ew::app::parseEntityExtractionResponse(const QString &content)
Parses a model reply content (the assistant text from an entity-extraction request) into the proposed entities. Tolerant of a JSON array wrapped in code fences or surrounding prose: it reads the first '[' through the last ']' and parses that. Entries with an empty name are dropped, a missing category defaults to "Other", and duplicate names (case-insensitive) are collapsed to the first. Returns an empty vector when no JSON array is present or it is malformed. Pure and unit-testable (no network).