Natural language based chart generation method, apparatus, device and storage medium
By acquiring data query text from natural language input, and utilizing domain knowledge graphs and virtual DOM technology, data charts are generated and rendered, solving the problem of in-depth analysis needs caused by users' limited professional capabilities, and achieving accurate chart fulfillment and efficient rendering.
Patent Information
- Application Number
- CN202511028231.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-25
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2045-07-25
AI Technical Summary
In existing technologies, the limitations of users' professional capabilities make it difficult for natural language-generated charts to meet the needs of in-depth analysis, and the generated charts cannot accurately meet the user's analytical requirements.
By acquiring data query text from natural language input, we extract extended dimensions and generate derived indicators using domain knowledge graphs, generate database query statements, and render data charts, including feature analysis and chart type matching, and use virtual DOM for dynamic rendering.
The generated data charts accurately meet users' needs for in-depth analysis, improving analysis efficiency and accuracy.
Smart Images

Figure CN120523933B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of artificial intelligence, and particularly relates to a natural language based chart generation method, device, equipment and storage medium. BACKGROUND
[0002] In the field of data analysis, automatically generating visual charts through natural language interaction can significantly reduce the operation threshold of users and improve analysis efficiency, so building an intelligent natural language chart generation system has become the core research direction of the industry. However, the existing technology faces fundamental constraints: the user's professional ability is limited, which makes it difficult for them to define the dimension system required for problem analysis in natural language queries, making it difficult for the generated charts to meet the user's deep analysis needs. Therefore, how to make the natural language generated chart accurately meet the user's deep analysis needs has become a technical bottleneck that needs to be broken through by technical personnel in the field. SUMMARY
[0003] Therefore, the present disclosure proposes a natural language based chart generation method, device, equipment and storage medium, which can make the generated data chart accurately meet the user's deep analysis needs.
[0004] According to a first aspect of the present disclosure, a natural language based chart generation method is provided, comprising:
[0005] Obtaining a data query text input in a natural language manner, and parsing the data query text to obtain a basic dimension and a basic indicator corresponding to the data query text;
[0006] Extracting an expanded dimension associated with the basic dimension from a pre-constructed domain knowledge graph, and generating a derived indicator corresponding to the expanded dimension;
[0007] Generating a database query statement based on the basic dimension, the basic indicator, the expanded dimension and the derived indicator, and performing data query based on the database query statement to obtain target data;
[0008] Based on the target data, rendering a data chart corresponding to the data query text.
[0009] In a possible implementation, when the target data is based on the target data, the data chart corresponding to the data query text is rendered, comprising:
[0010] Analyzing the characteristics of the target data, and determining a chart type matched with the target data according to the characteristic analysis result;
[0011] Based on the target data and the chart type, the data chart corresponding to the data query text is rendered.
[0012] In a possible implementation, when rendering the data chart corresponding to the data query text based on the target data and the chart type, the following operations are included:
[0013] An independent canvas layer is created for each chart element divided in advance;
[0014] According to the target data and the chart type, the corresponding chart elements are sequentially rendered on each canvas layer;
[0015] The rendered canvas layers are sequentially superimposed to obtain the chart data corresponding to the data query text.
[0016] In a possible implementation, the chart elements divided in advance include at least one of a background element, a grid element, a data element, and a label element.
[0017] In a possible implementation, when rendering the data chart corresponding to the data query text based on the target data and the chart type, the following operations are included:
[0018] Based on the target data and the chart type, a chart visualization semantic specification is generated;
[0019] Based on the chart visualization semantic specification, an executable chart rendering code is generated;
[0020] The chart rendering code is executed to render the data chart corresponding to the data query text.
[0021] In a possible implementation, when rendering the data chart corresponding to the data query text based on the target data, the target data is dynamically rendered in batches through a virtual DOM.
[0022] In a possible implementation, after obtaining the target data based on the database query statement, the following operations are further included:
[0023] The target data is preprocessed;
[0024] After the preprocessing of the target data is completed, the operation of rendering the data chart corresponding to the data query text based on the target data is performed.
[0025] According to a second aspect of the present disclosure, a natural language-based chart generation apparatus is provided, including:
[0026] A natural language processing module is configured to obtain a data query text input in a natural language manner, and parse the data query text to obtain a basic dimension and a basic index corresponding to the data query text;
[0027] an expansion module configured to extract an expansion dimension associated with the basic dimension from a pre-constructed domain knowledge graph, and generate a corresponding derivative index for the expansion dimension;
[0028] a data query module configured to generate a database query statement based on the basic dimension, the basic index, the expansion dimension and the derivative index, and perform data query based on the database query statement to obtain target data;
[0029] a chart generation module configured to render a data chart corresponding to the data query text based on the target data.
[0030] According to a third aspect of the present disclosure, there is provided a natural language-based chart generation device, comprising: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to execute the method of the first aspect of the present disclosure.
[0031] According to a fourth aspect of the present disclosure, there is provided a non-volatile computer-readable storage medium having computer program instructions stored thereon, wherein the computer program instructions are executed by a processor to implement the method of the first aspect of the present disclosure.
[0032] The present disclosure provides a natural language-based chart generation method, device, equipment and storage medium, the method comprising: obtaining a data query text input in a natural language manner, and parsing the data query text to obtain a basic dimension and a basic index corresponding to the data query text; extracting an expansion dimension associated with the basic dimension from a pre-constructed domain knowledge graph, and generating a corresponding derivative index for the expansion dimension; generating a database query statement based on the basic dimension, the basic index, the expansion dimension and the derivative index, and performing data query based on the database query statement to obtain target data; and rendering a data chart corresponding to the data query text based on the target data. In the present disclosure, the expansion of the analysis dimension and the generation of the derivative index can be automatically performed by using the domain knowledge graph, so as to construct a complete dimension and index system meeting the data query analysis of the user, and then the generated data chart can accurately meet the deep analysis requirement of the user.
[0033] Other features and aspects of the present disclosure will become apparent from the following detailed description of exemplary embodiments with reference to the drawings. BRIEF DESCRIPTION OF DRAWINGS
[0034] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate exemplary embodiments, features, and aspects of the present disclosure and serve to explain the principles of the present disclosure.
[0035] Figure 1 a flowchart showing a natural language-based chart generation method according to an embodiment of the present disclosure;
[0036] Figure 2 FIG. 1 shows a schematic block diagram of a natural language based chart generation apparatus according to an embodiment of the present disclosure;
[0037] Figure 3 FIG. 1 shows a schematic block diagram of a natural language based chart generation apparatus according to an embodiment of the present disclosure; DETAILED DESCRIPTION
[0038] Various exemplary embodiments, features and aspects of the present disclosure will be explained in greater detail below with reference to the accompanying drawings. The same reference numerals in different drawings denote the same or similar elements. Although various aspects of the embodiments are illustrated in the drawings, the drawings are not necessarily drawn to scale unless specifically noted.
[0039] The word "exemplary" is used herein to mean "serving as an example, instance, or illustration." Any implementation described herein as "exemplary" is not necessarily to be construed as preferred or advantageous over other implementations.
[0040] In addition, for the purpose of convenience and brevity, detailed descriptions of well-known functions and structures incorporated in the present disclosure can be omitted. It will be appreciated by those skilled in the art that the present disclosure can be practiced without these specific details. In some instances, well-known methods, procedures, components, and circuits have not been described in detail since it can obscure the pertinent aspects of the subject matter.
[0041] <Method Embodiment>
[0042] Figure 1 FIG. 2 shows a flowchart of a natural language based chart generation method according to an embodiment of the present disclosure. As shown in FIG. 2, the method includes steps S1100-S1400. Figure 1
[0043] S1100, obtaining a data query text input in a natural language manner, and parsing the data query text to obtain a basic dimension and a basic index corresponding to the data query text.
[0044] It should be noted that the system performing the method of the present disclosure can provide a natural language interaction interface, and the user can input a data query text in multiple modalities such as voice and text through the natural language interaction interface. After completing the input of the data query text, the user clicks to send, and the system can obtain the data query text input by the user in a natural language manner. The data query text can reflect the user's data analysis requirements, for example, "please analyze the change trend of the sales of down jackets this year".
[0045] After receiving the data query text input in natural language, the data query text will be parsed to obtain the corresponding basic dimensions and indicators. Specifically, a prompt template for extracting basic dimensions and indicators is prepared. The data query text is filled into the prompt template to obtain prompt words for extraction. These prompt words are then input into the large language model, which can automatically perform semantic parsing and extract the basic dimensions and indicators contained in the data query text based on the semantic parsing results. For example, when a user inputs the data query text "Please analyze the changing trend of down jacket sales this year," the corresponding basic indicator for this data query text is sales volume, and the corresponding basic dimensions and their values are as follows:
[0046]
[0047] In one possible implementation, after obtaining the data query text, the query intent corresponding to the data query text is first identified to determine whether the query intent is related to data analysis.
[0048] If the query is unrelated to data analysis, prompt the user to send a data query text related to data analysis. For example, if the query intent is determined to be unrelated to data analysis, the system will automatically reply, "I am a data analysis intelligent assistant. I'm sorry I cannot answer your question. You can ask questions related to data analysis."
[0049] If the query is unrelated to data analysis, continue to determine if the query intent is clear. If the query intent is clear, then parse the data query text to obtain the corresponding basic dimensions and indicators. If the query intent is unclear, initiate multiple rounds of interactive confirmation based on contextual memory, using guided questioning to clarify the query intent. For example, when a user enters the data query text "Please analyze the changing trend of down jacket sales this year," the user may be querying the changing trend of sales volume or the changing trend of sales revenue. In this case, a new round of dialogue will be initiated, automatically replying, "Do you want to query the changing trend of sales volume? Or do you want to query the changing trend of sales revenue?" This new round of dialogue guides the user to further clarify their query intent.
[0050] After parsing the basic dimensions and metrics corresponding to the data query text, step S1200 can be executed. From the pre-constructed domain knowledge graph, extended dimensions associated with the basic dimensions are extracted, and corresponding derived metrics are generated for these extended dimensions. The domain knowledge graph is a structured semantic knowledge base that represents entities, attributes, and relationships in a specific domain in graph form. It consists of nodes (representing entities, such as dimensions or metrics) and edges (representing relationships, such as "belongs to," "depends on," or "influences"). For example, in the retail domain, the knowledge graph might contain nodes "product" (dimension), "sales revenue" (metric), and edges "product - belongs to -> category" (relationship).
[0051] When extracting extended dimensions related to basic dimensions from a pre-built domain knowledge graph, the following steps can be included: First, determine the core dimensions from the basic dimensions. Second, traverse the edge relationships in the domain knowledge graph to extract dimensions that are directly related to the core dimensions and have a causal path with the basic indicators as extended dimensions. This causal path is the shortest path that influences the basic indicators.
[0052] For example, in an embodiment where the user inputs the data query text "Please analyze the changing trend of down jacket sales this year," the basic dimensions of the data query text are first determined to include "this year" (time dimension) and "down jacket" (category dimension), with sales as the basic indicator. Then, "down jacket" is identified as the core dimension. Next, the edge relationships in the domain knowledge graph are traversed to extract temperature (environment dimension), duck down (raw material dimension), and graphene thermal clothing (competitor dimension), which are directly related to the core dimension of "down jacket" and have a causal path with the basic indicator of "down jacket sales," as extended dimensions. The shortest causal paths between each extended dimension and the basic indicator of "down jacket sales" are shown in the table below.
[0053]
[0054] After determining the expansion dimensions, derivative indicators that explain changes in the basic indicators will be generated for each expansion dimension. The generation process for the derivative indicators for each expansion dimension is as follows: First, starting from the expansion dimension, extract quantifiable entity attributes or relationship attributes that influence the basic indicators along the shortest causal path between the expansion dimension and the basic indicators. Second, based on the extracted entity attributes and / or relationship attributes, configure the derivative indicators corresponding to the expansion dimension and their calculation formulas. Specifically, the extracted entity attributes and / or relationship attributes can be recommended to users for configuring the derivative indicators and their calculation formulas. Alternatively, the expansion dimension, the shortest causal path containing the expansion dimension, and the entity attributes and / or relationship attributes extracted along that shortest causal path can be input into a pre-trained neural network model to automatically generate the derivative indicators corresponding to the expansion dimension and their calculation formulas.
[0055] For example, regarding the extended dimension "temperature", the entity of temperature has the attribute of temperature difference, the relationship of climate sensitivity has the attribute of climate sensitivity coefficient, and the entity of down jacket has the attribute of sales volume. First, the attributes of temperature difference, climate sensitivity coefficient, and sales volume are extracted. Then, the extracted attributes of temperature difference, climate sensitivity coefficient, and sales volume are recommended to users. Based on the attributes of temperature difference, climate sensitivity coefficient, and sales volume, users configure the derived indicator of warm winter impact value corresponding to the extended dimension of temperature. The warm winter impact value = sales volume × climate sensitivity coefficient × temperature difference.
[0056] In another example, for the extended dimension "temperature", the entity of temperature has the attribute of temperature difference on its shortest causal path, the relationship of climate sensitivity has the attribute of climate sensitivity coefficient, and the entity of down jacket has the attribute of sales volume. First, the attributes of temperature difference, climate sensitivity coefficient and sales volume are extracted. Then, the extended dimension temperature, the shortest causal path of temperature, and the extracted attributes of temperature difference, climate sensitivity coefficient and sales volume are input into a pre-trained neural network model so that the neural network model can automatically generate the derived index of warm winter impact value corresponding to the extended dimension of temperature. The warm winter impact value = sales volume × climate sensitivity coefficient × temperature difference.
[0057] After extracting the extended dimensions associated with the basic dimensions and generating corresponding derived indicators for the extended dimensions, step S1300 can be executed. Based on the basic dimensions, basic indicators, extended dimensions, and derived indicators, a database query statement is generated, and a data query is performed based on the database query statement to obtain the target data. Specifically, a prompt for generating the database query statement is constructed based on the basic dimensions, basic indicators, extended dimensions, and derived indicators. This prompt is input into a pre-trained large language model, which can automatically generate the database query statement (e.g., an SQL query statement) and perform a data query based on the database query statement, returning the corresponding target data.
[0058] After obtaining the target data returned by the data query, step S1400 can be executed to render the data chart corresponding to the data query text based on the target data. Specifically, this may include the following steps:
[0059] First, analyze the characteristics of the target data and determine the chart type that matches the target data based on the results of the characteristic analysis.
[0060] First, the target data is analyzed for at least one of the following features:
[0061] 1. Dimensional Analysis: Identify basic dimensions (such as time), extended dimensions (such as temperature), and their types;
[0062] 2. Indicator Analysis: Identify basic indicators (such as sales revenue), derivative indicators (such as the impact of a mild winter), and their types;
[0063] 3. Distribution analysis: Statistical data points, time series characteristics, discreteness / continuity, and significance of comparative relationships;
[0064] 4. Relationship Pattern Analysis: a. Analyze the relationship between basic dimensions and basic indicators (e.g., time vs. sales trend); b. Analyze the correlation between extended dimensions and basic indicators (e.g., temperature vs. sales); c. Analyze the explanatory power of derived indicators on changes in basic indicators (e.g., the impact of a warm winter explains sales fluctuations); d. Combine scenario analysis with domain knowledge graphs (e.g., the causal path "temperature → ... → sales" in the domain knowledge graph is climate attribution analysis), and label the business scenario type (trend / relation / attribution analysis).
[0065] Secondly, based on the feature analysis results of the target data and combined with pre-set chart type mapping rules, the chart type matching the target data is determined. The pre-set chart type mapping rules are shown in the table below:
[0066]
[0067] It should be noted that the following principles should be followed when matching chart types: charts that can reveal the correlation patterns between extended dimensions, derived indicators and basic indicators should be selected in order to meet the purpose of in-depth analysis.
[0068] When the feature analysis results match multiple feasible chart types, a selection can be made according to a preset priority strategy. The priority strategies, from highest to lowest, are: a. Select the chart type that can display the most dimensional indicator relationships; b. Select the recommended chart from the domain knowledge graph for this type of analysis scenario; c. Consider generating a combined chart; d. Initiate multiple rounds of interaction to confirm the user's chart preferences.
[0069] Second, based on the target data and chart type, render the data chart corresponding to the data query text. Specifically, this can include the following steps: First, create independent canvas layers for each pre-defined chart element. These pre-defined chart elements include at least one of background elements, grid elements, data elements, and label elements. The background element defines the overall style of the chart, the grid element assists in data positioning, the data element visually displays the target data, and the label element annotates key information. Second, according to the target data and chart type, render the corresponding chart elements sequentially on each canvas layer. In the embodiment where each chart element includes background elements, grid elements, data elements, and label elements, static elements such as the chart's background color and borders are drawn on the canvas layer corresponding to the background element. Auxiliary lines such as coordinate axes and grid lines are drawn on the canvas layer corresponding to the grid element. Core data visualization elements, such as line charts, bar charts, and pie charts, are drawn on the canvas layer corresponding to the data element. Dynamic text such as data labels, legends, and tooltips are drawn on the canvas layer corresponding to the label element. Finally, the rendered canvas layers are overlaid sequentially to obtain the chart data corresponding to the data query text.
[0070] In one possible implementation, when the target data changes, a difference comparison algorithm is used to determine the specific chart elements that have changed, and only the canvas layer corresponding to the changed chart elements is incrementally updated. This setup can significantly reduce rendering computation, achieve millisecond-level response times, and avoid page flickering issues.
[0071] In one possible implementation, when rendering the data chart corresponding to the data query text based on the target data and chart type, the rendering is achieved by executing the constructed chart rendering code. The specific chart rendering process is as follows: First, a chart visualization semantic specification is generated based on the target data and chart type. Specifically, the definition of the visualization semantic specification, the target data, and the chart type are obtained. Based on these criteria, prompt words for generating the chart semantic specification are constructed. These prompt words are then input into a large language model, which automatically generates the chart visualization semantic specification. The visualization semantic specification is in the system-defined JSON format. Second, executable chart rendering code is generated based on the chart visualization semantic specification. Again, prompt words for generating the chart rendering code are constructed based on the chart visualization semantic specification. These prompt words are then input into the large language model, which automatically generates the executable chart rendering code corresponding to the chart visualization semantic specification. Finally, the chart rendering code is executed to render the data chart corresponding to the data query text.
[0072] When rendering data charts corresponding to data query text based on target data, especially when the target data volume is large, virtual DOM (Document Object Model) technology can be used to dynamically render the target data in batches to optimize performance and ensure smooth interaction. Specifically, this can include the following steps:
[0073] First, the visualization window is initialized and data is loaded in batches. Specifically, the pre-set visualization window size is obtained, and the maximum number of data points that can be displayed in real time within the window (e.g., 100 data points) is determined based on this size. During the initial rendering, only the following two parts of data are loaded: 1. Initial visualization window data: data points that need to be directly displayed within the window area (e.g., 100); 2. Preload buffer data: data points to be rendered in the adjacent area of the window (e.g., 100 before and 100 after the window, for a total of 200). By controlling the total amount of data loaded initially within a reasonable range (e.g., 300 data points), the computational load of the initial rendering is significantly reduced.
[0074] Secondly, interactive triggers dynamic updates and batch construction of the virtual DOM. Specifically, when a user performs an interactive operation (such as scrolling or zooming in a chart), the data range of the new visualization window is dynamically calculated. The preload buffer is checked to see if it contains the data required for the new window: if so, these data points are directly updated and rendered on the data element layer canvas. Simultaneously, the background is asynchronously triggered to load the next batch of data to be rendered from neighboring areas (e.g., 200 data points), maintaining data supply continuity. For data points requiring batch updates (e.g., scrolling across 20 points), a lightweight virtual DOM is constructed in memory, and the changes to the data points to be updated (e.g., the displacement of a polyline path) are uniformly concatenated into this virtual DOM, avoiding point-by-point rendering operations.
[0075] Finally, efficient decoupling of synchronous and asynchronous operations is achieved. Specifically, after the virtual DOM is constructed, only one physical rendering operation is performed (such as updating the state via setState or directly manipulating the Canvas API), and all accumulated changes are synchronized to the data element layer canvas at once. This mechanism avoids the performance overhead and page flickering issues caused by frequent partial repaints.
[0076] In one possible implementation, user interaction characteristics are monitored in real time, including swipe speed, swipe direction, and dwell time. The amount of preloaded data is dynamically adjusted based on swipe speed: when a user swipes quickly (speed threshold > 50 pixels per second), the preload buffer is expanded to 300 data points before and after the window; when the user browses slowly (speed threshold < 10 pixels per second), it is reduced to 50 data points before and after. Simultaneously, a swipe direction prediction model is constructed—if three consecutive swipes are in the same direction (e.g., all to the right), an additional data area for the next direction is preloaded (increasing the buffer by 30%), significantly reducing loading latency caused by swipe inertia.
[0077] In this embodiment, user interaction operations are decoupled from the data loading / rendering process through an asynchronous mechanism, which allows user operations to receive immediate responses and ensures smooth interaction.
[0078] In one possible implementation, after retrieving the target data based on a database query statement, the process further includes: preprocessing the target data, whereby preprocessing includes at least one of outlier handling and format conversion. Outlier handling is used to check for and automatically correct outliers in the target data. Format conversion is used to convert the data format in the target data into a standard and reasonable data format. After completing the preprocessing of the target data, the operation of rendering a data chart corresponding to the data query text based on the target data is then performed.
[0079] This disclosure provides a natural language-based chart generation method, comprising: acquiring data query text input in natural language, parsing the data query text to obtain the basic dimensions and basic indicators corresponding to the data query text; extracting extended dimensions associated with the basic dimensions from a pre-constructed domain knowledge graph, and generating corresponding derived indicators for the extended dimensions; generating a database query statement based on the basic dimensions, basic indicators, extended dimensions, and derived indicators, and performing a data query based on the database query statement to obtain the target data; and rendering a data chart corresponding to the data query text based on the target data. In this disclosure, the domain knowledge graph can be used to automatically expand the analysis dimensions and generate derived indicators, thereby constructing a complete dimension and indicator system that meets the user's data query and analysis needs, and thus enabling the generated data charts to accurately meet the user's in-depth analysis requirements.
[0080] <Device Embodiment>
[0081] Figure 2 A schematic block diagram of a natural language-based graph generation apparatus according to an embodiment of the present disclosure is shown. Figure 2 As shown, the device 100 includes:
[0082] Natural Language Processing Module 110 is used to acquire data query text input in natural language and parse the data query text to obtain the basic dimensions and basic indicators corresponding to the data query text.
[0083] The extension module 120 is used to extract extended dimensions associated with the basic dimensions from the pre-built domain knowledge graph, and generate corresponding derived indicators for the extended dimensions.
[0084] The data query module 130 is used to generate a database query statement based on the basic dimension, the basic indicator, the extended dimension and the derived indicator, and to perform data query based on the database query statement to obtain the target data;
[0085] The chart generation module 140 is used to render a data chart corresponding to the data query text based on the target data.
[0086] <Equipment Example>
[0087] Figure 3 A schematic block diagram of a natural language-based graph generation device according to an embodiment of the present disclosure is shown. Figure 3 As shown, the natural language-based graph generation device 200 includes a processor 210 and a memory 220 for storing executable instructions of the processor 210. The processor 210 is configured to implement any of the aforementioned natural language-based graph generation methods when executing the executable instructions.
[0088] It should be noted here that the number of processors 210 can be one or more. Furthermore, the natural language-based graph generation device 200 of this embodiment may also include an input device 230 and an output device 240. The processors 210, memory 220, input device 230, and output device 240 can be connected via a bus or other means, without specific limitations here.
[0089] The memory 220, as a computer-readable storage medium, can be used to store software programs, computer-executable programs, and various modules, such as the program or module corresponding to the natural language-based chart generation method of this disclosure embodiment. The processor 210 executes various functional applications and data processing of the natural language-based chart generation device 200 by running the software program or module stored in the memory 220.
[0090] Input device 230 can be used to receive input digital numbers or signals. These signals may include key signals related to user settings and function control of the device / terminal / server. Output device 240 may include a display device such as a screen.
[0091] <Storage Medium Examples>
[0092] According to a fourth aspect of this disclosure, a non-volatile computer-readable storage medium is also provided, on which computer program instructions are stored, which, when executed by processor 210, implement any of the preceding natural language-based graph generation methods.
[0093] The various embodiments of this disclosure have been described above. These descriptions are exemplary and not exhaustive, and are not limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is chosen to best explain the principles, practical applications, or technical improvements to the technology in the market, or to enable others skilled in the art to understand the embodiments disclosed herein.
Claims
1. A method for generating charts based on natural language, characterized in that, include: Obtain the data query text input in natural language, and parse the data query text to obtain the basic dimensions and basic indicators corresponding to the data query text; From the pre-constructed domain knowledge graph, the extended dimensions associated with the basic dimensions are extracted, and corresponding derived indicators are generated for the extended dimensions. Based on the basic dimensions, basic indicators, extended dimensions, and derived indicators, a database query statement is generated, and data is queried based on the database query statement to obtain the target data; Based on the target data, render the data chart corresponding to the data query text; When extracting extended dimensions related to basic dimensions from a pre-built domain knowledge graph, the process includes: identifying core dimensions from the basic dimensions; traversing the edge relationships in the domain knowledge graph to extract dimensions that are directly related to the core dimensions and have a causal path with the basic indicators as extended dimensions, where the causal path is the shortest path that affects the basic indicators. After extracting the extended dimensions, corresponding derived indicators will be generated for the extended dimensions. Specifically, this includes: taking the extended dimension as the starting point, extracting quantifiable entity attributes or relational attributes that have an impact on the basic indicators along the shortest causal path between the extended dimension and the basic indicators; and configuring the derived indicators corresponding to the extended dimensions and the calculation formula of the derived indicators based on the extracted entity attributes and / or relational attributes.
2. The method according to claim 1, characterized in that, When rendering a data chart corresponding to the data query text based on the target data, the process includes: The characteristics of the target data are analyzed, and the chart type that matches the target data is determined based on the characteristics analysis results; Based on the target data and the chart type, render the data chart corresponding to the data query text.
3. The method according to claim 2, characterized in that, When rendering the data chart corresponding to the data query text based on the target data and the chart type, the process includes: Create separate canvas layers for each of the pre-defined chart elements; Based on the target data and the chart type, the corresponding chart elements are rendered sequentially on each of the canvas layers; The rendered canvas layers are stacked sequentially to obtain the chart data corresponding to the data query text.
4. The method according to claim 3, characterized in that, The pre-defined chart elements include at least one of the following: background elements, grid elements, data elements, and label elements.
5. The method according to claim 2, characterized in that, When rendering the data chart corresponding to the data query text based on the target data and the chart type, the process includes: Based on the target data and the chart type, generate chart visualization semantic specifications; Based on the aforementioned chart visualization semantics specification, generate executable chart rendering code; Execute the chart rendering code to render the data chart corresponding to the data query text.
6. The method according to claim 1, characterized in that, When rendering the data chart corresponding to the data query text based on the target data, the target data is dynamically rendered in batches using a virtual DOM.
7. The method according to claim 1, characterized in that, After obtaining the target data by performing a data query based on the database query statement, the process further includes: The target data is preprocessed; After preprocessing the target data, the operation of rendering the data chart corresponding to the data query text based on the target data is then performed.
8. A chart generation device based on natural language, characterized in that, include: The natural language processing module is used to acquire data query text input in natural language, and parse the data query text to obtain the basic dimensions and basic indicators corresponding to the data query text. The extension module is used to extract extended dimensions associated with the basic dimensions from the pre-built domain knowledge graph, and generate corresponding derived indicators for the extended dimensions. The data query module is used to generate a database query statement based on the basic dimension, the basic indicator, the extended dimension and the derived indicator, and to perform data query based on the database query statement to obtain the target data; The chart generation module is used to render a data chart corresponding to the data query text based on the target data; When extracting extended dimensions related to basic dimensions from a pre-built domain knowledge graph, the process includes: identifying core dimensions from the basic dimensions; traversing the edge relationships in the domain knowledge graph to extract dimensions that are directly related to the core dimensions and have a causal path with the basic indicators as extended dimensions, where the causal path is the shortest path that affects the basic indicators. After extracting the extended dimensions, corresponding derived indicators will be generated for the extended dimensions. Specifically, this includes: taking the extended dimension as the starting point, extracting quantifiable entity attributes or relational attributes that have an impact on the basic indicators along the shortest causal path between the extended dimension and the basic indicators; and configuring the derived indicators corresponding to the extended dimensions and the calculation formula of the derived indicators based on the extracted entity attributes and / or relational attributes.
9. A chart generation device based on natural language, characterized in that, include: processor; Memory used to store processor-executable instructions; The processor is configured to implement the method of any one of claims 1 to 7 when executing the executable instructions.
10. A non-volatile computer-readable storage medium storing computer program instructions thereon, characterized in that, When the computer program instructions are executed by the processor, they implement the method described in any one of claims 1 to 7.
Citation Information
Patent Citations
Index data analysis method and system based on knowledge graph and natural language
CN116244410A