UNPKG

@antv/narrative-text-schema

Version:

Json schema of narrative text visualization

17 lines (16 loc) 712 B
import { PhraseSpec } from '../schema'; /** * parse string template to phrases * @example * str = `<%= time %>, <%= columnAlias$$metric_name$$ %> is <%= price$$metric_value$$ %>` * data = { time: "2020", columnAlias: "price total", price: "123" } * => * [ * { type: "text", value: "2020" }, * { type: "text", value: ", " }, * { type: "entity", value: "price total", metadata: { entityType: metric_name } }, * { type: "text", value: " is " }, * { type: "entity", value: "123", metadata: { entityType: metric_value } }, * ] */ export declare function generateSentence(template: string, formattedData?: Record<string, string>, originalData?: Record<string, unknown>): PhraseSpec[];