Domain-specific language statement generation method, related device and medium
By guiding the asynchronous execution of code segments and DSL statement generators, the problem of unclear error locations in DSL statement generation is solved, and DSL statement generation with high accuracy and low resource consumption is achieved.
Patent Information
- Application Number
- CN202410283947.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-12
- Publication Date
- 2025-09-12
AI Technical Summary
In the prior art, when domain-specific language statement generation methods generate statements that do not conform to DSL syntax, the parsing process is prone to errors and the error locations and causes are unclear, resulting in resource waste and communication loss.
Through the asynchronous execution of code segment and DSL statement generator generated by guiding instructions, guiding instructions are generated and sent, and the execution of code segment is suspended until the DSL statement generator generates the target character. The cycle is repeated until the end symbol is generated, thereby improving the generation accuracy and reducing resource loss.
This improves the accuracy of DSL statement generation, reduces resource loss, and enables rapid location and repair of errors to continue generating new DSL statements.
Smart Images

Figure CN120631362A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of artificial intelligence, and in particular to a method for generating domain-specific language sentences, related devices, and media. Background Art
[0002] Domain-Specific Languages (DSLs) are formal languages for specific domains that can be accurately parsed into data structures by computer programs and used in program execution. Due to the excellent parsability and executable nature of DSLs, generating corresponding DSL statements from input source code (which may or may not be a DSL) is becoming increasingly urgent.
[0003] Several existing methods exist for generating DSL statements from source text. However, these methods share a common drawback: when the generated content doesn't conform to the DSL syntax, the parsing process typically fails and stops. However, the error location and cause are unclear, providing no guidance for fixing the error and continuing to generate new DSL statements. This results in a failure to reduce backtracking (deleting suffixes that prevent DSL generation), resulting in wasted computing resources and communication losses. Summary of the Invention
[0004] The embodiments of the present disclosure provide a method, related apparatus, and medium for generating domain-specific language (DSL) statements, which can improve the accuracy of generated DSL statements and reduce resource loss.
[0005] According to one aspect of the present disclosure, a method for generating a domain-specific language sentence is provided, comprising:
[0006] Generate a guiding instruction generation code segment based on a domain-specific language grammar rule, wherein the guiding instruction generation code segment includes a first statement, and the first statement is used to generate a guiding instruction of the domain-specific language statement;
[0007] executing, by the domain specific language statement generator, a second statement for generating the first request for calling the boot instruction to generate a code segment;
[0008] In response to the first request, starting execution of the guidance instruction generation code segment to execute the first statement, generate the guidance instruction, and send the guidance instruction to the domain specific language statement generator;
[0009] pausing the execution of the boot instruction generation code segment;
[0010] The domain specific language sentence generator generates target characters in the domain specific language sentence under the guidance of the guide instruction, and returns to the step of executing the second sentence when the generated target character is not a terminator.
[0011] According to one aspect of the present disclosure, a device for generating a domain-specific language sentence is provided, comprising:
[0012] A first generating unit is configured to generate a guiding instruction generation code segment based on a domain-specific language grammar rule, wherein the guiding instruction generation code segment includes a first statement, and the first statement is configured to generate a guiding instruction of the domain-specific language statement;
[0013] a first execution unit, configured to execute a second statement through the domain specific language statement generator, wherein the second statement is used to generate the first request for calling the boot instruction to generate a code segment;
[0014] a second execution unit, configured to, in response to the first request, start execution of the guide instruction generation code segment to execute the first statement, generate the guide instruction, and send the guide instruction to the domain specific language statement generator;
[0015] a pausing unit, configured to suspend the execution of the boot instruction generated code segment;
[0016] The second generating unit is configured to generate target characters in the domain specific language sentence under the guidance of the guiding instruction through the domain specific language sentence generator, and return to the step of executing the second sentence if the generated target character is not a terminator.
[0017] Optionally, the domain-specific language sentence generation device further includes:
[0018] A first receiving unit, configured to receive an input source character;
[0019] a third execution unit, configured to start execution of the guide instruction generation code segment in response to the source character to execute the first statement, so as to generate the guide instruction based on the domain-specific language grammar rules and the source character, and send the guide instruction to the domain-specific language statement generator, wherein the target character corresponds to the source character and complies with the domain-specific language grammar rules.
[0020] Optionally, the third execution unit is specifically configured to:
[0021] Acquiring intermediate state information, the intermediate state information including the generated target character context and position information of the target character to be generated;
[0022] In response to the source character, the execution of the guiding instruction generation code segment is started to execute the first statement, so as to generate the guiding instruction based on the domain specific language grammar rule, the source character, and the intermediate state information.
[0023] Optionally,
[0024] The first receiving unit is specifically configured to: receive a source character input in a source character input area of an input interface, wherein the input interface further includes a guide instruction display area;
[0025] The domain specific language sentence generation apparatus further includes: a display unit configured to display the guiding instruction in the guiding instruction display area so as to adjust the source character to be input next in the source character input area.
[0026] Optionally, the input interface further includes an automatic generation control;
[0027] The second generation unit is specifically used to: in response to the triggering of the automatic generation control, generate the target characters in the domain-specific language sentence through the domain-specific language sentence generator under the guidance of the guide instruction, and return to the step of executing the second sentence when the generated target characters are not terminators.
[0028] Optionally, the domain-specific language statement generator includes a plurality of domain-specific language statement generation program segments;
[0029] The second generating unit is further configured to:
[0030] inputting the guiding instruction into a current specific language statement generating program segment among the plurality of specific language statement generating program segments;
[0031] If the current specific language statement generation program segment does not generate the target character, using the next specific language statement generation program segment as the current specific language statement generation program segment, and returning to the step of executing the second statement;
[0032] In response to the triggering of the automatic generation control, if the current specific language statement generation program segment generates the target character, the target character is output, wherein, when the target character is the terminator, the generation of the domain-specific language statement is terminated; when the target character is not the terminator, the next specific language statement generation program segment is used as the current specific language statement generation program segment, and the step of executing the second statement is returned to.
[0033] Optionally, the current specific language statement generation program segment includes a sampling program sub-segment and a generation program sub-segment;
[0034] The second generating unit is further configured to:
[0035] The step of inputting the guiding instruction into a current specific language statement generation program segment among the plurality of specific language statement generation program segments comprises:
[0036] inputting the guiding instruction into the sampling program sub-segment, and having the sampling program sub-segment select the target character from a plurality of candidate characters based on the guiding instruction;
[0037] The target character is generated by the generating program sub-segment.
[0038] Optionally, the input interface further includes a single character generation control;
[0039] The domain specific language sentence generating device further comprises:
[0040] The third generating unit is configured to generate target characters in the domain specific language sentence in response to the triggering of the single character generation control, through the domain specific language sentence generator, under the guidance of the guiding instruction, and terminate the generation of the domain specific language sentence.
[0041] Optionally, the second execution unit is specifically configured to:
[0042] Obtaining, from the first statement, a task for generating the guidance instruction;
[0043] Get multiple subpackage generation programs;
[0044] Sending the generation task to the plurality of sub-package generation programs to generate a plurality of sub-boot instructions;
[0045] A plurality of the sub-boot instructions are integrated into the boot instruction.
[0046] Optionally, the generation task includes a top-level function and a plurality of bottom-level functions corresponding to a plurality of the sub-package generation programs;
[0047] The second execution unit is further configured to:
[0048] Distributing the plurality of underlying functions to the plurality of sub-package generation programs;
[0049] The generation task is sent to the plurality of sub-package generation programs, and the plurality of bottom-level functions in the plurality of sub-package generation programs are called by the top-level function to execute the generation task, thereby obtaining the plurality of sub-boot instructions.
[0050] Optionally, the second execution unit is specifically configured to:
[0051] Obtaining, from the first statement, a generation task for the guide instruction, the generation task comprising a top-level function and bottom-level functions corresponding to various non-terminal target character types, the non-terminal target character types being character types that cannot be uniquely determined based on a context of the target character;
[0052] When it is determined that the target character is a terminal target character type based on the generation task and the domain-specific language grammar rule, generating, by the top-level function, the guide instruction for outputting the terminal target character, the terminal target character type being a character type that can be uniquely determined based on the context of the target character;
[0053] When the target character is determined to be the non-terminal target character type based on the generation task and the domain-specific language grammar rules, the underlying function corresponding to the non-terminal target character type is determined, and the underlying function is forwarded to the sub-package generation program corresponding to the non-terminal target character type in multiple sub-package generation programs for execution to generate the boot instruction.
[0054] Optionally, the guiding instruction includes a target character restriction instruction and a modification suggestion instruction;
[0055] Before returning to the step of executing the second statement, the second execution unit is specifically configured to: in response to the first request, start the execution of the boot instruction generation code segment to execute the first statement and generate the target character restriction instruction;
[0056] After returning to the step of executing the second statement, the second execution unit is specifically used to: in response to the first request, start the execution of the boot instruction generation code segment to execute the first statement, and generate the modification suggestion instruction based on the target character restriction instruction and the context of the target character.
[0057] Optionally, the guiding instruction includes a target character restriction instruction, a modification suggestion instruction, and a read control instruction;
[0058] Before returning to the step of executing the second statement, the second execution unit is specifically configured to: in response to the first request, start the execution of the boot instruction generation code segment to execute the first statement and generate the target character restriction instruction;
[0059] After returning to the step of executing the second statement for the first time, the second execution unit is specifically configured to: in response to the first request, start execution of the boot instruction generation code segment to execute the first statement and generate the read control instruction to read the input source character;
[0060] After returning to the step of executing the second statement for the second time, the second execution unit is specifically used to: in response to the first request, start the execution of the boot instruction generation code segment to execute the first statement, and generate the modification suggestion instruction based on the restricted target character instruction, the context of the target character and the read source character.
[0061] Optionally, the guiding instruction generation code segment includes multiple guiding instruction generation code segment instances in a first thread, and the domain specific language statement generator includes multiple domain specific language statement generator instances in a second thread;
[0062] The first execution unit is specifically configured to: execute the second statement through the domain specific language statement generator instance in a target second thread among the plurality of second threads;
[0063] The second execution unit is specifically configured to: determine a target first thread among the plurality of first threads in response to the first request, and start execution of the boot instruction generation code segment instance in the target first thread;
[0064] The second generating unit is specifically configured to generate target characters in the domain specific language sentence through the domain specific language sentence generator instance in the target second thread under the guidance of the guiding instruction.
[0065] Optionally, the second execution unit is further configured to:
[0066] In response to the first request, determining a load of the plurality of first threads;
[0067] determining a plurality of processing environment parameters of the first threads;
[0068] A target first thread is determined among the plurality of first threads based on the load and the processing environment parameter.
[0069] Optionally, the domain-specific language sentence generation device further includes:
[0070] A saving unit, configured to save the running state of the boot instruction generation code segment before pausing the execution of the boot instruction generation code segment;
[0071] A recovery unit is used to restore the saved operating state.
[0072] Optionally, if the platform for generating the domain specific language statement does not support the first statement, the domain specific language statement generating apparatus further includes:
[0073] a compiling unit, configured to compile the first statement into a branch statement and a state saving statement supported by the platform;
[0074] The saving unit is specifically configured to: save the running state of the boot instruction generated code segment using the state saving statement;
[0075] The second execution unit is further specifically configured to execute the branch statement and generate the guide instruction.
[0076] According to one aspect of the present disclosure, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the above-mentioned method for generating domain-specific language sentences when executing the computer program.
[0077] According to one aspect of the present disclosure, a computer-readable storage medium is provided, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the method for generating a domain-specific language sentence as described above is implemented.
[0078] According to one aspect of the present disclosure, a computer program product is provided. The computer program product includes a computer program. The computer program is read and executed by a processor of a computer device, so that the computer device executes the domain-specific language sentence generation method as described above.
[0079] The disclosed embodiments improve the accuracy of generated DSL statements and reduce resource consumption by asynchronously executing the guidance instruction generation code segment and the DSL statement generator. When the DSL statement generator executes the second statement, it generates a first request to invoke the guidance instruction generation code segment. In response to the first request, the guidance instruction generation code segment initiates execution of the guidance instruction generation code segment. When executing the first statement, it generates a guidance instruction and sends it to the DSL statement generator to guide the generation of the DSL statement. After sending the guidance instruction, execution of the guidance instruction generation code segment is paused until the DSL statement generator generates the target characters in the DSL statement under the guidance of the guidance instruction. The execution of the guidance instruction generation code segment then returns to the second statement, thereby sending the first request to the guidance instruction generation code segment again. After receiving the first request, the guidance instruction generation code segment resumes execution of the paused guidance instruction generation code segment. This process is repeated multiple times until the generated target characters become the terminator, completing the generation of the DSL statement. As can be seen from the above, the guidance instruction generation code segment is paused during the generation process of the DSL statement generator. In this way, when the DSL statement generator detects an error, the pause in the code generation process allows the DSL statement generator to quickly locate the error. This allows the DSL statement generator to better reflect the error when generating the target character in the DSL statement, improving the accuracy of the generated DSL statement. This allows the DSL statement generator to continuously guide the generation of new DSL statements while correcting errors, reducing the resource consumption caused by backtracking.
[0080] Other features and advantages of the present disclosure will be described in the following description, and in part will become apparent from the description, or will be understood by practicing the present disclosure. The purposes and other advantages of the present disclosure can be realized and obtained by the structures particularly pointed out in the description, claims and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0081] The accompanying drawings are used to provide a further understanding of the technical solution of the present disclosure and constitute a part of the specification. Together with the embodiments of the present disclosure, they are used to explain the technical solution of the present disclosure and do not constitute a limitation to the technical solution of the present disclosure.
[0082] Figure 1 is a system architecture diagram of the method for generating domain-specific language sentences according to an embodiment of the present disclosure;
[0083] Figure 2A and Figure 2B This is a schematic diagram of an interface for applying the domain-specific language sentence generation method provided by an embodiment of the present disclosure to information transmission analysis and driving applications;
[0084] Figure 2C This is a schematic diagram of an interface of an integrated development tool in which the method for generating domain-specific language statements provided by an embodiment of the present disclosure is applied;
[0085] Figure 2D and Figure 2E This is a schematic diagram of an interface of a DSL language assistant in which the method for generating domain-specific language sentences provided by an embodiment of the present disclosure is applied;
[0086] Figure 2F This is a schematic diagram of an interface of a data mining tool in which the method for generating domain-specific language sentences provided by an embodiment of the present disclosure is applied;
[0087] Figure 3 is a main flow chart of a method for generating a domain-specific language sentence according to an embodiment of the present disclosure;
[0088] Figure 4A and Figure 4B is a schematic diagram of an overall implementation of a method for generating a domain-specific language sentence according to an embodiment of the present disclosure;
[0089] Figure 5 yes Figure 3 Step 330 generates a flow chart of the boot instructions;
[0090] Figure 6 yes Figure 5 A schematic diagram of generating boot instructions in ;
[0091] Figure 7 yes Figure 5 Step 530 generates a flow chart of the sub-boot instructions;
[0092] Figure 8 yes Figure 3 Another flow chart of step 330 generating a guide instruction;
[0093] Figure 9 yes Figure 8A schematic diagram of generating boot instructions in ;
[0094] Figure 10 yes Figure 3 Step 330 generates a flow chart of the target character restriction instruction and the modification suggestion instruction;
[0095] Figure 11 yes Figure 3 Step 330 generates a flow chart of the target character restriction instruction, the modification suggestion instruction and the read control instruction;
[0096] Figure 12 is a flow chart of generating a domain-specific language sentence based on source characters according to an embodiment of the present disclosure;
[0097] Figure 13A and Figure 13B yes Figure 12 Schematic diagram of generating domain-specific language sentences;
[0098] Figure 14 is a schematic diagram of the application of the domain specific language sentence generation device in Figure 13;
[0099] Figure 15 yes Figure 12 Step 1220 generates a flow chart of the boot instructions;
[0100] Figure 16 yes Figure 12 A flow chart for receiving source characters and guiding instructions for display;
[0101] Figure 17 yes Figure 12 Step 350 is a flow chart triggered in response to the automatic generation of a control;
[0102] Figure 18 yes Figure 17 A flowchart of step 1710 of domain-specific language sentence generation;
[0103] Figure 19 yes Figure 18 Step 1810 generates a schematic diagram of the target character;
[0104] Figure 20 yes Figure 19 A schematic diagram of generating target characters in ;
[0105] Figure 21 yes Figure 12 A schematic diagram of the triggering of the single character generation control;
[0106] Figure 22 This is a flow chart of multi-threaded domain-specific language statement generation provided according to an embodiment of the present disclosure;
[0107] Figure 23 This is a schematic diagram of multi-threaded domain-specific language statement generation provided according to an embodiment of the present disclosure;
[0108] Figure 24 yes Figure 22 Step 2220 starts a flow chart of the boot instruction generation code segment instance execution;
[0109] Figure 25 A flow chart of saving and restoring the running state of a code segment generated by a boot instruction according to an embodiment of the present disclosure is provided;
[0110] Figure 26 yes Figure 25 A flow chart for guiding execution is generated based on branch statements and state saving statements;
[0111] Figure 27A and Figure 27B This is another interface diagram of an integrated development tool in which the method for generating domain-specific language statements provided by an embodiment of the present disclosure is applied;
[0112] Figure 28A It is an interface diagram of the domain-specific language grammar rules determined based on the large model;
[0113] Figure 28B This is another interface diagram of the method for generating domain-specific language sentences provided by an embodiment of the present disclosure applied to a DSL language assistant;
[0114] Figure 29A is a schematic diagram of the domain-specific language grammar rules provided by an embodiment of the present disclosure;
[0115] Figure 29B and Figure 29C This is another interface diagram of the method for generating domain-specific language sentences provided by an embodiment of the present disclosure applied to a DSL language assistant;
[0116] Figure 30 is a schematic diagram of the application of the domain-specific language sentence generation method provided by an embodiment of the present disclosure to alphabet processing;
[0117] Figure 31 It is an implementation detail diagram of the domain-specific language sentence generation method of an embodiment of the present disclosure.
[0118] Figure 32 is a module diagram of a domain-specific language sentence generation device according to an embodiment of the present disclosure;
[0119] Figure 33 According to the embodiment of the present disclosure Figure 3The terminal structure diagram of the domain-specific language sentence generation method shown;
[0120] Figure 34 According to the embodiment of the present disclosure Figure 3 The server structure diagram of the domain-specific language statement generation method shown in FIG. DETAILED DESCRIPTION
[0121] In order to make the purpose, technical solutions and advantages of the present disclosure more clearly understood, the present disclosure is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present disclosure and are not intended to limit the present disclosure.
[0122] Before further explaining the embodiments of the present disclosure in detail, the nouns and terms involved in the embodiments of the present disclosure are explained. The nouns and terms involved in the embodiments of the present disclosure are subject to the following interpretations:
[0123] A Domain-Specific Language (DSL) is a computer language that focuses on a specific application domain. It is a formal language for a specific domain that can be accurately parsed into data structures by computer programs and used in program execution. DSLs can use custom languages or the syntax of other languages, such as XML, SQL, JSON, and Markdown.
[0124] JSON (JavaScript Object Notation): A lightweight data exchange format that's easy for humans to read and write, and can be used to exchange data between multiple languages. It's also easy for machines to parse and generate data. JSON can be used as a DSL.
[0125] Domain-specific languages (DSLs) are formal languages for specific domains that can be accurately parsed into data structures by computer programs and used in program execution. Due to the excellent parsability and executable nature of DSLs, generating corresponding DSL statements based on input source code (which may or may not be a DSL) is becoming increasingly urgent.
[0126] In the related art, there are some methods for generating DSL statements from source characters. However, these methods share a common drawback: when the generated content does not conform to the DSL syntax, the parsing process often fails and stops. However, the error location and cause are not clear enough to guide the process in fixing the error and continuing to generate new DSL statements. This results in a failure to reduce backtracking (deleting suffixes that prevent DSL generation), resulting in wasted computing resources and communication losses.
[0127] Based on this, embodiments of the present disclosure provide a method, related apparatus, and medium for generating domain-specific language (DSL) statements. The method provided by embodiments of the present disclosure can improve the accuracy of generated DSL statements and reduce resource consumption.
[0128] System architecture and scenario description of the application of the embodiments of the present disclosure
[0129] Figure 1 1 is a system architecture diagram for the method for generating domain-specific language sentences according to an embodiment of the present disclosure, which includes a target terminal 110, the Internet 120, a gateway 130, and a server 140.
[0130] The target terminal 110 is a device used to display the generated target characters so that the target can view them. The target can also use the target terminal 110 to input source characters, view guidance instructions, and perform other operations. The target terminal 110 includes various forms such as desktop computers, laptops, PDAs (personal digital assistants), mobile phones, in-vehicle terminals, home theater terminals, dedicated terminals, and digital tablets. In addition, it can be a single device or a collection of multiple devices. For example, multiple devices connected via a local area network and sharing a common display device work together to form a terminal. The terminal can also communicate with the Internet 120 in a wired or wireless manner to exchange data.
[0131] Gateway 130, also known as a gateway or protocol converter, implements network interconnection at the transport layer and is a computer system or device that performs a conversion function. It acts as a translator between two systems using different communication protocols, data formats, languages, or even completely different architectures. Gateway 130 also provides filtering and security functions. Messages sent from client terminals 110 to servers 140 are sent through gateway 130 to the corresponding servers 140. Messages sent from servers 140 to client terminals 110 are also sent through gateway 130 to the corresponding client terminals 110.
[0132] Server 140 is a computer system that provides domain-specific language statement generation services to target terminal 110. Compared to target terminal 110, server 140 has higher requirements in terms of stability, security, and performance. Server 140 can be a single high-performance computer within a network platform, a cluster of multiple high-performance computers, a portion of a single high-performance computer (e.g., a virtual machine), or a combination of portions of multiple high-performance computers (e.g., virtual machines). Server 140 can also communicate with the internet 120 via wired or wireless means to exchange data.
[0133] The embodiments of the present disclosure can be applied in various scenarios, such as Figure 2A and Figure 2B The interface diagram of information transmission analysis and driving application shown in the figure, Figure 2C The interface diagram of the integrated development tool shown in FIG. Figure 2D and the interface diagram of the DSL language learning assistant shown in Figure F, Figure 2F The interface diagram of the data mining tool shown, etc.
[0134] Figure 2A This is a diagram of the interface of the information transmission parsing and driver application used by subject A. Subject A enters the text message "let abc=123;" into the information transmission parsing and driver application and optionally selects subject B to transmit the message. After confirming the message and the target, subject A clicks the "Send" button to send the message to the target.
[0135] Figure 2B Schematic diagram of the interface for information transmission, parsing, and driving applications used by object B. The interface displays the information content "let abc=123;" obtained by parsing the received information based on the domain-specific language sentence generation method provided by the embodiments of the present disclosure, thereby transmitting and parsing the information with high accuracy.
[0136] Reference Figure 2C , the object can input source characters, i.e., code text, in the source character input area. However, the object may make mistakes when using the integrated development tool. Therefore, the integrated development tool constructed based on the domain-specific language statement generation method provided by the embodiment of the present disclosure can correct the source characters input by the object and display the corrected results in the target character display area. For example, if the object inputs "let ab c;=123" in the source character input area, the target character display area displays the corrected result "let abc=123;". In addition, the guide instruction area in the integrated development tool displays guide instructions, which include guide information and error information. The object can input subsequent source characters according to the guide information in the guide instruction, or modify the input source characters according to the error information in the guide instruction.
[0137] Figure 2D and Figure 2E This is a schematic diagram of the interface of the DSL language learning assistant. When the source characters input by the subject in the DSL language learning assistant are correct, the DSL language learning assistant constructed based on the domain-specific language sentence generation method provided by the embodiment of the present disclosure will provide spelling suggestions for the subject, such as Figure 2DIn the interface shown, the subject learns the JSON language through the DSL language learning assistant and enters the source character "{"key":0" in the source character input area. The DSL language learning assistant parses the input source character and displays the generated target character in the target character display area. It also provides the target character type for the subject to select. When the subject enters an error in the source character, the interface diagram of the DSL language learning assistant is as follows: Figure 2E As shown in the figure, the subject enters "{"key";1" in the source character input area. The DSL language learning assistant parses the input source characters, generates an error message in the target character display area, and provides modification suggestions based on the error message.
[0138] The interface diagram of the data mining tool is as follows Figure 2F As shown, the data mining tool constructed based on the domain-specific language sentence generation method provided by the embodiment of the present disclosure can process a large amount of text in the text input area, and extract sentences that conform to the DSL statement grammar, obtain mining results, and display them in the mining result display area, such as XML language and JSON language.
[0139] In addition, the domain-specific language sentence generation method provided by the embodiment of the present disclosure can also be applied to language generation, using the guiding instructions as guidance or constraints to assist other programs in achieving DSL language generation tasks.
[0140] It should be understood that the above content only illustrates some application scenarios of the present disclosure. The business scenarios to which the present disclosure can be applied may include but are not limited to the specific embodiments listed above.
[0141] General description of the embodiments of the present disclosure
[0142] It should be emphasized that the embodiments of the present disclosure are applicable to a variety of application scenarios, such as Figure 2A and Figure 2B The information transmission analysis and driving application shown, Figure 2C The integrated development tools shown, Figure 2D and Figure 2E The DSL language learning assistant shown, Figure 2F In the data mining tool scenario shown, for example. When the generated content of a DSL statement in a related art does not conform to the DSL syntax, the parsing process typically fails and stops. However, the error location and cause are not clear enough to guide the error correction and continue generating new DSL statements. This results in a failure to reduce backtracking (deleting suffixes that prevent DSL generation), resulting in wasted computing resources and communication losses. Some embodiments of the present disclosure provide a method, related apparatus, and medium for generating domain-specific language statements, which can improve the accuracy of generated DSL statements and reduce resource loss.
[0143] The domain-specific language sentence generation method is a method for generating target characters that conform to the grammatical rules of the domain-specific language. The domain-specific language sentence generation method can improve the accuracy of the generated DSL sentences and reduce resource consumption.
[0144] The domain-specific language sentence generation method of the embodiment of the present disclosure may be executed on the target terminal 110 , or on the server 140 , or partially on the target terminal 110 and partially on the server 140 .
[0145] like Figure 3 As shown, according to one embodiment of the present disclosure, a method for generating a domain-specific language sentence includes:
[0146] Step 310: Generate a guiding instruction generation code segment based on the domain-specific language grammar rules, wherein the guiding instruction generation code segment includes a first statement, and the first statement is used to generate a guiding instruction of the domain-specific language statement;
[0147] Step 320: Execute a second statement through the domain specific language statement generator, where the second statement is used to generate a first request for calling the boot instruction to generate a code segment;
[0148] Step 330: In response to the first request, start execution of the guidance instruction generation code segment to execute the first statement, generate the guidance instruction, and send the guidance instruction to the domain specific language statement generator;
[0149] Step 340: suspend the execution of the boot instruction generation code segment;
[0150] Step 350: Generate target characters in the domain specific language sentence through the domain specific language sentence generator under the guidance of the guide instruction, and if the generated target characters are not the terminator, return to the step of executing the second sentence.
[0151] Steps 310 to 350 are described in detail below.
[0152] In step 310 , a guiding instruction generation code segment is generated based on the domain specific language grammar rules, wherein the guiding instruction generation code segment includes a first statement, and the first statement is used to generate a guiding instruction of a domain specific language statement.
[0153] Domain-specific language grammar rules refer to the grammar rules that domain-specific languages, i.e. DSL languages, need to follow. Since domain-specific languages include JSON, XML, SQL and other languages, domain-specific language grammar rules need to be set according to the type of domain-specific language during the generation of domain-specific language statements. For example, objects are generated by Figure 2DThe DSL language learning assistant shown learns the JSON language, so the domain-specific language grammar rules corresponding to the DSL language learning assistant need to be set corresponding to the JSON language, which are specifically the grammar rules that the JSON language needs to follow.
[0154] It should be noted that the grammatical rules of domain-specific languages can also be set as needed. They can be sequences of any structure. The grammatical rules of domain-specific languages are not limited to DSLs such as strings, numbers, arrays, objects, and terminators (false / true / null). The grammatical rules of domain-specific languages can be expressed through a series of productions or through extended Backus-Naur Form (EBNF). In addition, the grammatical rules of domain-specific languages can also be specifically set to generate any recursively enumerable language, for example, Figure 2C The integrated development tool shown can set the domain specific language grammar rule to "let abc=123;", and the generated domain specific language statement is "let abc=123;".
[0155] Guidance instructions (Instruction DSL) correspond to DSL statements, and refer to instruction information used to guide the verification, parsing, and generation of DSL statements. Guidance instructions can provide accurate error information, error recovery information, etc. Guidance instructions include control instructions, target character restriction instructions, suggestion instructions, and symbol instructions. Control instructions include view control instructions, read control instructions, cancel control instructions, generate control instructions, terminate control instructions, etc., among which, view control instructions refer to instructions for only viewing characters, read control instructions refer to instructions for reading characters, cancel control instructions refer to instructions for canceling reading, generate control instructions refer to instructions for generating characters, and terminate control instructions refer to instructions for the termination of the domain-specific language statement generation method. Restriction target character instructions refer to instructions for restricting the characters to be read in next time, which include restriction information for the characters to be read in next time. Suggestion instructions include modification suggestion instructions and read suggestion instructions. Modification suggestion instructions refer to instructions for providing error information for the characters that have been read in and modification suggestions corresponding to the error information. In addition, read suggestion instructions include restriction information for the characters to be read in next time. Symbolic instructions are instructions for entering a character of a non-terminal target character type, instructions for leaving a character of a non-terminal target character type, and instructions for completing a character of a terminal target character type.
[0156] Intermediate Representation (IR) information is an intermediate form in the process of converting from one form to another, and guidance instructions are a kind of intermediate representation information, the purpose of which is to facilitate the generation of domain-specific language sentences.
[0157] The guiding instruction generation code segment refers to a code segment for generating guiding instructions, and the code segment includes at least one first statement. The first statement refers to a statement of the guiding instruction that can generate a domain-specific language statement, and the first statement is essentially a string of code. In addition, the guiding instruction generation code segment is generated based on the domain-specific language grammar rules, so the information contained in the guiding instruction generated based on the guiding instruction generation code segment meets the requirements of the domain-specific language grammar rules. For example, for Figure 2E The “{"key";1” shown in the figure generates a guidance instruction which is a modification suggestion instruction. The error message indicated by the modification suggestion instruction and the modification suggestion corresponding to the error message conform to the grammatical rules of the JSON language, that is, the grammatical rules of the domain-specific language.
[0158] Reference Figure 4B The first statement in the boot instruction generation code segment is specifically "let input = yield newInstruction(...args);", where yield refers to an asynchronous conversion method and program running method, which is an advanced feature of some programming languages. Input is the information received by the boot instruction generation code segment, new Instruction represents the boot instruction generated by the first statement, and args is the information carried by the boot instruction.
[0159] In step 320 , the domain specific language statement generator executes a second statement, where the second statement is used to generate a first request for invoking a boot instruction to generate a code segment.
[0160] The domain-specific language statement generator is a structural device capable of executing a second statement. The second statement is only set in the domain-specific language statement generator. The domain-specific language statement generator executes the second statement to generate a first request. The first request is a request instruction for invoking the boot instruction to generate a code segment for execution.
[0161] The second statement is a statement capable of generating the first request, and is essentially a string of code. The second statement is executed by the domain specific language statement generator to generate the first request for calling the guide instruction generation code segment.
[0162] Reference Figure 4BThe second statement is executed by the domain-specific language statement generator. The second statement is specifically "let instruction = generator.next(...asks);", where generator represents the domain-specific language statement generator, next represents next, and asks refers to the first request. Then next(...asks) is the new first request generated by the domain-specific language statement generator by executing the second statement.
[0163] In step 330 , in response to the first request, execution of the guidance instruction generation code segment is started to execute the first statement, generate the guidance instruction, and send the guidance instruction to the domain specific language statement generator.
[0164] In response to the generation of the first request, the bootstrap instruction generation code segment starts execution, and then the first statement in the bootstrap instruction generation code segment starts execution, thereby generating a bootstrap instruction, and sending the newly generated bootstrap instruction to the domain specific language statement generator.
[0165] In step 340, the execution of the code segment generating the guiding instruction is suspended. After the guiding instruction is generated and sent to the domain specific language statement generator, the execution of the code segment generating the guiding instruction is suspended to wait for the next execution of the code segment generating the guiding instruction.
[0166] In one embodiment, referring to Figure 4B In the disclosed embodiment, the first statement is constructed using the yield keyword. Yield does not rely on any programming language characteristics. In other words, any language or Turing machine that does not support yield can execute the first statement, i.e., the execution of the instruction-generating code segment. Furthermore, yield is an asynchronous programming and program execution method that allows the execution state of the instruction-generating code segment to be saved after it is paused, facilitating its next execution.
[0167] In step 350 , the domain specific language sentence generator generates target characters in the domain specific language sentence under the guidance of the guide instruction, and if the generated target character is not a terminator, the process returns to the step of executing the second sentence.
[0168] The target character refers to the character that conforms to the grammatical rules of the domain-specific language. The target character can be the character that the subject is about to input, such as Figure 2D The expected value in , the target character can also be the character after modifying the input error character, such as Figure 2C Characters in the target character display area.
[0169] A terminator refers to the last character of a statement that conforms to the grammatical rules of a domain-specific language. When the newly generated target character is a terminator, the target character and other characters can form a complete statement that conforms to the grammatical rules of the domain-specific language, and then there is no need to generate a new target character. Therefore, when the generated target character is a terminator, there is no need to return to the step of executing the second statement. In addition, when the newly generated target character is not a terminator, the target character and other characters cannot form a complete statement, and then it is necessary to continue to generate new target characters, that is, when the generated target character is not a terminator, return to the step of executing the second statement to generate a new target character, until the newly generated target character is a terminator.
[0170] The target character is generated by the domain-specific language statement generator, and the generation process is guided by the guide instruction. The generated target character is determined based on the guide instruction. For example, assuming the domain-specific language grammar rule is "let abc = 123;", then when a passive character is input, the guide instruction for executing the first statement generation is used to limit the value range of the generated target character to "l", and on this basis, it is recommended that the generated target character be "l". Then, under the guidance of the guide instruction, the first target character generated by the domain-specific language statement generator is "l", followed by "e", "t", and so on. When the newly generated target character is ";", i.e., the terminator, there is no need to generate a new target character. The guide instruction generation code segment is suspended, and the domain-specific language statement generator stops running.
[0171] In one embodiment, if the generated target character is not a terminator, the second operation is returned to generate the first request again, and the first request is sent to the guidance execution generation code segment. After receiving the first request, the guidance instruction generation code segment resumes the execution of the suspended guidance instruction generation code segment. This process is repeated multiple times until the generated target character becomes a terminator, completing the generation of the domain-specific language statement. During the generation of the domain-specific language statement, the guidance instruction generation code segment and the domain-specific language statement generator perform work alternately. That is, while the DSL statement generator is generating, the guidance instruction generation code segment is paused, thereby achieving asynchronous execution of the guidance instruction generation code segment.
[0172] It should be noted that the domain-specific language statement generation method provided in the embodiments of the present disclosure allows for calling other programs and can also be recursively executed directly or indirectly. Therefore, when the domain-specific language statement generation method is applied to language generation, such as in integrated development tools, it can generate recursively enumerable languages. Furthermore, when the domain-specific language statement generation method is applied to parsing, such as in information transmission parsing and driving applications and data mining tools, the method is used to parse context-free languages due to the potential for infinite recursion.
[0173] Reference Figure 4A and Figure 4B , the generation of domain-specific language statements first requires determining the corresponding domain-specific language grammar rules. Afterwards, the domain-specific language grammar rule parser is used to parse the domain-specific language grammar rule to generate a guide instruction generation code segment. In addition, the embodiment of the present disclosure is provided with a second statement, and the second statement is used to generate a first request to execute the guide instruction generation code segment. The domain-specific language statement generator executes the second statement "let instruction = generator.next(...asks);" to generate the first request. After the guide instruction generation code segment receives the first request, it starts the execution of the guide instruction generation code segment, thereby executing the first statement "let input = yield new instruction(...args);", generates a guide instruction, and sends the guide instruction to the domain-specific language statement generator. After the guide instruction is sent, the execution of the guide instruction generation code segment is paused. In addition, under the guidance of the guide instruction, the target characters in the domain-specific language statement are generated by the domain-specific language statement generator. When the generated target character is not a terminator, return to the step of executing the second statement, and generate a new target character through the domain-specific language statement generator and the guide instruction generation code segment until the generated target character is a terminator. The target character and the previously generated target character together constitute the domain-specific language statement.
[0174] The embodiment of steps 310 to 350 improves the accuracy of generated DSL statements and reduces resource consumption by asynchronously executing the guidance instruction generation code segment and the DSL statement generator. When the DSL statement generator executes the second statement, it generates a first request to invoke the guidance instruction generation code segment. In response to the first request, the guidance instruction generation code segment initiates execution of the guidance instruction generation code segment. When executing the first statement, it generates a guidance instruction and sends it to the DSL statement generator to guide the generation of the DSL statement. After sending the guidance instruction, execution of the guidance instruction generation code segment is paused until the DSL statement generator generates the target characters in the DSL statement under the guidance of the guidance instruction. The execution of the guidance instruction generation code segment then returns to the second statement, sending the first request to the guidance instruction generation code segment again. After receiving the first request, the guidance instruction generation code segment resumes execution of the paused guidance instruction generation code segment. This process is repeated multiple times until the generated target characters become the terminator, completing the generation of the DSL statement. As can be seen from the above, the guidance instruction generation code segment is paused during the generation process of the DSL statement generator. In this way, when the DSL statement generator detects an error, the pause in the code generation process allows the DSL statement generator to quickly locate the error. This allows the DSL statement generator to better reflect the error when generating the target character in the DSL statement, improving the accuracy of the generated DSL statement. This allows the DSL statement generator to continuously guide the generation of new DSL statements while correcting errors, reducing the resource consumption caused by backtracking.
[0175] The above is a general description of steps 310 to 350. Since steps 310 to 320 and steps 340 to 350 have been described in sufficient detail above, only the specific implementation process of step 330 will be described in detail below.
[0176] Detailed description of step 330
[0177] In step 330 , in response to the first request, execution of the guidance instruction generation code segment is started to execute the first statement, generate the guidance instruction, and send the guidance instruction to the domain specific language statement generator.
[0178] In one embodiment, referring to Figure 5 , step 330 includes:
[0179] Step 510: Obtain a generation task of a guidance instruction from the first statement;
[0180] Step 520: Obtain multiple sub-package generation programs;
[0181] Step 530: Send the generation task to multiple sub-package generation programs to generate multiple sub-boot instructions;
[0182] Step 540: Integrate the multiple sub-boot instructions into a boot instruction.
[0183] Steps 510 to 540 are described in detail below.
[0184] In step 510, a generation task of the guidance instruction is obtained from the first statement. The generation task refers to a task related to the generation of the guidance instruction.
[0185] The first sentence is a sentence for generating a guidance instruction for a domain-specific language sentence. Based on the first sentence, the type of guidance instruction to be generated and guidance information related to the domain-specific language sentence in the guidance instruction can be determined. Furthermore, the guidance instruction generation task is determined based on the first sentence. Therefore, the generation task includes the task of generating a guidance instruction of the expected type and the person who generates the guidance instruction containing the guidance information.
[0186] In step 520, multiple sub-package generation programs are obtained. Sub-package generation refers to dividing a completed program into multiple sub-packages according to requirements. Correspondingly, a sub-package generation program refers to the sub-packaged result corresponding to the generation program corresponding to the boot instruction. Different sub-package generation programs perform different parts of the generation task. For example, a number of sub-package generation programs may be provided, one of which is used to generate the instruction type of the boot instruction, and another is used to generate the boot information contained in the boot instruction.
[0187] In step 530, the generation task is sent to multiple sub-package generation programs to generate multiple sub-boot instructions. A sub-boot instruction is the result of its corresponding sub-package generation program processing the generation task. The number of sub-boot instructions corresponds to the number of sub-package generation programs. Each sub-package generation program processes the generation task to generate a corresponding sub-boot instruction.
[0188] Reference Figure 6 The multiple sub-package generation programs are respectively sub-package generation program A, sub-package generation program B, ..., sub-package generation program N. The generation task of the guidance instruction is sent to the multiple sub-package generation programs to obtain multiple sub-guidance instructions. Among them, sub-guidance instruction A is the generation result of the generation task in sub-package generation program A, sub-guidance instruction B is the generation result of the generation task in sub-package generation program B, and sub-guidance instruction N is the generation result of the generation task in sub-package generation program N.
[0189] In step 540, the multiple sub-guidance instructions are integrated into a guidance instruction. A sub-guidance instruction is the result of a single sub-package generation program processing a generation task, and a sub-package generation program is the sub-package result corresponding to the generation program corresponding to the guidance instruction. Therefore, a single guidance instruction cannot include all the information in the guidance instruction. Therefore, the embodiment of the present disclosure integrates multiple guidance instructions to obtain a complete instruction, which is the guidance instruction of the domain-specific language statement.
[0190] Reference Figure 6 The disclosed embodiment first parses the first statement to obtain a generation task for a guidance instruction. The generation task is then sent to sub-package generation program A, sub-package generation program B, ..., and sub-package generation program N, respectively. Each of the sub-package generation programs processes the generation task to obtain corresponding sub-guidance instructions. Finally, the multiple sub-guidance instructions are integrated to obtain a guidance instruction for a domain-specific language statement.
[0191] The embodiment of steps 510 to 530 described above includes multiple sub-package generation programs. To generate a guidance instruction, the generation task must first be obtained from the first statement. The generation task is then processed by multiple sub-package generation programs to generate multiple sub-guidance instructions. These sub-guidance instructions are then integrated into the guidance instruction. During the guidance instruction generation process, multiple sub-package generation programs can simultaneously process the generation tasks, thereby improving the processing efficiency of the generation tasks and, in turn, the efficiency of generating domain-specific language statements.
[0192] The above is a general description of steps 510 to 530 . The specific implementation process of step 530 will be described in detail below.
[0193] In step 530, the generation task is sent to multiple sub-package generation programs to generate multiple sub-boot instructions.
[0194] In one embodiment, the generation task includes a top-level function and a plurality of bottom-level functions corresponding to a plurality of sub-package generation programs, referring to Figure 7 , step 530 includes:
[0195] Step 710: Distribute the multiple underlying functions to multiple sub-package generation programs;
[0196] Step 720: Send the generation task to multiple sub-package generation programs, and call multiple bottom-level functions in the multiple sub-package generation programs through the top-level function to execute the generation task and obtain multiple sub-boot instructions.
[0197] Step 710 and step 720 are described in detail below.
[0198] In step 710, the plurality of underlying functions are distributed to the plurality of sub-package generation programs. The plurality of sub-package generation programs are respectively used to execute different parts of the generation task corresponding to the boot instruction. Accordingly, the underlying functions are the execution functions corresponding to the different parts of the generation task, which are also the basis for the sub-package generation program to execute the generation task.
[0199] In step 720, the generation task is sent to multiple sub-package generation programs, and multiple bottom-level functions in the multiple sub-package generation programs are called through the top-level function to execute the generation task and obtain multiple sub-boot instructions.
[0200] A top-level function is a calling function corresponding to a bottom-level function. It can call the bottom-level function in the sub-package generation program. In the sub-package generation program, the top-level function in the generation task calls the bottom-level function in the sub-package generation program to execute the generation task. Specifically, the part of the generation task corresponding to the bottom-level function is called to generate the sub-boot instructions.
[0201] Assuming that the domain-specific language statement generation method provided by the embodiment of the present disclosure is used to generate JSON statements, the top-level function can be expressed as "top=async lambda:yield*json". top is the top-level function. Async is used to define asynchronous functions to implement asynchronous execution of the boot instruction generation code segment. The lambda expression is essentially an anonymous function, which is usually used to write simple functions or as a parameter of other functions. Yield* refers to delegating the generation task of the boot instruction to another program, that is, subcontracting the generation program. Yield* is an advanced feature of some programming languages. Although not all programming languages support yield* in terms of syntax, in essence, any Turing-complete programming language can implement yield*, and even if the syntax does not support yield*, it can be implemented by the program. JSON indicates that the top-level function corresponds to the JSON language. In addition, for Figure 6 For the generation task shown, the top-level function can be expressed as "json=async lambda:yield*{or A or Bor…or N}", where A represents the underlying function A, B represents the underlying function B, and N represents the underlying function N. The subcontract generation program A is provided with the underlying function A from the generation task. The generation task is sent to the subcontract generation program A. Since the subcontract generation program A is only provided with the underlying function A, by executing the top-level function "json=async lambda:yield*{or A orB or…or N}", only the underlying function A can be called, and then the generation task is executed to obtain the sub-guidance instruction A. Similarly, the generation task is sent to the subcontract generation program B, and the generation task is executed by calling the underlying function B through the top-level function to obtain the sub-guidance instruction B. In the subcontract generation program N, the generation task is executed by calling the underlying function N through the top-level function to obtain the sub-guidance instruction N.
[0202] The generation task in the embodiment of the above-mentioned steps 710 and 720 includes a top-level function and a bottom-level function. First, a plurality of bottom-level functions are distributed to a plurality of sub-package programs, and then the generation task is sent to a plurality of sub-package generation programs. For each sub-package generation program, the bottom-level function is called through the top-level function to execute the generation task and generate the corresponding sub-guidance instruction. The embodiment of the present disclosure enables a plurality of sub-package generation programs to accurately execute their corresponding partial generation tasks through the setting of the top-level function and the bottom-level function, thereby ensuring the completeness of the guidance instruction finally obtained and ensuring the accuracy of the target characters and the domain-specific language sentences.
[0203] In another embodiment, referring to Figure 8 , step 330 includes:
[0204] Step 810: Obtain a generation task of a guide instruction from the first statement, the generation task including a top-level function and bottom-level functions corresponding to various non-terminal target character types, where the non-terminal target character type is a character type that cannot be uniquely determined based on the context of the target character.
[0205] Step 820: When the target character is determined to be a terminal target character type based on the generation task and the domain-specific language grammar rules, a guide instruction for outputting the terminal target character is generated through the top-level function. The terminal target character type is a character type that can be uniquely determined based on the context of the target character.
[0206] Step 830: When the target character is determined to be a non-terminal target character type based on the generation task and the domain-specific language grammar rules, the underlying function corresponding to the non-terminal target character type is determined, and the underlying function is forwarded to the sub-package generation program corresponding to the non-terminal target character type in the multiple sub-package generation programs for execution to generate a boot instruction.
[0207] Steps 810 to 830 are described in detail below.
[0208] In step 810, a generation task of the guide instruction is obtained from the first statement, the generation task including a top-level function and bottom-level functions corresponding to various non-terminal target character types, where the non-terminal target character type is a character type whose target character cannot be uniquely determined based on the context of the target character.
[0209] In computer science and linguistics, characters of the terminal and non-terminal target character types are used to specify inference rules. These characters are disjoint sets. Furthermore, characters of the terminal and non-terminal target character types are basic elements used in domain-specific languages and generally cannot be further decomposed, such as true, false, and null in JSON. However, characters of the non-terminal target character types can be further decomposed, such as number and string in JSON.
[0210] In addition, a non-terminal target character type is a character type whose target character cannot be uniquely determined based on the context of the target character. For example, referring to the interface diagram of the DSL language learning assistant shown in FIG2 , there are multiple expected values of the target character determined based on the context of the target character, and the target character cannot be determined to be a unique value. The expected values “.”, “E”, “e”, “,”, and “}” all belong to characters of the non-terminal target character type.
[0211] It should be noted that the domain-specific language grammar rules can be arbitrarily configured as needed. Correspondingly, the characters of the non-terminal target type and the terminal target type can be any value, which is specifically determined based on the domain-specific language grammar rules.
[0212] It should be noted that the embodiment of the present disclosure sets the underlying function corresponding to the non-terminal target character type. Figure 9 When the domain-specific language statement generation method provided by the embodiment of the present disclosure is used to generate JSON statements, the non-terminal target character types include number, string, object, and array. Then, there are four underlying functions, which are used to generate characters of type number, string, object, and array respectively. The generation process of object and array can be based on number, string, true, false, null, or even form a recursive definition itself.
[0213] In step 820, when the target character is determined to be a terminal target character type based on the generation task and the domain-specific language grammar rules, a guidance instruction for outputting the terminal target character is generated through the top-level function. The terminal target character type is a character type that can be uniquely determined based on the context of the target character.
[0214] The terminal target character type is a character type uniquely determined based on the context of the target character. When the target character is determined to be of the terminal target character type based on the generation task and the domain-specific language grammar rules, the target character is a character of the determined terminal target character type. Therefore, a guide instruction for outputting the terminal target character can be directly generated by the top-level function. Subsequently, the domain-specific language sentence generator, guided by the guide instruction, can generate the terminal target character.
[0215] In step 830, when the target character is determined to be a non-terminal target character type based on the generation task and the domain-specific language grammar rules, the underlying function corresponding to the non-terminal target character type is determined, and the underlying function is forwarded to the sub-package generation program corresponding to the non-terminal target character type in multiple sub-package generation programs for execution to generate a boot instruction.
[0216] When the target character is a non-terminal target character type, the target character cannot be uniquely determined. Therefore, it is necessary to determine the guidance instruction corresponding to the output target character based on the context of the target character and the domain-specific language grammar rules. Specifically, the non-terminal target character type of the target character to be generated is first determined, and the underlying function is sent to the sub-package generation program corresponding to the non-terminal target character type and executed to generate the guidance instruction. When there are multiple non-target character types corresponding to the target character, each sub-package generation program executes the generation task by calling the underlying function to obtain multiple sub-guidance instructions, and the multiple sub-guidance instructions are integrated to obtain the guidance instruction. For example, assuming that the domain-specific language statement to be generated is a number, the first character corresponding to the domain-specific language statement can be "-" of the string type or 0-9 of the number type. In this case, the sub-package generation program corresponding to the string type character and the sub-package program corresponding to the number type character execute the corresponding underlying functions, thereby obtaining two sub-guidance instructions, and then obtaining the guidance instruction.
[0217] Reference Figure 9 The generation task of the guidance instruction includes a top-level function and underlying functions corresponding to various non-terminal target character types. When the domain-specific language grammar rules are JSON, when the target character is determined to be a terminal target character type, i.e., false, true, or null, based on the generation task and the domain-specific language grammar rules, a guidance instruction for inputting the terminal target character is directly generated through the top-level function. When the determined target character is a non-terminal target character type, the underlying functions corresponding to the non-terminal target character type, i.e., the processing functions corresponding to number, string, object, and array, are sent to different sub-package generation programs and executed to generate guidance instructions.
[0218] It should be noted that, in the embodiment of the present disclosure, when the first statement is executed for the first time and the bootstrap instruction is generated, the underlying functions of all non-terminal target character types corresponding to the domain-specific language grammar rules can be sent to multiple sub-package generation programs, so that the sub-package generation programs and the underlying functions are set in a one-to-one correspondence. Then, when the first statement is executed to generate the bootstrap instruction, it is only necessary to send the bootstrap instruction generation task to the multiple sub-package generation programs, without having to determine the specific non-terminal target character type corresponding to the target character again.
[0219] In addition, in the process of generating a guidance instruction each time the first statement is executed, the embodiment of the present disclosure can first determine that the target character is a non-terminal target character type based on the generation task and the domain-specific language grammar rules, and determine the underlying function corresponding to the non-terminal target character, and forward the underlying function to the sub-package generation program corresponding to the non-terminal target character type in multiple sub-package generation programs for execution to generate a guidance instruction.
[0220] The above steps 810 to 830 determine the method for generating the guide instruction based on the character type of the target character. Specifically, when the target character is a terminal target character type, a guide instruction for outputting the terminal target character is generated through a top-level function. When the target character is a non-terminal target character type, a bottom-level function corresponding to the non-terminal target character type is determined, and the bottom-level function is forwarded to a sub-package generation program corresponding to the non-terminal target character type for execution to generate the guide instruction. The disclosed embodiment calls target characters of different character types through top-level functions and bottom-level functions to generate guide instructions. When the target character is a terminal target character type, the guide instruction is directly generated through the top-level function, thereby improving the generation efficiency of the guide instruction. When the target character is a non-terminal target character type, multiple sub-package generation programs can execute the corresponding bottom-level functions simultaneously, which also improves the generation efficiency of the guide instruction, thereby improving the generation efficiency of the domain-specific language sentence.
[0221] In one embodiment, the guidance instruction includes a target character restriction instruction and a modification suggestion instruction. Figure 10 Before returning to the step of executing the second statement, step 330 includes:
[0222] Step 1010: In response to the first request, start the execution of the boot instruction generation code segment to execute the first statement and generate a target character restriction instruction;
[0223] After returning to the step of executing the second statement, step 330 includes:
[0224] Step 1020: In response to the first request, start the execution of the guide instruction generation code segment to execute the first statement, and generate a modification suggestion instruction based on the target character restriction instruction and the context of the target character.
[0225] It should be noted that the target character restriction instruction refers to an instruction for restricting the characters to be read in next time, which contains restriction information on the characters to be read in next time, for example, restricting the characters to be read in next time to be a specific character, restricting the characters to be read in next time to have only certain specific optional characters, restricting the characters to be read in next time to be within a certain range, restricting the characters to be read in next time to not be a specific character, restricting the characters to be read in next time to not be within a certain range, etc. Assuming that the domain-specific language statement to be generated is a number, then the first character corresponding to the domain-specific language statement can be a "-" of string type or 0-9 of number type. In this case, the target character restriction instruction is used to restrict the characters to be read in next time to be "-" of string type or 0-9 of number type.
[0226] It should be noted that, when the characters that have been read in do not conform to the grammatical rules of the domain-specific language, the modification suggestion instruction refers to an instruction that provides error information for the characters that have been read in, as well as modification suggestions corresponding to the error information. When the character information that has been read in contains the grammatical rules of the domain-specific language, the modification suggestion instruction refers to an instruction that provides input suggestions for the target characters that are about to be input. It can be said that the target character restriction instruction refers to an instruction that includes restriction information for the target characters determined according to the grammatical rules of the domain-specific language, while the modification suggestion instruction refers to an instruction that includes optimal value information for the target characters determined according to neural networks, random logic, etc.
[0227] Steps 1010 and 1020 are described in detail below.
[0228] In step 1010 , in response to a first request, execution of a boot instruction generation code segment is started to execute a first statement to generate a target character restricted instruction.
[0229] If the guide instruction includes a target character restriction instruction and a modification suggestion instruction, the target character restriction instruction is generated during the first execution of the first statement, ie before returning to the step of executing the second statement, to determine the range of the target characters.
[0230] In step 1020 , in response to the first request, the execution of the guiding instruction generation code segment is started to execute the first statement, and a modification suggestion instruction is generated based on the target character restriction instruction and the context of the target character.
[0231] After determining the target character restriction instruction, a modification suggestion instruction can be generated based on the target character restriction instruction and the context of the target character, thereby providing a specific value of the target character.
[0232] In one embodiment, when the domain-specific language statement expected to be generated is a number, the first character corresponding to the domain-specific language statement can be "-" of string type or 0-9 of number type. In this case, the first statement is executed for the first time to generate a target character restriction instruction, which is used to restrict the characters read in next time to "-" of string type or 0-9 of number type. When the first statement is executed for the second time, the context of the target character is empty, and based on the context of the target character and the target character restriction instruction, a modification suggestion instruction is generated to suggest the object to select a character from "-" and "0-9" for input.
[0233] It should be noted that if the program to which the domain-specific language sentence generation method is applied requires direct input of the target character, then when there are multiple inputtable characters in the suggestions for the target character given by the target character restriction instruction, a modification suggestion instruction can be generated based on the target character restriction instruction and the context of the target character to determine the value of the target character that the object is most likely to enter, and the target character can be generated and written based on the modification suggestion instruction.
[0234] The embodiment of the above-mentioned steps 1010 and 1020 is provided with a target character restriction instruction and a modification suggestion instruction. Before returning to the step of executing the second statement, that is, executing the first statement for the first time, a target character restriction instruction is generated to provide restriction information of the target character. Afterwards, the instruction for generating the code segment by the guide instruction is paused, and under the guidance of the target character restriction instruction, the target character in the domain-specific language statement is generated by the domain-specific language statement generator, and the step of executing the second statement is returned. In the process of generating the guide instruction this time, based on the context of the target character and the target character restriction instruction, a modification suggestion instruction is generated to give the specific value of the target character. The target character restriction instruction is used to determine the restriction information of the target character, and the modification suggestion instruction is used to determine the modification suggestion of the target character. Then, in the process of generating the domain-specific language statement by the target character restriction instruction and the modification suggestion instruction, the information of the guide instruction obtained is more accurate, thereby improving the accuracy of the target character and further improving the accuracy of the domain-specific language statement. In addition, the modification suggestion instruction can point out the error location and guide the error repair, reducing the resource loss caused by backtracking.
[0235] In another embodiment, the guide instruction includes a target character restriction instruction, a modification suggestion instruction, and a read control instruction. Figure 11 Before returning to the step of executing the second statement, step 330 includes:
[0236] Step 1110: In response to the first request, start the execution of the boot instruction generation code segment to execute the first statement and generate a target character restriction instruction;
[0237] After returning to the step of executing the second statement for the first time, step 330 includes:
[0238] Step 1120: In response to the first request, start the execution of the boot instruction generation code segment to execute the first statement and generate a read control instruction to read the input source character;
[0239] After returning to the step of executing the second statement for the second time, step 330 includes:
[0240] Step 1130 : In response to the first request, start the execution of the boot instruction generation code segment to execute the first statement, and generate a modification suggestion instruction based on the target character restriction instruction, the context of the target character, and the read source character.
[0241] Steps 1110 to 1130 are described in detail below.
[0242] In step 1110 , in response to a first request, execution of a boot instruction generation code segment is started to execute a first statement to generate a target character restricted instruction.
[0243] If the guide instruction includes a target character restriction instruction, a modification suggestion instruction and a control execution, a target character restriction instruction is generated during the first execution of the first statement, that is, before returning to the step of executing the second statement, to determine the range of the target character.
[0244] In step 1120 , in response to the first request, execution of the boot instruction generation code segment is started to execute the first statement and generate a read control instruction to read the input source character.
[0245] A read control instruction is a control instruction that specifically refers to an instruction for reading characters. After the first step of returning to execute the second statement, in response to the first request, execution of the boot instruction generation code segment is initiated to execute the first statement and generate the read control instruction. The read control instruction is used to read the input source character.
[0246] In step 1130 , in response to the first request, the execution of the guiding instruction generation code segment is started to execute the first statement, and a modification suggestion instruction is generated based on the restricted target character instruction, the context of the target character, and the read source character.
[0247] After determining the target character restriction instruction and the read source character, that is, after returning to the step of executing the second statement for the second time, a modification suggestion instruction is generated based on the target character restriction instruction, the context of the target character and the read source character, thereby giving the specific value of the target character.
[0248] It should be noted that the source character is the character input by the object, and the context of the target character may be the source character input by the object or the target character generated before the current moment.
[0249] In one embodiment, when the domain-specific language statement expected to be generated is a number, the first character corresponding to the domain-specific language statement can be a "-" of string type or 0-9 of number type. In this case, the first statement is executed for the first time to generate a target character restriction instruction, which is used to restrict the characters read in next time to be "-" of string type or 0-9 of number type. After returning to the step of executing the second statement for the first time, the first statement is executed for the third time to generate a read control instruction for reading the input source character, and the current object has no input source character, so the source character is empty. Returning to the step of executing the second statement for the second time, that is, executing the first statement for the third time, the context of the target character and the source character are both empty. Based on the context of the target character and the target character restriction instruction, a modification suggestion instruction is generated to suggest the object to select a character from "-" and "0-9" for input.
[0250] It should be noted that if the program to which the domain-specific language sentence generation method is applied requires direct input of the target character, then when there are multiple inputtable characters in the suggestions for the target character given by the target character restriction instruction, a modification suggestion instruction can be generated based on the target character restriction instruction and the context of the target character to determine the value of the target character that the object is most likely to enter, and the target character can be generated and written based on the modification suggestion instruction.
[0251] In the embodiment of steps 1110 to 1130, the guiding instructions include a target character restriction instruction, a modification suggestion instruction, and a read control instruction. The modification suggestion instruction is based on the source character determined by the target character restriction instruction and the read control instruction, as well as the context of the target character. This results in a higher accuracy of the target character determined based on the modification suggestion instruction, thereby improving the efficiency of generating domain-specific language statements. Furthermore, the information provided by the guiding instructions during the generation of domain-specific language statements, including the target character restriction instruction, the modification suggestion instruction, and the read control instruction, is more accurate. Furthermore, the modification suggestion instruction can point out the location of the error and provide guidance on how to fix it, reducing resource loss caused by backtracking.
[0252] Steps 310 to 350 have been explained in detail above. The following will describe in detail some of the specific points or derived contents involved therein, including source character input, multi-threaded processing, and running state storage.
[0253] Source character input
[0254] Source characters refer to characters input by a subject. When using a program that applies a method for generating domain-specific language statements, the subject typically inputs characters into the application program based on its needs. These characters are referred to as source characters. Based on the source characters input by the subject, a domain-specific language statement can be generated.
[0255] In addition, if the domain-specific language grammar rules are fixed, then even if the subject does not input the source characters, a domain-specific language statement that conforms to the domain-specific language grammar rules can be generated. For example, when the domain-specific language grammar rules stipulate that the domain-specific language statement is "let abc=123;", even if the subject does not input the source characters or the input source characters are other incorrect characters, the domain-specific language statement ultimately obtained by the domain-specific language statement generation method provided by the embodiment of the present disclosure is "let abc=123;". When the domain-specific language grammar rules stipulate that the domain-specific language grammar rule is a number, if the subject does not input the source characters, the optional first target characters provided by the domain-specific language statement generation method provided by the embodiment of the present disclosure are "-" or "0-9".
[0256] In one embodiment, referring to Figure 12 Before step 340, the method for generating a domain-specific language statement further includes:
[0257] Step 1210: receiving input source characters;
[0258] Step 1220: In response to the source character, start the execution of the guidance instruction generation code segment to execute the first statement to generate the guidance instruction based on the domain-specific language grammar rules and the source character, and send the guidance instruction to the domain-specific language statement generator, wherein the target character corresponds to the source character and complies with the domain-specific language grammar rules.
[0259] Step 1210 and step 1220 are described in detail below.
[0260] In step 1210, an input source character is received. The source character refers to a character input by the subject, and may be a character directly input by the subject, or a character determined based on a natural language input by the subject.
[0261] When there is a source character input, it is first necessary to obtain the input source character in order to generate a target character corresponding to the source character.
[0262] Reference Figure 2A and Figure 2B In the information transmission analysis and driving application shown, on the terminal side of object B, the source character is the result of the character input by object A on its terminal side after transmission processing. Figures 2C to 2F In the application scenarios shown, the source characters are all characters input by the subject in the corresponding application interface.
[0263] In step 1220, in response to the source character, the execution of the guided instruction generation code segment is started to execute the first statement so as to generate the guided instruction based on the domain-specific language grammar rules and the source character, and send the guided instruction to the domain-specific language statement generator, wherein the target character corresponds to the source character and complies with the domain-specific language grammar rules.
[0264] In response to the received source character, execution of the guidance instruction generation code segment is initiated to execute the first statement. The guidance instruction is specifically generated based on the domain-specific language grammar rules and the source character. Then, under the guidance of the guidance instruction, the target character generated by the domain-specific language statement generator ultimately corresponds to the source character and conforms to the domain-specific language grammar rules.
[0265] In one embodiment, referring to Figure 2D In the interface diagram of the DSL language learning assistant shown, the source characters input by the object are "{"key":0", and the guidance instructions are generated based on the domain-specific language grammar rules, that is, the JSON grammar rules, and the source characters "{"key":0". Then the final target characters are ".", "E", "e", ",", "}", and the target characters are the following of the source characters. The combination of the input source characters and the target characters conforms to the domain-specific language grammar rules.
[0266] In one embodiment, referring to Figure 2E In the interface diagram of the DSL language learning assistant shown, the source characters of the object input are "{"key";1", and the guidance instructions are generated based on the domain-specific language grammar rules, that is, the JSON grammar rules, and the source characters "{"key";1". Then, the final target characters are "{"key":1". The target characters are the characters after the source characters are modified, and the modified target characters comply with the domain-specific language grammar rules.
[0267] Reference Figure 13A and Figure 13BThe generation of a domain-specific language statement first requires determining the corresponding domain-specific language grammar rules. Subsequently, the domain-specific language grammar rule parser parses the domain-specific language grammar rule to generate a guide instruction generation code segment. When a source character is present, the input source character is obtained. In response to the input of the source character, the execution of the guide instruction generation code segment is initiated to execute the first statement "let input = yield newInstruction(...args);", thereby generating a guide instruction based on the domain-specific language grammar rules and the source character, and sending the guide instruction to the domain-specific language statement generator. After the guide instruction is sent, the execution of the guide instruction generation code segment is paused. Furthermore, under the guidance of the guide instruction, the domain-specific language statement generator generates a target character in the domain-specific language statement. The target character corresponds to the source character and complies with the domain-specific language grammar rules. When the generated target character is not a terminator and there are no unprocessed source characters, the process returns to the step of executing the second statement "let instruction = generator.next(...asks);" to generate a first request, and a new target character is generated through the domain-specific language statement generator and the guide instruction generation code segment. When a new source character exists, a new input source character is received to generate a new target character through a domain specific language sentence generator and a guide instruction generation code segment until the generated target character is a terminator.
[0268] Reference Figure 14 The embodiment of the present disclosure can construct an application through a domain-specific language statement generation device, thereby providing services to the object through the specific capabilities of the application. The structural diagram of the domain-specific language statement generation device is shown in FIG. Figure 13A and Figure 13B As shown. Figure 2A and Figure 2B The embodiment of the present disclosure constructs an information transmission parsing and driving application based on a domain-specific language statement generation method, thereby providing information transmission parsing and driving services for objects. The information transmission parsing and driving application can asynchronously parse domain-specific language statements into data structures with extremely high robustness and drive other programs to run without waiting for the entire transmission to be completed, that is, the data input by object A on the terminal side will be parsed after the transmission is completed, and the application will not crash due to errors in the domain-specific language statement structure of part of the transmission message and loss of information, thereby improving the transmission and parsing reliability of the information transmission parsing and driving application. Figure 2C This is a schematic diagram of the interface of an integrated development tool constructed based on a domain-specific language statement generation method. The integrated development tool can respond to object input with higher efficiency and provide real-time feedback on generated guidance information or error information. Figure 2D and Figure 2EThis is a schematic diagram of the interface of a DSL language learning assistant constructed based on a domain-specific language statement generation method. Compared with learning assistants in related technologies, this DSL language learning assistant is able to provide accurate spelling suggestions, error messages, and modification suggestions, thereby helping the subject quickly master the grammar of DSL statements and realize the writing of DSL statements. Figure 2F This is a diagram of the interface of a data mining tool. Data mining tools in related technologies can only match regular languages such as numbers, mobile phone numbers, email addresses, and URLs. However, data mining tools constructed based on domain-specific language sentence generation methods can scan a large number of text characters one by one and extract DSL sentences that meet the requirements, finding target data from a large amount of data and processing it smoothly.
[0269] The guidance instructions in the embodiments of steps 1210 and 1220 are generated based on the domain-specific language grammatical rules and the received input source characters, so that the target characters correspond to the source characters and comply with the domain-specific language grammatical rules. The disclosed embodiments can generate guidance instructions based on the source characters, and when the source characters do not exist, guidance instructions are generated through the first request. The two guidance instructions are determined based on different methods. Therefore, regardless of whether the source characters exist, the target characters generated based on the guidance instructions can still be generated, and the domain-specific language sentences can also be determined, thereby increasing the scope of application of the domain-specific language sentence generation method.
[0270] The above is a general description of step 1210 and step 1220. The specific implementation process of step 1210 and step 1220 is described in detail below.
[0271] In step 1220, in response to the source character, the execution of the guided instruction generation code segment is started to execute the first statement so as to generate the guided instruction based on the domain-specific language grammar rules and the source character, and send the guided instruction to the domain-specific language statement generator, wherein the target character corresponds to the source character and complies with the domain-specific language grammar rules.
[0272] In one embodiment, referring to Figure 15 , step 1220 includes:
[0273] Step 1510: Acquire intermediate state information, where the intermediate state information includes the context of the generated target character and the position information of the target character to be generated;
[0274] Step 1520 : In response to the source character, start the execution of the guide instruction generation code segment to execute the first statement, so as to generate the guide instruction based on the domain specific language grammar rules, the source character, and the intermediate state information.
[0275] Step 1510 and step 1520 are described in detail below.
[0276] In step 1510, intermediate state information is obtained, where the intermediate state information includes the context of the generated target character and position information of the target character to be generated.
[0277] Intermediate state information refers to the state of the domain-specific language in the middle of its generation. The intermediate state information specifically includes the context of the generated target character and the position information of the target character to be generated. Figure 2D For the source character "{"key":0", the previous context of the generated target character is "{"key":0", and the position of the target character to be generated is the 9th character. The intermediate state information can be expressed as "{"key":0 9". In addition to numerical representation, the position of the target character to be generated can also be represented by the previous character. Correspondingly, the intermediate state information only includes the previous context of the generated target character, such as ["key":0]. Based on the previous context of the generated target character, the specific position of the target character to be generated can be determined.
[0278] It should be noted that the intermediate state information can also include the current generation state, that is, the type of the target character to be generated. Assuming that the source character is "{"key", the target character to be generated and the source character together constitute a string. Therefore, the intermediate state information of the target character also includes the current generation state string, then the intermediate state information is expressed as "{"key 6string".
[0279] In step 1520 , in response to the source character, execution of the guide instruction generation code segment is started to execute the first statement to generate the guide instruction based on the domain specific language grammar rules, the source character, and the intermediate state information.
[0280] After receiving the source characters and the intermediate state information corresponding to the target characters to be generated, the execution of the guidance instruction generation code segment is initiated to execute the first statement. During the execution of the first statement, guidance instructions are generated based on the domain-specific language grammar rules, the source characters, and the intermediate state information. The guidance instructions are then sent to the domain-specific language statement generator, so that the domain-specific language statement generator generates the target characters in the domain-specific language statement under the guidance of the guidance instructions.
[0281] The guidance instructions in the embodiments of the above-mentioned steps 1510 and 1520 are generated based on domain-specific language rules, source characters, and intermediate state information, and are provided with intermediate state information, wherein the intermediate state information includes the context of the generated target characters and the position information of the target characters to be generated. The setting of the intermediate state information makes the guidance information contained in the obtained guidance instructions more accurate, so the target characters finally obtained are more accurate, thereby improving the accuracy of the generation of domain-specific language sentences.
[0282] In one embodiment, referring to Figure 16 , step 1210 includes:
[0283] Step 1610: receiving an input source character in a source character input area of an input interface, wherein the input interface further includes a guide instruction display area;
[0284] Correspondingly, after step 1220, the method for generating a domain-specific language statement further includes:
[0285] Step 1620: Display a guidance instruction in the guidance instruction display area to adjust the source character to be input next in the source character input area.
[0286] Step 1610 and step 1620 are described in detail below.
[0287] In step 1610 , an input source character is received in a source character input area of an input interface, wherein the input interface further includes a guidance instruction display area.
[0288] The input interface refers to the input interface of the program used by the domain-specific language sentence generation method provided by the embodiment of the present disclosure, for example, Figure 2A The information transmission analysis and driving application interface shown, Figures 2C to 2F The input interface shown.
[0289] The source character input area refers to the area used to input source characters. The object can input source characters in this area. For example, Figure 2A The input area of "let abc=123;" is shown, Figures 2C to 2E The source character input area shown, Figure 2F The text input area shown.
[0290] The guidance instruction display area refers to an area used to display guidance instructions. The object can view the guidance instructions generated during the generation process of domain-specific language sentences in the guidance instruction display area, for example Figure 2C The boot instruction display area is shown.
[0291] In step 1620 , a guidance instruction is displayed in the guidance instruction display area to adjust the source character to be input next in the source character input area.
[0292] After the guidance instruction is generated, it is displayed in the guidance instruction display area so that the object can view the guidance instruction in the guidance instruction display area. The guidance instruction can provide guidance information, and the object can adjust the source character input next in the source character input area according to the guidance information. For example, referring to Figure 2D, the target characters in the target character display area can be generated according to the domain-specific language sentence generation method. In addition, the object can also adjust the source characters in the source character input area according to the guidance instructions in the guidance instruction display area to obtain "let abc=123;".
[0293] The embodiment of steps 1610 and 1620 described above is provided with an input interface, and the input interface includes a source character input area and a target character display area. The source character input area is an area for inputting source characters, and the guidance instruction display area is an area for displaying guidance instructions. The configuration of the source character input area and the guidance instruction display area enables the domain-specific language sentence generation method to be applied to a variety of scenarios, such as integrated development tools and DSL language learning assistants, thereby expanding the application scope of domain-specific language sentence generation and providing more comprehensive services for the target audience.
[0294] In one embodiment, the input interface also includes an automatic generation control, referring to Figure 17 , step 350 includes:
[0295] Step 1710: In response to the triggering of the automatic generation control, the domain specific language statement generator generates target characters in the domain specific language statement under the guidance of the guide instruction, and if the generated target character is not a terminator, returns to the step of executing the second statement.
[0296] Step 1710 is described in detail below.
[0297] In step 1710, in response to the triggering of the automatic generation control, the domain-specific language statement generator generates the target character in the domain-specific language statement under the guidance of the guidance instruction, and if the generated target character is not a terminator, the process returns to the step of executing the second statement. The automatic generation control is a control for controlling the automatic generation of domain-specific language statements.
[0298] Reference Figure 2C The interface of the integrated development tool displays an automatic generation control. Enabling this control allows for the continuous generation of multiple target characters. Specifically, assuming the DSL rule is "let abc = 123;," when the automatic generation control is triggered (i.e., enabled), the DSL statement generator, guided by the guidance instructions, generates the first target character "l" in the DSL statement. It then returns to execute the second statement, generating the second target character "e," and so on until the generated target character is ";." The resulting DSL statement is "let abc = 123;."
[0299] The input interface in the embodiment of step 1710 includes an automatic generation control. The setting of the automatic generation control enables the program applied by the domain-specific language sentence generation method to realize the continuous generation of multiple target characters until a complete domain-specific language sentence is generated.
[0300] The above is a general description of step 1710. The specific implementation process of step 1710 is described in detail below.
[0301] In step 1710, in response to the triggering of the automatic generation control, the domain-specific language statement generator generates the target characters in the domain-specific language statement under the guidance of the guide instruction, and when the generated target characters are not the terminator, returns to the step of executing the second statement.
[0302] In one embodiment, the domain specific language statement generator includes a plurality of specific language statement generation program segments, referring to Figure 18 , step 1710 includes:
[0303] Step 1810: inputting the guidance instruction into the current specific language statement generation program segment among the multiple specific language statement generation program segments;
[0304] Step 1820: If the current specific language statement generation program segment does not generate the target character, the next specific language statement generation program segment is used as the current specific language statement generation program segment, and the process returns to the step of executing the second statement.
[0305] Step 1830: In response to the triggering of the automatic generation control, if the current specific language statement generation program segment generates a target character, output the target character;
[0306] Step 1840: When the target character is a terminator, terminate the generation of the domain-specific language sentence.
[0307] Step 1850: When the target character is not a terminator, the next specific language statement generation program segment is used as the current specific language statement generation program segment, and the process returns to the step of executing the second statement.
[0308] It should be noted that the specific language sentence generation program segment refers to a code segment that can generate target characters under the guidance of the guide instruction, which is the main component of the domain-specific language sentence generator.
[0309] Steps 1810 to 1850 are described in detail below.
[0310] In step 1810, the guide instruction is input into the current specific language statement generation program segment among the multiple specific language statement generation program segments. The domain-specific language statement generator includes multiple specific language statement generation program segments, and different specific language statement generation program segments can process different types of guide instructions to obtain corresponding target characters.
[0311] In step 1820, if the current specific language statement generation program segment does not generate the target character, the next specific language statement generation program segment is used as the current specific language statement generation program segment, and the process returns to the step of executing the second statement.
[0312] If the current specific language statement generation program segment does not generate the target character, it means that the target character cannot be determined based on the current guidance instruction. Then the next specific language statement generation program segment is used as the current specific language statement generation program segment, and the second statement is returned to execute, so as to generate the target character through the new specific language statement generation program segment. Specifically, assuming that the guidance instruction includes a target character restriction instruction and a modification suggestion instruction, when the execution of the guidance instruction generation layer code segment is first started, the first statement is executed to generate the target character restriction instruction. However, the target character cannot be generated according to the target character restriction instruction and its corresponding domain specific language statement generation program segment. Therefore, the next specific language statement generation program segment is used as the current specific language statement generation program segment, and the second statement is returned to execute. When the execution of the guidance instruction generation layer code segment is started for the second time, the first statement is executed, and the modification suggestion instruction is generated based on the target character restriction instruction and the above-mentioned target character. Then, the target character is generated under the guidance of the modification suggestion instruction through the current specific language statement generation program segment.
[0313] In step 1830, in response to the triggering of the automatic generation control, if the current specific language sentence generation program segment generates the target character, the target character is output. If the current specific language sentence generation program segment can generate the target character under the guidance of the guide instruction, the generated target character is output and displayed. Figure 2C The integrated development tool is provided with a target character display area, which is used to display target characters. When a new target character is generated, the generated target character can be output to the target character display area for display.
[0314] In step 1840, when the target character is a terminator, the generation of the domain-specific language statement is terminated. When the automatic generation control is in the trigger state, if the target character generated by the current specific language statement generation program segment is a terminator, the generation of the domain-specific language statement is terminated. For example, referring to Figure 2C , assuming that the domain-specific language grammar rule is "let abc=123;", if the generated target character is the terminator ";", the generation of the domain-specific language statement ends.
[0315] In step 1850, when the target character is not a terminator, the next specific language statement generation program segment is used as the current specific language statement generation program segment, and the step of executing the second statement is returned. When the automatic generation control is in a triggered state, if the target character generated by the current specific language statement generation program segment is not a terminator, the next specific language statement generation program segment is used as the current specific language statement generation program segment, and the step of executing the second statement is returned to generate a new target character through the guide instruction generation code segment and the domain-specific language statement generator, until a complete domain-specific language statement can be obtained based on the generated multiple target characters. For example, referring to Figure 2C , assuming that the domain-specific language grammar rule is "let abc=123;", if the generated target character is not the terminator ";", it is necessary to return to the step of executing the second statement until the generated target character is the terminator ";".
[0316] The domain-specific language statement generator in the embodiment of steps 1810 to 1850 above includes multiple specific language statement generation program segments. Guide instructions include a variety of different types, and most guide instructions, such as read control instructions, target character restriction instructions, etc., cannot determine the target character to be input. The setting of the specific language statement generation segment can enable the method to return to executing the second statement to generate the first request when the target character is not generated, so that the code segment and the domain-specific language statement generator generate the target character based on the guide instruction. The setting of the specific language statement generation program segment in the embodiment of the present disclosure enables the target character to be correctly generated, thereby ensuring the generation of the domain-specific language statement.
[0317] The above is a general description of steps 1810 to 1850. The specific implementation process of step 1810 is described in detail below.
[0318] In step 1810 , a guiding instruction is input into a current specific language statement generation program segment among a plurality of specific language statement generation program segments.
[0319] In one embodiment, the current specific language statement generation program segment includes a sampling program sub-segment and a generation program sub-segment, referring to Figure 19 , step 1810 includes:
[0320] Step 1910: Input the guiding instruction into the sampling program sub-segment, and the sampling program sub-segment selects a target character from a plurality of candidate characters based on the guiding instruction;
[0321] Step 1920: Generate target characters by generating a program sub-segment.
[0322] Step 1910 and step 1920 are described in detail below.
[0323] In step 1910, a guiding instruction is input into the sample program sub-segment, and the sample program sub-segment selects a target character from a plurality of candidate characters based on the guiding instruction. The candidate characters generally include all characters that conform to the grammatical rules of the domain-specific language.
[0324] The sampling program sub-segment refers to a program code segment that selects a target character based on a guide instruction. The embodiment of the present disclosure writes the sampling program sub-segment through a neural network, random logic, custom logic, etc. to select a target character from multiple candidate characters based on a guide instruction.
[0325] It should be noted that the target character selected by the sampling program sub-segment based on the guide instruction from multiple candidate characters can be one or more. For example, when the domain-specific language sentence generation method is applied to a DSL language learning assistant, the DSL language learning assistant will provide the object with the expected values of all target characters to be input for the object to learn. Therefore, in this case, it is necessary to select all characters that meet the guide instruction from the candidate characters as target characters. When the domain-specific language sentence generation method is applied to an integrated development tool, in order to improve the work efficiency of the object, the integrated development tool usually tends to provide the object with a single target character. Therefore, the target character with the highest probability can be selected from the candidate characters through a neural network.
[0326] In step 1920, a target character is generated by a generator sub-segment. The generator sub-segment is a program code segment that generates the target character. After the sampling sub-segment selects a target character from a plurality of candidate characters based on the guidance instruction, the selected target character is sent to a generator field and converted into a format that conforms to the grammatical rules of a domain-specific language to obtain the target character.
[0327] Reference Figure 20 The domain-specific language sentence generator specifically includes a sampling program sub-segment and a generation program sub-segment. The guidance instruction generation code segment sends the guidance instruction to the sampling program sub-segment for processing. The sampling program field selects a target character from multiple candidate characters based on the guidance instruction. The target character meets the guidance information of the guidance instruction. The generation program sub-segment then generates the target character selected by the sampling program field to obtain a new target character.
[0328] The embodiment of the above-mentioned steps 1910 and 1920 is provided with a sampling program sub-segment and a generation program sub-segment. The sampling program field selects a target character from multiple candidate characters based on the guide instruction so that the final target character meets the requirements of the guide instruction, thereby improving the accuracy of the target character and further improving the accuracy of the generated domain-specific language sentence.
[0329] In one embodiment, the input interface also includes a single character generation control, referring to Figure 21 After step 340, the method for generating domain-specific language statements further includes:
[0330] Step 2110 : In response to the triggering of the single-character generation control, the domain-specific language sentence generator generates the target character in the domain-specific language sentence under the guidance of the guidance instruction, and ends the generation of the domain-specific language sentence.
[0331] Step 2110 is described in detail below.
[0332] In step 2110 , in response to the triggering of the single-character generation control, the domain-specific language sentence generator generates the target character in the domain-specific language sentence under the guidance of the guidance instruction, and the generation of the domain-specific language sentence is terminated.
[0333] Single character generation control is used to control the generation of a single character. Figure 2C When the automatic generation control is in a non-triggered state, click the single-character generation control to generate a single target character. Specifically, when the automatic generation control is in a non-triggered state, in response to the triggering of the single-character generation control, the domain-specific language sentence generator generates the target character in the domain-specific language sentence under the guidance of the guide instruction, and ends the generation of the domain-specific language sentence. Click the single-character generation control again to generate a new target character.
[0334] It should be noted that when the target character display area is set to display only one domain-specific language sentence, if the target character display area currently displays a complete domain-specific language sentence, triggering the single-character generation control will not respond. However, when the target character display area is set to display multiple domain-specific language sentences, if the target character display area currently displays a complete domain-specific language sentence, triggering the single-character generation control will generate a new target character.
[0335] The embodiment of the above-mentioned step 2110 is provided with a single-character generation control. The setting of the single-character generation control facilitates the generation of each character in the domain-specific language sentence one by one, thereby strengthening the connection between each character, which is conducive to the object learning the domain-specific language sentence through the program applying the domain-specific language sentence.
[0336] Multithreading
[0337] In one embodiment, the guiding instruction generation code segment includes a plurality of guiding instruction generation code segment instances in a first thread, and the domain specific language statement generator includes a plurality of domain specific language statement generator instances in a second thread.
[0338] Reference Figure 22 , step 320 includes:
[0339] Step 2210: Execute the second statement through the domain specific language statement generator instance in the target second thread among the plurality of second threads;
[0340] Correspondingly, step 330 includes:
[0341] Step 2220: In response to the first request, determine a target first thread from the plurality of first threads, and start execution of the boot instruction generation code segment instance in the target first thread;
[0342] Correspondingly, step 350 includes:
[0343] Step 2230: Generate target characters in the domain specific language sentence through the domain specific language sentence generator instance in the target second thread under the guidance of the guidance instruction.
[0344] It should be noted that the guiding instruction generation code segment instance refers to a code segment including a first statement, which is capable of generating a guiding instruction for a domain-specific language statement. The first thread refers to the execution thread of the guiding instruction generation code segment. The domain-specific language statement generator refers to the code segment for executing the second statement, generating the first request, and generating the target character. The second thread refers to the thread for executing the domain-specific language statement generator instance.
[0345] Steps 2210 to 2230 are described in detail below.
[0346] In step 2210 , the second statement is executed by a domain specific language statement generator instance in a target second thread among the plurality of second threads.
[0347] There are multiple second threads, and the embodiments of the present disclosure can set the domain-specific language grammar rules to correspond to the second threads according to actual needs. Specifically, the same domain-specific language grammar rule can be set to correspond to multiple second threads, so that the application platform built based on the domain-specific language statement generation method can provide services to multiple objects. In addition, multiple second threads can also be set to correspond to different domain-specific language grammar rules, so the domain-specific language statement generation method can generate DSL statements of different domain-specific language grammar rules, and there is no need to update the domain-specific language statement generator when the domain-specific language grammar rules are updated, thereby improving the generation efficiency.
[0348] The target second thread refers to a thread for executing a domain-specific language sentence generator instance, and the domain-specific language sentence generator instance corresponds to a domain-specific language grammar rule.
[0349] In step 2220 , in response to the first request, a target first thread is determined among the plurality of first threads, and execution of the boot instruction generation code segment instance in the target first thread is started.
[0350] There are multiple first threads, each used to execute code segments for generating guidance instructions. These first threads correspond to domain-specific language grammar rules, and instances of guidance instruction generation code segments within multiple first threads under the same domain-specific language grammar rules can generate various types of guidance instructions. Specifically, two sets of first threads are provided for JSON and XML, respectively. The multiple first threads corresponding to JSON each have guidance instruction generation code segment instances used to generate target character restriction instructions, read control instructions, and modification suggestion instructions, among others.
[0351] The target first thread is a thread used to generate guidance instructions corresponding to the domain-specific language grammar rules and the first request. In response to the first request, based on the domain-specific language grammar rules and the first request, a target first thread is determined from among the multiple first threads, and execution of the guidance instruction generation code segment instance in the target first thread is initiated.
[0352] In step 2230, the domain-specific language sentence generator instance in the target second thread generates target characters in the domain-specific language sentence under the guidance of the guidance instructions. After the guidance instructions are generated based on the target second thread and the target thread inheritance, the domain-specific language sentence generator instance in the target second thread generates the target characters in the domain-specific language sentence.
[0353] Reference Figure 23 , the domain-specific language grammar rule is parsed by a domain-specific language grammar rule parser to generate a guiding instruction generation code segment, wherein the guiding instruction generation code segment includes a plurality of guiding instruction generation code segment instances in the first thread. The target second thread among the plurality of second threads, that is, the domain-specific language statement generator instance in the second thread N, executes the second statement to generate a first request. In response to the first request, the first thread N among the plurality of first threads is determined as the target first thread. Afterwards, based on starting the execution of the guiding instruction generation code segment instance in the target first thread, a guiding instruction is obtained, and the guiding instruction is sent to the domain-specific language statement generator instance in the target second thread. The execution of the guiding instruction generation code segment instance in the target first thread is paused. At the same time, under the guidance of the guiding instruction, the target character is generated by the domain-specific language statement generator instance in the target second thread.
[0354] In the embodiment of steps 2210 to 2230 described above, multiple first threads and multiple second threads are configured, and the first and second threads are configured to correspond to domain-specific language grammars, so that the application platform constructed based on the domain-specific language statement generation method can provide services to multiple objects. Furthermore, when multiple first threads and second threads are configured to correspond to different domain-specific language grammar rules, the domain-specific language statement generation method can generate DSL statements according to different domain-specific language grammar rules without having to update the domain-specific language statement generator when the domain-specific language grammar rules are updated, thereby improving generation efficiency.
[0355] In step 2220 , in response to the first request, a target first thread is determined among the plurality of first threads, and execution of the boot instruction generation code segment instance in the target first thread is started.
[0356] In one embodiment, referring to Figure 24 , step 2220 includes:
[0357] Step 2410: In response to the first request, determine the load of the plurality of first threads;
[0358] Step 2420: Determine processing environment parameters of the plurality of first threads;
[0359] Step 2430: Determine a target first thread among the plurality of first threads based on the load and the processing environment parameters.
[0360] Steps 2410 to 2430 are described in detail below.
[0361] In step 2410, in response to the first request, the workload of multiple first threads is determined. Multiple first threads are threads whose bootstrap instruction generation code segment instances conform to the grammatical rules of a domain-specific language. In response to the first request, multiple first threads are first determined that conform to the grammatical rules of the domain-specific language and are capable of generating bootstrap instructions of the expected type. The workload of the multiple first threads is then determined. The workload is a measure of the workload of the current first thread.
[0362] In step 2420, the processing environment parameters of the plurality of first threads are determined. The processing environment parameters refer to the parameters of the working environment of the first threads, and the processing environment parameters may include the constant frequency and memory parameters of the processor where the first thread resides.
[0363] In step 2430, a target first thread is determined from among the plurality of first threads based on the load and the processing environment parameters. The smaller the load of the first thread and the higher the processing environment parameters, the higher the efficiency of generating the code segment instance from the boot instruction in the first thread. Therefore, the first thread is determined from among the plurality of first threads based on the load and the processing environment parameters to improve the efficiency of generating the boot instruction.
[0364] Reference Figure 23 The embodiment of the present disclosure first obtains the load and environmental processing parameters of multiple first threads, and determines the target first thread among the multiple first threads based on the load and processing environment parameters, wherein the target first thread is the thread with the highest processing efficiency for generating a code segment instance for the boot instruction among the multiple first threads.
[0365] In the embodiment of steps 2410 to 2430 described above, a target first thread is determined from among multiple first threads based on the load and processing environment parameters. In the disclosed embodiment, the load and processing environment parameters are used as criteria to select the target first thread, so that the resulting first thread has a higher execution efficiency for generating a code segment instance from a boot instruction, thereby improving the efficiency of generating boot instructions and, in turn, the efficiency of generating domain-specific language statements.
[0366] Running status save
[0367] In one embodiment, referring to Figure 25 Before step 340, the method for generating a domain-specific language statement further includes:
[0368] Step 2510: Save the running status of the boot instruction generated code segment;
[0369] Correspondingly, step 330 includes:
[0370] Step 2520: In response to the first request, start execution of the boot instruction generation code segment;
[0371] Step 2530: Restore the saved running state;
[0372] Step 2540: Execute the first statement, generate a guide instruction, and send the guide instruction to the domain-specific language statement generator.
[0373] Steps 2510 to 2540 are described in detail below.
[0374] In step 2510, the running state of the boot instruction generation code segment is saved. The running state refers to the running state of the boot instruction generation code segment at the current moment, which specifically includes the execution position of the boot instruction generation code segment at the current moment.
[0375] In step 2520, in response to the first request, execution of the guided instruction generation code segment is initiated. After returning to the execution step of the second statement, the second statement is executed by the domain-specific language statement generator to generate a first request for invoking the guided instruction generation code segment. In response to the first request, the guided instruction generation code segment is executed.
[0376] In step 2530, the saved running state is restored. The execution of the boot instruction generation code segment is in a suspended state, so to start the execution of the boot instruction generation code segment, it is first necessary to restore the boot instruction generation code segment to an execution state and restore the previously saved running state of the boot instruction generation code segment.
[0377] In step 2540, the first statement is executed to generate a guide instruction, which is then sent to the domain-specific language statement generator. After the saved running status of the code segment generating the guide instruction is restored, the current running environment satisfies the execution conditions of the code segment generating the guide instruction, and the first statement is executed to generate the guide instruction.
[0378] In the embodiment of steps 2510 to 2540, when the execution of the bootstrap instruction generation code segment is suspended, the running state of the bootstrap instruction generation code segment is saved, and when the execution of the bootstrap instruction generation code segment is restarted, the running state of the bootstrap instruction generation code segment that was previously saved is restored. The saving and restoration of the running state of the bootstrap instruction generation code segment in the disclosed embodiment ensures that the bootstrap instruction generation code segment can be executed normally and can achieve asynchronous execution of the bootstrap instruction generation code segment, thereby improving the accuracy of the generated DSL statements and reducing resource consumption.
[0379] The above is a general description of steps 2510 to 2540. The specific implementation process of steps 2510 to 2540 will be described in detail below.
[0380] In one embodiment, if the platform for generating domain specific language statements does not support the first statement, refer to Figure 26 After step 310, the method for generating domain-specific language statements further includes:
[0381] Step 2610: compile the first statement into a branch statement and a state saving statement supported by the platform;
[0382] Correspondingly, step 2510 includes:
[0383] Step 2620: Use a state save statement to save the running state of the code segment generated by the boot instruction;
[0384] Correspondingly, step 2540 includes:
[0385] Step 2630: Execute the branch statement to generate a guide instruction.
[0386] Steps 2610 to 2630 are described in detail below.
[0387] In step 2610, the first statement is compiled into a branch statement and a state saving statement supported by the platform. A branch statement is a statement code used to generate a guide instruction, and a state saving statement is a statement that saves the execution state of a branch statement.
[0388] In step 2620, the state save statement is used to save the running state of the code segment generated by the guiding instruction. When the code segment is paused, the running state of the code segment generated by the guiding instruction, that is, the running state of the branch statement, is saved by the state save statement.
[0389] In step 2630, the branch statement is executed to generate the boot instruction. When restoring the saved boot instruction generation code segment running state, the execution position of the branch statement can be determined through the state saving statement, and the branch statement is continued to be executed from the execution position to generate the boot instruction.
[0390] The embodiment of the above-mentioned steps 2610 to 2630 realizes the saving and restoration of the running state of the boot instruction generation code segment through branch statements and state saving statements, ensuring that the running generation of the boot execution generation code segment is consistent when saving and restoring, thereby improving the accuracy of the boot instruction generated after returning to the step of executing the second statement, and thereby improving the accuracy of the generated domain-specific language statement.
[0391] In one embodiment, the method for generating domain-specific language statements provided by the embodiment of the present disclosure can modify erroneous DSL statements. Figure 27A and Figure 27B , integrated development tools use JSON language for coding development. Figure 27A As shown in the figure, the source character entered in the source character input area is ""key":123," which does not conform to the domain-specific language grammar rules corresponding to the JSON language. After the source character is processed by the integrated development tool built based on the domain-specific language statement generation method, the target character ""key":123" is obtained. This shows that the domain-specific language statement generation method can delete unnecessary incorrect characters in the DSL statement. Figure 27B The source character entered in the source character input area is ""key"_123," which does not conform to the DOM grammar rules of the JSON language. After the source character is processed by the integrated development tool built based on the DOM grammar generation method, the target character ""key":123" is obtained. This shows that the DOM grammar generation method can delete the incorrect characters in the DSL statement and repair it.
[0392] In one embodiment, referring to Figure 28A , the object asks the large language model for the grammatical rules of the JSON language, and the large language model explains the specific rules of JSON. Figure 28B When the subject inputs "-" in the source character input area of the DSL language learning assistant, the target characters displayed in the target character display area are 0 and / 1-9 / . Based on the source character "-", the DSL language learning assistant determines that the subject's current input is a number, and thus provides the following optional characters. Obviously, Figure 28B The target character given matches Figure 28A If the grammatical rules of the JSON language in the embodiment of the present disclosure are followed, the domain-specific language statements generated by the embodiment of the present disclosure comply with the domain-specific language statement rules and have high accuracy.
[0393] In one embodiment, referring to Figure 29A , which shows the specific structure of object, members and member in JSON language. Figure 29B , the subject enters "{"key"" in the source character input area of the DSL language learning assistant. It can be clearly concluded that the subject is entering a member and hopes to generate members and objects based on the member. To generate a member, the next character of "{"key"" can only be ":". The target character given by the DSL language learning assistant is ":", which is consistent with Figure 29A The domain-specific language grammar rules shown. Figure 29C , the object enters "{"key":1,"" in the source character input area of the DSL Language Learning Assistant, and the target character is """. Specifically, the "," in "{"key":1,"" means that the corresponding object's members have not yet ended. The "," must be followed by a new member. Since members starts with a string, the string must start with a double quote, which means the target character is """.
[0394] In one embodiment, referring to Figure 30 When the alphabet is ASCII code, the device based on the domain-specific language statement generation method has undergone nearly 300 million JSON random generation tasks. The average length of the generated JSON is 17.86, and it has passed the parsing of the device and other devices. The generation success rate, parsing success rate, and information consistency rate are all 100%, without a single error. When the alphabet is expanded to Unicode, the device generates random JSON with a length of more than 2000, all successfully, that is, the string conforms to the grammatical rules and can be correctly parsed into the data structure in the program. This shows that the domain-specific language statements generated by the domain-specific language statement generation method provided by the embodiment of the present disclosure have high accuracy.
[0395] It should be noted that if the alphabet is defined as ∑, the context-free grammar is G, and the language that conforms to the context-free grammar is L(G), then
[0396]
[0397]
[0398] Where x is a character or string, y is a character or string, ∑ * The above two functions indicate that if the strings x and y belong to the same alphabet, then both xy and yx conform to the context-free grammar. The domain-specific language sentence generation method provided by the embodiment of the present disclosure can implement the following two functions:
[0399] M P (s) = {m∈∑|sm∈P(G)}
[0400] M S (s) = {m∈∑|ms∈S(G)}
[0401] The above two functions indicate that the target character m corresponding to the source character s determined based on the embodiment of the present disclosure belongs to the alphabet, and then both sm and ms conform to the context-free grammar.
[0402] Implementation details of the method for generating domain-specific language sentences according to the embodiment of the present disclosure
[0403] Refer to the following Figure 31 , which illustrates in detail the implementation details of the method for generating domain-specific language sentences according to an embodiment of the present disclosure.
[0404] In step 3110 , domain specific language grammar rules are obtained.
[0405] In step 3120 , a guiding instruction generation code segment is generated based on the domain-specific language grammar rules, wherein the guiding instruction generation code segment includes a first statement, and the first statement is used to generate a guiding instruction of a domain-specific language statement.
[0406] In step 3131 , when there is a source character input, the execution of the boot instruction generation code segment is started in response to the input source character.
[0407] In one embodiment, the input source character is received in a source character input area of the input interface.
[0408] In step 3132, when the passive character is input, the second statement is executed by the domain specific language statement generator, and the second statement is used to generate a first request for calling the boot instruction to generate a code segment.
[0409] In step 3133 , in response to the first request, execution of the boot instruction generation code segment is started.
[0410] In step 3140 , corresponding to the execution of the boot instruction generation code segment, the first statement is executed to generate the boot instruction.
[0411] Specifically, when there is a source character input, a guiding instruction is generated based on the domain-specific language grammar rules and the source character.
[0412] In step 3151, when the target character is determined to be a terminal target character type based on the generation task and domain-specific language grammar rules, a guidance instruction for outputting the terminal target character is generated through the top-level function. The terminal target character type is a character type that can be uniquely determined based on the context of the target character.
[0413] In step 3152, when the target character is determined to be a non-terminal target character type based on the generation task and the domain-specific language grammar rules, the underlying function corresponding to the non-terminal target character type is determined, and the underlying function is forwarded to the sub-package generation program corresponding to the non-terminal target character type in multiple sub-package generation programs for execution to generate a boot instruction.
[0414] In step 3160, a guidance instruction is displayed in the guidance instruction display area to adjust the source character to be input next in the source character input area.
[0415] In step 3170, the guidance instructions are sent to the domain specific language sentence generator.
[0416] In step 3180, execution of the boot instruction generation code segment is suspended.
[0417] In step 3191, the domain-specific language statement generator includes a plurality of domain-specific language statement generation program segments.
[0418] A guide instruction is input into a current specific language statement generation program segment among a plurality of specific language statement generation program segments.
[0419] If the current specific language statement generation program segment does not generate the target character, the next specific language statement generation program segment is used as the current specific language statement generation program segment, and the process returns to the step of executing the second statement.
[0420] In response to the triggering of the automatic generation control, if the current specific language statement generation program segment generates a target character, the target character is output. When the target character is not a terminator, the next specific language statement generation program segment is used as the current specific language statement generation program segment, and the step of executing the second statement is returned.
[0421] In step 3192, the domain specific language sentence generator generates the target character in the domain specific language sentence under the guidance of the guide instruction, and ends the generation of the domain specific language sentence when the target character is a terminator.
[0422] Description of the apparatus and device of the present disclosure
[0423] It is to be understood that, although the steps in the above-mentioned flowcharts are shown in sequence according to the arrow representations, these steps are not necessarily performed in sequence according to the order represented by the arrows. Unless otherwise specified in the present embodiment, there is no strict order restriction on the execution of these steps, and these steps can be performed in other orders. Moreover, at least a portion of the steps in the above-mentioned flowcharts may include multiple steps or multiple stages, and these steps or stages are not necessarily performed at the same time, but can be performed at different times, and the execution order of these steps or stages is not necessarily performed in sequence, but can be performed in turn or alternately with other steps or at least a portion of the steps or stages in other steps.
[0424] It should be noted that in each specific embodiment of the present application, when it comes to the need to perform relevant processing based on data related to the characteristics of the task content, such as task content attribute information or attribute information sets, the permission or consent of the task content will be obtained first, and the collection, use and processing of such data will comply with relevant laws, regulations and standards. In addition, when the embodiment of the present application needs to obtain task content attribute information, it will obtain a separate permission or separate consent for the task content through a pop-up window or jump to a confirmation page. After clearly obtaining a separate permission or separate consent for the task content, the necessary task content-related data for the normal operation of the embodiment of the present application will be obtained.
[0425] Figure 32 This is a schematic diagram of the structure of a domain-specific language sentence generation device 3200 provided in an embodiment of the present disclosure. The domain-specific language sentence generation device 3200 includes:
[0426] A first generating unit 3210 is configured to generate a guiding instruction generation code segment based on a domain-specific language grammar rule, wherein the guiding instruction generation code segment includes a first statement, and the first statement is configured to generate a guiding instruction of a domain-specific language statement;
[0427] The first execution unit 3220 is configured to execute a second statement through a domain specific language statement generator, where the second statement is configured to generate a first request for invoking a boot instruction to generate a code segment;
[0428] The second execution unit 3230 is configured to start execution of the guidance instruction generation code segment in response to the first request, so as to execute the first statement, generate the guidance instruction, and send the guidance instruction to the domain specific language statement generator;
[0429] A pause unit 3240, configured to pause execution of the boot instruction generated code segment;
[0430] The second generating unit 3250 is configured to generate target characters in the domain specific language sentence under the guidance of the guiding instruction through the domain specific language sentence generator, and return to the step of executing the second sentence if the generated target character is not a terminator.
[0431] Optionally, the domain-specific language sentence generating device 3200 further includes:
[0432] A first receiving unit, configured to receive an input source character;
[0433] The third execution unit is configured to start execution of a guide instruction generation code segment in response to the source character to execute the first statement so as to generate a guide instruction based on the domain-specific language grammar rules and the source character, and send the guide instruction to the domain-specific language statement generator, wherein the target character corresponds to the source character and complies with the domain-specific language grammar rules.
[0434] Optionally, the third execution unit is specifically configured to:
[0435] Obtaining intermediate state information, the intermediate state information including the context of the generated target character and the position information of the target character to be generated;
[0436] In response to the source character, execution of the guide instruction generation code segment is started to execute the first statement to generate the guide instruction based on the domain specific language grammar rules, the source character, and the intermediate state information.
[0437] Optionally,
[0438] The first receiving unit is specifically configured to: receive a source character input in a source character input area of the input interface, wherein the input interface further includes a guide instruction display area;
[0439] The domain specific language sentence generating apparatus 3200 further includes: a display unit configured to display a guiding instruction in the guiding instruction display area so as to adjust the source character to be input next in the source character input area.
[0440] Optionally, the input interface further includes an automatic generation control;
[0441] The second generation unit 3250 is specifically used to: in response to the triggering of the automatic generation control, generate the target characters in the domain-specific language sentence through the domain-specific language sentence generator under the guidance of the guide instruction, and return to the step of executing the second sentence when the generated target character is not a terminator.
[0442] Optionally, the domain-specific language statement generator includes a plurality of specific language statement generation program segments;
[0443] The second generating unit 3250 is further specifically configured to:
[0444] inputting a guide instruction into a current specific language statement generation program segment among the multiple specific language statement generation program segments;
[0445] If the current specific language statement generation program segment does not generate the target character, the next specific language statement generation program segment is used as the current specific language statement generation program segment, and the process returns to the step of executing the second statement;
[0446] In response to the triggering of the automatic generation control, if the current specific language statement generation program segment generates a target character, the target character is output, wherein, when the target character is a terminator, the generation of the domain-specific language statement is terminated; when the target character is not a terminator, the next specific language statement generation program segment is used as the current specific language statement generation program segment, and the step of executing the second statement is returned.
[0447] Optionally, the current specific language statement generation program segment includes a sampling program sub-segment and a generation program sub-segment;
[0448] The second generating unit 3250 is further specifically configured to:
[0449] Inputting a guide instruction into a current specific language statement generation program segment among a plurality of specific language statement generation program segments includes:
[0450] Inputting the guiding instruction into the sampling program sub-segment, and the sampling program sub-segment selecting the target character from a plurality of candidate characters based on the guiding instruction;
[0451] Generate target characters by generating program subsections.
[0452] Optionally, the input interface further includes a single character generation control;
[0453] The domain-specific language sentence generation device 3200 further includes:
[0454] The third generating unit is configured to generate target characters in a domain specific language sentence in response to triggering of the single character generating control, through the domain specific language sentence generator and under the guidance of the guiding instruction, and terminate the generation of the domain specific language sentence.
[0455] Optionally, the second execution unit 3230 is specifically configured to:
[0456] From the first statement, obtain the generation task of the guide instruction;
[0457] Get multiple subpackage generation programs;
[0458] Sending the generation task to multiple sub-package generation programs to generate multiple sub-boot instructions;
[0459] Combine multiple sub-boot instructions into a boot instruction.
[0460] Optionally, the generation task includes a top-level function and a plurality of bottom-level functions corresponding to a plurality of sub-package generation programs;
[0461] The second execution unit 3230 is further configured to:
[0462] Distribute multiple underlying functions to multiple subpackage generators;
[0463] The generation task is sent to multiple sub-package generation programs, and multiple bottom-level functions in the multiple sub-package generation programs are called through the top-level function to execute the generation task and obtain multiple sub-guidance instructions.
[0464] Optionally, the second execution unit 3230 is specifically configured to:
[0465] Obtaining a generation task of a guide instruction from the first statement, the generation task including a top-level function and bottom-level functions corresponding to various non-terminal target character types, the non-terminal target character type being a character type that cannot be uniquely determined based on the context of the target character;
[0466] When the target character is determined to be a terminal target character type based on the generation task and the domain-specific language grammar rules, a guide instruction for outputting the terminal target character is generated through the top-level function, where the terminal target character type is a character type that can be uniquely determined based on the context of the target character;
[0467] When the target character is determined to be a non-terminal target character type based on the generation task and the domain-specific language grammar rules, the underlying function corresponding to the non-terminal target character type is determined, and the underlying function is forwarded to the sub-package generation program corresponding to the non-terminal target character type in multiple sub-package generation programs for execution to generate a guide instruction.
[0468] Optionally, the guiding instruction includes an instruction for limiting target characters and an instruction for modifying suggestions;
[0469] Before returning to the step of executing the second statement, the second execution unit 3230 is specifically configured to: in response to the first request, start the execution of the guide instruction generation code segment to execute the first statement and generate a target character restriction instruction;
[0470] After returning to the step of executing the second statement, the second execution unit 3230 is specifically used to: in response to the first request, start the execution of the boot instruction generation code segment to execute the first statement, and generate a modification suggestion instruction based on the restriction target character instruction and the above context of the target character.
[0471] Optionally, the guiding instruction includes a target character restriction instruction, a modification suggestion instruction, and a read control instruction;
[0472] Before returning to the step of executing the second statement, the second execution unit 3230 is specifically configured to: in response to the first request, start the execution of the guide instruction generation code segment to execute the first statement and generate a target character restriction instruction;
[0473] After returning to the step of executing the second statement for the first time, the second execution unit 3230 is specifically configured to: in response to the first request, start execution of the boot instruction generation code segment to execute the first statement and generate a read control instruction to read the input source character;
[0474] After the step of returning to execute the second statement for the second time, the second execution unit 3230 is specifically used to: in response to the first request, start the execution of the boot instruction generation code segment to execute the first statement, and generate a modification suggestion instruction based on the restricted target character instruction, the context of the target character and the read source character.
[0475] Optionally, the guiding instruction generation code segment includes multiple guiding instruction generation code segment instances in the first thread, and the domain specific language statement generator includes multiple domain specific language statement generator instances in the second thread;
[0476] The first execution unit 3220 is specifically configured to: execute the second statement through the domain specific language statement generator instance in the target second thread among the plurality of second threads;
[0477] The second execution unit 3230 is specifically configured to: determine a target first thread from the plurality of first threads in response to the first request, and start execution of the boot instruction generation code segment instance in the target first thread;
[0478] The second generating unit 3250 is specifically configured to generate target characters in the domain specific language sentence through the domain specific language sentence generator instance in the target second thread under the guidance of the guiding instruction.
[0479] Optionally, the second execution unit 3230 is further configured to:
[0480] In response to the first request, determining a load of the plurality of first threads;
[0481] determining processing environment parameters of a plurality of first threads;
[0482] A target first thread is determined among the plurality of first threads based on the load amount and the processing environment parameter.
[0483] Optionally, the domain-specific language sentence generating device 3200 further includes:
[0484] A saving unit, configured to save the running state of the boot instruction generation code segment before pausing the execution of the boot instruction generation code segment;
[0485] The recovery unit is used to restore the saved running state.
[0486] Optionally, if the platform for generating domain-specific language sentences does not support the first sentence, the domain-specific language sentence generating apparatus 3200 further includes:
[0487] A compilation unit, configured to compile the first statement into a branch statement and a state saving statement supported by the platform;
[0488] The saving unit is specifically used to: save the running state of the code segment generated by the boot instruction using a state saving statement;
[0489] The second execution unit 3230 is further specifically configured to execute branch statements and generate guide instructions.
[0490] Reference Figure 33 , Figure 33 The structural block diagram of the terminal for implementing the method for generating domain-specific language sentences according to an embodiment of the present disclosure is as follows: the terminal includes: a radio frequency (RF) circuit 3310, a memory 3315, an input unit 3330, a display unit 3340, a sensor 3350, an audio circuit 3360, a wireless fidelity (WiFi) module 3370, a processor 3380, and a power supply 3390. It will be understood by those skilled in the art that Figure 33 The terminal structure shown does not constitute a limitation on the mobile phone or computer, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0491] The RF circuit 3310 may be used for receiving and sending signals during information transmission or calls. In particular, after receiving downlink information from the base station, it is sent to the processor 3380 for processing; in addition, the designed uplink data is sent to the base station.
[0492] The memory 3315 may be used to store software programs and modules. The processor 3380 executes various functional applications and data processing of the content terminal by running the software programs and modules stored in the memory 3315 .
[0493] The input unit 3330 may be configured to receive input digital or character information and generate key signal input related to the settings and function control of the content terminal. Specifically, the input unit 3330 may include a touch panel 3331 and other input devices 3332 .
[0494] The display unit 3340 may be configured to display input information or provided information and various menus of the content terminal. The display unit 3340 may include a display panel 3341.
[0495] The audio circuit 3360 , the speaker 3361 , and the microphone 3362 may provide an audio interface.
[0496] In this embodiment, the processor 3380 included in the terminal can execute the domain-specific language sentence generation method of the previous embodiment.
[0497] The terminals of the embodiments of the present disclosure include but are not limited to mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals, aircraft, etc. The embodiments of the present invention can be applied to various scenarios, including but not limited to content recommendation, data screening, etc.
[0498] Figure 34 A structural block diagram of a portion of the server 140 for implementing the domain-specific language statement generation method of an embodiment of the present disclosure. The server 140 may vary greatly due to different configurations or performance, and may include one or more central processing units (CPUs) 3422 (for example, one or more processors) and memories 3432, and one or more storage media 3430 (for example, one or more mass storage devices) for storing application programs 3442 or data 3444. Among them, the memories 3432 and the storage media 3430 may be temporary storage or permanent storage. The program stored in the storage medium 3430 may include one or more modules (not shown in the figure), each module may include a series of instruction operations on the server 140. Furthermore, the central processing unit 3422 may be configured to communicate with the storage medium 3430 to execute a series of instruction operations in the storage medium 3430 on the server 140.
[0499] The server 140 may also include one or more power supplies 3426, one or more wired or wireless network interfaces 3450, one or more input and output interfaces 3458, and / or one or more operating systems 3441, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.
[0500] The central processing unit 3422 in the server 140 can be used to execute the domain-specific language sentence generation method of the embodiment of the present disclosure.
[0501] The embodiments of the present disclosure further provide a computer-readable storage medium for storing program codes, and the program codes are used to execute the domain-specific language statement generation method of each of the aforementioned embodiments.
[0502] The present disclosure also provides a computer program product, which includes a computer program. A processor of a computer device reads and executes the computer program, so that the computer device implements the above-mentioned method for generating domain-specific language sentences.
[0503] The terms "first," "second," "third," "fourth," and the like (if any) in the specification of the present disclosure and the accompanying drawings are used to distinguish between similar contents and are not necessarily used to describe a particular order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments of the present disclosure described herein, for example, can be implemented in orders other than those illustrated or described herein. In addition, the terms "comprises" and "comprising," and any variations thereof, are intended to cover non-exclusive inclusions, e.g., a process, method, system, product, or apparatus comprising a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0504] It should be understood that in the present disclosure, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated content, indicating that there can be three relationships. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and following associated content is in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0505] It should be understood that in the description of the embodiments of the present disclosure, the meaning of multiple (or multiple items) is more than two, greater than, less than, exceed, etc. are understood to exclude the number itself, and above, below, within, etc. are understood to include the number itself.
[0506] In the several embodiments provided in the present disclosure, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0507] Units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0508] In addition, the functional units in the various embodiments of the present disclosure may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0509] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present disclosure is essentially or the part that contributes to the relevant technology or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server 140, or network device, etc.) to execute all or part of the steps of the various embodiments of the present disclosure. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc., various media that can store program code.
[0510] It should also be understood that the various implementations provided in the embodiments of the present disclosure can be arbitrarily combined to achieve different technical effects.
[0511] The above is a specific description of the implementation methods of the present disclosure, but the present disclosure is not limited to the above implementation methods. Those skilled in the art can make various equivalent modifications or substitutions without violating the spirit of the present disclosure. These equivalent modifications or substitutions are all included in the scope defined by the claims of the present disclosure.
Claims
1. A method for generating domain-specific language sentences, characterized in that: include: Generate a guiding instruction generation code segment based on a domain-specific language grammar rule, wherein the guiding instruction generation code segment includes a first statement, and the first statement is used to generate a guiding instruction of the domain-specific language statement; executing, by the domain specific language statement generator, a second statement for generating the first request for calling the boot instruction to generate a code segment; In response to the first request, starting execution of the guidance instruction generation code segment to execute the first statement, generate the guidance instruction, and send the guidance instruction to the domain specific language statement generator; pausing the execution of the boot instruction generation code segment; The domain specific language sentence generator generates target characters in the domain specific language sentence under the guidance of the guide instruction, and returns to the step of executing the second sentence when the generated target character is not a terminator.
2. The method for generating domain-specific language sentences according to claim 1, wherein: Before pausing the execution of the boot instruction generation code segment, the method for generating a domain specific language statement further includes: Receive the input source character; In response to the source character, the execution of the guide instruction generation code segment is started to execute the first statement so as to generate the guide instruction based on the domain-specific language grammar rules and the source character, and send the guide instruction to the domain-specific language statement generator, wherein the target character corresponds to the source character and complies with the domain-specific language grammar rules.
3. The method for generating domain-specific language sentences according to claim 2, wherein: The step of starting execution of the guiding instruction generation code segment in response to the source character to execute the first statement so as to generate the guiding instruction based on the domain specific language grammar rule and the source character comprises: Acquiring intermediate state information, the intermediate state information including the generated target character context and position information of the target character to be generated; In response to the source character, the execution of the guiding instruction generation code segment is started to execute the first statement, so as to generate the guiding instruction based on the domain specific language grammar rule, the source character, and the intermediate state information.
4. The method for generating domain-specific language sentences according to claim 2, wherein: The receiving of the input source character comprises: receiving the input source character in a source character input area of an input interface, wherein the input interface further comprises a guide instruction display area; After starting the execution of the guiding instruction generation code segment in response to the source character to execute the first statement so as to generate the guiding instruction based on the domain-specific language grammar rules and the source character, the domain-specific language statement generation method further includes: displaying the guiding instruction in the guiding instruction display area so as to adjust the source character to be input next in the source character input area.
5. The method for generating domain-specific language sentences according to claim 4, wherein: The input interface also includes an automatic generation control; The step of generating the target characters in the domain-specific language sentence by the domain-specific language sentence generator under the guidance of the guiding instruction, and returning to the step of executing the second sentence when the generated target characters are not terminators, includes: in response to the triggering of the automatic generation control, generating the target characters in the domain-specific language sentence by the domain-specific language sentence generator under the guidance of the guiding instruction, and returning to the step of executing the second sentence when the generated target characters are not terminators.
6. The method for generating domain-specific language sentences according to claim 5, wherein: The domain specific language statement generator includes a plurality of specific language statement generation program segments; In response to the triggering of the automatic generation control, generating, by the domain specific language sentence generator, a target character in the domain specific language sentence under the guidance of the guide instruction, and returning to the step of executing the second sentence if the generated target character is not a terminator, includes: inputting the guiding instruction into a current specific language statement generating program segment among the plurality of specific language statement generating program segments; If the current specific language statement generation program segment does not generate the target character, using the next specific language statement generation program segment as the current specific language statement generation program segment, and returning to the step of executing the second statement; In response to the triggering of the automatic generation control, if the current specific language statement generation program segment generates the target character, the target character is output, wherein, when the target character is the terminator, the generation of the domain-specific language statement is terminated; when the target character is not the terminator, the next specific language statement generation program segment is used as the current specific language statement generation program segment, and the step of executing the second statement is returned to.
7. The method for generating domain-specific language sentences according to claim 6, wherein: The current specific language statement generation program segment includes a sampling program sub-segment and a generation program sub-segment; The step of inputting the guiding instruction into a current specific language statement generation program segment among the plurality of specific language statement generation program segments comprises: inputting the guiding instruction into the sampling program sub-segment, and having the sampling program sub-segment select the target character from a plurality of candidate characters based on the guiding instruction; The target character is generated by the generating program sub-segment.
8. The method for generating domain-specific language sentences according to claim 4, wherein: The input interface also includes a single character generation control; After pausing the execution of the boot instruction generation code segment, the method for generating a domain specific language statement further includes: In response to the triggering of the single-character generation control, the domain-specific language sentence generator generates the target character in the domain-specific language sentence under the guidance of the guiding instruction, and ends the generation of the domain-specific language sentence.
9. The method for generating domain-specific language sentences according to claim 1, wherein: The executing the first statement to generate the guiding instruction includes: Obtaining, from the first statement, a task for generating the guidance instruction; Get multiple subpackage generation programs; Sending the generation task to the plurality of sub-package generation programs to generate a plurality of sub-boot instructions; A plurality of the sub-boot instructions are integrated into the boot instruction.
10. The method for generating domain-specific language sentences according to claim 9, wherein: The generation task includes a top-level function and a plurality of bottom-level functions corresponding to a plurality of the sub-package generation programs; The step of sending the generation task to the plurality of sub-package generation programs to generate a plurality of sub-boot instructions includes: Distributing the plurality of underlying functions to the plurality of sub-package generation programs; The generation task is sent to the plurality of sub-package generation programs, and the plurality of bottom-level functions in the plurality of sub-package generation programs are called by the top-level function to execute the generation task, thereby obtaining the plurality of sub-boot instructions.
11. The method for generating domain-specific language sentences according to claim 1, wherein: The executing the first statement to generate the guiding instruction includes: Obtaining, from the first statement, a generation task for the guide instruction, the generation task comprising a top-level function and bottom-level functions corresponding to various non-terminal target character types, the non-terminal target character types being character types that cannot be uniquely determined based on a context of the target character; When it is determined that the target character is a terminal target character type based on the generation task and the domain-specific language grammar rule, generating, by the top-level function, the guide instruction for outputting the terminal target character, the terminal target character type being a character type that can be uniquely determined based on the context of the target character; When the target character is determined to be the non-terminal target character type based on the generation task and the domain-specific language grammar rules, the underlying function corresponding to the non-terminal target character type is determined, and the underlying function is forwarded to the sub-package generation program corresponding to the non-terminal target character type in multiple sub-package generation programs for execution to generate the boot instruction.
12. The method for generating domain-specific language sentences according to claim 1, wherein: The guiding instruction includes a target character restriction instruction and a modification suggestion instruction; Before returning to the step of executing the second statement, in response to the first request, starting the execution of the guide instruction generation code segment to execute the first statement and generate the guide instruction, including: in response to the first request, starting the execution of the guide instruction generation code segment to execute the first statement and generate the target character restriction instruction; After returning to the step of executing the second statement, in response to the first request, the execution of the boot instruction generation code segment is started to execute the first statement, and the boot instruction is generated, including: in response to the first request, the execution of the boot instruction generation code segment is started to execute the first statement, and the modification suggestion instruction is generated based on the target character restriction instruction and the context of the target character.
13. The method for generating domain-specific language sentences according to claim 1, wherein: The guiding instructions include a target character restriction instruction, a modification suggestion instruction, and a read control instruction; Before returning to the step of executing the second statement, in response to the first request, starting the execution of the guide instruction generation code segment to execute the first statement and generate the guide instruction, including: in response to the first request, starting the execution of the guide instruction generation code segment to execute the first statement and generate the target character restriction instruction; After returning to the step of executing the second statement for the first time, in response to the first request, starting the execution of the boot instruction generation code segment to execute the first statement and generate the boot instruction, including: in response to the first request, starting the execution of the boot instruction generation code segment to execute the first statement and generate the read control instruction to read the input source character; After returning to the step of executing the second statement for the second time, the step of starting the execution of the boot instruction generation code segment in response to the first request to execute the first statement and generate the boot instruction includes: starting the execution of the boot instruction generation code segment in response to the first request to execute the first statement, and generating the modification suggestion instruction based on the target character restriction instruction, the context of the target character and the read source character.
14. The method for generating domain-specific language sentences according to claim 1, wherein: The guiding instruction generation code segment includes a plurality of guiding instruction generation code segment instances in a first thread, and the domain specific language statement generator includes a plurality of domain specific language statement generator instances in a second thread; The executing the second statement by the domain specific language statement generator includes: executing the second statement by the domain specific language statement generator instance in a target second thread among the plurality of second threads; The step of starting the execution of the boot instruction generation code segment in response to the first request includes: determining a target first thread among the plurality of first threads in response to the first request, and starting the execution of the boot instruction generation code segment instance in the target first thread; Generating the target characters in the domain specific language sentence by the domain specific language sentence generator under the guidance of the guiding instruction includes: generating the target characters in the domain specific language sentence by the domain specific language sentence generator instance in the target second thread under the guidance of the guiding instruction.
15. The method for generating domain-specific language sentences according to claim 14, characterized in that: Determining a target first thread from among the plurality of first threads in response to the first request includes: In response to the first request, determining a load of the plurality of first threads; determining a plurality of processing environment parameters of the first threads; A target first thread is determined among the plurality of first threads based on the load and the processing environment parameter.
16. The method for generating domain-specific language sentences according to claim 1, wherein: Before pausing the execution of the boot instruction generation code segment, the domain specific language statement generation method further includes: saving the running state of the boot instruction generation code segment; After starting the execution of the boot instruction generation code segment, the domain specific language statement generation method further includes: restoring the saved running state.
17. A domain-specific language sentence generation device, characterized in that: include: A first generating unit is configured to generate a guiding instruction generation code segment based on a domain-specific language grammar rule, wherein the guiding instruction generation code segment includes a first statement, and the first statement is configured to generate a guiding instruction of the domain-specific language statement; a first execution unit, configured to execute a second statement through the domain specific language statement generator, wherein the second statement is used to generate the first request for calling the boot instruction to generate a code segment; a second execution unit, configured to, in response to the first request, start execution of the guide instruction generation code segment to execute the first statement, generate the guide instruction, and send the guide instruction to the domain specific language statement generator; a pausing unit, configured to suspend the execution of the boot instruction generated code segment; The second generating unit is configured to generate target characters in the domain specific language sentence under the guidance of the guiding instruction through the domain specific language sentence generator, and return to the step of executing the second sentence if the generated target character is not a terminator.
18. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the method for generating a domain-specific language sentence according to any one of claims 1 to 16 is implemented.
19. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method for generating a domain-specific language sentence according to any one of claims 1 to 16 is implemented.
20. A computer program product, comprising a computer program, wherein the computer program is read and executed by a processor of a computer device, so that the computer device executes the method for generating a domain-specific language sentence according to any one of claims 1 to 16.