CN117010358A - Message card generation method, device, computer equipment and storage medium - Google Patents
Message card generation method, device, computer equipment and storage medium Download PDFInfo
- Publication number
- CN117010358A CN117010358A CN202211008687.4A CN202211008687A CN117010358A CN 117010358 A CN117010358 A CN 117010358A CN 202211008687 A CN202211008687 A CN 202211008687A CN 117010358 A CN117010358 A CN 117010358A
- Authority
- CN
- China
- Prior art keywords
- data
- template
- message
- expression
- instruction
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 112
- 230000014509 gene expression Effects 0.000 claims abstract description 241
- 238000009877 rendering Methods 0.000 claims abstract description 59
- 238000004590 computer program Methods 0.000 claims abstract description 26
- 238000004458 analytical method Methods 0.000 claims description 111
- 238000012545 processing Methods 0.000 claims description 74
- 238000004422 calculation algorithm Methods 0.000 claims description 15
- 238000005457 optimization Methods 0.000 claims description 13
- 230000008569 process Effects 0.000 description 62
- 238000004891 communication Methods 0.000 description 13
- 238000010586 diagram Methods 0.000 description 11
- 230000002829 reductive effect Effects 0.000 description 9
- 238000005516 engineering process Methods 0.000 description 5
- 238000007726 management method Methods 0.000 description 3
- 238000004364 calculation method Methods 0.000 description 2
- 230000008859 change Effects 0.000 description 2
- 238000010276 construction Methods 0.000 description 2
- 238000013500 data storage Methods 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 230000000670 limiting effect Effects 0.000 description 2
- 230000007246 mechanism Effects 0.000 description 2
- 230000003068 static effect Effects 0.000 description 2
- OKTJSMMVPCPJKN-UHFFFAOYSA-N Carbon Chemical compound [C] OKTJSMMVPCPJKN-UHFFFAOYSA-N 0.000 description 1
- 230000009471 action Effects 0.000 description 1
- 230000001413 cellular effect Effects 0.000 description 1
- 238000006243 chemical reaction Methods 0.000 description 1
- 238000007405 data analysis Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 229910021389 graphene Inorganic materials 0.000 description 1
- 238000003384 imaging method Methods 0.000 description 1
- 230000002452 interceptive effect Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000012544 monitoring process Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000036961 partial effect Effects 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
- 230000009466 transformation Effects 0.000 description 1
- 230000000007 visual effect Effects 0.000 description 1
- 239000011800 void material Substances 0.000 description 1
- 239000002699 waste material Substances 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/10—Text processing
- G06F40/166—Editing, e.g. inserting or deleting
- G06F40/186—Templates
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/10—Text processing
- G06F40/12—Use of codes for handling textual entities
- G06F40/151—Transformation
- G06F40/154—Tree transformation for tree-structured or markup documents, e.g. XSLT, XSL-FO or stylesheets
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/20—Natural language analysis
- G06F40/205—Parsing
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/20—Natural language analysis
- G06F40/253—Grammatical analysis; Style critique
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/20—Natural language analysis
- G06F40/279—Recognition of textual entities
- G06F40/284—Lexical analysis, e.g. tokenisation or collocates
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L51/00—User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
- H04L51/04—Real-time or near real-time messaging, e.g. instant messaging [IM]
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Audiology, Speech & Language Pathology (AREA)
- Health & Medical Sciences (AREA)
- Computational Linguistics (AREA)
- General Health & Medical Sciences (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Artificial Intelligence (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The application relates to a message card generation method, a message card generation device, a message card generation computer device, a message card storage medium and a message card generation computer program product. The method comprises the following steps: acquiring a message card generation request containing template specification information and business data; obtaining a message template corresponding to the message card generation request based on the template specification information; obtaining message data according to the message template and the service data; identifying expression data in the message data, searching instruction data corresponding to the expression data in an expression instruction set, and obtaining an operation result of the expression data according to the instruction data; and rendering and generating a message card based on the message data and the operation result. The application can effectively improve the generation efficiency of the message card.
Description
Technical Field
The present application relates to the field of computer technology, and in particular, to a message card generating method, a message card generating device, a computer device, a storage medium, and a computer program product.
Background
With the development of computer technology and communication technology, web-based instant messaging (Instant Messaging, IM) technology has emerged that allows two or more people to communicate text messages, documents, voice and video in real time using a web. In general, in the instant messaging process, the content appearing in the page of the message session is called a message card, and at present, the message card commonly used in the message service includes text, rich text, voice, photo, video and notification message.
At present, the message card can be analyzed and rendered through a cross-platform view control with dynamic analysis and rendering capabilities, however, in the analysis process of the dynamic message card, the cost of an expression operation process in the message card process is high, and the communication efficiency of the message card is affected.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a message card generating method, apparatus, computer device, computer readable storage medium, and computer program product that can effectively improve the communication efficiency of a message card.
In a first aspect, the present application provides a message card generation method. The method comprises the following steps:
acquiring a message card generation request containing template specification information and business data;
obtaining a message template corresponding to the message card generation request based on the template specification information;
obtaining message data according to the message template and the service data;
identifying expression data in the message data, searching instruction data corresponding to the expression data in an expression instruction set, and obtaining an operation result of the expression data according to the instruction data, wherein the instruction data in the expression instruction set is generated based on nodes in abstract syntax trees of various expressions in traversal history data, the abstract syntax trees are constructed by performing lexical analysis and grammar analysis on various expressions in the history data, and the nodes in the abstract syntax trees represent operands or operators of the expression algorithm;
And rendering and generating a message card based on the message data and the operation result.
In a second aspect, the application further provides a message card generating device. The device comprises:
the request acquisition module is used for acquiring a message card generation request containing template specification information and business data;
the template searching module is used for obtaining a message template corresponding to the message card generation request based on the template specification information;
the message analysis module is used for obtaining message data according to the message template and the service data;
the data operation module is used for identifying the expression data in the message data, searching the instruction data corresponding to the expression data in an expression instruction set, obtaining the operation result of the expression data according to the instruction data, wherein the instruction data in the expression instruction set is generated based on nodes in abstract syntax trees of various expressions in traversal history data, the abstract syntax trees are constructed by performing lexical analysis and grammar analysis on various expressions in the history data, and the nodes in the abstract syntax trees represent operands or operators of the expression operation rule;
and the message card generation module is used for rendering and generating a message card based on the message data and the operation result.
In a third aspect, the present application also provides a computer device. The computer device comprises a memory storing a computer program and a processor which when executing the computer program performs the steps of:
acquiring a message card generation request containing template specification information and business data;
obtaining a message template corresponding to the message card generation request based on the template specification information;
obtaining message data according to the message template and the service data;
identifying expression data in the message data, searching instruction data corresponding to the expression data in an expression instruction set, and obtaining an operation result of the expression data according to the instruction data, wherein the instruction data in the expression instruction set is generated based on nodes in abstract syntax trees of various expressions in traversal history data, the abstract syntax trees are constructed by performing lexical analysis and grammar analysis on various expressions in the history data, and the nodes in the abstract syntax trees represent operands or operators of the expression algorithm;
and rendering and generating a message card based on the message data and the operation result.
In a fourth aspect, the present application also provides a computer-readable storage medium. The computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of:
acquiring a message card generation request containing template specification information and business data;
obtaining a message template corresponding to the message card generation request based on the template specification information;
obtaining message data according to the message template and the service data;
identifying expression data in the message data, searching instruction data corresponding to the expression data in an expression instruction set, and obtaining an operation result of the expression data according to the instruction data, wherein the instruction data in the expression instruction set is generated based on nodes in abstract syntax trees of various expressions in traversal history data, the abstract syntax trees are constructed by performing lexical analysis and grammar analysis on various expressions in the history data, and the nodes in the abstract syntax trees represent operands or operators of the expression algorithm;
and rendering and generating a message card based on the message data and the operation result.
In a fifth aspect, the present application also provides a computer program product. The computer program product comprises a computer program which, when executed by a processor, implements the steps of:
acquiring a message card generation request containing template specification information and business data;
obtaining a message template corresponding to the message card generation request based on the template specification information;
obtaining message data according to the message template and the service data;
identifying expression data in the message data, searching instruction data corresponding to the expression data in an expression instruction set, and obtaining an operation result of the expression data according to the instruction data, wherein the instruction data in the expression instruction set is generated based on nodes in abstract syntax trees of various expressions in traversal history data, the abstract syntax trees are constructed by performing lexical analysis and grammar analysis on various expressions in the history data, and the nodes in the abstract syntax trees represent operands or operators of the expression algorithm;
and rendering and generating a message card based on the message data and the operation result.
The message card generation method, the device, the computer equipment, the storage medium and the computer program product are used for generating a request after acquiring the message card containing template specification information and business data; firstly, obtaining a message template corresponding to a message card generation request based on template specification information; obtaining message data according to the message template and the service data; and then, identifying the expression data in the message data, searching instruction data corresponding to the expression data in an expression instruction set, and obtaining an operation result of the expression data according to the instruction data, wherein the instruction in the expression instruction set is generated based on nodes in abstract syntax trees of various expressions in the traversal history data, and the abstract syntax trees are constructed by performing lexical analysis and syntax analysis on the various expressions in the history data, and the nodes in the abstract syntax trees represent operands or operators of the expression algorithm. By abstracting the lexical analysis and grammar analysis processes in the expression operation process into instruction data, the expression operation can be directly realized through the instruction data when repeated expressions are faced, the expenditure of the expression operation process is reduced, and finally, a message card can be rendered and generated based on the message data and the operation result.
Drawings
FIG. 1 is an application environment diagram of a message card generation method in one embodiment;
FIG. 2 is a schematic diagram of a message card generation method in one embodiment;
FIG. 3 is a schematic diagram of a data operation process in one embodiment;
FIG. 4 is a flow chart of a data operation process according to an embodiment of the present application;
FIG. 5 is a schematic diagram illustrating a comparison of a template loading process according to an embodiment of the present application with a template loading process according to the present application;
FIG. 6 is a flow diagram of the module loading process steps in one embodiment;
FIG. 7 is a flow chart of the steps of a module cache data multiplexing process in one embodiment;
FIG. 8 is a flow diagram that illustrates the steps of generating code based on expressions, in one embodiment;
FIG. 9 is a schematic diagram of field nulling optimization in one embodiment;
FIG. 10 is a schematic diagram of a constant expression optimization process in one embodiment;
FIG. 11 is a block diagram of a message card generating device in one embodiment;
fig. 12 is an internal structural diagram of a computer device in one embodiment.
Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application.
In this context, it is to be understood that the terms involved:
FunView: is a cross-platform view control with dynamic analysis rendering capability;
XmlNode: is the view node structure in FunView that is used to describe the user interface style.
The message card generation method provided by the embodiment of the application can be applied to an application environment shown in fig. 1. Wherein the terminal 102 communicates with the server 104 via a network. The data storage system may store data that the server 104 needs to process. The data storage system may be integrated on the server 104 or may be located on the cloud or other servers. When a worker on the server 104 side needs to push a message card to the terminal 102 side, a message card generation request containing template specification information and service data can be sent to the terminal 102, and the terminal 102 obtains the message card generation request containing the template specification information and the service data; obtaining a message template corresponding to the message card generation request based on the template specification information; obtaining message data according to the message template and the service data; identifying expression data in the message data, searching instruction data corresponding to the expression data in an expression instruction set, obtaining an operation result of the expression data according to the instruction data, generating the instruction data in the expression instruction set based on nodes in abstract syntax trees of various expressions in traversal history data, constructing the abstract syntax trees by performing lexical analysis and grammar analysis on various expressions in the history data, and representing operands or operators of the expression algorithm by the nodes in the abstract syntax trees; and finally, rendering and generating a message card on a display screen of the terminal 102 based on the message data and the operation result. The terminals 102 and 104 may be, but not limited to, various desktop computers, notebook computers, smart phones, tablet computers, internet of things devices, and portable wearable devices, and the internet of things devices may be smart speakers, smart televisions, smart air conditioners, smart vehicle devices, and the like. The portable wearable device may be a smart watch, smart bracelet, headset, or the like. The server 104 may be implemented as a stand-alone server or as a server cluster of multiple servers.
In one embodiment, as shown in fig. 2, a message card generating method is provided, and the method is applied to the terminal 102 in fig. 1 for illustration, and includes the following steps:
step 201, a message card generation request containing template specification information and service data is acquired.
Where a message card generation request refers to a request that the server 104 wishes to generate by communicating information through the message card. The message card is also called card message, which is a structured message that can provide an easy-to-use, unified rich interactive form. In one embodiment, the message card may specifically refer to a FunView message, where FunView is a cross-platform view control with dynamic parsing and rendering capability, and is widely used in message flows of various instant messaging software at present, and the FunView performs dynamic parsing and rendering based on templates and data, where the templates are a pattern description set, and are issued with the message in a file link form, dynamically downloaded and parsed when needed, and then combined with data operation to obtain a renderable view tree, and finally drawn on a screen. The message card generation request specifically comprises template specification information and service data, wherein the template specification information is used for specifying a message template used in the message card generation process, and the service data is also used for filling the message template to obtain data of the message card. The template specification information is used for specifying a message template used for generating the message card, and the template specification information can specifically specify a required message template through information such as a template name, a template number or a template type.
Specifically, when the staff on the server 104 side needs to send a message to the user on the terminal 102 side, the message may be sent in the form of a message card, and at this time, the server 104 needs to submit a corresponding message card generation request to the terminal 102 first to render and generate the message card on the display interface of the terminal 102. Meanwhile, a template designating message is added to the message card generating request to designate a message template for the message card, and corresponding service data is added at the same time, after receiving the message card generating request, the server 104 may determine the template for generating the message card, and download corresponding message data from the terminal 102 side to generate the message card. In one embodiment, the scheme of the application is suitable for instant messaging software used for enterprise internal communication, the message card can be specifically a FunView message, when enterprise personnel need to send the message to individual users or group chat in the instant messaging software, the data can be sent in the form of the FunView message card, at the moment, the message card generation request needs to be submitted to each terminal, meanwhile, template specification information and service data are submitted, the terminal 102 obtains the message data, the message template is dynamically downloaded, and then a renderable view tree is obtained through operations such as data analysis, data operation and the like, and finally, the renderable view tree is drawn on a screen of the terminal.
And 203, obtaining a message template corresponding to the message card generation request based on the template specification information.
The message template is one of the components of the message card, and the final required message card can be generated through loading and analyzing the business data and the message template. The message template specifically comprises information such as template name, template type, template content and the like. The template content comprises a specific style of the message card, and comprises a message title, a message content and the like. The final required message card (containing some of the content requiring expression calculation) can be generated by combining the business data with the message template. And the service data is data containing specific message contents. The message templates may be transmitted to the server 104 in the form of binary data.
Specifically, after the server obtains the message card generation request, the template specification information and the service data contained in the message card generation request can be resolved first, and the message card generation request is searched and downloaded to the corresponding message template according to the template specification information. Meanwhile, the binary message data can be downloaded from the terminal 102 based on the message card generation request, and then the required message card can be generated based on the message data and the message template. In one embodiment, the scheme of the application is suitable for instant messaging software used for enterprise internal communication, a plurality of message templates are preset in the instant messaging software, a terminal can specify a required message template through a template name, a server can search and download a corresponding message template through the template name when receiving a message card generation request of the terminal, and meanwhile, a terminal side can obtain service data from the message card generation request so as to generate the required message card.
And step 205, obtaining message data according to the message template and the service data.
The message data specifically refers to data obtained by combining the message template with service data after the message template is converted into a style description tree.
Specifically, the message template is specifically binary data, and needs to be rendered onto the screen of the terminal 102 through parsing processing. The parsing and rendering process of the message template specifically comprises steps of reading binary, parsing the binary into a style description tree, parsing the same data operation, converting the same style description tree into a rendering tree, and the like. The binary message template is first downloaded and read from the server 104, and then converted into a style description tree, in which the service data is combined with the intermediate nodes of the style description tree obtained by parsing the message template. The attribute node value in the template may be an expression, and the expression designates a field in the service data to be taken for operation, and at this time, after the style description tree is obtained, the corresponding field of the service data may be added to the style description tree to fill the expression therein. In one embodiment, the application is specifically used for realizing the analysis and rendering of the FunView dynamic message card, the style description tree is specifically an Xmlnode style description tree, and the service data is combined with the Xmlnode style description tree corresponding to the message template to obtain the message data.
Step 207, identifying the expression data in the message data, searching the instruction data corresponding to the expression data in the expression instruction set, obtaining the operation result of the expression data according to the instruction data, generating the instruction data in the expression instruction set based on nodes in abstract syntax trees of various expressions in the traversal history data, wherein the abstract syntax trees are constructed by performing lexical analysis and grammar analysis on various expressions in the history data, and the nodes in the abstract syntax trees represent operands or operators of the expression algorithm.
Wherein the expression is a combination obtained by a meaningful arrangement method of numbers, operators, numerical grouping symbols (brackets), free variables, constraint variables, and the like to obtain numerical values. Constraint variables have been assigned values in an expression, while free variables may be assigned values outside of the expression. Instruction data contains a plurality of instructions, and the instructions (instruction) are used for telling a computer to perform a code of a special operation. Such as: data transfer instructions, arithmetic operation instructions, bit operation instructions, program flow control instructions, string operation instructions, processor control instructions and the like, and the instructions are used for caching operation results of lexical analysis and grammar analysis in the expression operation process. Specifically, a corresponding abstract syntax tree can be generated according to the lexical analysis of the expression and the operation result of the syntax analysis, and each instruction can be generated according to node generation by traversing the abstract syntax tree. And the expression instruction set refers to an instruction set constructed based on expression data previously parsed. Nodes in the abstract syntax tree represent operands or operators of the expression algorithm. The nodes of the abstract syntax tree specifically comprise two types of leaf nodes and non-leaf nodes, the leaf nodes represent operands in one algorithm, and the non-leaf nodes represent operators in one algorithm.
Specifically, the rich and dynamic style presentation of the message card is declared by the expression together with the business data. In an actual message card business scenario, a large number of similar or repeated expressions need to be operated, and these expressions need to be subjected to repeated processes such as lexical analysis, grammar analysis, numerical operation and the like one by one, which occupy a large part of overhead in the message card analysis process. At present, the result of lexical analysis of the expression is directly cached, and when repeated expressions are encountered, the cost of repeatedly performing lexical analysis can be saved. The specific method is that the hash value of the expression is used as a key, the data structure of the lexical analysis result is used as a value, and in the lexical analysis flow, the buffer memory is updated and taken by the key value, and the specific method can be shown by referring to fig. 3, however, the method can only save the cost of the lexical analysis flow, and most of lexical analysis is performed in a sequential traversal and fresh backtracking scene, compared with the syntax analysis, the lexical analysis only accounts for about 10% of the total cost, and the cost is far less than that of the syntax analysis flow. The method brings about poor performance, so that the application provides an idea of an intermediate instruction layer, thereby effectively caching the results of lexical analysis and grammar analysis, and greatly saving the repeated expenditure when facing repeated expressions. The whole flow is changed into: the method comprises 4 steps of lexical analysis, grammar analysis, instruction generation and instruction operation, and is shown in fig. 4. Firstly, after the repeated expression is obtained, instruction data corresponding to the expression data can be directly extracted from constructed instruction data, then data operation is carried out according to the instruction data, an operation result of the expression data is obtained, and the quick operation of the expression can be directly realized through the instruction by caching lexical analysis and grammar analysis as instructions, so that the generation efficiency of a message card is improved, and the communication efficiency based on the message card is further improved.
Step 209, rendering and generating a message card based on the message data and the operation result.
Specifically, after the operation result is obtained, the style description tree corresponding to the operation result and the style description tree of the non-expression part message data may be converted into a rendering tree, and then the rendering and screen-loading processes are performed on the obtained rendering tree, so that a corresponding message card is generated on the terminal 104 side, and the generation flow of the message card is completed. In one embodiment, the scheme of the application is suitable for instant messaging software used for communication in an enterprise, and the message card can be pushed to individuals or group chat in the enterprise. When pushing to the group chat, pushing to all members in the group chat, and displaying the message card on the terminals of the members of the group chat.
The message card generation method comprises the steps of obtaining a message card generation request containing template specification information and service data; firstly, obtaining a message template corresponding to a message card generation request based on template specification information; obtaining message data according to the message template and the service data; and then, identifying the expression data in the message data, searching instruction data corresponding to the expression data in an expression instruction set, and obtaining an operation result of the expression data according to the instruction data, wherein the instruction in the expression instruction set is generated based on nodes in abstract syntax trees of various expressions in the traversal history data, and the abstract syntax trees are constructed by performing lexical analysis and syntax analysis on the various expressions in the history data, and the nodes in the abstract syntax trees represent operands or operators of the expression algorithm. By abstracting the lexical analysis and grammar analysis processes in the expression operation process into instruction data, the expression operation can be directly realized through the instruction data when repeated expressions are faced, the expenditure of the expression operation process is reduced, and finally, a message card can be rendered and generated based on the message data and the operation result.
In one embodiment, step 203 comprises: when the template loading task corresponding to the template designating information is not found in the task queue, according to the template loading task corresponding to the template designating information, registering a interception task in the created template loading task, wherein the interception task is used for intercepting the downloading completion condition of the message template designated by the template designating information; and obtaining a message template corresponding to the message card generation request based on the template loading task.
The task queues refer to queues used for sending messages, and each queue is used for realizing a task generated by a message card. The template loading task is a task of downloading a message template corresponding to a message card generation request from a template library, and because template data and business data are needed for generating the message card, the corresponding template is needed to be loaded from the template library to construct the message card when the message card needs to be generated. The interception task is a task for intercepting whether the downloading of the message template is completed or not, the downloading process of the message template can be intercepted through the interception task, and the corresponding message template can be directly obtained to execute the process of generating the follow-up message card as long as the downloading is completed.
Specifically, in the current message template using method, when a plurality of messages using the same template are required to be loaded simultaneously, each message can independently carry out the template file downloading and reading operation, and the condition that one template is read for multiple times is existed, so that unnecessary waste is caused. Therefore, as shown in fig. 5, the template loading process is managed by adding the template manager, and when the template loading action occurs, a template loading task corresponding to the template to be loaded is generated through the template manager. When a new template needs to be loaded, whether a template loading task corresponding to the new template exists or not is searched in a task queue before loading. If the message template is not stored, the template needs to be taken out through a new template loading task, at the moment, the template loading task can be established according to the message template, and a interception task is registered in the established template loading task according to the template specification information, so that the downloading flow of the message template corresponding to the template specification information is intercepted, and then the corresponding message template can be obtained through the template loading task. In the process, other template loading tasks can also determine the loading flow of the message template by monitoring the template loading tasks, so that the template reading tasks of a plurality of message card creation processes can be realized through one template loading task. In one embodiment, the scheme of the application is suitable for instant messaging software used for enterprise internal communication, at this time, a message template library can be established according to enterprise needs, different message templates are stored in the message template library by using template names as key values, when a message card needs to be established, the corresponding message template can be searched and downloaded in the message template library by using the template names, meanwhile, in the process of template loading, if other message card generating tasks need to read the message template, a process of interception for intercepting the message template loading can be directly added, and after the message template loading is completed, the generating tasks of the message cards can directly obtain the message templates for subsequent analysis and rendering processing. In this embodiment, interception and management of the template loading process are implemented through the template manager and the task queue, so that the number of times of reading the same message template can be reduced, and the processing efficiency of the process of generating the message card based on the message template is improved.
In one embodiment, step 203 further comprises: when a template loading task corresponding to the template designating information is found in the task queue, registering a interception task in the template loading task corresponding to the template designating information, wherein the interception task is used for intercepting the downloading completion condition of the message template designated by the template designating information; and when the completion of the downloading of the message template is detected based on the interception task, obtaining the message template corresponding to the message card generation request.
Specifically, as shown in fig. 6, when a new template needs to be loaded, before creating a template loading task, the server 104 searches for whether a template loading task corresponding to the new template exists in the task queue based on the template specifying information. If the message template exists, the downloading flow of the message template in the template loading task can be directly intercepted through registering the interception task, so that the template reading task of the multiple message card creation processes can be realized through one template loading task. And if the task is completed, informing all listeners that the file loading is completed, and then carrying out the next operation. And when not present, the template loading process needs to be implemented by first creating a template loading task. In this embodiment, interception and management of the template loading process are implemented through the template manager and the task queue, so that the number of times of reading the same message template can be reduced, and the processing efficiency of the process of generating the message card based on the message template is improved.
In one embodiment, step 205 comprises: analyzing the message template to obtain a style description tree; and obtaining message data according to the style description tree and the service data.
The parsing of the message template refers to parsing the message template into a style description tree. The expression data refers to part of data in the message data, after the server obtains the message template, the message template in a binary form can be converted into a corresponding data structure and then is analyzed into a style description tree, the style description tree comprises a hierarchical structure among multiple nodes, attribute description of a single node and the like, however, some attributes in the description tree at this time can be expressions and cannot be directly rendered, the data needs to be applied to the expressions, specific values are calculated and assigned to node attributes, and then the rendering tree obtained after the specific values are assigned, so that the rendering can be performed. Thus, after the style description tree is obtained, the style description tree may be combined with the business data to populate the related expressions to obtain the message data.
Specifically, after obtaining the service data and the message template, the message template needs to be converted into a style description tree, data operation, the style description tree is converted into a rendering tree, and the screen is rendered through analyzing the message template. The data operation process specifically refers to performing data operation processing on the style description tree corresponding to the expression, so as to calculate a specific value and assign the specific value to the node attribute, so that subsequent rendering processing can be performed. Therefore, after obtaining the message template, the server may parse the message template and then combine it with the service data to obtain the message data including the expression data, so as to pad for subsequent operation processing.
In one embodiment, after step 209, further comprises: acquiring a template multiplexing request containing a template identifier; searching a cache file based on the template identification, wherein the cache file comprises at least one of view cache, node cache or file cache; when the view cache corresponding to the template identifier is found, a rendering tree corresponding to the template multiplexing request is obtained through data operation processing; when the node cache corresponding to the template identifier is found, a rendering tree corresponding to the template multiplexing request is obtained through node analysis processing and data operation processing; when the file cache corresponding to the template identification is found, a rendering tree corresponding to the template multiplexing request is obtained through the template full-quantity analysis processing; when view cache, node cache and file cache corresponding to the template identification are not searched, a rendering tree corresponding to the template multiplexing request is obtained through template loading processing and template full-quantity analysis processing; and generating a message card corresponding to the template multiplexing request based on rendering of the rendering tree.
Wherein the template identification refers to identification information for identifying a desired target message template from a message template library. The template identification may specifically include a template type, a template number, a template name, and the like. The template cache file refers to a cache file of a message template, and the same template can be loaded and analyzed according to different stages to generate three products: files, style description trees, rendering view trees. The cache data of different stages are different, and unnecessary analysis processes for the message template can be reduced by identifying the cache file of the message template. And the generation efficiency of the message card is improved. The message template is a view file, so that the process of analyzing the template is also a process of analyzing the view, and the complete process of analyzing the message template also comprises the processes of loading the message template file, converting node analysis into a style description tree, operating data and the like. The view cache file contains a view tree converted from a style description tree, namely, the view cache file is generated after the message template node is resolved, so that when the view cache exists in the cache file, the current message template is indicated to have passed the template loading processing and the node resolving processing, the view tree in the template is converted into the view tree, the message template file with complete resolution can be obtained only by carrying out data operation processing on the basis of the view tree, and the specific data can be calculated by the expression in the view tree and then be endowed with attributes for rendering. The node caches the cache data corresponding to the style description tree file, and after the message template is read, the cache data can be converted into the style description tree, and the obtained cache data is the node cache file. The node cache file needs to be converted into a view tree through node analysis processing, and then the rendering tree can be obtained through data operation processing, so that the node cache is obtained, and further the analysis is performed through two steps of node analysis and data operation processing. The file caching refers to the caching of the template file, and the full-quantity analysis processing of the template comprises all analysis processes of node analysis, transformation into a style description tree, data operation and the like. If the file cache exists in the cache and the view cache and the node cache do not exist, the method indicates that the full-quantity analysis processing of the template needs to be completed once. If the file cache does not exist, the message template is read first, and then the template full-quantity analysis processing is carried out, so that the rendering tree for rendering can be obtained.
Specifically, the application can also realize the multiplexing of the message templates through the template cache file, and can realize the searching of the message template related cache data or the message template body by the template identification of the message templates and then taking the template identification as a key value. Because three different products, namely three products of a file, a style description tree and a rendering view tree are generated in the template process, and template cache files corresponding to the different products can be searched by setting a multi-level cache mechanism, then different template loading processes are carried out based on the searched cache files, and the analysis process for the message template is reduced, so that the processing efficiency is ensured. In one embodiment, as shown in fig. 7, when the view cache file obtained by final parsing is found, only the rendering tree corresponding to the template multiplexing request needs to be obtained through data operation processing. When only the Xmlnode cache file of the node cache is found, the Xmlnode cache file is required to be converted into a view tree through Xmlnode analysis, and then the rendering is obtained through data operation processing. When only the file cache corresponding to the template identifier is found, the rendering tree corresponding to the template multiplexing request can be obtained by executing the template full-quantity analysis processing comprising style description tree conversion, node analysis and data operation on the message template file, and if the file cache is not found, the corresponding message template file is loaded first and then the template full-quantity analysis is carried out. In this embodiment, the template cache file is searched through the template identifier, so that loading analysis of the message template can be performed through the template cache file, the analysis flow of the message template is reduced, and the generation efficiency of the message card is improved.
In one embodiment, before step 207, further comprises: acquiring expression data in historical data; performing lexical analysis processing on the expression data in the historical data to obtain word stream data; carrying out grammar analysis processing on word stream data to construct an abstract grammar tree; traversing each node in the abstract syntax tree, and generating each instruction in the instruction data according to the traversing result.
The term analysis refers to a process of converting a character sequence into a word (Token) stream in computer science. The program or function that performs the lexical analysis is called a lexical analyzer, also called a scanner. The lexical analyzer typically exists in the form of a function for the parser to call. The program that performs the lexical analysis task is called a lexical analysis program or a lexical analyzer or scanner. The program that performs the lexical analysis task is called a lexical analysis program or a lexical analyzer or scanner. The source program is scanned from left to right, various words are identified according to the lexical rules of the language, and attribute words of the corresponding words are generated. Whereas parsing is a logical stage of the compilation process. The task of parsing is to combine word sequences into various grammar phrases such as "programs", "sentences", "expressions", etc., on the basis of lexical analysis. The parser determines if the source program is structurally correct. The structure of the source program is described by context-free grammar. The parser may also be automatically generated with tools. The process of completing a parser task is called a parser, or parser. And identifying corresponding grammar category from the lexical analysis result according to grammar rules of the source language, and simultaneously carrying out grammar checking. An abstract Syntax tree (Abstract Syntax Tree, AST), or simply Syntax tree (syncax tree), is an abstract representation of the source code Syntax structure. It represents the syntax structure of a programming language in the form of a tree, each node on the tree representing a structure in the source code. The scheme of the application is mainly used for processing the expression data. Thus, a node characterizes an operand or operator of an expression algorithm. And generating each instruction in the instruction data according to the traversing result by traversing each node in the abstract syntax tree.
Specifically, the scheme of the application analyzes and caches the lexical analysis and grammar analysis processes through instruction data to obtain each instruction data, and the instructions can be specifically generated through grammar analysis. Firstly, lexical analysis is needed to be carried out on each expression in the historical data through a lexical analyzer such as a Lex and the like to obtain word stream data corresponding to the expression, then the word stream data is subjected to syntax analysis through a syntax analyzer such as a Yacc and the like, so that a corresponding abstract syntax tree is constructed, and after the syntax analysis tree is obtained, instructions corresponding to each node can be obtained through traversing the nodes. In one embodiment, the process of constructing each instruction in the instruction data based on the expression "a=b+c×d" in the history data may be shown in fig. 8, where the expression is firstly lexically analyzed by the lexical analysis tool Lex to obtain word stream data "id1=id2+id3-id4", then the word stream is parsed by the syntax analysis tool Yace to obtain an abstract syntax tree as shown in the figure, and then the nodes in the abstract syntax tree are traversed, where the found instruction includes "load id3", "mulid 4", "add id2" and "store id1"4 instructions. In this embodiment, various instructions can be constructed by analyzing the grammar of the expression, and the instruction data can be directly used for operation during the subsequent data operation processing, so that the generation efficiency of the message card is improved.
In one embodiment, the operation result of obtaining the expression data according to the instruction data includes: performing field nulling processing on the instruction data, and identifying data to be optimized in the instruction data; optimizing the instruction data based on the data to be optimized to obtain an optimized instruction; and obtaining an operation result of the expression data according to the optimization instruction.
The optimizing processing of the instruction specifically refers to optimizing a part of empty judgment instructions in the instruction data, for example, the grammar of common array empty judgment (array capacity) and the grammar of character string empty judgment (character string length) can be optimized, so that a plurality of instructions are replaced by a single instruction.
Specifically, the found instructions may include partial null instructions, and in order to reduce the consumption of instruction execution, the null instructions may be optimized first. At this time, whether each instruction in the instruction data is a null instruction or not can be identified through a null instruction (check_empty), and null operation is specially executed through the null instruction, so that null can be performed on an array and a character string in the instruction data, and the previous LOAD, CALL, EQAL three instructions can be replaced. Therefore, the instruction quantity is reduced, and the processing efficiency of the data operation process is improved. In one embodiment, as shown in the left side of fig. 9, the data to be optimized is first identified from the code of the instruction data, where two "desc_list.size ()" and "num 0" are included. Therefore, the first three instructions in the right side of fig. 9 are optimized, and the found instruction corresponding to the EMPTY judging operation is replaced by the check_empty instruction. In this embodiment, the number of instructions can be effectively reduced by the void determination processing of the instruction data, thereby improving the processing efficiency in the data operation processing process.
In one embodiment, the operation result of obtaining the expression data according to the instruction data includes: identifying a highest frequency data field in the instruction data; constructing a quick access instruction corresponding to the highest frequency data field; updating instruction data based on the quick access instruction; and obtaining the operation result of the expression data through the updated instruction data.
The highest frequency data field refers to a data field with highest occurrence frequency in the instruction data containing all instructions. Such more frequently occurring data fields generally need to be accessed by a policy that progressively accesses nested fields. The quick access instruction is a strategy capable of accessing the nested fields at one time, and can prevent the data from being repeatedly circulated in the temporary register.
Specifically, the scheme of the application can also simplify the data operation processing process through field access optimization measures, and identify the highest frequency data field in the instruction data; constructing a quick access instruction corresponding to the highest frequency data field; updating instruction data based on the quick access instruction; and obtaining the direct access grammar of the expression data aiming at the highest frequency data field by the operation result of the updated instruction data, and replacing the strategy of accessing the nested fields step by step with the strategy of accessing the nested fields once, thereby avoiding repeated circulation of the data in the temporary register. For the highest frequency data field, the highest frequency data field can be converted into a one-time access nested field, so that the optimization of instruction data is realized. In this embodiment, the flow of the data operation can be effectively simplified through field access optimization, so as to improve the processing efficiency of the data operation.
In one embodiment, the operation result of obtaining the expression data according to the instruction data includes: recognizing constant expression nodes in expression data, wherein the constant expression is a grammar node with constant operands; performing data operation processing on the constant expression nodes to obtain constant operation results; replacing constant expression nodes in the expression data with constant operation results corresponding to the constant expression nodes to update the expression data; and searching instruction data corresponding to the updated expression data in the expression instruction set, and obtaining an operation result of the expression data according to the instruction data.
The constant expression is a grammar node with constant operands, and the grammar node can directly calculate to obtain a result to replace the original node.
Specifically, the application can also optimize the constant expression in the expression data, if all operands in one node of the expression are identified as constants, as shown in fig. 10, wherein the operands in the node (2+1) are constants, so that the constant operation result is obtained by firstly operating the constant expression, then replacing the original (2+1) with 3 to update the expression, and then acquiring instruction data according to the updated expression, thereby directly avoiding generating instructions and improving the processing efficiency of the data operation process. In this embodiment, the constant expression optimization is used to further optimize the expression data, so that the processing efficiency can be effectively improved.
The application also provides an application scene, which applies the message card generation method. Specifically, the application of the message card generation method in the application scene is as follows:
the application can be particularly applied to instant messaging software suitable for enterprise management, an administrator can push messages to each member of an enterprise or group chat containing a plurality of enterprise members in the instant messaging software at a server side, and the form of the push messages can be particularly realized in the form of a FunView message card. An administrator at the server side submits business data for generating message cards at the server side, and sets template specification information of message templates to be used. And pushing a message card generation request containing template specification information and service data to the terminal corresponding to each member so as to render and generate a corresponding message card at the terminal side. And the terminal obtains a message card generation request containing the template specification information and the service data. First, a message template corresponding to the message card generation request needs to be obtained based on the template specification information, and this process can be implemented by downloading the message template to the server through a template loading task, where multiple messages may load the same message template at the same time. At this time, for the loading process of the message template, the template loading task corresponding to the template designating information can be searched in the task queue for loading the message template based on the template designating message, when the template loading task corresponding to the template designating information is not searched in the task queue, the interception task is registered in the created template loading task according to the template loading task corresponding to the template designating information, and the interception task is used for intercepting the downloading completion condition of the message template designated by the template designating information; and obtaining a message template corresponding to the message card generation request based on the template loading task. When a template loading task corresponding to the template designating information is found in the task queue, registering a interception task in the template loading task corresponding to the template designating information, wherein the interception task is used for intercepting the downloading completion condition of the message template designated by the template designating information; and when the completion of the downloading of the message template is detected based on the interception task, obtaining the message template corresponding to the message card generation request. After the message template is obtained, the message template can be analyzed to obtain an Xmlnode style description tree; and obtaining message data according to the Xmlnode style description tree and the service data. And then, identifying the expression data in the message data, searching the instruction data corresponding to the expression data in an expression instruction set, obtaining an operation result of the expression data according to the instruction data, generating the instruction data in the expression instruction set based on nodes in abstract syntax trees of various expressions in the traversal history data, and constructing the abstract syntax tree by performing lexical analysis and grammar analysis on various expressions in the history data, wherein the nodes in the abstract syntax tree represent operands or operators of the expression algorithm. Specifically, for the construction process of the expression instruction set, expression data in the history data can be obtained; performing lexical analysis processing on the expression data in the historical data to obtain word stream data; carrying out grammar analysis processing on word stream data to construct an abstract grammar tree; traversing each node in the abstract syntax tree, and generating each instruction in the instruction data according to the traversing result. The calculation process of the expression can also comprise three optimization processes, namely field blank optimization, and the data to be optimized in the instruction data are identified by carrying out field blank optimization on the instruction data; optimizing the instruction data based on the data to be optimized to obtain an optimized instruction; and obtaining an operation result of the expression data according to the optimization instruction. Secondly, optimizing field access by identifying the highest frequency data field in the instruction data; constructing a quick access instruction corresponding to the highest frequency data field; updating instruction data based on the quick access instruction; and obtaining the operation result of the expression data through the updated instruction data. Thirdly, optimizing a constant expression, wherein the constant expression is a grammar node with constant operands by identifying constant expression nodes in expression data; performing data operation processing on the constant expression nodes to obtain constant operation results; replacing constant expression nodes in the expression data with constant operation results corresponding to the constant expression nodes to update the expression data; and searching instruction data corresponding to the updated expression data in the expression instruction set, and obtaining an operation result of the expression data according to the instruction data. In addition, the application also comprises a flow for realizing template buffer data multiplexing through a buffer mechanism, specifically, the terminal can start the template multiplexing process after receiving the template multiplexing request containing the template identifier; firstly, searching a cache file based on a template identifier, wherein the cache file comprises at least one of view cache, node cache or file cache; when the view cache corresponding to the template identifier is found, a rendering tree corresponding to the template multiplexing request is obtained through data operation processing; when the node cache corresponding to the template identifier is found, a rendering tree corresponding to the template multiplexing request is obtained through node analysis processing and data operation processing; when the file cache corresponding to the template identification is found, a rendering tree corresponding to the template multiplexing request is obtained through the template full-quantity analysis processing; when view cache, node cache and file cache corresponding to the template identification are not searched, a rendering tree corresponding to the template multiplexing request is obtained through template loading processing and template full-quantity analysis processing; and generating a message card corresponding to the template multiplexing request based on rendering of the rendering tree. Thereby effectively improving the processing efficiency of the message card generation process.
It should be understood that, although the steps in the flowcharts related to the above embodiments are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the flowcharts described in the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages is not necessarily performed sequentially, but may be performed alternately or alternately with at least some of the other steps or stages.
Based on the same inventive concept, the embodiment of the application also provides a message card generating device for realizing the message card generating method. The implementation of the solution provided by the device is similar to the implementation described in the above method, so the specific limitation in the embodiments of the message card generating device or devices provided below may refer to the limitation of the message card generating method hereinabove, and will not be repeated herein.
In one embodiment, as shown in FIG. 11, there is provided a message card generating apparatus comprising
A request acquisition module 1102, configured to acquire a message card generation request including template specification information and service data;
the template searching module 1104 is used for obtaining a message template corresponding to the message card generation request based on the template specification information;
the message parsing module 1106 is configured to obtain message data according to the message template and the service data;
the data operation module 1108 is configured to identify expression data in the message data, search instruction data corresponding to the expression data in the expression instruction set, obtain an operation result of the expression data according to the instruction data, generate the instruction data in the expression instruction set based on nodes in abstract syntax trees of various expressions in the traversal history data, and construct the abstract syntax tree by performing lexical analysis and syntax analysis on various expressions in the history data, where the nodes in the abstract syntax tree represent operands or operators of the expression algorithm;
message card generation module 1110 is configured to render and generate a message card based on the message data and the operation result.
In one embodiment, the template lookup module 1104 is specifically configured to: when the template loading task corresponding to the template designating information is not found in the task queue, according to the template loading task corresponding to the template designating information, registering a interception task in the created template loading task, wherein the interception task is used for intercepting the downloading completion condition of the message template designated by the template designating information; and obtaining a message template corresponding to the message card generation request based on the template loading task.
In one embodiment, the template lookup module 1104 is specifically configured to: when a template loading task corresponding to the template designating information is found in the task queue, registering a interception task in the template loading task corresponding to the template designating information, wherein the interception task is used for intercepting the downloading completion condition of the message template designated by the template designating information; and when the completion of the downloading of the message template is detected based on the interception task, obtaining the message template corresponding to the message card generation request.
In one embodiment, the message parsing module 1106 is specifically configured to: analyzing the message template to obtain a style description tree; and obtaining message data according to the style description tree and the service data.
In one embodiment, the method further comprises a template multiplexing module for: acquiring a template multiplexing request containing a template identifier; searching a cache file based on the template identification, wherein the cache file comprises at least one of view cache, node cache or file cache; when the view cache corresponding to the template identifier is found, a rendering tree corresponding to the template multiplexing request is obtained through data operation processing; when the node cache corresponding to the template identifier is found, a rendering tree corresponding to the template multiplexing request is obtained through node analysis processing and data operation processing; when the file cache corresponding to the template identification is found, a rendering tree corresponding to the template multiplexing request is obtained through the template full-quantity analysis processing; when view cache, node cache and file cache corresponding to the template identification are not searched, a rendering tree corresponding to the template multiplexing request is obtained through template loading processing and template full-quantity analysis processing; and generating a message card corresponding to the template multiplexing request based on rendering of the rendering tree.
In one embodiment, the method further comprises an instruction construction module for: acquiring historical data; performing lexical analysis processing on the historical data to obtain word stream data; carrying out grammar analysis processing on word stream data to construct an abstract grammar tree; traversing each node in the abstract syntax tree, and generating each instruction in the instruction data according to the traversing result.
In one embodiment, the data operation module 1108 is specifically configured to: performing field nulling processing on the instruction data, and identifying data to be optimized in the instruction data; optimizing the instruction data based on the data to be optimized to obtain an optimized instruction; and obtaining an operation result of the expression data according to the optimization instruction.
In one embodiment, the data operation module 1108 is specifically configured to: identifying a highest frequency data field in the instruction data; constructing a quick access instruction corresponding to the highest frequency data field; updating instruction data based on the quick access instruction; and obtaining the operation result of the expression data through the updated instruction data.
In one embodiment, the data operation module 1108 is specifically configured to: recognizing constant expression nodes in expression data, wherein the constant expression is a grammar node with constant operands; performing data operation processing on the constant expression nodes to obtain constant operation results; replacing constant expression nodes in the expression data with constant operation results corresponding to the constant expression nodes to update the expression data; and searching instruction data corresponding to the updated expression data in the expression instruction set, and obtaining an operation result of the expression data according to the instruction data.
The respective modules in the message card generating device described above may be implemented in whole or in part by software, hardware, or a combination thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, a computer device is provided, which may be a terminal, and the internal structure thereof may be as shown in fig. 12. The computer device includes a processor, a memory, an input/output interface, a communication interface, a display unit, and an input means. The processor, the memory and the input/output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input/output interface. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The input/output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used for carrying out wired or wireless communication with an external terminal, and the wireless mode can be realized through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. The computer program is executed by a processor to implement a message card generation method. The display unit of the computer equipment is used for forming a visual picture, and can be a display screen, a projection device or a virtual reality imaging device, wherein the display screen can be a liquid crystal display screen or an electronic ink display screen, the input device of the computer equipment can be a touch layer covered on the display screen, can also be a key, a track ball or a touch pad arranged on a shell of the computer equipment, and can also be an external keyboard, a touch pad or a mouse and the like.
It will be appreciated by those skilled in the art that the structure shown in FIG. 12 is merely a block diagram of some of the structures associated with the present inventive arrangements and is not limiting of the computer device to which the present inventive arrangements may be applied, and that a particular computer device may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
In an embodiment, there is also provided a computer device comprising a memory and a processor, the memory having stored therein a computer program, the processor implementing the steps of the method embodiments described above when the computer program is executed.
In one embodiment, a computer-readable storage medium is provided, storing a computer program which, when executed by a processor, implements the steps of the method embodiments described above.
In one embodiment, a computer program product or computer program is provided that includes computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps in the above-described method embodiments.
It should be noted that, the user information (including but not limited to user equipment information, user personal information, etc.) and the data (including but not limited to data for analysis, stored data, presented data, etc.) related to the present application are information and data authorized by the user or sufficiently authorized by each party, and the collection, use and processing of the related data need to comply with the related laws and regulations and standards of the related country and region.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (ReRAM), magnetic random access Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (Phase Change Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in the form of a variety of forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), and the like. The databases referred to in the embodiments provided herein may include at least one of a relational database and a non-relational database. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processor referred to in the embodiments provided in the present application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, or the like, but is not limited thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The foregoing examples illustrate only a few embodiments of the application and are described in detail herein without thereby limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of the application should be assessed as that of the appended claims.
Claims (13)
1. A method of generating a message card, the method comprising:
acquiring a message card generation request containing template specification information and business data;
obtaining a message template corresponding to the message card generation request based on the template specification information;
obtaining message data according to the message template and the service data;
identifying expression data in the message data, searching instruction data corresponding to the expression data in an expression instruction set, and obtaining an operation result of the expression data according to the instruction data, wherein the instruction data in the expression instruction set is generated based on nodes in abstract syntax trees of various expressions in traversal history data, the abstract syntax trees are constructed by performing lexical analysis and grammar analysis on various expressions in the history data, and the nodes in the abstract syntax trees represent operands or operators of the expression algorithm;
And rendering and generating a message card based on the message data and the operation result.
2. The method of claim 1, wherein obtaining a message template corresponding to the message card generation request based on the template specification information comprises:
when a template loading task corresponding to the template designating information is not found in a task queue, a interception task is registered in the created template loading task according to the template loading task corresponding to the template designating information, wherein the interception task is used for intercepting the downloading completion condition of the message template designated by the template designating information;
and obtaining a message template corresponding to the message card generation request based on the template loading task.
3. The method of claim 1, wherein obtaining a message template corresponding to the message card generation request based on the template specification information comprises:
when a template loading task corresponding to the template designating information is found in a task queue, registering a interception task in the template loading task corresponding to the template designating information, wherein the interception task is used for intercepting the downloading completion condition of the message template designated by the template designating information;
And when the completion of downloading the message template is detected based on the interception task, obtaining the message template corresponding to the message card generation request.
4. The method of claim 1, wherein obtaining message data from the message template and the traffic data comprises:
analyzing the message template to obtain a style description tree;
and obtaining message data according to the style description tree and the service data.
5. The method of claim 1, wherein the rendering the generated message card based on the message data and the operation result further comprises:
acquiring a template multiplexing request containing a template identifier;
searching a cache file based on the template identifier, wherein the cache file comprises at least one of view cache, node cache or file cache;
when the view cache corresponding to the template identifier is found, a rendering tree corresponding to the template multiplexing request is obtained through data operation processing;
when node caches corresponding to the template identifiers are found, a rendering tree corresponding to the template multiplexing request is obtained through node analysis processing and data operation processing;
When the file cache corresponding to the template identification is found, a rendering tree corresponding to the template multiplexing request is obtained through template full-quantity analysis processing;
when the view cache, the node cache and the file cache corresponding to the template identification are not searched, a rendering tree corresponding to the template multiplexing request is obtained through template loading processing and template full-quantity analysis processing;
and generating a message card corresponding to the template multiplexing request based on the rendering tree rendering.
6. The method according to claim 1, wherein the searching instruction data corresponding to the expression data in the expression instruction set, before obtaining the operation result of the expression data according to the instruction data, further comprises:
acquiring expression data in historical data;
performing lexical analysis processing on the expression data in the historical data to obtain word stream data;
carrying out grammar analysis processing on the word stream data to construct an abstract grammar tree;
traversing each node in the abstract syntax tree, and generating each instruction in the instruction data according to the traversing result.
7. The method of claim 1, wherein the deriving the result of the operation of the expression data from the instruction data comprises:
Performing field nulling processing on the instruction data, and identifying data to be optimized in the instruction data;
optimizing the instruction data based on the data to be optimized to obtain an optimized instruction;
and obtaining an operation result of the expression data according to the optimization instruction.
8. The method according to any one of claims 1 to 7, wherein the obtaining the operation result of the expression data from the instruction data includes:
identifying a highest frequency data field in the instruction data;
constructing a quick access instruction corresponding to the highest frequency data field;
updating the instruction data based on the quick access instruction;
and obtaining the operation result of the expression data through the updated instruction data.
9. The method according to any one of claims 1 to 7, wherein the identifying the expression data in the message data, searching the instruction data corresponding to the expression data in the expression instruction set, and obtaining the operation result of the expression data according to the instruction data includes:
recognizing constant expression nodes in the expression data, wherein the constant expression is a grammar node with constant operands;
Performing data operation processing on the constant expression nodes to obtain constant operation results;
replacing constant expression nodes in the expression data with the constant operation results corresponding to the constant expression nodes to update the expression data;
and searching the updated instruction data corresponding to the expression data in an expression instruction set, and obtaining an operation result of the expression data according to the instruction data.
10. A message card generating device, the device comprising:
the request acquisition module is used for acquiring a message card generation request containing template specification information and business data;
the template searching module is used for obtaining a message template corresponding to the message card generation request based on the template specification information;
the message analysis module is used for obtaining message data according to the message template and the service data;
the data operation module is used for identifying the expression data in the message data, searching the instruction data corresponding to the expression data in an expression instruction set, obtaining the operation result of the expression data according to the instruction data, wherein the instruction data in the expression instruction set is generated based on nodes in abstract syntax trees of various expressions in traversal history data, the abstract syntax trees are constructed by performing lexical analysis and grammar analysis on various expressions in the history data, and the nodes in the abstract syntax trees represent operands or operators of the expression operation rule;
And the message card generation module is used for rendering and generating a message card based on the message data and the operation result.
11. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any one of claims 1 to 9 when the computer program is executed.
12. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 9.
13. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any one of claims 1 to 9.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211008687.4A CN117010358A (en) | 2022-08-22 | 2022-08-22 | Message card generation method, device, computer equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211008687.4A CN117010358A (en) | 2022-08-22 | 2022-08-22 | Message card generation method, device, computer equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117010358A true CN117010358A (en) | 2023-11-07 |
Family
ID=88575037
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211008687.4A Pending CN117010358A (en) | 2022-08-22 | 2022-08-22 | Message card generation method, device, computer equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117010358A (en) |
-
2022
- 2022-08-22 CN CN202211008687.4A patent/CN117010358A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110291517B (en) | Query language interoperability in graph databases | |
US10366053B1 (en) | Consistent randomized record-level splitting of machine learning data | |
WO2021217846A1 (en) | Interface data processing method and apparatus, and computer device and storage medium | |
CN106648569B (en) | Target serialization realization method and device | |
CN111177113B (en) | Data migration method, device, computer equipment and storage medium | |
CN110764760B (en) | Method, apparatus, computer system, and medium for drawing program flow chart | |
CN109710220B (en) | Relational database query method, relational database query device, relational database query equipment and storage medium | |
CN110647316A (en) | Method and device for generating universal business object, computer equipment and storage medium | |
CN115599386A (en) | Code generation method, device, equipment and storage medium | |
CN115237805A (en) | Test case data preparation method and device | |
CN112970011A (en) | Recording pedigrees in query optimization | |
CN113760894A (en) | Data calling method and device, electronic equipment and storage medium | |
CN116450723A (en) | Data extraction method, device, computer equipment and storage medium | |
CN115809304A (en) | Method and device for analyzing field-level blood margin, computer equipment and storage medium | |
CN117010358A (en) | Message card generation method, device, computer equipment and storage medium | |
CN115114297A (en) | Data lightweight storage and search method and device, electronic equipment and storage medium | |
CN115080616A (en) | Dictionary data acquisition method and device, storage medium and electronic equipment | |
CN114186958A (en) | Method, computing device and storage medium for exporting list data as spreadsheet | |
US11256679B2 (en) | Systems and methods for storing object state on hash chains | |
CN113254455A (en) | Dynamic configuration method and device of database, computer equipment and storage medium | |
CN112347794A (en) | Data translation method, device, equipment and computer storage medium | |
CN112988778A (en) | Method and device for processing database query script | |
CN110908993A (en) | Method and device for analyzing reasonability of database index | |
CN117891531B (en) | System parameter configuration method, system, medium and electronic equipment for SAAS software | |
CN107169098A (en) | Data method for carrying, data handling device and electronic equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |