Text data generation method and device, computer equipment and storage medium
By preprocessing text data and updating key-value pairs, the problem of low parsing efficiency in traditional technology is solved, and efficient generation of text data in line with JSON format is achieved.
Patent Information
- Application Number
- CN202411463567.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-18
- Publication Date
- 2025-02-18
AI Technical Summary
When analyzing text data, traditional technology needs to first determine whether the data complies with the syntax rules of JSON format. If it does not match, the parsing will be stopped, resulting in low efficiency.
Provide a text data generation method, by obtaining the initial text data corresponding to the prompt word, pre-processing based on the target syntax rules, updating the initial key and value of the key-value pair in the intermediate text data, ensuring that the data conforms to the JSON format.
Improve the efficiency of text data generation, ensuring that the generated text data not only meets the target syntax rules in form, but also meets the requirements of keys and values, and can be directly parsed by the parser.
Smart Images

Figure CN119476207A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a text data generation method, apparatus, computer equipment, storage medium and computer program product. Background Art
[0002] With the development of computer technology, computer devices parse text data in JSON (JavaScript Object Notation) format to obtain objects or data structures used by computer devices in programs, thereby implementing parsing of text data in JSON format.
[0003] In traditional technology, before parsing text data, a computer device first determines whether the text data conforms to the grammatical rules of the JSON format. If it is determined that the text data does not conform to the grammatical rules of the JSON format, the computer device will stop parsing the text data, resulting in low efficiency in text data parsing. Summary of the invention
[0004] Based on this, it is necessary to provide a text data generation method, apparatus, computer device, computer-readable storage medium and computer program product that can improve the efficiency of text data generation in response to the above technical problems.
[0005] In a first aspect, the present application provides a method for generating text data. The method comprises:
[0006] Obtaining initial text data corresponding to the prompt word;
[0007] Based on the target grammar rules, preprocessing the initial text data to obtain intermediate text data that meets the target grammar rules;
[0008] Based on the field mapping relationship and the optimization mapping relationship corresponding to the prompt word, the initial key of the key-value pair in the intermediate text data is updated to obtain updated text data; the optimization mapping relationship refers to the corresponding relationship between the key and the optimization strategy;
[0009] Based on the field mapping relationship and the set of field types to be processed, the initial values of the key-value pairs in the update text data are updated to obtain target text data.
[0010] In one embodiment, the updating of the initial key of the key-value pair in the intermediate text data based on the field mapping relationship and the optimized mapping relationship corresponding to the prompt word to obtain the updated text data includes:
[0011] Compare the associated key in the field mapping relationship corresponding to the prompt word with the initial key of the key-value pair in the intermediate text data;
[0012] determining an associated key that does not exist in the plurality of initial keys as a missing key;
[0013] determining an initial key that does not exist in the plurality of associated keys as a redundant key;
[0014] Obtaining the optimization strategy corresponding to the missing key and the optimization strategy corresponding to the redundant key from the optimization mapping relationship;
[0015] Based on the missing keys and the optimization strategies corresponding to the missing keys, and the redundant keys and the optimization strategies corresponding to the redundant keys, the initial keys of the key-value pairs in the intermediate text data are updated to obtain updated text data.
[0016] In one embodiment, the updating of the initial key of the key-value pair in the intermediate text data based on the missing key and the optimization strategy corresponding to the missing key, and the redundant key and the optimization strategy corresponding to the redundant key, comprises:
[0017] For each missing key, if the optimization strategy corresponding to the missing key is completion, then the missing key is added to the intermediate text data;
[0018] For each of the redundant keys, if the optimization strategy corresponding to the redundant key is discarding, the redundant key and the initial value corresponding to the redundant key are deleted from the intermediate text data.
[0019] In one embodiment, the updating of the initial value of the key-value pair in the update text data based on the field mapping relationship and the set of field types to be processed includes:
[0020] For each update key of the key-value pair in the update text data, obtaining the target field type corresponding to the update key from the field mapping relationship;
[0021] Compare the target field type with the to-be-processed field types in the to-be-processed field type set;
[0022] In the case that there is a to-be-processed field type that is the same as the target field type, obtaining a target data set identifier corresponding to the update key from the field mapping relationship;
[0023] Based on the target data set corresponding to the target data set identifier, the initial value corresponding to the update key is updated.
[0024] In one embodiment, updating the initial value corresponding to the update key based on the target data set corresponding to the target data set identifier includes:
[0025] Obtaining a target field identifier corresponding to the update key from the field mapping relationship;
[0026] Acquire a target field data subset corresponding to the target field identifier from the target data set; the target data set includes multiple field data subsets, and the field data set subset includes a mapping relationship between field values and field value identifiers;
[0027] Determine the field value identifier corresponding to the initial value in the target field data subset as the update value corresponding to the update key;
[0028] Based on the update value, the initial value of the update key is updated.
[0029] In one embodiment, the obtaining of initial text data corresponding to the prompt word includes:
[0030] Get the prompt word;
[0031] Determine the text data template corresponding to the prompt word;
[0032] Based on the text data template, initial text data corresponding to the prompt word is generated.
[0033] In a second aspect, the present application also provides a text data generating device. The device comprises:
[0034] An acquisition module, used to acquire initial text data corresponding to the prompt word;
[0035] A preprocessing module, used for preprocessing the initial text data based on the target grammar rules to obtain intermediate text data that meets the target grammar rules;
[0036] A structure optimization module, used for updating the initial key of the key-value pair in the intermediate text data based on the field mapping relationship and the optimization mapping relationship corresponding to the prompt word to obtain updated text data; the optimization mapping relationship refers to the corresponding relationship between the key and the optimization strategy;
[0037] The data adaptation module is used to update the initial value of the key-value pair in the update text data based on the field mapping relationship and the set of field types to be processed to obtain the target text data.
[0038] In a third aspect, the present application further provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of any one of the methods described in the first aspect when executing the computer program.
[0039] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of any one of the methods described in the first aspect.
[0040] In a fifth aspect, the present application further provides a computer program product, comprising a computer program, which, when executed by a processor, implements the steps of any one of the methods described in the first aspect.
[0041] The above-mentioned text data generation method, device, computer equipment, storage medium and computer program product obtain the initial text data corresponding to the prompt word. If the initial text data is text data that does not meet the JSON format, the initial text data is first preprocessed based on the target grammatical rules to obtain intermediate text data that meets the target grammatical rules, that is, by preprocessing the initial text data, the intermediate text data that meets the target grammatical rules is obtained, and the intermediate text data formally meets the target grammatical rules; secondly, based on the field mapping relationship and the optimized mapping relationship corresponding to the prompt word, the initial key of the key-value pair in the intermediate text data is updated to obtain the updated text data, that is, through the field mapping relationship and the optimized mapping relationship, the updated text data does not contain redundant keys and does not lack necessary The updated text data not only formally meets the target grammatical rules, but also the keys in the updated text data meet the requirements; the initial values of the key-value pairs in the updated text data are updated again based on the field mapping relationship and the set of field types to be processed to obtain the target text data, that is, through the field mapping relationship and the set of field types to be processed, the values that do not meet the parsing requirements are converted into values that meet the parsing requirements. The target text data not only formally meets the target grammatical rules, the keys in the target text data meet the requirements, but also the values in the target text data meet the requirements. The initial text data is converted into parseable target text data through a computer device. Compared with the operator who needs to process the initial text data, it takes more time, which improves the generation efficiency of the target text data. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] FIG. 1 is an application environment diagram of a text data generating method in one embodiment;
[0043] FIG2 is a schematic diagram of a flow chart of a method for generating text data in one embodiment;
[0044] FIG3 is a schematic flow chart of the steps of generating initial text data in one embodiment;
[0045] FIG4 is a schematic diagram of initial text data in one embodiment;
[0046] FIG5 is a schematic diagram of intermediate text data in one embodiment;
[0047] FIG6 is a schematic diagram of a field mapping relationship setting interface in one embodiment;
[0048] FIG7 is a schematic diagram of an optimization strategy setting interface in one embodiment;
[0049] FIG8 is a schematic diagram of a structure optimization strategy setting interface in one embodiment;
[0050] FIG9 is a schematic diagram of a flow chart of text data parsing in one embodiment;
[0051] FIG10 is a schematic diagram of updating text data in one embodiment;
[0052] FIG11 is a schematic diagram of a process of updating initial values in one embodiment;
[0053] FIG12 is a schematic diagram of target text data in one embodiment;
[0054] FIG13 is a schematic diagram of a text data template in one embodiment;
[0055] FIG14 is a schematic diagram of the overall architecture of a text data generation system in one embodiment;
[0056] FIG15 is a schematic diagram of the processing logic of a structure recognition optimization component in one embodiment;
[0057] FIG16 is a schematic diagram of the processing logic of a metadata adaptation component in one embodiment;
[0058] FIG17 is a schematic diagram of a flow chart of a text data generation and parsing method in one embodiment;
[0059] FIG18 is a block diagram of a text data generating device according to an embodiment;
[0060] FIG. 19 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0061] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0062] The text data generation method provided in the embodiment of the present application can be applied in the application environment shown in Figure 1. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. Both the terminal and the server can be used alone to execute the text data generation method provided in the embodiment of the present application. The terminal and the server can also be used in collaboration to execute the text data generation method provided in the embodiment of the present application. For example, the terminal 102 obtains the initial text data corresponding to the prompt word; based on the target grammatical rules, the initial text data is preprocessed to obtain the intermediate text data that meets the target grammatical rules; based on the field mapping relationship corresponding to the prompt word and the optimized mapping relationship, the initial key of the key-value pair in the intermediate text data is updated to obtain the updated text data; the optimized mapping relationship refers to the corresponding relationship between the key and the optimization strategy; based on the field mapping relationship and the set of field types to be processed, the initial value of the key-value pair in the updated text data is updated to obtain the target text data. The terminal 102 may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, IoT devices, and portable wearable devices. The IoT devices may be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. The portable wearable devices may be smart watches, smart bracelets, head-mounted devices, etc. The server 104 may be implemented as an independent server or a server cluster consisting of multiple servers.
[0063] In one embodiment, as shown in FIG. 2 , a text data generating method is provided. This embodiment is described by taking the method applied to a computer device as an example, and includes steps 202 to 208 .
[0064] Step 202: Obtain initial text data corresponding to the prompt word.
[0065] The prompt word refers to a character string used to generate initial text data. The prompt word can be composed of numbers, letters, symbols, etc., and can be understood as a character string describing a subject, for example, automatically generating a recruitment JD (Job Description).
[0066] Exemplarily, the computer device inputs the prompt word into a natural language processing model, the natural language processing model outputs initial text data corresponding to the prompt word, and the computer device obtains the initial text data corresponding to the prompt word.
[0067] In one embodiment, the computer device inputs the prompt word into GPT (Generative Pre-trained Transformer), GPT outputs reference text data corresponding to the prompt word, and the computer device responds to the correction operation or confirmation operation on the reference text data to obtain the initial text data corresponding to the prompt word. For example, the flowchart of the initial text data generation step is shown in Figure 3, the computer device obtains the user instruction, inputs the prompt word in the user instruction into GPT, GPT outputs the reference text data corresponding to the prompt word, and the computer device responds to the operator's correction operation or confirmation operation on the reference text data to obtain the initial text data corresponding to the prompt word.
[0068] Step 204 , preprocessing the initial text data based on the target grammar rules to obtain intermediate text data that meets the target grammar rules.
[0069] Among them, the target grammatical rules refer to the grammatical rules corresponding to the target format. For example, the target grammatical rules are the grammatical rules corresponding to the JSON format. The target grammatical rules include but are not limited to the content in the data text being surrounded by curly brackets {}, {} containing key-value pairs, the key and value in the key-value pairs being separated by colons, different key-value pairs being separated by commas, arrays being surrounded by square brackets [], and the elements in the array being separated by commas, etc. Preprocessing refers to the process of modifying the content in the initial text data that does not meet the target grammatical rules so that it meets the target grammatical rules. For example, the initial text data is shown in FIG4. The "Based on the recruitment position information "Senior Software Development" you provided previously, the following is a detailed recruitment position description (JD):" and "```json" in the initial text data are redundant texts that do not meet the target grammatical rules, ""jobduty":" lacks a corresponding value, and lacks "}". After preprocessing the initial text data, the intermediate text data obtained is shown in FIG5.
[0070] Exemplarily, the computer device obtains the target grammar rule, preprocesses the initial text data based on the target grammar rule, and obtains the intermediate text data satisfying the target grammar rule.
[0071] In one embodiment, a computer device determines whether the initial text data is text data that satisfies the JSON format. If the initial text data is text data that does not satisfy the JSON format, the computer device obtains target grammar rules, preprocesses the initial text data based on the target grammar rules, and obtains intermediate text data that satisfies the target grammar rules.
[0072] Step 206, based on the field mapping relationship and the optimization mapping relationship corresponding to the prompt word, the initial key of the key-value pair in the intermediate text data is updated to obtain updated text data; the optimization mapping relationship refers to the corresponding relationship between the key and the optimization strategy.
[0073] The field mapping relationship refers to the correspondence between prompt words and keys, data set identifiers, field identifiers, and field types, etc. The field mapping relationship includes but is not limited to the correspondence between prompt words and keys, data set identifiers, field identifiers, field types, and usage status. For example, the field mapping relationship setting interface is shown in FIG6. Through the field mapping relationship setting interface shown in FIG6, the setting personnel can set the correspondence between prompt words, keys, data set identifiers, field identifiers, field types, and usage status.
[0074] The optimization mapping relationship refers to the correspondence between the key and the optimization strategy, and the optimization mapping relationship includes but is not limited to the correspondence between the key, key state and optimization strategy. For example, the optimization strategy setting interface is shown in Figure 7. The correspondence between the optimization strategy code, optimization strategy name, usage status and implementation class can be set through the optimization strategy setting page shown in Figure 7. After setting the correspondence between the optimization strategy code, optimization strategy name, usage status and implementation class, the correspondence between the key, key state and optimization strategy can be set through the structural optimization strategy setting interface shown in Figure 8 to obtain the optimization mapping relationship.
[0075] A key-value pair refers to the basic unit of text data in JSON format, that is, the basic unit in the intermediate text data. A key-value pair consists of a key and a value, and the key and value are separated by a colon. It can be understood that the key is the field name and the value is the field value corresponding to the field. For example, in the intermediate text data shown in Figure 5, "jobtitle": "Senior Software Development Engineer" is a key-value pair, where "jobtitle" is the key in the key-value pair and "Senior Software Development Engineer" is the value in the key-value pair. Optimization strategy refers to the strategy for processing keys. Optimization strategies include but are not limited to discarding, padding, and retaining. Discarding refers to deleting the key and the corresponding value from the text data, padding refers to adding the key to the text data, and retaining refers to not processing the key and the corresponding value in the data text.
[0076] Exemplarily, a computer device obtains a field mapping relationship and an optimization mapping relationship corresponding to a prompt word from a database, determines the missing keys and redundant keys corresponding to the intermediate text data based on the field mapping relationship, determines the optimization strategies corresponding to the missing keys and redundant keys based on the optimization mapping relationship, and updates the initial keys of the key-value pairs in the intermediate text data based on the missing keys and the optimization strategies corresponding to the missing keys, as well as the optimization strategies corresponding to the redundant keys, to obtain updated text data.
[0077] Step 208: based on the field mapping relationship and the set of field types to be processed, the initial values of the key-value pairs in the update text data are updated to obtain the target text data.
[0078] Among them, the set of field types to be processed refers to a set composed of field types to be processed, and the set of field types to be processed includes at least one field type to be processed. The field type to be processed refers to the field type that needs to be converted. The field type to be processed can be understood as a field type that cannot be parsed. For example, in the intermediate text data shown in Figure 5, the value corresponding to the key "jobdegree" is "undergraduate degree", and the target field type of the key "jobdegree" is a drop-down list. The drop-down list is a field type to be processed, and the value "undergraduate degree" needs to be converted. The set of field types to be processed can be pre-set according to actual needs, and the field types that cannot be parsed can be determined as field types to be processed, and then the field types to be processed are combined into a set of field types to be processed.
[0079] Exemplarily, the computer device obtains the update key of each key-value pair in the updated text data, obtains the target field type corresponding to the update key from the field mapping table, and if there is a to-be-processed field type that is the same as the target field type in the to-be-processed field type set, the initial value corresponding to the update key is updated based on the field mapping relationship to obtain the target text data.
[0080] In one embodiment, after step 208, the target text data is further parsed to obtain a data structure that can be directly operated in a programming language. For example, a flowchart of text data parsing is shown in FIG9 , where it is first determined whether the target text data satisfies the target grammar rules, and when the target text data satisfies the target grammar rules, the target text data is subjected to the steps of identifying data types, parsing key-value pairs, processing nested results, processing special characters, and verifying data completeness, to obtain a data structure that can be directly operated in a programming language.
[0081] In the above text generation method, the initial text data corresponding to the prompt word is obtained. If the initial text data is text data that does not meet the JSON format, the initial text data is first preprocessed based on the target grammar rules to obtain intermediate text data that meets the target grammar rules, that is, the initial text data is preprocessed to obtain intermediate text data that meets the target grammar rules, and the intermediate text data formally meets the target grammar rules; secondly, based on the field mapping relationship and the optimized mapping relationship corresponding to the prompt word, the initial key of the key-value pair in the intermediate text data is updated to obtain updated text data, that is, the field mapping relationship and the optimized mapping relationship are used to ensure that the updated text data does not contain redundant keys or lack necessary keys, and the updated text data is not only in The target grammatical rules are formally satisfied, and the keys in the updated text data meet the requirements; the initial values of the key-value pairs in the updated text data are updated again based on the field mapping relationship and the set of field types to be processed to obtain the target text data, that is, the values that do not meet the parsing requirements are converted into values that meet the parsing requirements through the field mapping relationship and the set of field types to be processed. The target text data not only formally satisfies the target grammatical rules, the keys in the target text data meet the requirements, but also the values in the target text data meet the requirements. The initial text data is converted into parseable target text data through a computer device. Compared with the need for operators to process the initial text data, which takes more time, the efficiency of generating the target text data is improved.
[0082] In one embodiment, based on the field mapping relationship and the optimized mapping relationship corresponding to the prompt word, the initial key of the key-value pair in the intermediate text data is updated to obtain the updated text data, including:
[0083] Compare the associated key in the field mapping relationship corresponding to the prompt word with the initial key of the key-value pair in the intermediate text data; determine the associated key that does not exist in multiple initial keys as a missing key; determine the initial key that does not exist in multiple associated keys as a redundant key; obtain the optimization strategy corresponding to the missing key and the optimization strategy corresponding to the redundant key from the optimization mapping relationship; based on the missing key and the optimization strategy corresponding to the missing key, and the redundant key and the optimization strategy corresponding to the redundant key, update the initial key of the key-value pair in the intermediate text data to obtain updated text data.
[0084] Among them, the associated key refers to the key associated with the prompt word in the field mapping relationship. The initial key refers to the key in the key-value pair in the intermediate text data. The missing key refers to the missing key in the intermediate text data, and the redundant key refers to the redundant key in the intermediate text data.
[0085] Exemplarily, a computer device obtains multiple associated keys corresponding to prompt words from a field mapping relationship, obtains multiple initial keys from multiple key-value pairs in the intermediate text data, compares the multiple associated keys with the multiple initial keys, determines the associated keys that do not exist in the multiple initial keys as missing keys, and determines the initial keys that do not exist in the multiple associated keys as redundant keys, and then obtains optimization strategies corresponding to the missing keys and the optimization strategies corresponding to the redundant keys from the optimization mapping relationship, and based on the missing keys and the optimization strategies corresponding to the missing keys, and the redundant keys and the optimization strategies corresponding to the redundant keys, updates the initial keys of the key-value pairs in the intermediate text data to obtain updated text data.
[0086] In this embodiment, by comparing multiple associated keys with multiple initial keys, redundant keys and missing keys are determined. Missing keys can be understood as missing keys in the intermediate text data, and redundant keys can be understood as redundant keys in the intermediate text data. Then, the optimization strategy corresponding to the missing keys and the optimization strategy corresponding to the redundant keys are obtained from the optimization mapping relationship. The optimization strategy corresponding to the missing keys is a strategy for processing the missing keys, and the optimization strategy corresponding to the redundant keys is a strategy for processing the redundant keys. Finally, the missing keys are processed according to the optimization strategy corresponding to the missing keys, and the redundant keys are processed according to the optimization strategy corresponding to the redundant keys to obtain updated text data. Even if the updated text data does not contain redundant keys, it is not missing necessary keys. The updated text data not only formally satisfies the target grammatical rules, but also the keys in the updated text data meet the requirements.
[0087] In one embodiment, based on the missing keys and the optimization strategies corresponding to the missing keys, and the redundant keys and the optimization strategies corresponding to the redundant keys, the initial keys of the key-value pairs in the intermediate text data are updated, including:
[0088] For each missing key, if the optimization strategy corresponding to the missing key is completion, the missing key is added to the intermediate text data; for each redundant key, if the optimization strategy corresponding to the redundant key is discarding, the redundant key and the initial value corresponding to the redundant key are deleted from the intermediate text data.
[0089] Exemplarily, the computer device adds the missing keys whose optimization strategy is to complete to the intermediate text data; and deletes the redundant keys whose optimization strategy is to discard and the initial values corresponding to the redundant keys from the intermediate text data. For example, for the intermediate text data shown in FIG5, where "jobtitle" is a redundant key, "jobdes" is a redundant key, and "jobage" is a missing key, and the optimization strategy corresponding to the redundant key "jobtitle" is to retain, the optimization strategy corresponding to the redundant key "jobdes" is to discard, and the optimization strategy corresponding to the missing key "jobage" is to complete, then the "jobtitle" and the value corresponding to "jobtitle" "Senior Software Development Engineer" in the intermediate text data are retained, and the value corresponding to "jobdes" and "jobdes" "Professional position responsible for development and design" are deleted from the intermediate text data, and the value corresponding to "jobdes" and "jobdes" "" are added to the intermediate text data to obtain the updated text data shown in FIG10.
[0090] In this embodiment, by adding missing keys whose optimization strategy is to fill in to the intermediate text data, and deleting redundant keys and initial values corresponding to the redundant keys whose optimization strategy is to discard from the intermediate text data, the updated text data does not contain redundant keys and does not lack necessary keys.
[0091] In one embodiment, based on the field mapping relationship and the set of field types to be processed, the initial value of the key-value pair in the update text data is updated, including:
[0092] For the update key of each key-value pair in the updated text data, obtain the target field type corresponding to the update key from the field mapping relationship; compare the target field type with the pending field type in the pending field type set; if there is a pending field type that is the same as the target field type, obtain the target data set identifier corresponding to the update key from the field mapping relationship; based on the target data set corresponding to the target data set identifier, update the initial value corresponding to the update key.
[0093] The target field type refers to the field type corresponding to the update key in the field mapping relationship. The target data set identifier refers to a string that represents the target data set. The target data set refers to the metadata corresponding to the target data set identifier. It can be understood that the target data set provides information or attributes about the data, rather than the data itself. The target data set includes field data subsets corresponding to multiple field identifiers.
[0094] Exemplarily, for the update key of each key-value pair in the updated text data, the computer device obtains the target field type corresponding to the update key from the field mapping relationship, compares the target field type with the to-be-processed field type in the to-be-processed field type set, and if there is an to-be-processed field type that is the same as the target field type, obtains the target data set identifier corresponding to the update key from the field mapping relationship, obtains the target field data subset corresponding to the update key from the target data set corresponding to the target data set identifier, and updates the initial value corresponding to the update key based on the target field data subset.
[0095] In one embodiment, when there is a pending field type that is the same as the target field type, the target data set identifier corresponding to the update key is obtained from the field mapping relationship, including: when there is a pending field type that is the same as the target field type, first determine whether there is a target field data subset corresponding to the target field identifier in the cache; if there is no target field data subset corresponding to the target field identifier in the cache, then obtain the target data set identifier corresponding to the update key from the field mapping relationship.
[0096] In one embodiment, if a target field data subset corresponding to the target field identifier exists in the cache, the target field data subset corresponding to the target field identifier is directly obtained from the cache, the field value identifier corresponding to the initial value in the target field data subset is determined as the update value corresponding to the update key, and the initial value of the update key is updated based on the update value.
[0097] In this embodiment, by comparing the target field type with the to-be-processed field types in the to-be-processed field type set, if there is an to-be-processed field type that is the same as the target field type, the target data set identifier corresponding to the update key is obtained from the field mapping relationship, that is, if the target field type corresponding to the update key is the to-be-processed field type, it means that the initial value corresponding to the update key does not meet the parsing requirements, and the initial value corresponding to the update key needs to be converted, and then the target data set identifier corresponding to the update key is obtained from the field mapping relationship, and the initial value corresponding to the update key is updated based on the target data set corresponding to the target data set identifier, so that the value corresponding to the update key meets the parsing requirements.
[0098] In one embodiment, based on the target data set corresponding to the target data set identifier, updating the initial value corresponding to the update key includes:
[0099] Obtain the target field identifier corresponding to the update key from the field mapping relationship; obtain the target field data subset corresponding to the target field identifier from the target data set; the target data set includes multiple field data subsets, and the field data set subset includes a mapping relationship between field values and field value identifiers; determine the field value identifier corresponding to the initial value in the target field data subset as the update value corresponding to the update key; and update the initial value of the update key based on the update value.
[0100] The target field identifier refers to the field identifier corresponding to the update key in the field mapping relationship. The update key can be the same as the target field identifier, or it can be different from the target field identifier. The field data subset refers to the set of mapping relationships between field values and field value identifiers. The field data subset corresponds to the field identifier one by one. The field value refers to the value of the field corresponding to the field identifier. The computer device cannot parse the field value. The field value identifier refers to the identifier that represents the field value. The computer device can parse the field value identifier. For example, as shown in Figure 10, the initial value corresponding to the update key "jobdegree" in the updated text data is "undergraduate", the target field type of the update key "jobdegree" is a drop-down list, the target field identifier corresponding to the update key "jobdegree" is jobdegree, and the target field data subset corresponding to the target field identifier jobdegree is {10=doctoral student; 20=master's student; 30=undergraduate; 40=junior college; 50=high school; 60=technical secondary school; 70=junior high school; 80=primary school; 90=other}, 10=doctoral student, in which doctoral student is the field value and 10 is the field identifier, 30=undergraduate, in which undergraduate is the field value and 30 is the field identifier, and the update value corresponding to the update key "jobdegree" is 30.
[0101] Exemplarily, the computer device obtains the target field identifier corresponding to the update key from the field mapping relationship, obtains the target field data subset corresponding to the target field identifier from the target data set, determines the field value identifier corresponding to the initial value in the target field data subset as the update value corresponding to the update key, and updates the initial value of the update key based on the update value.
[0102] In one embodiment, the flowchart of the initial value update is shown in FIG11. The computer device obtains the target field identifier corresponding to the update key from the field mapping relationship, first determines whether there is a target field data subset corresponding to the target field identifier in the cache, and if there is a target field data subset corresponding to the target field identifier in the cache, then directly obtain the target field data subset corresponding to the target field identifier from the cache, determine the field value identifier corresponding to the initial value in the target field data subset as the update value corresponding to the update key, and update the initial value of the update key based on the update value; if there is no target field data subset corresponding to the target field identifier in the cache, then obtain the target field data subset corresponding to the target field identifier from the target data set, determine the field value identifier corresponding to the initial value in the target field data subset as the update value corresponding to the update key, and update the initial value of the update key based on the update value. For example, the initial value of the update key "jobdegree" in the update text data shown in FIG10 is updated to obtain the target text data shown in FIG12.
[0103] In this embodiment, the target field label corresponding to the update key is obtained from the field mapping relationship, the target field data subset corresponding to the target field identifier is obtained from the target data set, the field value identifier corresponding to the initial value in the target field data subset is determined as the update value corresponding to the update key, the initial value of the update key is updated based on the update value, and the value that does not meet the parsing requirements is converted into a value that meets the parsing requirements.
[0104] In one embodiment, obtaining the initial text data corresponding to the prompt word includes:
[0105] Obtain a prompt word; determine a text data template corresponding to the prompt word; and generate initial text data corresponding to the prompt word based on the text data template.
[0106] Among them, the text data template refers to a template for generating text data. The text data template can be configured according to actual needs. One prompt word can correspond to multiple text data templates. For example, the text data template corresponding to the prompt word automatically generating recruitment JD is shown in Figure 13. Figure 13 includes three text data templates corresponding to the prompt word automatically generating recruitment JD.
[0107] Exemplarily, a computer device obtains a prompt word, inputs the prompt word into a natural language processing model, the natural language processing model obtains a candidate text data template corresponding to the prompt word, determines one of the candidate text data templates as the text data template corresponding to the prompt word, and the natural language processing model generates initial text data corresponding to the prompt word based on the text data template.
[0108] In one embodiment, a computer device obtains a prompt word and candidate text data templates corresponding to the prompt word, determines one of the candidate text data templates as the text data template corresponding to the prompt word, and then inputs the prompt word and the text data template corresponding to the prompt word into a natural language processing model, which generates initial text data corresponding to the prompt word based on the prompt word and the text data template corresponding to the prompt word.
[0109] In this embodiment, the initial text data corresponding to the prompt word is generated by using a text data template, and the initial text data may be text data that does not meet the JSON format.
[0110] In an exemplary embodiment, the schematic diagram of the overall architecture of the text data generation system is shown in Figure 14, including a user operation interface, business logic call, core processing layer and storage layer, and the core processing layer includes a text preprocessing component, a structure optimization strategy processing center, a structure recognition optimization component and a metadata adaptation component. Among them, the schematic diagram of the processing logic of the structure recognition optimization component is shown in Figure 15, that is, the structure recognition optimization component is used to save the field mapping relationship set by the operator in the storage layer, and is used to update the initial key of the key-value pair in the intermediate text data based on the field mapping relationship and the optimization mapping relationship corresponding to the prompt word, and obtain the updated text data; the schematic diagram of the processing logic of the metadata adaptation component is shown in Figure 16. The metadata adaptation component is used to save the field mapping relationship and the optimization mapping relationship set by the operator in the storage layer, and is used to update the initial value of the key-value pair in the updated text data based on the field mapping relationship and the set of field types to be processed, and obtain the target text data.
[0111] The flowchart of the text data generation and parsing method is shown in FIG17 , and includes the following steps:
[0112] The text data generation system obtains the initial text data corresponding to the prompt word, and determines whether the initial text data is text data that meets the JSON format. If the initial text data is text data that does not meet the JSON format, the text data generation system obtains the target grammar rules, and preprocesses the initial text data based on the target grammar rules to obtain intermediate text data that meets the target grammar rules.
[0113] The structure recognition optimization component in the text data generation system obtains the field mapping relationship and the optimization mapping relationship corresponding to the prompt word, obtains multiple associated keys corresponding to the prompt word from the field mapping relationship, obtains multiple initial keys from multiple key-value pairs in the intermediate text data, compares the multiple associated keys with the multiple initial keys, determines the associated keys that do not exist in the multiple initial keys as missing keys, determines the initial keys that do not exist in the multiple associated keys as redundant keys, and then obtains the optimization strategy corresponding to the missing keys and the optimization strategy corresponding to the redundant keys from the optimization mapping relationship, adds the missing keys whose optimization strategy is to be completed to the intermediate text data; deletes the redundant keys whose optimization strategy is to be discarded and the initial values corresponding to the redundant keys from the intermediate text data to obtain updated text data.
[0114] The metadata adapter component in the text data generation system obtains the target field type corresponding to the update key from the field mapping relationship for each key-value pair in the updated text data, compares the target field type with the to-be-processed field type in the to-be-processed field type set, and if there is an to-be-processed field type that is the same as the target field type, obtains the target data set identifier corresponding to the update key from the field mapping relationship, obtains the target field identifier corresponding to the update key from the field mapping relationship, obtains the target field data subset corresponding to the target field identifier from the target data set corresponding to the target data set identifier, determines the field value identifier corresponding to the initial value in the target field data subset as the update value corresponding to the update key, updates the initial value of the update key based on the update value, and obtains the target text data.
[0115] The computer device executes the steps of identifying data types, parsing key-value pairs, processing nested results, processing special characters and verifying data completeness on the target text data to obtain a data structure that can be directly operated in a programming language.
[0116] In the above text generation method, the initial text data corresponding to the prompt word is obtained. If the initial text data is text data that does not meet the JSON format, the initial text data is first preprocessed based on the target grammar rules to obtain intermediate text data that meets the target grammar rules, that is, the initial text data is preprocessed to obtain intermediate text data that meets the target grammar rules, and the intermediate text data formally meets the target grammar rules; secondly, based on the field mapping relationship and the optimized mapping relationship corresponding to the prompt word, the initial key of the key-value pair in the intermediate text data is updated to obtain updated text data, that is, the field mapping relationship and the optimized mapping relationship are used to ensure that the updated text data does not contain redundant keys or lack necessary keys, and the updated text data is not only in The target grammatical rules are formally satisfied, and the keys in the updated text data meet the requirements; the initial values of the key-value pairs in the updated text data are updated again based on the field mapping relationship and the set of field types to be processed to obtain the target text data, that is, the values that do not meet the parsing requirements are converted into values that meet the parsing requirements through the field mapping relationship and the set of field types to be processed. The target text data not only formally satisfies the target grammatical rules, the keys in the target text data meet the requirements, but also the values in the target text data meet the requirements. The initial text data is converted into parseable target text data through a computer device. Compared with the need for operators to process the initial text data, which takes more time, the efficiency of generating the target text data is improved.
[0117] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0118] Based on the same inventive concept, the embodiment of the present application also provides a text data generating device for implementing the above-mentioned text data generating method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above-mentioned method, so the specific limitations in one or more text data generating device embodiments provided below can refer to the limitations of the text data generating method above, and will not be repeated here.
[0119] In one embodiment, as shown in FIG. 18 , a text data generating device is provided, including: an acquisition module 1802, a preprocessing module 1804, a structure optimization module 1806 and a data adaptation module 1808, wherein:
[0120] An acquisition module 1802 is used to acquire initial text data corresponding to the prompt word;
[0121] A preprocessing module 1804 is used to preprocess the initial text data based on the target grammar rules to obtain intermediate text data that meets the target grammar rules;
[0122] The structure optimization module 1806 is used to update the initial key of the key-value pair in the intermediate text data based on the field mapping relationship and the optimization mapping relationship corresponding to the prompt word to obtain the updated text data; the optimization mapping relationship refers to the corresponding relationship between the key and the optimization strategy;
[0123] The data adaptation module 1808 is used to update the initial value of the key-value pair in the update text data based on the field mapping relationship and the set of field types to be processed to obtain the target text data.
[0124] In one embodiment, the structure optimization module 1806 is also used to: compare the associated key in the field mapping relationship corresponding to the prompt word with the initial key of the key-value pair in the intermediate text data, and determine the associated key that does not exist in multiple initial keys as a missing key; determine the initial key that does not exist in multiple associated keys as a redundant key; obtain the optimization strategy corresponding to the missing key and the optimization strategy corresponding to the redundant key from the optimization mapping relationship; based on the missing key and the optimization strategy corresponding to the missing key, and the redundant key and the optimization strategy corresponding to the redundant key, update the initial key of the key-value pair in the intermediate text data to obtain updated text data.
[0125] In one embodiment, the structure optimization module 1806 is also used for: for each missing key, if the optimization strategy corresponding to the missing key is completion, the missing key is added to the intermediate text data; for each redundant key, if the optimization strategy corresponding to the redundant key is discarding, the redundant key and the initial value corresponding to the redundant key are deleted from the intermediate text data.
[0126] In one embodiment, the data adaptation module 1808 is also used to: for the update key of each key-value pair in the updated text data, obtain the target field type corresponding to the update key from the field mapping relationship; compare the target field type with the to-be-processed field type in the to-be-processed field type set; when there is a to-be-processed field type that is the same as the target field type, obtain the target data set identifier corresponding to the update key from the field mapping relationship; and update the initial value corresponding to the update key based on the target data set corresponding to the target data set identifier.
[0127] In one embodiment, the data adaptation module 1808 is also used to: obtain the target field identifier corresponding to the update key from the field mapping relationship; obtain the target field data subset corresponding to the target field identifier from the target data set; the target data set includes multiple field data subsets, and the field data set subset includes a mapping relationship between field values and field value identifiers; determine the field value identifier corresponding to the initial value in the target field data subset as the update value corresponding to the update key; and update the initial value of the update key based on the update value.
[0128] In one embodiment, the acquisition module 1802 is further used to: acquire a prompt word; determine a text data template corresponding to the prompt word; and generate initial text data corresponding to the prompt word based on the text data template.
[0129] Each module in the above-mentioned text data generating device can be implemented in whole or in part by software, hardware and a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each module above.
[0130] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be shown in FIG19. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit, and an input device. The processor, the memory, and the input / output interface are connected via a system bus, and the communication interface, the display unit, and the input device are connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner may be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a text data generation method is implemented. The display unit of the computer device is used to form a visually visible picture, which may be a display screen, a projection device, or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.
[0131] Those skilled in the art will understand that the structure shown in FIG. 19 is merely a block diagram of a partial structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0132] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.
[0133] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0134] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0135] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0136] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0137] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0138] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A method for generating text data, characterized in that: The method comprises: Obtaining initial text data corresponding to the prompt word; Based on the target grammar rules, preprocessing the initial text data to obtain intermediate text data that meets the target grammar rules; Based on the field mapping relationship and the optimization mapping relationship corresponding to the prompt word, the initial key of the key-value pair in the intermediate text data is updated to obtain updated text data; the optimization mapping relationship refers to the corresponding relationship between the key and the optimization strategy; Based on the field mapping relationship and the set of field types to be processed, the initial values of the key-value pairs in the update text data are updated to obtain target text data.
2. The method according to claim 1, characterized in that The updating of the initial key of the key-value pair in the intermediate text data based on the field mapping relationship and the optimized mapping relationship corresponding to the prompt word to obtain the updated text data includes: Compare the associated key in the field mapping relationship corresponding to the prompt word with the initial key of the key-value pair in the intermediate text data; determining an associated key that does not exist in the plurality of initial keys as a missing key; determining an initial key that does not exist in the plurality of associated keys as a redundant key; Obtaining the optimization strategy corresponding to the missing key and the optimization strategy corresponding to the redundant key from the optimization mapping relationship; Based on the missing key and the optimization strategy corresponding to the missing key, and the redundant key and the optimization strategy corresponding to the redundant key, the initial key of the key-value pair in the intermediate text data is updated to obtain updated text data.
3. The method according to claim 2, characterized in that The updating of the initial key of the key-value pair in the intermediate text data based on the missing key and the optimization strategy corresponding to the missing key, and the redundant key and the optimization strategy corresponding to the redundant key, comprises: For each missing key, if the optimization strategy corresponding to the missing key is completion, then the missing key is added to the intermediate text data; For each of the redundant keys, if the optimization strategy corresponding to the redundant key is discarding, the redundant key and the initial value corresponding to the redundant key are deleted from the intermediate text data.
4. The method according to claim 1, characterized in that The updating of the initial value of the key-value pair in the update text data based on the field mapping relationship and the set of field types to be processed includes: For each update key of the key-value pair in the update text data, obtaining the target field type corresponding to the update key from the field mapping relationship; Compare the target field type with the to-be-processed field types in the to-be-processed field type set; In the case that there is a to-be-processed field type that is the same as the target field type, obtaining a target data set identifier corresponding to the update key from the field mapping relationship; Based on the target data set corresponding to the target data set identifier, the initial value corresponding to the update key is updated.
5. The method according to claim 4, characterized in that The updating of the initial value corresponding to the update key based on the target data set corresponding to the target data set identifier includes: Obtaining a target field identifier corresponding to the update key from the field mapping relationship; Acquire a target field data subset corresponding to the target field identifier from the target data set; the target data set includes multiple field data subsets, and the field data set subset includes a mapping relationship between field values and field value identifiers; Determine the field value identifier corresponding to the initial value in the target field data subset as the update value corresponding to the update key; Based on the update value, the initial value of the update key is updated.
6. The method according to any one of claims 1 to 5, characterized in that The obtaining of the initial text data corresponding to the prompt word includes: Get the prompt word; Determine the text data template corresponding to the prompt word; Based on the text data template, initial text data corresponding to the prompt word is generated.
7. A text data generating device, characterized in that: The device comprises: An acquisition module, used to acquire initial text data corresponding to the prompt word; A preprocessing module, used for preprocessing the initial text data based on the target grammar rules to obtain intermediate text data that meets the target grammar rules; A structure optimization module, used for updating the initial key of the key-value pair in the intermediate text data based on the field mapping relationship and the optimization mapping relationship corresponding to the prompt word to obtain updated text data; the optimization mapping relationship refers to the corresponding relationship between the key and the optimization strategy; The data adaptation module is used to update the initial value of the key-value pair in the update text data based on the field mapping relationship and the set of field types to be processed to obtain the target text data.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.