Report generation method and related equipment based on artificial intelligence
Through the report generation method based on artificial intelligence, dynamic character hash tables and template programs are used to solve the problem of inefficient report generation in the existing technology, and report generation is quickly responding to and adapting to changes in business demands.
Patent Information
- Application Number
- CN202210380739.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-08
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2042-04-08
AI Technical Summary
It is difficult for existing technology to generate reports efficiently, especially when business needs change, the form and content of reports need to be adjusted frequently, resulting in inefficient report generation.
Using an artificial intelligence-based report generation method, we use collectors the keywords and special characters of the report program from the database, build a dynamic character hash table, and encode and cluster the historical program to generate template programs to improve the efficiency of report generation.
It improves the efficiency of report generation, and through the increase in program reuse rate, it can quickly respond to and adapt to changes in business needs.
Smart Images

Figure CN114881001B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to an artificial intelligence-based report generation method, device, electronic device and storage medium. Background Art
[0002] Reports are a medium that uses structured forms to summarize and display data. Before the development of information technology, people usually used handwritten reports to summarize and display data. With the development of computer and big data technology, handwritten reports can no longer meet the increasing volume of data, and more and more companies use computer programs to batch produce reports during operations.
[0003] At present, enterprises usually extract data from enterprise databases and automatically generate reports by writing computer programs. However, the form and content of reports may change with the changes in business needs, so it is imperative to design an efficient report generation method. Summary of the invention
[0004] In view of the above, it is necessary to provide an artificial intelligence-based report generation method and related equipment to solve the technical problem of how to improve the efficiency of report generation, wherein the related equipment includes an artificial intelligence-based report generation device, an electronic device and a storage medium.
[0005] The present application provides a report generation method based on artificial intelligence, the method comprising:
[0006] Collect keywords and special characters of the report program from the database, and take all keywords and special characters as keyword sets and special character sets respectively;
[0007] Statistically reporting all historical programs in the project, and classifying the historical programs according to semantic information of the historical programs to obtain a plurality of program sets;
[0008] Matching the special character set with characters in the historical program to obtain key-value pairs, and constructing a dynamic character hash table based on the key-value pairs;
[0009] Encode each historical program to obtain an encoding vector corresponding to each historical program;
[0010] Clustering the encoding vectors in each program set respectively to obtain multiple program clusters;
[0011] Creating a template program corresponding to each program cluster according to the keyword set and the dynamic character hash table, each program cluster including at least one template program;
[0012] Analyze the semantic information of the business needs to be evaluated and call the existing template program based on the analysis results to generate report production results.
[0013] The above-mentioned artificial intelligence-based report generation method obtains a keyword set and a special character set by collecting keywords and special characters of the report program from the database, and obtains multiple program sets by counting the historical programs in the report generation project, and then constructs a dynamic character hash table based on the special character set and the characters in the historical program, and encodes each historical program to cluster all historical programs to obtain multiple program clusters, and further produces a template program corresponding to each program cluster based on the keyword set and the dynamic character hash table, and can call the template program to generate reports based on business needs. The above-mentioned method ensures the reuse rate of the program, thereby improving the efficiency of report generation.
[0014] In some embodiments, matching the special character set with characters in the historical program to obtain key-value pairs, and constructing a dynamic character hash table based on the key-value pairs includes:
[0015] Filtering dynamic characters in the historical program, wherein the dynamic characters refer to characters that change with business needs;
[0016] Classifying the dynamic characters according to semantic information of a preceding character of each dynamic character to obtain a plurality of dynamic character sets, wherein the preceding character refers to a character preceding the dynamic character;
[0017] The special character set is matched with the multiple dynamic character sets to obtain key-value pairs, and a dynamic character hash table is constructed according to all the key-value pairs, wherein the key of the key-value pair is the special character in the special character set, and the value is the dynamic character set.
[0018] In this way, the judgment result is obtained by judging each character in the historical program, and each character is further marked according to the judgment result. The semantic category of each marked character is determined by the semantic information of the preceding character of the character marked as "dynamic", and the characters belonging to the same semantic category are stored as dynamic character sets respectively, which provides data support for the production of subsequent template programs, thereby improving the efficiency of report production.
[0019] In some embodiments, encoding each historical program to obtain an encoding vector corresponding to each historical program includes:
[0020] Traversing each historical program according to the character arrangement order in the historical program;
[0021] Input each traversed character into a preset discrimination program to obtain a discrimination result;
[0022] Determine the encoding value corresponding to each character according to the discrimination result of the character;
[0023] The encoding values are combined according to the arrangement order of the characters in the historical program to generate an encoding vector.
[0024] In this way, each character in the historical program is judged by running the preset program, and a coding value is assigned to each character based on the judgment result, so as to obtain the coding vector corresponding to each historical program. Representing all historical programs in a fully quantitative form can provide data support for subsequent historical program clustering, thereby improving the efficiency of report production.
[0025] In some embodiments, after encoding each historical program to obtain an encoding vector corresponding to each historical program, the method further includes:
[0026] Count the maximum value of the dimension of the encoding vector corresponding to all historical programs in each program set;
[0027] For a code vector whose dimension is less than the maximum value, the code vector is padded with a value of 2 at the end of the code vector to ensure that the dimension of the code vector is equal to the maximum value.
[0028] In this way, by completing the coding vectors, it is ensured that all coding vectors remain at the same latitude, which can provide complete data support for the subsequent clustering of coding vectors, thereby improving the efficiency of report making.
[0029] In some embodiments, clustering to obtain a plurality of program clusters comprises:
[0030] a. Calculate the cosine similarity between the encoding vector corresponding to each historical program in the program set and each of the remaining encoding vectors;
[0031] b, randomly select two encoding vectors from the program set as vector X and vector Y;
[0032] c. If the vectors X and Y meet a first preset condition, then the vectors X and Y are defined to belong to the same program cluster; otherwise, the vectors X and Y belong to different program clusters;
[0033] d. Randomly select a coding vector that does not belong to any program cluster from the program set and record it as Z. If the coding vector Z meets the second preset condition, then classify the vector Z as a certain cluster; otherwise, treat Z as a separate cluster;
[0034] e. Repeat step d above until all encoding vectors in the program set belong to a cluster.
[0035] In this way, the coding vectors corresponding to all programs in each program set are clustered through a custom clustering algorithm to obtain multiple program clusters. The coding vectors in each program cluster are exactly the same, which can provide data support for the subsequent template statement production and improve the efficiency of report generation.
[0036] In some embodiments, after clustering the encoding vectors in each program set to obtain a plurality of program clusters, the method further includes:
[0037] The number of coding vectors in each program cluster is counted, and the number of coding vectors in each program cluster is used as the priority of the corresponding program cluster. The more the number of coding vectors in the program cluster is, the higher the priority of the program cluster is.
[0038] In this way, the priority of each program cluster is obtained by counting the number of encoding vectors in each program cluster, which can provide sequential guidance for the operation of subsequent template programs, thereby improving the efficiency of report production.
[0039] In some embodiments, analyzing the semantic information of the business requirement to be evaluated and calling an existing template program according to the analysis result to generate a report production result includes:
[0040] Selecting a program set according to the semantic information of the business requirement to be evaluated, and taking a template program in the program set as a first candidate program;
[0041] Screening the dynamic attributes in the business requirement to be evaluated, and inserting the value of the dynamic attribute into the first candidate program to obtain a second candidate program;
[0042] The second candidate program is run to obtain program output results, and the business requirements to be evaluated are compared with the program output results to select a report that meets the requirements.
[0043] In this way, the corresponding program set is selected through the semantic information of the business requirements and the template program in the corresponding program set is used as the first candidate program. Then, the dynamic attribute value in the business requirement is inserted into the first candidate program to obtain the second candidate program. The second candidate program is further run and the report that meets the business requirements is selected as the target report. The template program can be reused to improve the efficiency of report generation.
[0044] The embodiment of the present application also provides a report generation device based on artificial intelligence, the device comprising:
[0045] A collection unit is used to collect keywords and special characters of the report program from the database, and to take all the keywords and special characters as a keyword set and a special character set respectively;
[0046] A classification unit, used for counting all historical programs in the report generation project, and classifying the historical programs according to semantic information of the historical programs to obtain a plurality of program sets;
[0047] A construction unit, configured to match the special character set with characters in the historical program to obtain a key-value pair, and to construct a dynamic character hash table based on the key-value pair;
[0048] An encoding unit, used for encoding each historical program to obtain an encoding vector corresponding to each historical program;
[0049] A clustering unit, used for clustering the encoding vectors in each program set to obtain a plurality of program clusters;
[0050] A making unit, used for making a template program corresponding to each program cluster according to the keyword set and the dynamic character hash table, each program cluster including at least one template program;
[0051] The generation unit is used to analyze the semantic information of the business requirements to be evaluated and call the existing template program according to the analysis results to generate the report production results.
[0052] The present application also provides an electronic device, the device comprising:
[0053] a memory storing computer readable instructions; and
[0054] A processor executes the computer-readable instructions stored in the memory to implement the artificial intelligence-based report generation method.
[0055] An embodiment of the present application also provides a computer-readable storage medium, in which computer-readable instructions are stored. The computer-readable instructions are executed by a processor in an electronic device to implement the artificial intelligence-based report generation method.
[0056] The above-mentioned artificial intelligence-based report generation method obtains a keyword set and a special character set by collecting keywords and special characters of the report program from the database, and obtains multiple program sets by counting the historical programs in the report generation project, and then constructs a dynamic character hash table based on the special character set and the characters in the historical program, and encodes each historical program to cluster all historical programs to obtain multiple program clusters, and further produces a template program corresponding to each program cluster based on the keyword set and the dynamic character hash table, and can call the template program to generate reports based on business needs. The above-mentioned method ensures the reuse rate of the program, thereby improving the efficiency of report generation. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] Figure 1It is a flow chart of a preferred embodiment of a report generation method based on artificial intelligence involved in this application.
[0058] Figure 2 It is a functional module diagram of a preferred embodiment of the report generation device based on artificial intelligence involved in this application.
[0059] Figure 3 It is a structural schematic diagram of an electronic device of a preferred embodiment of the report generation method based on artificial intelligence involved in the present application.
[0060] Figure 4 It is a schematic diagram of some keywords of the report program involved in this application and their corresponding meanings. DETAILED DESCRIPTION
[0061] In order to more clearly understand the purpose, features and advantages of the present application, the present application is described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be noted that, in the absence of conflict, the embodiments of the present application and the features in the embodiments can be combined with each other. In the following description, many specific details are set forth to facilitate a full understanding of the present application, and the embodiments described are only a part of the embodiments of the present application, rather than all of the embodiments.
[0062] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of this application, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0063] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those generally understood by those skilled in the art to which the present application belongs. The terms used herein in the specification of the present application are only for the purpose of describing specific embodiments and are not intended to limit the present application. The term "and / or" used herein includes any and all combinations of one or more of the related listed items.
[0064] The embodiment of the present application provides a report generation method based on artificial intelligence, which can be applied to one or more electronic devices. The electronic device is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to a microprocessor, an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), a programmable gate array (Field-Programmable Gate Array, FPGA), a digital processor (Digital Signal Processor, DSP), an embedded device, etc.
[0065] The electronic device can be any electronic product that can perform human-computer interaction with a user, such as a personal computer, a tablet computer, a smart phone, a personal digital assistant (PDA), a game console, an interactive network television (IPTV), a smart wearable device, etc.
[0066] The electronic device may also include a network device and / or a user device, wherein the network device includes, but is not limited to, a single network server, a server group consisting of multiple network servers, or a cloud consisting of a large number of hosts or network servers based on cloud computing.
[0067] The network where the electronic device is located includes but is not limited to the Internet, a wide area network, a metropolitan area network, a local area network, a virtual private network (Virtual Private Network, VPN), etc.
[0068] like Figure 1 , which is a flow chart of a preferred embodiment of the report generation method based on artificial intelligence of the present application. According to different requirements, the order of the steps in the flow chart can be changed, and some steps can be omitted.
[0069] S10, collecting keywords and special characters of the report program from the database, and taking all the keywords and special characters as a keyword set and a special character set respectively.
[0070] In this optional embodiment, the report is a form that reports business information to a third party. Generally speaking, a report is a form that dynamically displays data in the form of tables, charts, etc., which can be expressed by the formula: "Report = various formats + dynamic data".
[0071] In this optional embodiment, the report program refers to a computer language that can be written and used to generate reports. Exemplarily, the report program in this solution can be an SQL program. The full name of SQL is Structured Query Language, which means structured query language. Its function is to access data and query, update and manage relational database systems.
[0072] In this optional embodiment, the keyword of the report program may be a keyword in the SQL language, where the keyword in the SQL language refers to a default string of SQL language that has different meanings and can implement different functions.
[0073] In this optional embodiment, the database is a data set designed, stored and managed according to a data structure. For example, the database in this solution may be a MySql database. Since the MySql database is an open source database, all keywords of the SQL language may be crawled by a preset web crawler and stored as a keyword set, and each keyword may be marked as "static". For example, the keywords of the SQL language include "create", "add", "drop", "alter" and "select", etc. Figure 4 The following is a diagram showing some keywords of the report program and their corresponding meanings.
[0074] In this optional embodiment, special characters may be enumerated to be stored as a special character set, where the special characters refer to characters that do not belong to the default syntax of the SQL language. Exemplarily, the special characters may be “@”, “#”, “$”, and the like.
[0075] In this optional embodiment, each special character in the special character set can be selected in turn, and the special character can be compared with each keyword in the keyword set according to a preset program. The preset program can be a Python code. Assuming that the selected special character is @, the Python program can be in the form of "print('@'intable_key)", and its function is to output the judgment result of whether @ is in the keyword set. The judgment result includes "YES" and "NO". If the judgment result is "YES", the character is deleted from the special character set and the judgment of the next special character is started. If the judgment result is "NO", no operation is performed and the judgment of the next special character is continued.
[0076] In this optional embodiment, each special character in the set of special characters may be marked as "dynamic".
[0077] In this way, the keywords in the program language required for the report production process are crawled by a web crawler, and each keyword is marked to obtain a keyword set. The elements in the keyword set include the information that cannot be changed in the program language; a special character set is constructed by enumerating special characters, and each special character is compared with the keyword set to update the special character set, which can provide data support for the construction of subsequent template programs and improve the efficiency of report production.
[0078] S11, generating a statistical report of all historical programs in the project, and classifying the historical programs according to semantic information of the historical programs to obtain a plurality of program sets.
[0079] In this optional embodiment, developers can count all historical programs in the report project. The report project refers to the operations such as "add", "delete", "modify", and "check" performed on the report by the developer by writing a programming language. The historical program refers to the programming language written by the developer in the process of completing the report project.
[0080] In this optional embodiment, each historical program may be marked according to the semantic information of the first character of each historical program, and the marks include "add", "delete", "change" and "check".
[0081] Exemplarily, when the first character of a historical program is "create" or "add", the historical program can be marked as "increase"; when the first character of a historical program is "delete", "drop" or "truncate", the historical program can be marked as "delete"; when the first character of a historical program is "alter", the historical program can be marked as "change"; when the first character of a historical program is "select", the historical program can be marked as "check".
[0082] In this optional embodiment, historical programs with the same label can be stored as the same program set, and the label can be used as the label of the program set. Exemplarily, there are four program sets in this scheme, and the labels of the program sets are "add", "delete", "modify" and "check", and each element in the program set is a historical program.
[0083] In this way, by counting all historical programs in the report project and classifying all historical programs, we obtained program sets of multiple categories, and added labels to each semantic set based on the semantic information of each program set, which can provide data support for the subsequent construction of template programs, thereby improving the efficiency of report making.
[0084] S12, matching the special character set with characters in the historical program to obtain key-value pairs, and constructing a dynamic character hash table based on the key-value pairs.
[0085] In an optional embodiment, matching the special character set with characters in the historical program to obtain key-value pairs, and constructing a dynamic character hash table based on the key-value pairs includes:
[0086] Filtering dynamic characters in the historical program, wherein the dynamic characters refer to characters that change with business needs;
[0087] Classifying the dynamic characters according to semantic information of a preceding character of each dynamic character to obtain a plurality of dynamic character sets, wherein the preceding character refers to a character preceding the dynamic character;
[0088] The special character set is matched with the multiple dynamic character sets to obtain key-value pairs, and a dynamic character hash table is constructed according to all the key-value pairs, wherein the key of the key-value pair is the special character in the special character set, and the value is the dynamic character set.
[0089] In this optional embodiment, each character in all historical programs can be judged according to a preset program to obtain a judgment result. The preset program can be a Python script, and its form can be "print(key1intable1)", where key1 represents a certain character in the historical program, table1 represents the keyword set, and the judgment result includes "YES" and "NO". When the judgment result for a certain character is "YES", no operation is performed on the character, and when the judgment result for a certain character is "NO", the character is marked as "dynamic".
[0090] In this optional embodiment, each "dynamic" character marked as "dynamic" can be classified according to its preceding character. For example, when the preceding character of a character marked as "dynamic" is "select", the character marked as "dynamic" belongs to both the "field" class and the "table" class; when the preceding character of a character marked as "dynamic" is "create", the character marked as "dynamic" belongs to the "table" class; when the preceding character of a character marked as "dynamic" is "where", the character marked as "dynamic" belongs to the "condition" class.
[0091] In this optional embodiment, characters marked as "dynamic" and belonging to the same category can be stored as a dynamic character set. In this scheme, multiple dynamic character sets can be obtained, each dynamic character set contains multiple characters marked as "dynamic", and the semantic information of the characters in each dynamic character set is the same.
[0092] In this optional embodiment, the special characters in the special character set and the dynamic character set can be enumerated simultaneously in any order, and a special character enumerated at the same time can be matched with a dynamic character set to construct a dynamic character hash table. Since the special character is any character that does not belong to a keyword, and the number of the dynamic character sets depends on the number of dynamic attribute categories in the report program language, the number of the special characters is greater than the number of the dynamic character sets. Exemplarily, if the dynamic character set includes a "table" set, a "field" set, and a "condition" set, if the special character currently enumerated is @, the special character @ can be matched with the "table" set, and the special character @ is used as a key and the "table" set is used as a value to construct a key-value pair; if the special character enumerated next is #, the special character # can be matched with the "field" set, and the special character # can be used as a key and the "field" set is used as a value to construct a key-value pair.
[0093] In this optional embodiment, all key-value pairs may be jointly stored to construct a dynamic character hash table, wherein the dynamic character hash table includes multiple key-value pairs, wherein each key represents a special character, and each value represents a set of characters marked as "dynamic".
[0094] In this way, the judgment result is obtained by judging each character in the historical program, and each character is further marked according to the judgment result. The semantic category of each marked character is determined by the semantic information of the preceding character of the character marked as "dynamic", and the characters belonging to the same semantic category are stored as dynamic character sets respectively, which provides data support for the production of subsequent template programs, thereby improving the efficiency of report production.
[0095] S13, encoding each historical program to obtain an encoding vector corresponding to each historical program.
[0096] In an optional embodiment, encoding each historical program to obtain an encoding vector corresponding to each historical program includes:
[0097] Traversing each historical program according to the character arrangement order in the historical program;
[0098] Input each traversed character into a preset discrimination program to obtain a discrimination result;
[0099] Determine the encoding value corresponding to each character according to the discrimination result of the character;
[0100] The encoding values are combined according to the arrangement order of the characters in the historical program to generate an encoding vector.
[0101] In this optional embodiment, each element of each program in each program set can be encoded separately. The encoding method is to traverse each character in the historical program according to the character arrangement order in the historical program, classify and mark the character according to a preset program, and further assign a coding value to each character according to the mark of each character.
[0102] Exemplarily, the preset program may be a Python script, and its form may be "print('character' in table_k)", where 'character' represents a character obtained by traversing the history program, and table_k represents the keyword set. The preset program output results include "YES" and "NO". If the output result is "YES", the classification result of the traversed character is "static", and if the output result is "NO", the classification result of the traversed character is "dynamic".
[0103] Exemplarily, if a historical program is in the form of "selecttable1fromdatabase1", then "select", "table1", "from" and "database1" are input into the preset Python program to obtain classification results, and the classification results of "select" and "from" are "static", and the classification results of "table1" and "database1" are "dynamic".
[0104] In this optional embodiment, the encoding value of the character with a classification result of "static" can be set to 1, and the encoding value of the character with a classification result of "dynamic" can be set to 0. The encoding values can be combined according to the arrangement order of the characters in the historical program to obtain the encoding vector of each historical program. The encoding vector is a binary vector and only contains two encoding values 0 and 1.
[0105] Exemplarily, if a historical program is in the form of "selecttable1fromdatabase1", and the classification results of "select" and "from" are "static", and the classification results of "table1" and "database1" are "dynamic", then the encoding values of "select" and "from" are set to 1, and the encoding values of "table1" and "database1" are set to 0. The encoding values can be further combined according to the arrangement order of the characters in the historical program to obtain the encoding vector corresponding to the historical program, and the encoding vector corresponding to the historical program is [1,0,1,0].
[0106] In an optional embodiment, after encoding each historical program to obtain an encoding vector corresponding to each historical program, the method further includes:
[0107] Count the maximum value of the dimension of the encoding vector corresponding to all historical programs in each program set;
[0108] For a code vector whose dimension is less than the maximum value, the code vector is padded with a value of 2 at the end of the code vector to ensure that the dimension of the code vector is equal to the maximum value.
[0109] In this optional embodiment, in order to make the dimensions of the encoding vectors corresponding to all historical programs consistent, the dimensions of all encoding vectors can be counted and the maximum dimension thereof is recorded as dimension max If the dimension of a coding vector is smaller than the maximum dimension, multiple values of 2 are added to the end of the coding vector to ensure that the dimension of the coding vector is equal to the maximum dimension.
[0110] For example, if the maximum dimension max =7, and a certain encoding vector is [1,0,1,0], then three values 2 can be added to the end of the encoding vector to ensure that the dimension of the encoding vector is 7. After dimension completion, the encoding vector is in the form of [1,0,1,0,2,2,2].
[0111] In this way, each character in the historical program is judged by running the preset program, and a coding value is assigned to each character based on the judgment result, so as to obtain the coding vector corresponding to each historical program. Representing all historical programs in a fully quantitative form can provide data support for subsequent historical program clustering, thereby improving the efficiency of report production.
[0112] S14, clustering the encoding vectors corresponding to all programs in each program set to obtain multiple program clusters.
[0113] In an optional embodiment, clustering the encoding vectors corresponding to all programs in each program set to obtain multiple program clusters includes:
[0114] a. Calculate the cosine similarity between the encoding vector corresponding to each historical program in the program set and each of the remaining encoding vectors;
[0115] b, randomly select an encoding vector from the program set as vector X;
[0116] c. randomly selecting another encoding vector from the program set as Y. If the vectors X and Y meet a first preset condition, then the vectors X and Y are defined to belong to the same program cluster; otherwise, the vectors X and Y belong to different program clusters respectively.
[0117] d. Randomly select a coding vector that does not belong to any program cluster from the program set and record it as Z. If the coding vector Z meets the second preset condition, then classify the vector Z as an existing cluster; otherwise, treat Z as a separate cluster;
[0118] e. Repeat step d above until all encoding vectors in the program set belong to a cluster.
[0119] In this optional embodiment, the encoding vectors in each program set may be clustered according to a custom clustering algorithm to obtain multiple program clusters in each program set. Taking the program set marked as "increase" as an example, the specific implementation steps of the custom clustering algorithm are:
[0120] A1: Calculate the cosine similarity between each encoding vector in the program set marked as "increase" and each other encoding vector, and the cosine similarity is calculated as follows:
[0121]
[0122] Among them, A represents a certain coding vector; B represents another coding vector; S represents the cosine similarity between coding vector A and coding vector B. The larger the value of S is, the higher the similarity between coding vector A and coding vector B, and the higher the similarity between the historical program represented by coding vector A and the historical program represented by coding vector B; n represents the maximum dimension of the coding vector in the program set whose function is "increase", and i represents the index of the coding vector dimension.
[0123] Exemplarily, when the encoding vector A is [1, 0, 1, 2] and the encoding vector B is [1, 0, 1, 0], the cosine similarity is calculated as follows:
[0124]
[0125] The cosine similarity between encoding vector A and encoding vector B is 0.57. Since the cosine similarity between encoding vector A and encoding vector B is not 1, it means that encoding vector A and encoding vector B are not exactly the same, so the historical programs corresponding to encoding vector A and encoding vector B are not exactly the same.
[0126] A2: Randomly select a coding vector from the set of programs marked as "increase" and record it as X;
[0127] A3: randomly select another encoding vector and record it as Y. If the X vector and the Y vector meet the first preset condition, then define the X vector and the Y vector as belonging to the same program cluster. Otherwise, define the X vector as a program cluster and the Y vector as another program cluster. The first preset condition means that the cosine similarity of the X vector and the Y vector is 1.
[0128] A4: Randomly select a coding vector that does not belong to any cluster and record it as Z. The second preset condition is that if the cosine similarity between the Z vector and any vector in each existing program cluster is 1, then the Z vector is added to the program cluster corresponding to the vector, otherwise the Z vector is defined as a new program cluster;
[0129] A5: Repeat the above step A4 until all the encoding vectors in the program set marked as "increase" belong to a certain cluster, and finally multiple program clusters can be obtained.
[0130] In this optional embodiment, the coding vectors contained in each cluster are completely identical, so the corresponding programs represented by the coding vectors in each cluster are also completely identical in the combination of static information and dynamic information.
[0131] In an optional embodiment, after clustering the encoding vectors in each program set to obtain a plurality of program clusters, the method further includes:
[0132] The number of coding vectors in each program cluster is counted, and the number of coding vectors in each program cluster is used as the priority of the corresponding program cluster. The more the number of coding vectors in the program cluster is, the higher the priority of the program cluster is.
[0133] In this optional embodiment, for each program set, the number of encoding vectors contained in each program cluster can be counted as the priority of each program cluster, and the program clusters in each program set can be further sorted according to the priority, and the program cluster with a higher priority is ranked higher.
[0134] For example, if the program set marked as "increase" contains 4 program clusters after clustering, namely Cl1, Cl2, Cl3 and Cl4, and the number of coding vectors in Cl1 is 7, the priority of the program cluster represented by Cl1 is 7; the number of coding vectors in Cl2 is 8, the priority of the program cluster represented by Cl2 is 8; the number of coding vectors in Cl3 is 5, the priority of the program cluster represented by Cl3 is 5; the number of coding vectors in Cl4 is 9, the priority of the program cluster represented by Cl4 is 9. If the 4 program clusters are sorted according to the priority of each program cluster, the sorting result may be Cl4, Cl2, Cl1, Cl3.
[0135] In this way, the coding vectors corresponding to all programs in each program set are clustered through a custom clustering algorithm to obtain multiple program clusters. The coding vectors in each program cluster are exactly the same, which can provide data support for the subsequent template statement production and improve the efficiency of report generation.
[0136] S15, creating a template program corresponding to each program cluster according to the keyword set and the dynamic character hash table, each program cluster including at least one template program.
[0137] In this optional embodiment, the template program includes keywords and special characters. The template program refers to program code that complies with SQL syntax but cannot be successfully run due to the presence of special characters. Its function is to provide developers or customers with template programs required for report production, and to limit the operation of the template program through special characters to improve data security during the report production process.
[0138] In this optional embodiment, since the program encoding within each program cluster is exactly the same, the combination of static characters and dynamic characters for the programs within the program cluster is also the same. Therefore, a coding vector can be randomly selected from the cluster and the keyword corresponding to the label of the program set to which the cluster belongs is used as the first character of the template program.
[0139] For example, if the format of the encoding vector in a program cluster is [1,0,1,0], and the program cluster belongs to a program set labeled "search", then the keyword corresponding to the label of the program cluster can be used as the first character of the encoding vector in the program cluster, and the first character of all template programs in the program cluster can be "select".
[0140] In this optional embodiment, after determining the first character of all template programs in each program cluster, the characters of each subsequent bit can be determined in turn according to the semantic information of the first character in the template program and the encoding value of each subsequent character bit and the SQL syntax. For example, if the first character of a template program is "select" and the encoding value of its post-position character bit is 0, then the post-position character bit is a dynamic character, then it can be determined according to the SQL syntax that the semantic information of the post-position character bit should be "table" or "field" in the dynamic character, so the "table" set and the "field" set can be used as values and the keys corresponding to the "table" set and the "field" set can be searched in the dynamic character hash table, that is, the special characters corresponding to the "table" set and the "field" set. For example, the special character corresponding to the "table" set can be @; if the encoding value of the post-position of the dynamic character is 1, then the post-position is a static character, that is, a keyword, then optional keywords can be added according to the semantic information and SQL syntax, such as and, where, orderby, etc.
[0141] In this optional embodiment, each program cluster includes at least one template program, and the number of the template programs is equal to the product of the number of values of each character in the template program.
[0142] In this optional embodiment, the priority of each program cluster can be used as the priority of each corresponding template program. Each program set can constitute multiple template programs, and the semantic information of the template programs in each program set is the same.
[0143] In this way, the first character of all template programs in each program set is determined by labeling each program set, and the character category that may appear in each post-position character is determined based on the semantic information of the first character and the encoding value of each post-position character, and a complete template program is constructed, thereby providing a program basis for subsequent report production, thereby improving the efficiency of report generation.
[0144] S16, analyzing the semantic information of the business requirements to be evaluated and calling the existing template program according to the analysis results to generate report production results.
[0145] In an optional embodiment, analyzing the semantic information of the business requirement to be evaluated and calling an existing template program according to the analysis result to generate a report production result includes:
[0146] Selecting a program set according to the semantic information of the business requirement to be evaluated, and taking a template program in the program set as a first candidate program;
[0147] Screening the dynamic attributes in the business requirement to be evaluated, and inserting the value of the dynamic attribute into the first candidate program to obtain a second candidate program;
[0148] The second candidate program is run to obtain program output results, and the business requirements to be evaluated are compared with the program output results to select a report that meets the requirements.
[0149] In this optional embodiment, developers can classify and mark the business needs to be evaluated based on the semantic information of the business needs to be evaluated. The business needs to be evaluated refer to the needs to perform operations such as "add", "delete", "modify", and "check" on the report. For example, when the business need to be evaluated is "create a data table named 'Table 1'", the semantic information of the business need is "create table", so the developer can classify the need as "add".
[0150] In this optional embodiment, the program set can be matched to the business requirement to be evaluated based on the category of the business requirement to be evaluated. For example, when the category of the business requirement to be evaluated is "increase", the template program in the program set marked as "increase" can be selected as the first candidate program, and the first candidate program consists of keywords and special characters to characterize the structure of the program.
[0151] In this optional embodiment, each character in the business requirement to be evaluated can be judged according to a preset program. The preset program can be a Python script, which can be in the form of "print(wordintable1)", wherein word represents a character in the business requirement to be evaluated, table1 represents the keyword set, and the results output by the preset Python script include "YES" and "NO". If the output result is "YES", the next character is judged; if the output result is "NO", it indicates that the character is a dynamic attribute in the business requirement to be evaluated, then the character can be used as a value and matched with each value in the dynamic hash table. If the character exists in a certain value set, the key corresponding to the value set, that is, the corresponding special character, is used as a calibration special character, and the special character is searched as the target character in the template program of the program set according to the priority of the template program. After finding the template program where the special character is located, the target character in the template program can be replaced with the dynamic attribute in the requirement to be evaluated to form a second candidate program.
[0152] In this optional embodiment, until all characters in the requirement to be evaluated are identified and the special characters corresponding to the characters are found, at least one second candidate program corresponding to the requirement to be evaluated can be obtained.
[0153] In this optional embodiment, the candidate programs can be run according to their priorities, candidate programs with error results can be deleted, successful candidate programs can be used as calibrated candidate programs, and the output results of the calibrated candidate programs can be stored as candidate reports.
[0154] In this optional embodiment, the developer may view the dimensions and field names of the candidate reports and other contents to select a candidate report that meets the business requirements to be evaluated from multiple candidate reports as a calibration report.
[0155] In this optional embodiment, the candidate program that generates the calibration report can be taken as a new historical program and added to the historical program set, with the purpose of increasing the capacity of the historical program set and improving its fault tolerance.
[0156] The above-mentioned artificial intelligence-based report generation method obtains a keyword set and a special character set by collecting keywords and special characters of the report program from the database, and obtains multiple program sets by counting the historical programs in the report generation project, and then constructs a dynamic character hash table based on the special character set and the characters in the historical program, and encodes each historical program to cluster all historical programs to obtain multiple program clusters, and further produces a template program corresponding to each program cluster based on the keyword set and the dynamic character hash table, and can call the template program to generate reports based on business needs. The above-mentioned method ensures the reuse rate of the program, thereby improving the efficiency of report generation.
[0157] like Figure 2 , which is a functional module diagram of a preferred embodiment of the report generation device based on artificial intelligence provided by the embodiment of the present application. The report generation device based on artificial intelligence 11 includes a collection unit 110, a classification unit 111, a construction unit 112, an encoding unit 113, a clustering unit 114, a production unit 115, and a generation unit 116. The module / unit referred to in the present application refers to a series of computer program segments that can be executed by the processor 13 and can complete fixed functions, which are stored in the memory 12. In this embodiment, the functions of each module / unit will be described in detail in subsequent embodiments.
[0158] In an optional embodiment, the collection unit 110 is used to collect keywords and special characters of the report program from the database, and take all the keywords and special characters as a keyword set and a special character set respectively.
[0159] In this optional embodiment, the report is a form that reports business information to a third party. Generally speaking, a report is a form that dynamically displays data in the form of tables, charts, etc., which can be expressed by the formula: "Report = various formats + dynamic data".
[0160] In this optional embodiment, the report program refers to a computer language that can be written and used to generate reports. Exemplarily, the report program in this solution can be an SQL program. The full name of SQL is Structured Query Language, which means structured query language. Its function is to access data and query, update and manage relational database systems.
[0161] In this optional embodiment, the keyword of the report program may be a keyword in the SQL language, where the keyword in the SQL language refers to a default string of SQL language that has different meanings and can implement different functions.
[0162] In this optional embodiment, the database is a data set designed, stored and managed according to a data structure. For example, the database in this solution may be a MySql database. Since the MySql database is an open source database, all keywords of the SQL language may be crawled by a preset web crawler and stored as a keyword set, and each keyword may be marked as "static". For example, the keywords of the SQL language include "create", "add", "drop", "alter" and "select", etc. Figure 4 The following is a diagram showing some keywords of the report program and their corresponding meanings.
[0163] In this optional embodiment, special characters may be enumerated to be stored as a special character set, where the special characters refer to characters that do not belong to the default syntax of the SQL language. Exemplarily, the special characters may be “@”, “#”, “$”, and the like.
[0164] In this optional embodiment, each special character in the special character set can be selected in turn, and the special character can be compared with each keyword in the keyword set according to a preset program. The preset program can be a Python code. Assuming that the selected special character is @, the Python program can be in the form of "print('@'intable_key)", and its function is to output the judgment result of whether @ is in the keyword set. The judgment result includes "YES" and "NO". If the judgment result is "YES", the character is deleted from the special character set and the judgment of the next special character is started. If the judgment result is "NO", no operation is performed and the judgment of the next special character is continued.
[0165] In this optional embodiment, each special character in the set of special characters may be marked as "dynamic".
[0166] In an optional embodiment, the classification unit 111 is used to collect statistics on all historical programs in the report generation project, and classify the historical programs according to semantic information of the historical programs to obtain multiple program sets.
[0167] In this optional embodiment, developers can count all historical programs in the report project. The report project refers to the operations such as "add", "delete", "modify", and "check" performed on the report by the developer by writing a programming language. The historical program refers to the programming language written by the developer in the process of completing the report project.
[0168] In this optional embodiment, each historical program may be marked according to the semantic information of the first character of each historical program, and the marks include "add", "delete", "change" and "check".
[0169] Exemplarily, when the first character of a historical program is "create" or "add", the historical program can be marked as "increase"; when the first character of a historical program is "delete", "drop" or "truncate", the historical program can be marked as "delete"; when the first character of a historical program is "alter", the historical program can be marked as "change"; when the first character of a historical program is "select", the historical program can be marked as "check".
[0170] In this optional embodiment, historical programs with the same label can be stored as the same program set, and the label can be used as the label of the program set. Exemplarily, there are four program sets in this scheme, and the labels of the program sets are "add", "delete", "modify" and "check", and each element in the program set is a historical program.
[0171] In an optional embodiment, the construction unit 112 is used to match the special character set with characters in the historical program to obtain key-value pairs, and construct a dynamic character hash table based on the key-value pairs.
[0172] In an optional embodiment, matching the special character set with characters in the historical program to obtain key-value pairs, and constructing a dynamic character hash table based on the key-value pairs includes:
[0173] Filtering dynamic characters in the historical program, wherein the dynamic characters refer to characters that change with business needs;
[0174] Classifying the dynamic characters according to semantic information of a preceding character of each dynamic character to obtain a plurality of dynamic character sets, wherein the preceding character refers to a character preceding the dynamic character;
[0175] The special character set is matched with the multiple dynamic character sets to obtain key-value pairs, and a dynamic character hash table is constructed according to all the key-value pairs, wherein the key of the key-value pair is the special character in the special character set, and the value is the dynamic character set.
[0176] In this optional embodiment, each character in all historical programs can be judged according to a preset program to obtain a judgment result. The preset program can be a Python script, and its form can be "print(key1intable1)", where key1 represents a certain character in the historical program, table1 represents the keyword set, and the judgment result includes "YES" and "NO". When the judgment result for a certain character is "YES", no operation is performed on the character, and when the judgment result for a certain character is "NO", the character is marked as "dynamic".
[0177] In this optional embodiment, each "dynamic" character marked as "dynamic" can be classified according to its preceding character. For example, when the preceding character of a character marked as "dynamic" is "select", the character marked as "dynamic" belongs to both the "field" class and the "table" class; when the preceding character of a character marked as "dynamic" is "create", the character marked as "dynamic" belongs to the "table" class; when the preceding character of a character marked as "dynamic" is "where", the character marked as "dynamic" belongs to the "condition" class.
[0178] In this optional embodiment, characters marked as "dynamic" and belonging to the same category can be stored as a dynamic character set. In this scheme, multiple dynamic character sets can be obtained, each dynamic character set contains multiple characters marked as "dynamic", and the semantic information of the characters in each dynamic character set is the same.
[0179] In this optional embodiment, the special characters in the special character set and the dynamic character set can be enumerated simultaneously in any order, and a special character enumerated at the same time can be matched with a dynamic character set to construct a dynamic character hash table. Since the special character is any character that does not belong to a keyword, and the number of the dynamic character sets depends on the number of dynamic attribute categories in the report program language, the number of the special characters is greater than the number of the dynamic character sets. Exemplarily, if the dynamic character set includes a "table" set, a "field" set, and a "condition" set, if the special character currently enumerated is @, the special character @ can be matched with the "table" set, and the special character @ is used as a key and the "table" set is used as a value to construct a key-value pair; if the special character enumerated next is #, the special character # can be matched with the "field" set, and the special character # can be used as a key and the "field" set is used as a value to construct a key-value pair.
[0180] In this optional embodiment, all key-value pairs may be jointly stored to construct a dynamic character hash table, wherein the dynamic character hash table includes multiple key-value pairs, wherein each key represents a special character, and each value represents a set of characters marked as "dynamic".
[0181] In an optional embodiment, the encoding unit 113 is used to encode each historical program to obtain an encoding vector corresponding to each historical program.
[0182] In an optional embodiment, encoding each historical program to obtain an encoding vector corresponding to each historical program includes:
[0183] Traversing each historical program according to the character arrangement order in the historical program;
[0184] Input each traversed character into a preset discrimination program to obtain a discrimination result;
[0185] Determine the encoding value corresponding to each character according to the discrimination result of the character;
[0186] The encoding values are combined according to the arrangement order of the characters in the historical program to generate an encoding vector.
[0187] In this optional embodiment, each element of each program in each program set can be encoded separately. The encoding method is to traverse each character in the historical program according to the character arrangement order in the historical program, classify and mark the character according to a preset program, and further assign a coding value to each character according to the mark of each character.
[0188] Exemplarily, the preset program may be a Python script, and its form may be "print('character' in table_k)", where 'character' represents a character obtained by traversing the history program, and table_k represents the keyword set. The preset program output results include "YES" and "NO". If the output result is "YES", the classification result of the traversed character is "static", and if the output result is "NO", the classification result of the traversed character is "dynamic".
[0189] Exemplarily, if a historical program is in the form of "selecttable1fromdatabase1", then "select", "table1", "from" and "database1" are input into the preset Python program to obtain classification results, and the classification results of "select" and "from" are "static", and the classification results of "table1" and "database1" are "dynamic".
[0190] In this optional embodiment, the encoding value of the character with a classification result of "static" can be set to 1, and the encoding value of the character with a classification result of "dynamic" can be set to 0. The encoding values can be combined according to the arrangement order of the characters in the historical program to obtain the encoding vector of each historical program. The encoding vector is a binary vector and only contains two encoding values 0 and 1.
[0191] Exemplarily, if a historical program is in the form of "selecttable1fromdatabase1", and the classification results of "select" and "from" are "static", and the classification results of "table1" and "database1" are "dynamic", then the encoding values of "select" and "from" are set to 1, and the encoding values of "table1" and "database1" are set to 0. The encoding values can be further combined according to the arrangement order of the characters in the historical program to obtain the encoding vector corresponding to the historical program, and the encoding vector corresponding to the historical program is [1,0,1,0].
[0192] In an optional embodiment, after encoding each historical program to obtain an encoding vector corresponding to each historical program, the method further includes:
[0193] Count the maximum value of the dimension of the encoding vector corresponding to all historical programs in each program set;
[0194] For a code vector whose dimension is less than the maximum value, the code vector is padded with a value of 2 at the end of the code vector to ensure that the dimension of the code vector is equal to the maximum value.
[0195] In this optional embodiment, in order to make the dimensions of the encoding vectors corresponding to all historical programs consistent, the dimensions of all encoding vectors can be counted and the maximum dimension thereof is recorded as dimension max If the dimension of a coding vector is smaller than the maximum dimension, multiple values of 2 are added to the end of the coding vector to ensure that the dimension of the coding vector is equal to the maximum dimension.
[0196] For example, if the maximum dimension max =7, and a certain encoding vector is [1,0,1,0], then three values 2 can be added to the end of the encoding vector to ensure that the dimension of the encoding vector is 7. After dimension completion, the encoding vector is in the form of [1,0,1,0,2,2,2].
[0197] In an optional embodiment, the clustering unit 114 is configured to cluster the encoding vectors in each program set respectively to obtain a plurality of program clusters.
[0198] In an optional embodiment, clustering the encoding vectors corresponding to all programs in each program set to obtain multiple program clusters includes:
[0199] a. Calculate the cosine similarity between the encoding vector corresponding to each historical program in the program set and each of the remaining encoding vectors;
[0200] b, randomly select an encoding vector from the program set as vector X;
[0201] c. randomly selecting another encoding vector from the program set as Y. If the vectors X and Y meet a first preset condition, then the vectors X and Y are defined to belong to the same program cluster; otherwise, the vectors X and Y belong to different program clusters respectively.
[0202] d. Randomly select a coding vector that does not belong to any program cluster from the program set and record it as Z. If the coding vector Z meets the second preset condition, then classify the vector Z as an existing cluster; otherwise, treat Z as a separate cluster;
[0203] e. Repeat step d above until all encoding vectors in the program set belong to a cluster.
[0204] In this optional embodiment, the encoding vectors in each program set may be clustered according to a custom clustering algorithm to obtain multiple program clusters in each program set. Taking the program set marked as "increase" as an example, the specific implementation steps of the custom clustering algorithm are:
[0205] A1: Calculate the cosine similarity between each encoding vector in the program set marked as "increase" and each other encoding vector, and the cosine similarity is calculated as follows:
[0206]
[0207] Among them, A represents a certain coding vector; B represents another coding vector; S represents the cosine similarity between coding vector A and coding vector B. The larger the value of S is, the higher the similarity between coding vector A and coding vector B, and the higher the similarity between the historical program represented by coding vector A and the historical program represented by coding vector B; n represents the maximum dimension of the coding vector in the program set whose function is "increase", and i represents the index of the coding vector dimension.
[0208] Exemplarily, when the encoding vector A is [1, 0, 1, 2] and the encoding vector B is [1, 0, 1, 0], the cosine similarity is calculated as follows:
[0209]
[0210] The cosine similarity between encoding vector A and encoding vector B is 0.57. Since the cosine similarity between encoding vector A and encoding vector B is not 1, it means that encoding vector A and encoding vector B are not exactly the same, so the historical programs corresponding to encoding vector A and encoding vector B are not exactly the same.
[0211] A2: Randomly select a coding vector from the set of programs marked as "increase" and record it as X;
[0212] A3: randomly select another encoding vector and record it as Y. If the X vector and the Y vector meet the first preset condition, then define the X vector and the Y vector as belonging to the same program cluster. Otherwise, define the X vector as a program cluster and the Y vector as another program cluster. The first preset condition means that the cosine similarity of the X vector and the Y vector is 1.
[0213] A4: Randomly select a coding vector that does not belong to any cluster and record it as Z. The second preset condition is that if the cosine similarity between the Z vector and any vector in each existing program cluster is 1, then the Z vector is added to the program cluster corresponding to the vector, otherwise the Z vector is defined as a new program cluster;
[0214] A5: Repeat the above step A4 until all the encoding vectors in the program set marked as "increase" belong to a certain cluster, and finally multiple program clusters can be obtained.
[0215] In this optional embodiment, the coding vectors contained in each cluster are completely identical, so the corresponding programs represented by the coding vectors in each cluster are also completely identical in the combination of static information and dynamic information.
[0216] In an optional embodiment, after clustering the encoding vectors in each program set to obtain a plurality of program clusters, the method further includes:
[0217] The number of coding vectors in each program cluster is counted, and the number of coding vectors in each program cluster is used as the priority of the corresponding program cluster. The more the number of coding vectors in the program cluster is, the higher the priority of the program cluster is.
[0218] In this optional embodiment, for each program set, the number of encoding vectors contained in each program cluster can be counted as the priority of each program cluster, and the program clusters in each program set can be further sorted according to the priority, and the program cluster with a higher priority is ranked higher.
[0219] For example, if the program set marked as "increase" contains 4 program clusters after clustering, namely Cl1, Cl2, Cl3 and Cl4, and the number of coding vectors in Cl1 is 7, the priority of the program cluster represented by Cl1 is 7; the number of coding vectors in Cl2 is 8, the priority of the program cluster represented by Cl2 is 8; the number of coding vectors in Cl3 is 5, the priority of the program cluster represented by Cl3 is 5; the number of coding vectors in Cl4 is 9, the priority of the program cluster represented by Cl4 is 9. If the 4 program clusters are sorted according to the priority of each program cluster, the sorting result may be Cl4, Cl2, Cl1, Cl3.
[0220] In an optional embodiment, the making unit 115 is used to make a template program corresponding to each program cluster according to the keyword set and the dynamic character hash table, and each program cluster includes at least one template program.
[0221] In this optional embodiment, the template program includes keywords and special characters. The template program refers to program code that complies with SQL syntax but cannot be successfully run due to the presence of special characters. Its function is to provide developers or customers with template programs required for report production, and to limit the operation of the template program through special characters to improve data security during the report production process.
[0222] In this optional embodiment, since the program encoding within each program cluster is exactly the same, the combination of static characters and dynamic characters for the programs within the program cluster is also the same. Therefore, a coding vector can be randomly selected from the cluster and the keyword corresponding to the label of the program set to which the cluster belongs is used as the first character of the template program.
[0223] For example, if the format of the encoding vector in a program cluster is [1,0,1,0], and the program cluster belongs to a program set labeled "search", then the keyword corresponding to the label of the program cluster can be used as the first character of the encoding vector in the program cluster, and the first character of all template programs in the program cluster can be "select".
[0224] In this optional embodiment, after determining the first character of all template programs in each program cluster, the characters of each subsequent bit can be determined in turn according to the semantic information of the first character in the template program and the encoding value of each subsequent character bit and the SQL syntax. For example, if the first character of a template program is "select" and the encoding value of its post-position character bit is 0, then the post-position character bit is a dynamic character, then it can be determined according to the SQL syntax that the semantic information of the post-position character bit should be "table" or "field" in the dynamic character, so the "table" set and the "field" set can be used as values and the keys corresponding to the "table" set and the "field" set can be searched in the dynamic character hash table, that is, the special characters corresponding to the "table" set and the "field" set. For example, the special character corresponding to the "table" set can be @; if the encoding value of the post-position of the dynamic character is 1, then the post-position is a static character, that is, a keyword, then optional keywords can be added according to the semantic information and SQL syntax, such as and, where, orderby, etc.
[0225] In this optional embodiment, each program cluster includes at least one template program, and the number of the template programs is equal to the product of the number of values of each character in the template program.
[0226] In this optional embodiment, the priority of each program cluster can be used as the priority of each corresponding template program. Each program set can constitute multiple template programs, and the semantic information of the template programs in each program set is the same.
[0227] In an optional embodiment, the generating unit 116 is used to analyze the semantic information of the business requirement to be evaluated and call an existing template program according to the analysis result to generate a report making result.
[0228] In an optional embodiment, analyzing the semantic information of the business requirement to be evaluated and calling an existing template program according to the analysis result to generate a report production result includes:
[0229] Selecting a program set according to the semantic information of the business requirement to be evaluated, and taking a template program in the program set as a first candidate program;
[0230] Screening the dynamic attributes in the business requirement to be evaluated, and inserting the value of the dynamic attribute into the first candidate program to obtain a second candidate program;
[0231] The second candidate program is run to obtain program output results, and the business requirements to be evaluated are compared with the program output results to select a report that meets the requirements.
[0232] In this optional embodiment, developers can classify and mark the business needs to be evaluated based on the semantic information of the business needs to be evaluated. The business needs to be evaluated refer to the needs to perform operations such as "add", "delete", "modify", and "check" on the report. For example, when the business need to be evaluated is "create a data table named 'Table 1'", the semantic information of the business need is "create table", so the developer can classify the need as "add".
[0233] In this optional embodiment, the program set can be matched to the business requirement to be evaluated based on the category of the business requirement to be evaluated. For example, when the category of the business requirement to be evaluated is "increase", the template program in the program set marked as "increase" can be selected as the first candidate program, and the first candidate program consists of keywords and special characters to characterize the structure of the program.
[0234] In this optional embodiment, each character in the business requirement to be evaluated can be judged according to a preset program. The preset program can be a Python script, which can be in the form of "print(wordintable1)", wherein word represents a character in the business requirement to be evaluated, table1 represents the keyword set, and the results output by the preset Python script include "YES" and "NO". If the output result is "YES", the next character is judged; if the output result is "NO", it indicates that the character is a dynamic attribute in the business requirement to be evaluated, then the character can be used as a value and matched with each value in the dynamic hash table. If the character exists in a certain value set, the key corresponding to the value set, that is, the corresponding special character, is used as a calibration special character, and the special character is searched as the target character in the template program of the program set according to the priority of the template program. After finding the template program where the special character is located, the target character in the template program can be replaced with the dynamic attribute in the requirement to be evaluated to form a second candidate program.
[0235] In this optional embodiment, until all characters in the requirement to be evaluated are identified and the special characters corresponding to the characters are found, at least one second candidate program corresponding to the requirement to be evaluated can be obtained.
[0236] In this optional embodiment, the candidate programs can be run according to their priorities, candidate programs with error results can be deleted, successful candidate programs can be used as calibrated candidate programs, and the output results of the calibrated candidate programs can be stored as candidate reports.
[0237] In this optional embodiment, the developer may view the dimensions and field names of the candidate reports and other contents to select a candidate report that meets the business requirements to be evaluated from multiple candidate reports as a calibration report.
[0238] In this optional embodiment, the candidate program that generates the calibration report can be taken as a new historical program and added to the historical program set, with the purpose of increasing the capacity of the historical program set and improving its fault tolerance.
[0239] like Figure 3 , which is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device 1 includes a memory 12 and a processor 13. The memory 12 is used to store computer-readable instructions, and the processor 13 executes the computer-readable instructions stored in the memory to implement the report generation method based on artificial intelligence in any of the above embodiments.
[0240] In an optional embodiment, the electronic device 1 further includes a bus, a computer program stored in the memory 12 and executable on the processor 13, such as an artificial intelligence-based report generation program.
[0241] Figure 3 Only the electronic device 1 having components 12-13 is shown, and those skilled in the art will understand that Figure 3 The structure shown does not constitute a limitation on the electronic device 1 , and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.
[0242] Combination Figure 1 The memory 12 in the electronic device 1 stores a plurality of computer-readable instructions to implement a report generation method based on artificial intelligence, and the processor 13 can execute the plurality of instructions to implement:
[0243] Collect keywords and special characters of the report program from the database, and take all keywords and special characters as keyword sets and special character sets respectively;
[0244] Statistically reporting all historical programs in the project, and classifying the historical programs according to semantic information of the historical programs to obtain a plurality of program sets;
[0245] Matching the special character set with characters in the historical program to obtain key-value pairs, and constructing a dynamic character hash table based on the key-value pairs;
[0246] Encode each historical program to obtain an encoding vector corresponding to each historical program;
[0247] Clustering the encoding vectors in each program set respectively to obtain multiple program clusters;
[0248] Creating a template program corresponding to each program cluster according to the keyword set and the dynamic character hash table, each program cluster including at least one template program;
[0249] Analyze the semantic information of the business needs to be evaluated and call the existing template program based on the analysis results to generate report production results.
[0250] Specifically, the specific implementation method of the processor 13 for the above instructions can refer to Figure 1 The description of the relevant steps in the corresponding embodiments will not be repeated here.
[0251] Those skilled in the art will appreciate that the schematic diagram is merely an example of the electronic device 1 and does not constitute a limitation on the electronic device 1. The electronic device 1 may have either a bus structure or a star structure. The electronic device 1 may also include more or less other hardware or software than shown in the diagram, or a different arrangement of components. For example, the electronic device 1 may also include input and output devices, network access devices, etc.
[0252] It should be noted that the electronic device 1 is only an example, and other existing or future electronic products that are suitable for the present application should also be included in the protection scope of the present application and included here by reference.
[0253] Among them, the memory 12 includes at least one type of readable storage medium, and the readable storage medium can be non-volatile or volatile. The readable storage medium includes flash memory, mobile hard disk, multimedia card, card-type memory (for example: SD or DX memory, etc.), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 12 can be an internal storage unit of the electronic device 1, such as a mobile hard disk of the electronic device 1. In other embodiments, the memory 12 can also be an external storage device of the electronic device 1, such as a plug-in mobile hard disk, a smart memory card (SmartMediaCard, SMC), a secure digital (SecureDigital, SD) card, a flash card (FlashCard), etc. equipped on the electronic device 1. Further, the memory 12 can also include both an internal storage unit of the electronic device 1 and an external storage device. The memory 12 can not only be used to store application software and various types of data installed in the electronic device 1, such as the code of a report generation program based on artificial intelligence, but also can be used to temporarily store data that has been output or is to be output.
[0254] In some embodiments, the processor 13 may be composed of an integrated circuit, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips. The processor 13 is the control core (Control Unit) of the electronic device 1, and uses various interfaces and lines to connect the various components of the entire electronic device 1, and executes or executes programs or modules stored in the memory 12 (for example, executing a report generation program based on artificial intelligence, etc.), and calls data stored in the memory 12 to execute various functions of the electronic device 1 and process data.
[0255] The processor 13 executes the operating system of the electronic device 1 and various installed applications. The processor 13 executes the applications to implement the steps in the above-mentioned embodiments of the report generation method based on artificial intelligence, for example Figure 1 Steps shown.
[0256] Exemplarily, the computer program may be divided into one or more modules / units, which are stored in the memory 12 and executed by the processor 13 to complete the present application. The one or more modules / units may be a series of computer-readable instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program in the electronic device 1. For example, the computer program may be divided into a collection unit 110, a classification unit 111, a construction unit 112, an encoding unit 113, a clustering unit 114, a production unit 115, and a generation unit 116.
[0257] The above-mentioned integrated unit implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a computer device, or a network device, etc.) or a processor to execute a part of the report generation method based on artificial intelligence described in each embodiment of the present application.
[0258] If the module / unit integrated in the electronic device 1 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also instruct the relevant hardware devices to complete through a computer program. The computer program can be stored in a computer-readable storage medium, and when the computer program is executed by the processor, the steps of each of the above-mentioned method embodiments can be implemented.
[0259] The computer program includes computer program code, which may be in source code form, object code form, executable file or some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory and other memory, etc.
[0260] Furthermore, the computer-readable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the blockchain node, etc.
[0261] The blockchain referred to in this application is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.
[0262] The bus can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 Only one arrow is used in the figure, but it does not mean that there is only one bus or one type of bus. The bus is configured to realize the connection and communication between the memory 12 and at least one processor 13, etc.
[0263] Although not shown, the electronic device 1 may also include a power source (such as a battery) for supplying power to each component. Preferably, the power source may be logically connected to the at least one processor 13 through a power management device, so that the power management device can realize functions such as charging management, discharging management, and power consumption management. The power source may also include any components such as one or more DC or AC power sources, recharging devices, power failure detection circuits, power converters or inverters, and power status indicators. The electronic device 1 may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be described in detail here.
[0264] Furthermore, the electronic device 1 may also include a network interface. Optionally, the network interface may include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is generally used to establish a communication connection between the electronic device 1 and other electronic devices.
[0265] Optionally, the electronic device 1 may further include a user interface, which may be a display (Display), an input unit (such as a keyboard (Keyboard)), and optionally, the user interface may also be a standard wired interface or a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode) touch device, etc. The display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device 1 and to display a visual user interface.
[0266] An embodiment of the present application also provides a computer-readable storage medium (not shown), in which computer-readable storage medium is stored computer-readable instructions, and the computer-readable instructions are executed by a processor in an electronic device to implement the artificial intelligence-based report generation method described in any of the above embodiments.
[0267] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.
[0268] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.
[0269] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0270] In addition, each functional module in each embodiment of the present application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above integrated unit can be implemented in the form of hardware or in the form of hardware plus software functional modules.
[0271] In addition, it is obvious that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the specification can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any specific order.
[0272] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present application and are not intended to limit it. Although the present application has been described in detail with reference to the preferred embodiments, a person of ordinary skill in the art should understand that the technical solution of the present application may be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present application.
Claims
1. A report generation method based on artificial intelligence, characterized in that: The method comprises: Collect keywords and special characters of the report program from the database, and take all keywords and special characters as keyword sets and special character sets respectively; Statistically reporting all historical programs in the project, and classifying the historical programs according to semantic information of the historical programs to obtain a plurality of program sets; Matching the special character set with characters in the historical program to obtain key-value pairs, and constructing a dynamic character hash table based on the key-value pairs; Encode each historical program to obtain an encoding vector corresponding to each historical program; Clustering the encoding vectors corresponding to all programs in each program set to obtain multiple program clusters; Creating a template program corresponding to each program cluster according to the keyword set and the dynamic character hash table, each program cluster including at least one template program; Analyze the semantic information of the business needs to be evaluated and call the existing template program based on the analysis results to generate report production results.
2. The report generation method based on artificial intelligence according to claim 1, characterized in that: The matching of the special character set with the characters in the historical program to obtain a key-value pair, and constructing a dynamic character hash table based on the key-value pair comprises: Filtering dynamic characters in the historical program, wherein the dynamic characters refer to characters that change with business needs; Classifying the dynamic characters according to semantic information of a preceding character of each dynamic character to obtain a plurality of dynamic character sets, wherein the preceding character refers to a character preceding the dynamic character; The special character set is matched with the multiple dynamic character sets to obtain key-value pairs, and a dynamic character hash table is constructed according to all the key-value pairs, wherein the key of the key-value pair is the special character in the special character set, and the value is the dynamic character set.
3. The report generation method based on artificial intelligence according to claim 1, characterized in that: The encoding of each historical program to obtain an encoding vector corresponding to each historical program includes: Traversing each historical program according to the character arrangement order in the historical program; Input each traversed character into a preset discrimination program to obtain a discrimination result; Determine the encoding value corresponding to each character according to the discrimination result of the character; The encoding values are combined according to the arrangement order of the characters in the historical program to generate an encoding vector.
4. The report generation method based on artificial intelligence according to claim 1, characterized in that: After encoding each historical program to obtain an encoding vector corresponding to each historical program, the method further includes: Count the maximum value of the dimension of the encoding vector corresponding to all historical programs in each program set; For a code vector whose dimension is less than the maximum value, the code vector is padded with a value of 2 at the end of the code vector to ensure that the dimension of the code vector is equal to the maximum value.
5. The report generation method based on artificial intelligence according to claim 1, characterized in that: The clustering to obtain a plurality of program clusters comprises: a. Calculate the cosine similarity between the encoding vector corresponding to each historical program in the program set and each of the remaining encoding vectors; b, randomly select two encoding vectors from the program set as vector X and vector Y; c. If the vectors X and Y meet a first preset condition, then the vectors X and Y are defined to belong to the same program cluster; otherwise, the vectors X and Y belong to different program clusters; d. Randomly select a coding vector that does not belong to any program cluster from the program set and record it as Z. If the coding vector Z meets the second preset condition, then classify the vector Z as a certain cluster; otherwise, treat Z as a separate cluster; e. Repeat d until all encoding vectors in the program set belong to a cluster.
6. The report generation method based on artificial intelligence according to claim 1, characterized in that: After clustering the encoding vectors in each program set to obtain a plurality of program clusters, the method further includes: The number of coding vectors in each program cluster is counted, and the number of coding vectors in each program cluster is used as the priority of the corresponding program cluster. The more the number of coding vectors in the program cluster is, the higher the priority of the program cluster is.
7. The report generation method based on artificial intelligence as claimed in claim 1, characterized in that: The step of analyzing the semantic information of the business requirements to be evaluated and calling an existing template program according to the analysis results to generate a report production result includes: Selecting a program set according to the semantic information of the business requirement to be evaluated, and taking a template program in the program set as a first candidate program; Screening the dynamic attributes in the business requirement to be evaluated, and inserting the value of the dynamic attribute into the first candidate program to obtain a second candidate program; The second candidate program is run to obtain program output results, and the business requirements to be evaluated are compared with the program output results to select a report that meets the requirements.
8. A report generation device based on artificial intelligence, characterized in that: The device comprises: A collection unit is used to collect keywords and special characters of the report program from the database, and to take all the keywords and special characters as a keyword set and a special character set respectively; A classification unit, used for counting all historical programs in the report generation project, and classifying the historical programs according to semantic information of the historical programs to obtain a plurality of program sets; A construction unit, configured to match the special character set with characters in the historical program to obtain a key-value pair, and to construct a dynamic character hash table based on the key-value pair; An encoding unit, used for encoding each historical program to obtain an encoding vector corresponding to each historical program; A clustering unit, used for clustering the encoding vectors in each program set to obtain a plurality of program clusters; A making unit, used for making a template program corresponding to each program cluster according to the keyword set and the dynamic character hash table, each program cluster including at least one template program; The generation unit is used to analyze the semantic information of the business requirements to be evaluated and call the existing template program according to the analysis results to generate the report production results.
9. An electronic device, characterized in that: The electronic device comprises: a memory storing computer readable instructions; and A processor executes computer-readable instructions stored in the memory to implement the artificial intelligence-based report generation method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, and the computer-readable instructions are executed by a processor in an electronic device to implement the artificial intelligence-based report generation method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Report generation method and device, computer device, and storage medium
CN109271411A
Report generation method and device, electronic equipment and storage medium
CN112949276A