Structure tree construction method and apparatus, computer device, and computer-readable storage medium
By constructing a template structure tree and integrating SMS template fragments, the problem of low template creation efficiency in cloud SMS services is solved, enabling rapid matching and intelligent processing of SMS messages.
Patent Information
- Application Number
- CN202411751578.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-11-11
- Estimated Expiration
- 2044-12-02
AI Technical Summary
In cloud SMS services, enterprise users spend a lot of time and effort creating a large number of templates, resulting in low SMS sending efficiency.
By receiving uploaded SMS text messages, the template segments are determined and a template structure tree is constructed. By integrating SMS template fragments, the template structure tree can be quickly matched.
It improves SMS sending efficiency, reduces manual composing time and error rate, and enhances the intelligence and automation of SMS services.
Smart Images

Figure CN119647439B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, computer device, computer-readable storage medium, and computer program product for constructing a tree structure. Background Technology
[0002] With the development of cloud computing technology, cloud SMS services have emerged. Relying on cloud computing, these services offer global SMS coverage and support both regular and marketing SMS messages. The service supports personalized SMS templates to meet the needs of different user groups, reducing the time and error rate of manual composing while mitigating security risks.
[0003] Currently, cloud SMS services mostly send messages by customizing templates and passing parameters. For enterprise users, creating a large number of templates is time-consuming and laborious, resulting in low SMS sending efficiency. Summary of the Invention
[0004] Therefore, it is necessary to provide a method, apparatus, computer device, computer-readable storage medium, and computer program product for constructing a tree structure that can improve the efficiency of SMS sending, in order to address the above-mentioned technical problems.
[0005] Firstly, this application provides a structure tree construction method applied to an SMS service platform, the structure tree construction method comprising:
[0006] Receive SMS text messages uploaded to the SMS service platform;
[0007] Based on the SMS text, an SMS template containing multiple template segments is determined;
[0008] A template structure tree is determined based on the starting character of the SMS template. The template structure tree is used to integrate template fragments of each SMS template.
[0009] The multiple template segments are sequentially matched with nodes of existing paths in the template structure tree, and new paths of the template structure tree are constructed based on template segments that do not match corresponding nodes.
[0010] Secondly, this application provides a structure tree construction apparatus for use in an SMS service platform, the structure tree construction apparatus comprising:
[0011] The SMS receiving module is used to receive SMS text messages uploaded to the SMS service platform;
[0012] The template determination module is used to determine an SMS template containing multiple template segments based on the SMS text;
[0013] The structure tree determination module is used to determine the template structure tree based on the starting character of the SMS template. The template structure tree is used to integrate the template fragments of each SMS template.
[0014] The structure tree construction module is used to match the multiple template segments with the nodes of the existing paths in the template structure tree in sequence, and to construct new paths of the template structure tree based on the template segments that do not match the corresponding nodes.
[0015] Thirdly, this application provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement:
[0016] Receive SMS text messages uploaded to the SMS service platform;
[0017] Based on the SMS text, an SMS template containing multiple template segments is determined;
[0018] A template structure tree is determined based on the starting character of the SMS template. The template structure tree is used to integrate template fragments of each SMS template.
[0019] The multiple template segments are sequentially matched with nodes of existing paths in the template structure tree, and new paths of the template structure tree are constructed based on template segments that do not match corresponding nodes.
[0020] Fourthly, this application provides a computer-readable storage medium having a computer program stored thereon, which is implemented when executed by a processor:
[0021] Receive SMS text messages uploaded to the SMS service platform;
[0022] Based on the SMS text, an SMS template containing multiple template segments is determined;
[0023] A template structure tree is determined based on the starting character of the SMS template. The template structure tree is used to integrate template fragments of each SMS template.
[0024] The multiple template segments are sequentially matched with nodes of existing paths in the template structure tree, and new paths of the template structure tree are constructed based on template segments that do not match corresponding nodes.
[0025] Fifthly, this application provides a computer program product, including a computer program, which is implemented when executed by a processor:
[0026] Receive SMS text messages uploaded to the SMS service platform;
[0027] Based on the SMS text, an SMS template containing multiple template segments is determined;
[0028] A template structure tree is determined based on the starting character of the SMS template. The template structure tree is used to integrate template fragments of each SMS template.
[0029] The multiple template segments are sequentially matched with nodes of existing paths in the template structure tree, and new paths of the template structure tree are constructed based on template segments that do not match corresponding nodes.
[0030] The aforementioned structure tree construction method, apparatus, computer equipment, computer-readable storage medium, and computer program product are applied to an SMS service platform. They receive SMS text uploaded to the platform; determine an SMS template containing multiple template segments based on the SMS text; determine a template structure tree based on the starting character of the SMS template, whereby the template structure tree integrates template fragments from each SMS template; sequentially match the multiple template segments with nodes of existing paths in the template structure tree; and construct new paths for the template structure tree based on template segments that do not match corresponding nodes. This application automatically generates SMS templates from SMS text uploaded to the SMS service platform and integrates these templates into a template structure tree. The integrated template structure tree enables rapid matching of SMS templates, thereby improving SMS sending efficiency. Attached Figure Description
[0031] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0032] Figure 1 This is an application environment diagram of the structure tree construction method in one embodiment;
[0033] Figure 2 This is a flowchart illustrating a method for constructing a structure tree in one embodiment;
[0034] Figure 3 This is a schematic diagram of the storage structure of the template tree structure in one embodiment;
[0035] Figure 4 This is a schematic diagram illustrating the creation process of a template structure tree in one embodiment;
[0036] Figure 5 This is a schematic diagram of the template structure tree matching process in one embodiment;
[0037] Figure 6 This is a flowchart illustrating the structure tree construction method in another embodiment;
[0038] Figure 7This is a structural block diagram of a structure tree construction device in one embodiment;
[0039] Figure 8 This is a structural block diagram of the structure tree construction device in another embodiment;
[0040] Figure 9 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0041] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to be used in the overall description of this application. The use of terms like "first" and "second" is merely for distinguishing technical features and should not be construed as indicating or implying relative importance, the number of indicated technical features, or the sequential relationship between indicated technical features.
[0042] In the description of this application, unless otherwise expressly defined, terms such as "setup," "installation," and "connection" should be interpreted broadly, and those skilled in the art can reasonably determine the specific meaning of the above terms in this application in conjunction with the specific content of the technical solution.
[0043] Please see Figure 1 , Figure 1 This is an application environment diagram of the structure tree construction method in one embodiment. The structure tree construction method provided in this application embodiment can be applied to, for example... Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104, or it can be located in the cloud or on another server.
[0044] The terminal 102 can be a smartphone, tablet, laptop, desktop computer, smart speaker, smartwatch, IoT device, or portable wearable device. IoT devices can include smart speakers, smart TVs, smart air conditioners, and smart in-vehicle devices, etc. Portable wearable devices can include smartwatches, smart bracelets, and head-mounted devices, etc.
[0045] Server 104 can be a standalone physical server or a service node in a blockchain system. These service nodes form a peer-to-peer (P2P) network. The P2P protocol is an application layer protocol running on top of the Transmission Control Protocol (TCP). Furthermore, server 104 can also be a server cluster composed of multiple physical servers, and can be a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.
[0046] Terminal 102 and server 104 can be connected via Bluetooth, USB (Universal Serial Bus) or network, etc., and this application does not impose any restrictions.
[0047] A text messaging service platform can be deployed on server 104 to provide cloud text messaging services. Server 104 can execute the structure tree construction method of this application. For example, the server receives text messages uploaded to the text messaging service platform. The server determines a text message template containing multiple template segments based on the text message. The server determines a template structure tree based on the starting character of the text message template, and the template structure tree is used to integrate the template fragments of each text message template. The server sequentially matches the multiple template segments with the nodes of the existing paths in the template structure tree, and constructs a new path for the template structure tree based on the template segments that do not match the corresponding nodes.
[0048] Please refer to 2. Figure 2 This is a flowchart illustrating a structure tree construction method in one embodiment. In one embodiment, such as... Figure 2 As shown, a structure tree construction method is provided, which is applied to an SMS service platform and includes the following steps S202 to S208:
[0049] Step S202: Receive the SMS text uploaded to the SMS service platform.
[0050] The SMS service platform is a comprehensive system integrating SMS sending and receiving functions. It connects to the SMS channels of telecommunications operators via internet technology, providing users with convenient SMS communication services. The platform supports not only sending regular SMS messages but also various other types, such as verification code SMS messages and marketing SMS messages, to meet the needs of different users. Users can send, receive, and manage SMS messages through API interfaces or web interfaces.
[0051] Enterprise users can register and create accounts on the SMS service platform. After completing the necessary authentication process, they can design and upload personalized SMS templates based on their business needs. These templates can cover various types, including verification codes, notifications, and marketing messages, to meet the communication needs of enterprises in different scenarios. Enterprise users can also set their own SMS signatures on the platform.
[0052] When enterprise users need to send SMS messages, they can do so through the API interface or web interface provided by the SMS service platform. For example, the API interface can be used to integrate the SMS sending function into the user's own business system to automate the SMS sending process, while the web interface provides a more intuitive operation method, allowing enterprise users to send SMS messages manually or in batches.
[0053] Based on the structure tree construction method provided in this application, when a user wants to send an SMS message or create a new SMS template, they can upload the SMS text to the SMS service platform. For example, they can write the SMS content in the input box or editing interface provided by the platform, or select a previously created and saved SMS template and fill in the corresponding parameters.
[0054] The SMS service platform receives SMS text uploaded by users and performs subsequent operations based on the uploaded text. For example, it automatically generates and stores a corresponding SMS template based on the SMS text. When the user sends an SMS with the same format again, the corresponding SMS template can be matched. Furthermore, the SMS template can be constructed into a template structure tree based on the structure tree construction method provided in this application to achieve fast matching.
[0055] Step S204: Determine the SMS template containing multiple template segments based on the SMS text.
[0056] Template segments are independent text fragments contained within an SMS template, which can be divided from the SMS template. For example, by combining language processing techniques such as semantic segmentation, entity recognition, and keyword matching, the text of an SMS template containing variables can be segmented into multiple independent text fragments according to content or structure, resulting in multiple template segments.
[0057] For example, variables can be identified from an SMS template using named entity recognition. Parameterized placeholders can be set for each variable, and the corresponding variable positions in the SMS text can be replaced with these placeholders to obtain the SMS template. Based on the positions of the parameterized placeholders in the SMS template, multiple template segments can be obtained. For instance, the text between the starting character of the SMS template and the first parameterized placeholder can be used as the first template segment, the text between the first and second parameterized placeholders can be used as the second template segment, and so on.
[0058] Understandably, SMS text, as the text corresponding to an SMS template, can be obtained by replacing parameters in the SMS template. Therefore, in some cases, template fragments can also be segmented from the SMS text. For example, variables can be identified from the SMS text based on named entity recognition, and after removing the variables from the SMS text, the remaining SMS text can be segmented into template segments.
[0059] In one embodiment, after determining an SMS template containing multiple template segments based on the SMS text, the determined SMS template can be saved in the SMS service platform. Subsequently, users can upload a parameter set based on this SMS template to achieve unified sending of a large number of SMS messages.
[0060] Optionally, after identifying an SMS template containing multiple template segments based on the SMS text, the review process for that SMS template can be automatically initiated. This brings the review process forward, so if a user subsequently matches the SMS template, they do not need to review it again; if the match is successful, the SMS can be sent directly, thereby speeding up SMS delivery efficiency.
[0061] Optionally, the subsequent steps S206 and S208 can be carried out after the approval.
[0062] Step S206: Determine the template structure tree based on the starting character of the SMS template.
[0063] The template structure tree is used to integrate template fragments from various SMS templates.
[0064] The starting character of an SMS template refers to the character at the beginning of the text in the SMS template that marks the start of the template. The starting character can be a single character or multiple characters. For example, the starting character can be the first character, which is the first letter or symbol at the beginning of the SMS template.
[0065] In different programming languages, the number of bytes corresponding to the same starting character may differ. Taking the first character of a Chinese character as an example, in the Go programming language, the starting character refers to the first three bytes of the SMS template text, while in other programming languages, it may refer to the first two bytes.
[0066] A template tree structure is a hierarchical data structure used to integrate various SMS templates. It consists of nodes and edges connecting the nodes. Each node can have zero or more child nodes, used to represent the hierarchical or containment relationships between data, such as binary trees, B-trees, etc.
[0067] Taking a binary tree as an example, it can include leaf nodes, non-leaf nodes, sibling nodes, child nodes, and parent nodes. The descriptions of each node are shown in Table 1:
[0068] Table 1
[0069]
[0070] Non-leaf nodes can be used to store information about template segments, with one non-leaf node storing information for one template segment. For example, a non-leaf node may contain an `index` field to record the start and end positions of the template segment in the original SMS text or SMS template; a `hash` field to record the hash value of the template segment for fast matching of segmented text; a `left` pointer to point to the child nodes of the non-leaf node; and a `right` pointer to point to the parent node of the non-leaf node.
[0071] Leaf nodes can be used to store the template ID of the SMS template in the database, and the corresponding SMS template can be found based on the template ID.
[0072] Each template structure tree is built based on the starting character. SMS templates with the same starting character can be integrated into the same template structure tree, while different starting characters correspond to different template structure trees. Therefore, the template structure tree can be determined based on the starting character.
[0073] It should be noted that determining the template structure tree based on the starting character of the SMS template includes matching the corresponding template structure tree from existing template structure trees based on the starting character of the SMS template, as well as creating a new template structure tree. For example, the starting character of the SMS template is matched with each template structure tree. If a match is successful, the matched template structure tree is used as the template structure tree corresponding to the starting character; if a match fails, a new template structure tree is created based on the starting character.
[0074] Step S208: Match multiple template segments with nodes of existing paths in the template structure tree in sequence, and construct new paths of the template structure tree based on template segments that do not match corresponding nodes.
[0075] The existing path refers to the path formed by nodes that already exist in the template structure tree. The existing path starts from the root node, follows the branching structure of the tree, and extends to a specific node. Based on the depth of each node in the template structure tree, the nodes can be divided into the root node (Node0), first-level child nodes (Node1), second-level child nodes (Node2), and so on. The root node is the starting node of the template structure tree, first-level child nodes are children of the root node, second-level child nodes are children of the first-level child nodes, and so on.
[0076] Multiple template segments are matched sequentially with nodes of the existing path in the template structure tree, including matching each template segment sequentially with child nodes at different levels according to the position of each template segment in the SMS template.
[0077] Optionally, the hash values of the template segment and the node can be obtained separately. If the hash values are the same, the match is successful, and the template segment has matched the corresponding node; if the hash values are different, the match fails, and the template segment has not matched the corresponding node.
[0078] Since each level may have multiple child nodes, when matching each template segment sequentially with child nodes of different levels, the next matching object can be determined based on the matching result of the previous template segment, such as entering the child node or sibling node of the N-level child node. Entering the child node or sibling node of the N-level child node can be achieved using the left or right pointer built into the N-level child node.
[0079] For a template segment that matches the corresponding node, you can continue to match the next template segment; for a template segment that does not match the corresponding node, it means that there is no complete path in the template structure tree that matches the SMS template, and you need to start from the template segment that has not matched the corresponding node and build a new path in the template structure tree.
[0080] For example, the Nth template segment is matched with an Nth-level child node in the template structure tree. If the match is successful, the (N+1)th template segment is matched with the child nodes (i.e., N+1th-level child nodes) of that Nth-level child node. If the match fails, the Nth template segment is matched with the sibling node (i.e., another Nth-level child node) of that Nth-level child node. If the Nth template segment fails to match with any Nth-level child node in the template structure tree, a new empty Nth-level child node is added, and the template segment is filled into the newly added Nth-level child node. Starting from the newly added Nth-level child node, a new path in the template structure tree is constructed, and the template segments following the Nth template segment are sequentially filled into the N+1th-level child nodes, N+2th-level child nodes, and so on, under that Nth-level child node.
[0081] In the aforementioned structure tree construction method, the following steps are taken: receiving SMS text uploaded to the SMS service platform; determining an SMS template containing multiple template segments based on the SMS text; determining a template structure tree based on the starting character of the SMS template, which is used to integrate template fragments from various SMS templates; sequentially matching multiple template segments with nodes of existing paths in the template structure tree; and constructing new paths for the template structure tree based on template segments that do not match corresponding nodes. This application automatically generates SMS templates from the SMS text uploaded to the SMS service platform and integrates these SMS templates into a template structure tree. The integrated template structure tree enables rapid matching of SMS templates, thereby improving SMS sending efficiency.
[0082] In one embodiment, determining an SMS template containing multiple template segments based on the SMS text includes:
[0083] The parameter entities are identified from the SMS text; the parameter entities in the SMS text are replaced with the corresponding template parameters to obtain the SMS template corresponding to the SMS text; based on the position of each template parameter in the SMS template, the SMS template is divided into multiple template fragments.
[0084] A parameter entity is a variable, representing a part of the SMS text that can change or be replaced. For example, in the SMS text "Dear Mr. Li, your account was charged 500 yuan on June 28, 2024," "Mr. Li," "June 28, 2024," and "500 yuan" are all parameter instances. Specifically, the parameter instance "Mr. Li" is an instance of the parameter entity "Customer Name," the parameter instance "June 28, 2024" is an instance of the parameter entity "Date," and the parameter instance "500 yuan" is an instance of the parameter entity "Amount."
[0085] Optionally, parameter entities can be identified from SMS text using named entity recognition (NER) technology, which includes: predefining entity categories for parameter entities, using named entity recognition technology to identify parameter entities from SMS text based on the predefined entity categories, and classifying the identified parameter entities into the corresponding entity categories.
[0086] After identifying the parameter entities in the SMS text, the parameter entities are replaced with the corresponding template parameters to obtain the SMS template corresponding to the SMS text. The template parameters corresponding to the parameter entities can be parameterized placeholders. For example, taking the SMS text "Dear Mr. Li, your account made a purchase of 500 yuan on June 28, 2024." as an example, if we use {} to identify the parameter entities, we can identify the parameter entities {customer name}, {date}, and {amount} from the SMS text. Replacing the customer name, date, and amount in the SMS text with the corresponding template parameters yields the SMS template "Dear {customer name}, your account made a purchase of {amount} yuan on {date}."
[0087] After obtaining the SMS template, based on the position of each template parameter within the template, the SMS template can be divided into multiple template fragments. For example, the above SMS template can be divided into four template fragments: "Dear," "Your account is," "Consumption," and "Yuan." These fragments can then be used for node matching within the existing path of the template tree, as well as for constructing new paths in the template tree based on template fragments that do not match corresponding nodes.
[0088] Optionally, before identifying parameter entities from SMS text, the SMS text can be preprocessed, including word segmentation and annotation, and then the parameter entities can be identified more accurately from the preprocessed SMS text.
[0089] In one embodiment, the SMS service platform stores a first mapping relationship and a second mapping relationship. The first mapping relationship is a mapping between SMS length and the second mapping relationship, as shown in Table 2.
[0090] Table 2
[0091]
[0092] The second mapping relationship is the mapping relationship between the starting character of the SMS template and the template structure tree, please refer to Table 3.
[0093] Table 3
[0094]
[0095] Please see Figure 3 The template structure tree can also contain a two-level map to store the two-level mapping relationship. The first-level map, also called LenMap, stores the first mapping relationship between the SMS length and the second mapping relationship. The second-level map, also called HeadMap, stores the second mapping relationship between the starting character of the SMS template and the template structure tree. Each non-leaf node can contain an index field, a hash field, a left pointer, and a right pointer.
[0096] In one embodiment, determining the template structure tree based on the starting character of the SMS template includes:
[0097] Get the SMS length of the SMS template; find the second mapping relationship that matches the SMS length based on the first mapping relationship; if the second mapping relationship that matches the SMS length is found, get the starting character of the SMS template, and determine the template structure tree that matches the starting character based on the second mapping relationship.
[0098] If no second mapping relationship matching the SMS length is found, a template structure tree is created, and a target second mapping relationship between the template structure tree and the starting character is established; a target second mapping relationship between the target second mapping relationship and the SMS length is established.
[0099] In one embodiment, multiple template segments are sequentially matched with nodes of existing paths in the template structure tree. Constructing new paths for the template structure tree based on template segments that do not match corresponding nodes includes:
[0100] Enter the child nodes of the root node in the template structure tree; determine the current template segment to be matched, and whether the entered child node is an empty node; if the child node is an empty node, fill the child node with the template segment to be matched; if the child node is not an empty node, match the template segment to be matched with the child node, and enter the child node or sibling node of the child node based on the matching result; based on the entered child node or sibling node, return to execute the steps of determining the current template segment to be matched and determining whether the entered child node is an empty node, and subsequent steps, until all template segments that have not been matched with the corresponding node are filled into the empty nodes of the template structure tree, forming a new path in the template structure tree.
[0101] When matching multiple template segments with nodes of the existing path in the template structure tree, the process starts from the root node of the template structure tree and gradually moves down to each level of child nodes until all template segments are properly placed.
[0102] If a child node is empty, it means that the child node has not yet been occupied by any template segment. For example, the child node may be an empty node created during initialization or a newly created empty node during the matching process. If a child node is not empty, it means that it already contains some data or template segments. For empty nodes, the template segments to be matched can be filled in. For non-empty nodes, the template segments to be matched need to be further matched with the child nodes, the path is adjusted according to the matching results, and the above steps continue.
[0103] When adjusting the path based on the matching results, the template to be matched is segmented and matched with child nodes. Based on the matching results, the child nodes or sibling nodes of the child nodes include:
[0104] Get the template hash value of the template segment to be matched, and get the node hash value of the child node; match the child node with the template segment to be matched based on the template hash value and the node hash value; if the template hash value and the node hash value are the same, the matching result is determined to be a successful match, and the child node is entered; if the template hash value and the node hash value are different, the matching result is determined to be a failed match, and the child node is entered as a sibling node.
[0105] A hash value is a numerical value generated based on information through specific logical operations (i.e., a hash algorithm). For different input information, its hash value is usually unique. Even a small change in the information can result in a significant change in the hash value. Therefore, the consistency between the hash values of a template fragment and its child nodes can be verified by comparing them, achieving accurate and fast matching. For the template fragment and its child nodes to be matched, the template hash value and node hash value are obtained respectively. Based on the template hash value and the node hash value, the child nodes are matched against segments of the template to be matched. If the template hash value and the node hash value are the same, the matching result is considered successful; if the template hash value and the node hash value are different, the matching result is considered unsuccessful.
[0106] When adjusting the path based on the matching results, different handling is applied to successful and unsuccessful matches. Please refer to the following: Figure 3 and Figure 4 If the template fragment to be matched has the same hash value as its child node Node1, the match is successful. The left pointer in Node1 is used to enter Node2, a child node of Node1, and the current template fragment to be matched is updated, such as setting the next template fragment to be matched. If the template fragment to be matched has a different hash value than its child node Node1, the match fails. The right pointer in Node1 is used to enter another sibling node of Node1, without updating the current template fragment, and the matching process continues with this other Node1. If the template fragment to be matched successfully matches another Node1, the current template fragment is updated, and the process moves to the other Node1's child node Node2. If the template fragment to be matched fails to match another Node1, the current template fragment is not updated, and the matching process continues with the next Node1. This continues until all nodes NodeN at a certain level fail to match. Then, a new empty NodeN is added, and the latest template fragment to be matched is filled into the newly added NodeN. Starting from the newly added NodeN, construct a new path for the template structure tree, and sequentially fill the template segments following the segment to be matched into NodeN+1, NodeN+2, etc. under this Node1N.
[0107] The process continues until the template fragment to be matched is the last template fragment in the SMS template. A leaf node is created as the left child node (the child node pointed to by the left pointer) on the child node corresponding to the previous template fragment of that last template fragment. The last template fragment is then filled into this leaf node. A mapping between the SMS template's template ID and this leaf node is established and saved so that the corresponding SMS template can be directly called based on the matched leaf node later.
[0108] In one embodiment, the method further includes:
[0109] Receive the SMS message to be sent uploaded to the SMS service platform; based on the starting character of the SMS message to be sent, search for the target template structure tree corresponding to the starting character; if the corresponding target template structure tree is found, and the complete path of the target template structure tree is matched based on the SMS message to be sent, then call the SMS service platform to send the SMS message to be sent; otherwise, treat the SMS message to be sent as the SMS text, and execute the steps of determining the SMS template containing multiple template segments based on the SMS text and subsequent steps.
[0110] In the SMS service platform to which the structure tree construction method provided in this application embodiment is applied, users can not only use the SMS service platform to automatically generate SMS templates and construct template structure trees, but also, based on the pre-approval of SMS templates and template structure trees, achieve direct sending of SMS messages without approval when sending them automatically.
[0111] This process is achieved through matching template structure trees. Users upload the text message to be sent to the SMS service platform. The platform matches the message with various template structure trees. If a match is found in the target structure tree and a complete path is found within the target template structure tree, it means the platform has previously received a text message with the same template uploaded by the user and constructed a new path in the template structure tree based on that uploaded message, integrating the corresponding text message template into the structure tree. If the corresponding text message template and its structure tree have already been approved, the message can be directly approved, allowing the user to send the message through the platform, thus accelerating the sending efficiency.
[0112] Please see Figure 5 , Figure 5 This is a schematic diagram of the matching process of the template structure tree provided in this application embodiment. The process of finding the target template structure tree corresponding to the starting character of the SMS message to be sent includes: obtaining the length of the SMS message to be sent; finding a second mapping relationship that matches the length of the SMS message to be sent based on a first mapping relationship; if a second mapping relationship matching the SMS length is found, obtaining the starting character of the SMS message to be sent (e.g., the first three bytes), and determining the target template structure tree matching the starting character based on the second mapping relationship; if no second mapping relationship matching the length of the SMS message to be sent is found, the matching is determined to have failed.
[0113] If a corresponding target template structure tree is found, the system matches the SMS message to be sent with the existing path in the target template structure tree to determine if a complete path of the target template structure tree can be matched. This includes: extracting SMS fragments from the SMS text based on the nodes of the target template structure tree, and comparing the SMS fragments with the template segment information in the nodes. Extracting SMS fragments from the SMS text based on the nodes of the target template structure tree includes extracting SMS fragments from the SMS text based on the index field contained in the nodes of the target template structure tree, and comparing the SMS fragments with the template segment information in the nodes includes comparing the hash value of the SMS fragments with the hash value of the template segments in the nodes.
[0114] For example, the `index1` field of the first Node1 in the target template structure tree is retrieved. Based on the `index1` field, the first SMS fragment is extracted from the SMS text. The hash value of the first SMS fragment is compared with that of the first Node1 to determine the matching result. If the hash values are the same, the matching result is considered successful, and the process moves to Node2, a child node of the first Node1. Based on the `index2` field of Node2, the second SMS fragment is extracted from the SMS text, and then matched with Node2 based on the hash value of the second SMS fragment. If the hash values are different, the matching result is considered unsuccessful, and the process moves to a sibling node of the first Node1, such as the second Node1. Based on the `index1` field of the second Node1, the first SMS fragment is extracted from the SMS text again, and then matched with the second Node1 based on the hash value of the first SMS fragment. This process continues until a match is successful or unsuccessful. As long as the currently matched child node is not a leaf node, the process moves to the child or sibling node of the current child node based on the comparison result, and the matching is repeated based on the newly entered node until a match is successful or unsuccessful. Before entering a sibling node, it checks if there are any unmatched sibling nodes and selects an unmatched sibling node to proceed. If there are no unmatched sibling nodes, it means that all sibling nodes at the same level have failed to match, indicating that the SMS message to be sent has not matched the complete path of the target template structure tree.
[0115] When the child node being matched is a leaf node, the matching result with the leaf node determines whether the SMS message to be sent matches the SMS template corresponding to the leaf node, and thus determines whether the SMS message to be sent matches the complete path of the target template structure tree. If the SMS message fragment matches the leaf node successfully, it means that the SMS message to be sent matches the SMS template corresponding to the leaf node, and the complete path of the SMS message to be sent matching the target template structure tree can be determined; if the SMS message fragment fails to match the leaf node, it means that the SMS message to be sent does not match the SMS template corresponding to the leaf node, and the complete path of the SMS message to be sent matching the target template structure tree can be determined.
[0116] For SMS messages to be sent that match a complete path, the SMS service platform is invoked to send the SMS message directly; for SMS messages to be sent that do not match a complete path, the SMS message to be sent is used as the SMS text, and the steps of determining the SMS template containing multiple template segments based on the SMS text and subsequent steps are performed, namely, generating the SMS template of the SMS message to be sent based on the structure tree creation method provided in the embodiments of this application and integrating the SMS template into the template structure tree.
[0117] In the above embodiments, when matching SMS messages, the template is first initially filtered based on the length and starting character, and then template matching is performed based on the template structure tree, which greatly improves the efficiency of sending SMS messages and ensures the timeliness of SMS messages; at the same time, it provides a technical foundation for a more efficient and intelligent cloud SMS service platform.
[0118] This application also provides a specific embodiment, please refer to [link / reference]. Figure 6 The specific implementation of this structure tree construction method is as follows:
[0119] (1) Structure tree construction
[0120] S1. Receive SMS text uploaded to the SMS service platform.
[0121] S2. Identify parameter entities from SMS text.
[0122] S3. Replace the parameter entities in the SMS text with the corresponding template parameters to obtain the SMS template corresponding to the SMS text.
[0123] S4. Based on the position of each template parameter in the SMS template, divide the SMS template into multiple template fragments.
[0124] S5. Get the SMS length of the SMS template.
[0125] S6. Based on the first mapping relationship, find the second mapping relationship that matches the SMS length. If no match is found, proceed to step S7; if a match is found, proceed to step S9.
[0126] S7. Create a template structure tree and establish a second target mapping relationship between the template structure tree and the starting character.
[0127] S8. Establish the second mapping relationship between the target and the first mapping relationship between the SMS length.
[0128] S9. Obtain the starting character of the SMS template and determine the template structure tree that matches the starting character based on the second mapping relationship.
[0129] S10, Enter the child node of the root node of the template structure tree.
[0130] S11. Determine the current template segment to be matched, and determine whether the incoming child node is an empty node. If yes, proceed to step S12; otherwise, proceed to step S13.
[0131] S12. Fill the child nodes with segments of the template to be matched.
[0132] S13. Obtain the template hash value of the template fragment to be matched, and obtain the node hash value of the child node.
[0133] S14. Match the child nodes with the template segments to be matched based on the template hash value and the node hash value. If the template hash value and the node hash value are the same, proceed to step S15; if the template hash value and the node hash value are different, proceed to step S6.
[0134] S15. Confirm the matching result as a successful match and proceed to the child node of the child node.
[0135] S16. If the matching result is determined to be a match failure, proceed to the sibling node of the child node.
[0136] S17. Based on the entered child or sibling node, return to the steps of determining the current template segment to be matched and determining whether the entered child node is an empty node, and follow-up steps, until all template segments that have not matched the corresponding node are filled into the empty nodes of the template structure tree, forming a new path of the template structure tree.
[0137] (2) Structure tree matching
[0138] S18. Receive SMS messages to be sent that have been uploaded to the SMS service platform.
[0139] S19. Based on the starting character of the SMS message to be sent, search for the target template structure tree corresponding to the starting character. If found, proceed to step S20; otherwise, proceed to step S21.
[0140] S20. Match the complete path of the target template structure tree based on the SMS message to be sent. If the match is successful, proceed to step S21; otherwise, proceed to step S22.
[0141] S21. Once a matching SMS template is found, call the SMS service platform to send the SMS to be sent.
[0142] S22. Confirmed that no matching SMS template was found.
[0143] S23. Treat the text message to be sent as the text message text and execute the steps in (1) structure tree construction.
[0144] The above embodiments provide a fast channel for sending SMS messages. It can intelligently generate SMS templates and simultaneously establish a rapid SMS index. Subsequent sending of SMS messages with the same template can proceed directly without replacing template parameters, thanks to intelligent matching. For SMS messages that fail to send, SMS templates can be intelligently and automatically added. This significantly improves the intelligence and automation of the cloud SMS platform, increases SMS sending speed, and ensures the timeliness of SMS messages.
[0145] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0146] Based on the same inventive concept, this application also provides a structure tree construction apparatus for implementing the structure tree construction method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more embodiments of the structure tree construction apparatus provided below can be found in the limitations of the structure tree construction method described above, and will not be repeated here.
[0147] In one embodiment, such as Figure 7 As shown, a structure tree construction device is provided, applied to an SMS service platform. The device includes: an SMS receiving module 701, a template determining module 702, a structure tree determining module 703, and a structure tree construction module 704, wherein:
[0148] SMS receiving module 701 is used to receive SMS text uploaded to the SMS service platform;
[0149] The template determination module 702 is used to determine an SMS template containing multiple template segments based on the SMS text.
[0150] The structure tree determination module 703 is used to determine the template structure tree based on the starting character of the SMS template. The template structure tree is used to integrate the template fragments of each SMS template.
[0151] The structure tree construction module 704 is used to match multiple template segments with the nodes of the existing path in the template structure tree in sequence, and to construct a new path of the template structure tree based on the template segments that do not match the corresponding nodes.
[0152] In one embodiment, when determining an SMS template containing multiple template segments based on the SMS text, the template determination module 702 is further configured to:
[0153] Identify parameter entities from SMS text;
[0154] Replace the parameter entities in the SMS text with the corresponding template parameters to obtain the SMS template corresponding to the SMS text.
[0155] Based on the position of each template parameter in the SMS template, the SMS template is divided into multiple template segments.
[0156] In one embodiment, the SMS service platform stores a first mapping relationship and a second mapping relationship, wherein the first mapping relationship is a mapping relationship between the SMS length and the second mapping relationship, and the second mapping relationship is a mapping relationship between the starting character of the SMS template and the template structure tree.
[0157] When determining the template structure tree based on the starting character of the SMS template, the structure tree determination module 703 is also used for:
[0158] Get the length of the SMS template;
[0159] Based on the first mapping relationship, find the second mapping relationship that matches the SMS length;
[0160] If a second mapping relationship matching the SMS length is found, the starting character of the SMS template is obtained, and the template structure tree matching the starting character is determined based on the second mapping relationship.
[0161] In one embodiment, when sequentially matching multiple template segments with nodes of existing paths in the template structure tree, and constructing new paths for the template structure tree based on template segments that do not match corresponding nodes, the structure tree construction module 704 is further configured to:
[0162] Enter the child node of the root node in the template structure tree;
[0163] Determine the current template segment to be matched, and determine whether the incoming child node is an empty node;
[0164] If the child node is an empty node, then the template to be matched will be segmented and filled into the child node;
[0165] If the child node is not empty, the template to be matched is segmented and matched with the child node, and the matching result is used to enter the child node or sibling node of the child node.
[0166] Based on the child or sibling node that is entered, return to the steps of determining the current template segment to be matched, and determining whether the entered child node is an empty node, and follow-up steps, until all template segments that have not matched the corresponding node are filled into the empty nodes of the template structure tree, forming a new path of the template structure tree.
[0167] In one embodiment, when matching the template segments to be matched with child nodes, and entering the child nodes or sibling nodes of the child nodes based on the matching results, the structure tree construction module 704 is further used for:
[0168] Get the template hash value of the template segment to be matched, and get the node hash value of the child nodes;
[0169] The child nodes are matched with the template segments to be matched based on the template hash value and the node hash value;
[0170] If the template hash value is the same as the node hash value, the matching result is determined to be successful, and the node proceeds to the child node of the child node;
[0171] If the template hash value is different from the node hash value, the matching result is determined to be a failure, and the process proceeds to the sibling node of the child node.
[0172] Please continue reading. Figure 8 In one embodiment, the structure tree construction apparatus further includes a structure tree matching module 705, for:
[0173] Receive SMS messages to be sent uploaded to the SMS service platform;
[0174] Based on the starting character of the SMS message to be sent, find the target template structure tree corresponding to the starting character;
[0175] If the corresponding target template structure tree is found, and the complete path of the target template structure tree is matched based on the SMS to be sent, then the SMS service platform is called to send the SMS to be sent.
[0176] Otherwise, the SMS to be sent is treated as the SMS text, and the steps of determining the SMS template containing multiple template segments based on the SMS text and subsequent steps are performed.
[0177] The aforementioned structure tree construction device is applied to an SMS service platform. The SMS receiving module 701 receives SMS text uploaded to the platform; the template determination module 702 determines an SMS template containing multiple template segments based on the SMS text; the structure tree determination module 703 determines a template structure tree based on the starting character of the SMS template, and this structure tree is used to integrate template fragments from various SMS templates; the structure tree construction module 704 sequentially matches the multiple template segments with nodes of existing paths in the template structure tree, constructing new paths for the template structure tree based on template segments that do not match corresponding nodes. This application automatically generates SMS templates from the SMS text uploaded to the SMS service platform and integrates these templates into a template structure tree. The integrated template structure tree enables rapid matching of SMS templates, thereby improving SMS sending efficiency.
[0178] Each module in the aforementioned structure tree construction device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.
[0179] Terms such as “component,” “module,” and “system” are intended to refer to computer-related entities, which can be hardware, a combination of hardware and software, software, or software in execution. For example, a component can be, but is not limited to, a process running on a processor, a processor, an object, executable code, a thread of execution, a program, and / or a computer. For illustration, a running program on a server and the server itself can both be components. One or more components may reside within a process and / or a thread of execution, and components may be located within a single computer and / or distributed across two or more computers.
[0180] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 9As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes a non-volatile computer-readable storage medium and internal memory. The non-volatile computer-readable storage medium stores the operating system, computer-readable instructions, and a database. The internal memory provides an environment for the operation of the operating system and computer-readable instructions stored in the non-volatile computer-readable storage medium. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer-readable instructions are executed by the processor, they implement a structure tree construction method.
[0181] Those skilled in the art will understand that Figure 9 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0182] In one embodiment, a computer device is also provided, including a memory and a processor, the memory storing computer-readable instructions, the processor executing the computer-readable instructions to implement the steps in the above method embodiments.
[0183] In one embodiment, a computer-readable storage medium is provided storing computer-readable instructions that, when executed by a processor, implement the steps in the above method embodiments.
[0184] In one embodiment, a computer program product is provided, the computer program product including computer-readable instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer-readable instructions from the computer-readable storage medium, and executes the computer-readable instructions, causing the computer device to perform the steps in the above-described method embodiments.
[0185] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by instructing related hardware through computer-readable instructions. These computer-readable instructions can be stored in a non-volatile computer-readable storage medium. When executed, these computer-readable instructions can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0186] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0187] The above embodiments are merely illustrative of several implementation methods of this application, and their descriptions are relatively specific and detailed. However, they should not be construed as limiting the scope of this application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method for constructing a tree structure, characterized in that, The structure tree construction method, applied to an SMS service platform, includes: Receive SMS text messages uploaded to the SMS service platform; Determining a text message template containing multiple template segments based on the text message includes: identifying parameter entities from the text message; replacing the parameter entities in the text message with corresponding template parameters to obtain the text message template corresponding to the text message; and dividing the text message template into multiple template segments based on the position of each template parameter in the text message template. A template structure tree is determined based on the starting character of the SMS template. The template structure tree is used to integrate template fragments of each SMS template. Enter the child node of the root node of the template structure tree; Determine the current template segment to be matched, and determine whether the incoming child node is an empty node; If the child node is an empty node, then the template to be matched is segmented and filled into the child node; If the child node is a non-empty node, the template to be matched is segmented and matched with the child node, and the child node or sibling node of the child node is entered based on the matching result. Based on the child or sibling node that is entered, return to the steps of determining the current template segment to be matched and determining whether the entered child node is an empty node, and subsequent steps, until all template segments that have not matched the corresponding node are filled into the empty nodes of the template structure tree, forming a new path of the template structure tree.
2. The method according to claim 1, characterized in that, The SMS service platform stores a first mapping relationship and a second mapping relationship, wherein the first mapping relationship is the mapping relationship between SMS length and the second mapping relationship, and the second mapping relationship is the mapping relationship between the starting character of the SMS template and the template structure tree. The process of determining the template structure tree based on the starting character of the SMS template includes: Obtain the length of the SMS message from the given SMS template; Based on the first mapping relationship, find the second mapping relationship that matches the length of the SMS message; If a second mapping relationship matching the length of the SMS message is found, the starting character of the SMS message template is obtained, and a template structure tree matching the starting character is determined based on the second mapping relationship.
3. The method according to claim 1, characterized in that, The step of segmenting the template to be matched and matching it with the child node, and then entering the child node or sibling node of the child node based on the matching result, includes: Obtain the template hash value of the template segment to be matched, and obtain the node hash value of the child node; The child nodes are matched with the template to be matched segment by segment based on the template hash value and the node hash value; If the template hash value is the same as the node hash value, the matching result is determined to be a successful match, and the process proceeds to the child node of the child node. If the template hash value is different from the node hash value, the matching result is determined to be a failure, and the process proceeds to the sibling node of the child node.
4. The method according to claim 1, characterized in that, The method further includes: Receive SMS messages to be sent uploaded to the SMS service platform; Based on the starting character of the SMS message to be sent, find the target template structure tree corresponding to the starting character; If a corresponding target template structure tree is found, and the complete path of the target template structure tree is matched based on the SMS message to be sent, then the SMS service platform is invoked to send the SMS message to be sent. Otherwise, the text message to be sent is used as the text message text, and the steps of determining the text message template containing multiple template segments based on the text message text and subsequent steps are executed.
5. A structure tree construction device, characterized in that, The structure tree construction device, applied to an SMS service platform, includes: The SMS receiving module is used to receive SMS text messages uploaded to the SMS service platform; The template determination module is used to determine an SMS template containing multiple template segments based on the SMS text, including: identifying parameter entities from the SMS text; replacing the parameter entities in the SMS text with corresponding template parameters to obtain the SMS template corresponding to the SMS text; and dividing the SMS template into multiple template segments based on the position of each template parameter in the SMS template. The structure tree determination module is used to determine the template structure tree based on the starting character of the SMS template. The template structure tree is used to integrate the template fragments of each SMS template. The structure tree construction module is used to enter the child nodes of the root node of the template structure tree; determine the current template segment to be matched, and determine whether the entered child node is an empty node; if the child node is an empty node, then fill the child node with the template segment to be matched; if the child node is not an empty node, then match the template segment to be matched with the child node, and enter the child node or sibling node of the child node based on the matching result; based on the entered child node or sibling node, return to execute the steps of determining the current template segment to be matched and determining whether the entered child node is an empty node and subsequent steps, until all template segments that have not been matched with corresponding nodes are filled into the empty nodes of the template structure tree, forming a new path of the template structure tree.
6. The apparatus according to claim 5, characterized in that, The SMS service platform stores a first mapping relationship and a second mapping relationship, wherein the first mapping relationship is a mapping relationship between SMS length and the second mapping relationship, and the second mapping relationship is a mapping relationship between the starting character of the SMS template and the template structure tree; when determining the template structure tree based on the starting character of the SMS template, the structure tree determination module is used for: Obtain the length of the SMS message from the given SMS template; Based on the first mapping relationship, find the second mapping relationship that matches the length of the SMS message; If a second mapping relationship matching the length of the SMS message is found, the starting character of the SMS message template is obtained, and a template structure tree matching the starting character is determined based on the second mapping relationship.
7. The apparatus according to claim 5, characterized in that, When matching the template segments to be matched with the child nodes, and entering the child nodes or sibling nodes of the child nodes based on the matching results, the structure tree construction module is used for: Obtain the template hash value of the template segment to be matched, and obtain the node hash value of the child node; The child nodes are matched with the template to be matched segment by segment based on the template hash value and the node hash value; If the template hash value is the same as the node hash value, the matching result is determined to be a successful match, and the process proceeds to the child node of the child node. If the template hash value is different from the node hash value, the matching result is determined to be a failure, and the process proceeds to the sibling node of the child node.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 4.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 4.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Short message sending method and device, computer equipment and storage medium
CN110290487A
Customization and recommendation of tree-structured templates
US20210011896A1