Regular expression-based data processing method, system and equipment and medium
By acquiring and adjusting the regular expression rule model, and using feature variables to segment and match text data, the problem of low efficiency and low accuracy in regular expression generation is solved, and more efficient and accurate data extraction is achieved.
Patent Information
- Application Number
- CN202410704389.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-03
- Publication Date
- 2024-08-27
AI Technical Summary
The existing regular expression generation efficiency is low and the accuracy is not high, which leads to the problem of low data extraction accuracy.
By obtaining the original text data and the pre-built regular expression rule model, feature variables are used to segment and match the text data, correct the feature variables of repeated data, and adjust the regular expression rule model through machine learning training to improve the accuracy of data extraction. sex.
It improves the accuracy and efficiency of data extraction, reduces the time and errors of manually writing regular expressions, and enhances the accuracy of data processing.
Smart Images

Figure CN118550994A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to a data processing method, system, device and medium based on regular expressions. Background Art
[0002] Regular expressions, also known as regular expressions, are specific patterns composed of single characters, with obscure semantics and each character having its own specific meaning. It is becoming more and more common to use regular expressions to extract text data. However, the existing regular expression development process requires the programmer to have very professional skills, which is difficult and time-consuming, thus affecting the efficiency of data processing; the regular expression of the field to be extracted in the text data is simply combined with the regular expression of the field not to be extracted to obtain the final regular expression, which has poor accuracy and results in low accuracy of data extraction based on regular expressions. Summary of the invention
[0003] The technical problem to be solved by the present invention is to overcome the defects of low efficiency and low accuracy in generating regular expressions in the prior art, resulting in low accuracy in extracting data based on regular expressions, and to provide a data processing method, system, device and medium based on regular expressions.
[0004] The present invention solves the above technical problems through the following technical solutions:
[0005] In a first aspect, the present invention provides a data processing method based on regular expressions, the data processing method comprising:
[0006] Obtaining original text data and a pre-built regular expression rule model; the regular expression rule model includes a plurality of feature variables;
[0007] Performing data segmentation on the original text data based on the characteristic variables to generate a text data queue arranged in a set sequence number;
[0008] Using the characteristic variables to sequentially traverse the text data queue to perform rule matching processing until no new characteristic variables are segmented out of the regular expression, thereby generating a data processing result;
[0009] Check whether the data processing result contains repeated text data. If so, modify the feature variables corresponding to the repeated text data to obtain a new regular expression rule model.
[0010] Preferably, the step of using the feature variables to sequentially traverse the text data queue to perform rule matching processing until no new feature variables are segmented out of the regular expression to generate a data processing result includes:
[0011] During a single traversal, if the current feature variable does not match the text data queue, the text data that does not conform to the rules will be screened out in the rule matching process of the current feature variable, a matching result will be generated, and the text data queue will be initialized, and the rule matching process of the remaining feature variables will continue to be executed in sequence.
[0012] Preferably, the regular expression rule model is trained by the following method:
[0013] Obtaining a first sample set and an initial rule model for data extraction; the initial rule model includes a plurality of preset rules, each of the preset rules includes a plurality of feature variables, and each of the feature variables corresponds to a feature regular expression;
[0014] Acquire matching results corresponding to the first sample set based on the characteristic regular expression, and generate a matching result set;
[0015] Generate a second sample set according to all the characteristic regular expressions and the matching result set;
[0016] The initial rule model is trained based on the second sample set to obtain the regular expression rule model.
[0017] Preferably, the step of training the initial rule model based on the second sample set to obtain the regular expression rule model includes:
[0018] Determining an initial training set and an initial test set in the second sample set;
[0019] Adjusting the quantity of the initial training set and the initial test set according to the hit rate of the matching result of the characteristic regular expression to generate a target training set and a target test set;
[0020] The initial rule model is trained based on the target training set and the target test set to obtain model accuracy, and the feature variables are adjusted according to the model accuracy to generate the regular expression rule model.
[0021] In a second aspect, the present invention provides a data processing system based on regular expressions, the data processing system comprising:
[0022] An acquisition module is used to acquire original text data and a pre-built regular expression rule model; the regular expression rule model includes a number of feature variables;
[0023] A segmentation module, used for performing data segmentation on the original text data based on the characteristic variables, and generating a text data queue arranged in a set sequence number;
[0024] A matching module, used to use the feature variables to sequentially traverse the text data queue to perform rule matching processing until no new feature variables are segmented out of the regular expression, thereby generating a data processing result;
[0025] The checking module is used to check whether the data processing result contains repeated text data. If so, the feature variables corresponding to the repeated text data are modified to obtain a new regular expression rule model.
[0026] Preferably, the matching module is specifically used for:
[0027] During a single traversal, if the current feature variable does not match the text data queue, the text data that does not conform to the rules will be screened out in the rule matching process of the current feature variable, a matching result will be generated, and the text data queue will be initialized, and the rule matching process of the remaining feature variables will continue to be executed in sequence.
[0028] Preferably, the regular expression rule model is obtained by training the following modules:
[0029] A rule acquisition module, used to acquire a first sample set and an initial rule model for data extraction; the initial rule model includes a plurality of preset rules, each of which includes a plurality of feature variables, and each of which corresponds to a feature regular expression;
[0030] A result generation module, used to obtain the matching result corresponding to the first sample set based on the characteristic regular expression, and generate a matching result set;
[0031] A sample acquisition module, used to generate a second sample set according to all the characteristic regular expressions and the matching result set;
[0032] A model training module is used to train the initial rule model based on the second sample set to obtain the regular expression rule model.
[0033] Preferably, the model training module includes:
[0034] A determination unit, used to determine an initial training set and an initial test set in the second sample set;
[0035] An adjusting unit, configured to adjust the quantity of the initial training set and the initial test set according to the hit rate of the matching result of the characteristic regular expression, so as to generate a target training set and a target test set;
[0036] A training unit is used to train the initial rule model based on the target training set and the target test set to obtain model accuracy, and adjust the feature variables according to the model accuracy to generate the regular expression rule model.
[0037] In a third aspect, the present invention provides an electronic device comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the regular expression-based data processing method described in the first aspect.
[0038] In a fourth aspect, the present invention provides a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the regular expression-based data processing method described in the first aspect.
[0039] The positive progressive effect of the present invention is that the present invention corrects the characteristic variables corresponding to the repeated text data, continuously improves the regular expression rule model obtained based on machine learning training, solves the problems of low efficiency and poor accuracy of manually written regular expressions, and enhances the accuracy of data extraction. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 This is a first flow chart of a data processing method based on regular expressions according to Embodiment 1 of the present invention.
[0041] Figure 2 This is a second flow chart of the regular expression-based data processing method according to Embodiment 1 of the present invention.
[0042] Figure 3 This is a third flow chart of the regular expression-based data processing method according to Embodiment 1 of the present invention.
[0043] Figure 4 This is a schematic diagram of the first module of the regular expression-based data processing system of Example 2 of the present invention.
[0044] Figure 5 This is a schematic diagram of the second module of the regular expression-based data processing system of Example 2 of the present invention.
[0045] Figure 6 This is a schematic diagram of the structure of an electronic device for implementing a data processing method based on regular expressions according to Embodiment 3 of the present invention. DETAILED DESCRIPTION
[0046] The present invention is further described below by way of examples, but the present invention is not limited to the scope of the examples.
[0047] Example 1
[0048] The data processing method based on regular expressions in this embodiment is as follows: Figure 1 As shown, the data processing method includes:
[0049] S11, obtaining original text data and a pre-built regular expression rule model; the regular expression rule model includes a number of feature variables;
[0050] S12, segmenting the original text data based on the feature variables to generate a text data queue arranged in a set sequence number;
[0051] S13, using the feature variables to sequentially traverse the text data queue to perform rule matching processing until no new feature variables are segmented out of the regular expression, thereby generating a data processing result;
[0052] S14. Check whether the data processing result contains repeated text data. If so, modify the feature variables corresponding to the repeated text data to obtain a new regular expression rule model.
[0053] Wherein, step S13 specifically includes:
[0054] During a single traversal, if the current feature variable does not match the text data queue, the text data that does not meet the rules will be screened out in the rule matching process of the current feature variable, a matching result will be generated, the text data queue will be initialized, and the rule matching process of the remaining feature variables will continue to be executed in sequence.
[0055] For the above steps S11-12, determine the original text data that needs to be matched by the regular expression, and obtain the regular expression rule model pre-trained by machine learning. Each character in the original text data is numbered in order. For example, if the original text data is: I am Xiao Yue born on May 22, 1997, then number 1 is "I", number 2 is "Yes", number 3 is "Xiao", number 4 is "Yue", and so on. The regular expression rule model includes a number of rules, each rule includes a plurality of feature variables, for example, rule 1 is composed of feature variables 1, feature variables 2 and feature variables 3, feature variable 1 is "4 digits", feature variable 2 is "number or Chinese number", and feature variable 3 is "no more than 2025". According to the feature variables corresponding to each rule in the regular expression rule model, the original text data is cut. For example, after the original text data is segmented into four characters as a group, the text data queues are obtained as "I am Xiao Yue", "born in 1", "997", "No. 522" and so on.
[0056] For the above steps S13-14, during a single traversal, if the current feature variable cannot match the text data queue, it indicates that the data that does not conform to the rule corresponding to the current feature variable is invalid data, and the text data is screened out instead of deleted in the rule matching process of the current feature variable; if the current feature variable can match the text data queue, it indicates that the data that conforms to the rule corresponding to the current feature variable is valid data. For example, "I am Xiao Yue" does not conform to the digital rule and is screened out; "born in" in "born in 1" does not conform to the digital rule and is screened out, "1" is retained; "997" in "997" conforms to the digital rule and is retained, while "year" does not conform to the digital rule and is screened out; "522" in "May 22" conforms to the digital rule and is retained, while "month" does not conform to the digital rule and is screened out. This method saves the time of a single traversal of the feature variable and improves the efficiency of data extraction.
[0057] The data processing results are checked to determine whether they contain repeated text data. If there is no repeated text data, the matching ends and the data processing results are used as the final results. If there is repeated text data, after the rule list of repeated text data is salvaged, new feature variables are modified or added to the rule list to obtain a regular expression rule model. For example, if rule 3 is used to extract year data, the data processing result contains "1997", and if rule 4 is used to extract date of birth data, the data processing result contains "1997", then "1997" is repeated text data, and new feature variables are adjusted, modified, or added in rules 3 and 4. This method improves the data extraction accuracy of the regular expression rule model by grouping the feature variables of the rules, salvaging repeated text data, and modifying the feature variables.
[0058] In an alternative embodiment, Figure 2 As shown, the regular expression rule model is trained by the following method:
[0059] S21, obtaining a first sample set and an initial rule model for data extraction; the initial rule model includes a plurality of preset rules, each preset rule includes a plurality of feature variables, and each feature variable corresponds to a feature regular expression;
[0060] S22, obtaining matching results corresponding to the first sample set based on the characteristic regular expression, and generating a matching result set;
[0061] S23, generating a second sample set according to all characteristic regular expressions and matching result sets;
[0062] S24. Train an initial rule model based on the second sample set to obtain a regular expression rule model.
[0063] For the above steps S21-24, a large amount of data is obtained and processed into a structured first sample set, and the result set after the actual matching rule is set according to the text content, and the corresponding feature regular expression is generated according to all the feature variables of the rule to construct an initial rule model. The feature regular expression and the matching result set are combined as the second sample set, and the training set and the test set are split out with the second sample set. The default value is supplemented and the sample data is rearranged so that the hit and non-hit data ratios of the matching result set in the training set and the test set are both 1:1. The initial rule model is trained based on the new training set and the test set to obtain a regular expression rule model. This method uses the second sample set obtained by the feature regular expression and the matching result set, and uses machine learning training to generate a regular expression rule model, thereby reducing human intervention in writing regular expressions and improving data extraction accuracy.
[0064] In an alternative embodiment, Figure 3 As shown, step S24 specifically includes:
[0065] S241, determining an initial training set and an initial test set in the second sample set;
[0066] S242, adjusting the number of the initial training set and the initial test set according to the hit rate of the matching result of the characteristic regular expression, and generating a target training set and a target test set;
[0067] S243. Train the initial rule model based on the target training set and the target test set to obtain model accuracy, and adjust feature variables according to the model accuracy to generate a regular expression rule model.
[0068] For the above steps S241-S243, a setting method is used to balance the data of the initial training set and the processing test set, such as default value supplementation, sample data rearrangement, etc., so that the ratio of the hit and non-hit data in the matching result set in the target training set is 1:1, and the ratio of the hit and non-hit data in the matching result set in the target test set is also 1:1. The model accuracy of the initial rule model is calculated according to the decision tree and stochastic gradient descent algorithm. When the model accuracy is not within the preset threshold interval, the feature variables are adjusted, added or deleted to obtain a new regular expression rule model, and the above training method is repeated to obtain the target rule and the corresponding target regular expression, and a regular expression rule model is generated. This method reduces human intervention. For text processing, only feature variables need to be added or adjusted. The regular expression for extracting data is improved through machine learning, which improves data extraction efficiency and accuracy.
[0069] This embodiment provides a data processing method based on regular expressions. By correcting feature variables, a regular expression rule model obtained based on machine learning training is continuously improved to solve the problems of low efficiency and poor accuracy of manually written regular expressions and enhance the accuracy of data extraction.
[0070] Example 2
[0071] The data processing system based on regular expressions in this embodiment is as follows: Figure 4 As shown, the data processing system includes: an acquisition module 310, a segmentation module 320, a matching module 330 and a verification module 340;
[0072] The acquisition module 310 is used to acquire the original text data and the pre-built regular expression rule model; the regular expression rule model includes a number of feature variables;
[0073] The segmentation module 320 is used to segment the original text data based on the characteristic variables and generate a text data queue arranged in a set sequence number;
[0074] The matching module 330 is used to use the characteristic variables to sequentially traverse the text data queue to perform rule matching processing until no new characteristic variables are segmented out of the regular expression, thereby generating a data processing result;
[0075] The checking module 340 is used to check whether the data processing result contains repeated text data. If so, the feature variables corresponding to the repeated text data are modified to obtain a new regular expression rule model.
[0076] The matching module 330 is specifically used for:
[0077] During a single traversal, if the current feature variable does not match the text data queue, the text data that does not meet the rules will be screened out in the rule matching process of the current feature variable, a matching result will be generated, the text data queue will be initialized, and the rule matching process of the remaining feature variables will continue to be executed in sequence.
[0078] The acquisition module 310 determines the original text data that needs to be matched by the regular expression, and obtains the regular expression rule model pre-trained by machine learning. Each character in the original text data is numbered in ascending order. For example, if the original text data is: I am Xiao Yue born on May 22, 1997, then number 1 is "I", number 2 is "Yes", number 3 is "Xiao", number 4 is "Yue", and so on. The regular expression rule model includes a number of rules, each rule includes a plurality of feature variables, for example, rule 1 is composed of feature variables 1, feature variables 2 and feature variables 3, feature variable 1 is "4 digits", feature variable 2 is "number or Chinese number", and feature variable 3 is "no more than 2025". The segmentation module 320 performs data segmentation on the original text data according to the feature variables corresponding to each rule in the regular expression rule model. For example, after segmenting the original text data into four characters as a group, the text data queues are obtained as "I am Xiao Yue", "born in 1", "997", "No. 522" and so on.
[0079] In a single traversal process of the matching module 330, if the current feature variable cannot match the text data queue, it indicates that the data that does not conform to the rule corresponding to the current feature variable is invalid data, and the text data is screened out instead of deleted in the rule matching process of the current feature variable; if the current feature variable can match the text data queue, it indicates that the data that conforms to the rule corresponding to the current feature variable is valid data. For example, "I am Xiao Yue" does not conform to the digital rule and is screened out; "born in" in "born in 1" does not conform to the digital rule and is screened out, "1" is retained; "997" in "997" conforms to the digital rule and is retained, while "year" does not conform to the digital rule and is screened out; "522" in "May 22" conforms to the digital rule and is retained, while "month" does not conform to the digital rule and is screened out. This method saves the time of a single traversal of the feature variable and improves the efficiency of data extraction.
[0080] The verification module 340 verifies the data processing result to determine whether it contains repeated text data. If there is no repeated text data, the matching ends and the data processing result is used as the final result. If there is repeated text data, after the rule list of repeated text data is salvaged, new feature variables are modified or added to the rule list to obtain a regular expression rule model. For example, if rule 3 is used to extract year data, the data processing result includes "1997", and if rule 4 is used to extract date of birth data, the data processing result includes "1997", then "1997" is repeated text data, and new feature variables are adjusted, modified or added in rules 3 and 4. This method improves the data extraction accuracy of the regular expression rule model by grouping the feature variables of the rules, salvaging repeated text data, and modifying the feature variables.
[0081] In an alternative embodiment, Figure 5 As shown in the figure, the regular expression rule model is trained through the following modules:
[0082] The rule acquisition module 301 is used to acquire a first sample set and an initial rule model for data extraction; the initial rule model includes a plurality of preset rules, each preset rule includes a plurality of feature variables, and each feature variable corresponds to a feature regular expression;
[0083] A result generation module 302, configured to obtain matching results corresponding to the first sample set based on the characteristic regular expression and generate a matching result set;
[0084] A sample acquisition module 303 is used to generate a second sample set according to all characteristic regular expressions and matching result sets;
[0085] The model training module 304 is used to train the initial rule model based on the second sample set to obtain a regular expression rule model.
[0086] The rule acquisition module 301 acquires a large amount of data and processes it into a structured first sample set, sets the result set after the actual matching rule according to the text content, generates the corresponding feature regular expression according to all the feature variables of the rule, and constructs the initial rule model. The sample acquisition module 303 combines the feature regular expression and the matching result set as the second sample set, and the model training module 304 splits the second sample set into a training set and a test set, supplements the default values, and rearranges the sample data so that the hit and non-hit data ratios of the matching result set in the training set and the test set are both 1:1, and trains the initial rule model based on the new training set and the test set to obtain the regular expression rule model. This method uses the second sample set obtained by the feature regular expression and the matching result set, and uses machine learning training to generate a regular expression rule model, thereby reducing human intervention in writing regular expressions and improving data extraction accuracy.
[0087] In an alternative embodiment, Figure 5 As shown, the model training module 304 includes:
[0088] A determination unit 3041 is used to determine an initial training set and an initial test set in the second sample set;
[0089] An adjusting unit 3042, configured to adjust the number of the initial training set and the initial test set according to the hit rate of the matching result of the characteristic regular expression, and generate a target training set and a target test set;
[0090] The training unit 3043 is used to train the initial rule model based on the target training set and the target test set to obtain the model accuracy, and adjust the feature variables according to the model accuracy to generate a regular expression rule model.
[0091] The adjustment unit 3042 uses a setting method to balance the data of the initial training set and the processing test set, such as default value supplementation, sample data rearrangement, etc., so that the ratio of the hit and non-hit data in the matching result set in the target training set is 1:1, and the ratio of the hit and non-hit data in the matching result set in the target test set is also 1:1. The training unit 3043 calculates the model accuracy of the initial rule model based on the decision tree and stochastic gradient descent algorithm. When the model accuracy is not within the preset threshold interval, the feature variables are adjusted, added or deleted to obtain a new regular expression rule model, and the aforementioned training method is repeated to obtain the target rule and the corresponding target regular expression, and generate a regular expression rule model. This method reduces human intervention, and only requires adding or adjusting feature variables for text processing. The regular expression for extracting data is improved through machine learning, thereby improving data extraction efficiency and accuracy.
[0092] This embodiment provides a data processing system based on regular expressions, in which a matching module uses feature variables to sequentially traverse a text data queue to perform rule matching processing until no new feature variables are segmented out of the regular expression; a verification module continuously improves a regular expression rule model obtained through machine learning training by correcting feature variables, thereby solving the problems of low efficiency and poor accuracy of manually written regular expressions and enhancing the accuracy of data extraction.
[0093] Example 3
[0094] Figure 6 The schematic diagram of the structure of an electronic device provided in this embodiment includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the data processing method based on regular expressions in embodiment 1 when executing the program. Figure 6 The electronic device 90 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0095] like Figure 6 As shown, the electronic device 90 may be in the form of a general-purpose computing device, for example, it may be a server device. The components of the electronic device 90 may include, but are not limited to: at least one processor 91, at least one memory 92, and a bus 93 connecting different system components (including the memory 92 and the processor 91).
[0096] The bus 93 includes a data bus, an address bus, and a control bus.
[0097] The memory 92 may include a volatile memory, such as a random access memory (RAM) 921 and / or a cache memory 922 , and may further include a read-only memory (ROM) 923 .
[0098] The memory 92 may also include a program / utility 925 having a set (at least one) of program modules 924, such program modules 924 including but not limited to: an operating system, one or more application programs, other program modules and program data, each of which or some combination may include an implementation of a network environment.
[0099] The processor 91 executes various functional applications and data processing by running the computer programs stored in the memory 92, such as the data processing method based on regular expressions in Embodiment 1 of the present invention.
[0100] The electronic device 90 may also communicate with one or more external devices 94 (e.g., keyboards, pointing devices, etc.). Such communication may be performed via an input / output (I / O) interface 95. Furthermore, the model generating device 90 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 96. Figure 6 As shown, the network adapter 96 communicates with other modules of the model-generated device 90 via the bus 93. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with the model-generated device 90, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID (disk array) systems, tape drives, and data backup storage systems, etc.
[0101] It should be noted that although several units / modules or sub-units / modules of the electronic device are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to an embodiment of the present invention, the features and functions of two or more units / modules described above can be embodied in one unit / module. Conversely, the features and functions of one unit / module described above can be further divided into multiple units / modules to be embodied.
[0102] Example 4
[0103] This embodiment provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps in the regular expression-based data processing method of Embodiment 1 are implemented.
[0104] The readable storage medium may include but is not limited to: a portable disk, a hard disk, a random access memory, a read-only memory, an erasable programmable read-only memory, an optical storage device, a magnetic storage device or any suitable combination of the above.
[0105] In a possible implementation manner, the present invention may also be implemented in the form of a program product, which includes program code. When the program product runs on a terminal device, the program code is used to enable the terminal device to execute the steps in the regular expression-based data processing method of embodiment 1.
[0106] Among them, the program code for executing the present invention can be written in any combination of one or more programming languages, and the program code can be executed completely on the user device, partially on the user device, as an independent software package, partially on the user device and partially on a remote device, or completely on the remote device.
[0107] Although the specific embodiments of the present invention are described above, it should be understood by those skilled in the art that this is only for illustration and the protection scope of the present invention is defined by the appended claims. Those skilled in the art may make various changes or modifications to these embodiments without departing from the principles and essence of the present invention, but these changes and modifications all fall within the protection scope of the present invention.
Claims
1. A data processing method based on regular expressions, characterized in that: The data processing method comprises: Obtaining original text data and a pre-built regular expression rule model; the regular expression rule model includes a plurality of feature variables; Performing data segmentation on the original text data based on the characteristic variables to generate a text data queue arranged in a set sequence number; Using the characteristic variables to sequentially traverse the text data queue to perform rule matching processing until no new characteristic variables are segmented out of the regular expression, thereby generating a data processing result; Check whether the data processing result contains repeated text data. If so, modify the feature variables corresponding to the repeated text data to obtain a new regular expression rule model.
2. The data processing method based on regular expressions as claimed in claim 1, characterized in that: The step of using the feature variables to sequentially traverse the text data queue to perform rule matching processing until no new feature variables are segmented out of the regular expression to generate a data processing result includes: During a single traversal, if the current feature variable does not match the text data queue, the text data that does not conform to the rules will be screened out in the rule matching process of the current feature variable, a matching result will be generated, and the text data queue will be initialized, and the rule matching process of the remaining feature variables will continue to be executed in sequence.
3. The data processing method based on regular expressions as claimed in claim 1, characterized in that: The regular expression rule model is trained by the following method: Obtaining a first sample set and an initial rule model for data extraction; the initial rule model includes a plurality of preset rules, each of the preset rules includes a plurality of feature variables, and each of the feature variables corresponds to a feature regular expression; Acquire matching results corresponding to the first sample set based on the characteristic regular expression, and generate a matching result set; Generate a second sample set according to all the characteristic regular expressions and the matching result set; The initial rule model is trained based on the second sample set to obtain the regular expression rule model.
4. The data processing method based on regular expressions as claimed in claim 3, characterized in that: The step of training the initial rule model based on the second sample set to obtain the regular expression rule model comprises: Determining an initial training set and an initial test set in the second sample set; Adjusting the quantity of the initial training set and the initial test set according to the hit rate of the matching result of the characteristic regular expression to generate a target training set and a target test set; The initial rule model is trained based on the target training set and the target test set to obtain model accuracy, and the feature variables are adjusted according to the model accuracy to generate the regular expression rule model.
5. A data processing system based on regular expressions, characterized in that: The data processing system comprises: An acquisition module is used to acquire original text data and a pre-built regular expression rule model; the regular expression rule model includes a number of feature variables; A segmentation module, used for performing data segmentation on the original text data based on the characteristic variables, and generating a text data queue arranged in a set sequence number; A matching module, used to use the feature variables to sequentially traverse the text data queue to perform rule matching processing until no new feature variables are segmented out of the regular expression, thereby generating a data processing result; The checking module is used to check whether the data processing result contains repeated text data. If so, the feature variables corresponding to the repeated text data are modified to obtain a new regular expression rule model.
6. The data processing system based on regular expressions as claimed in claim 5, characterized in that: The matching module is specifically used for: During a single traversal, if the current feature variable does not match the text data queue, the text data that does not conform to the rules will be screened out in the rule matching process of the current feature variable, a matching result will be generated, and the text data queue will be initialized, and the rule matching process of the remaining feature variables will continue to be executed in sequence.
7. The data processing system based on regular expressions as claimed in claim 1, characterized in that: The regular expression rule model is trained by the following modules: A rule acquisition module, used to acquire a first sample set and an initial rule model for data extraction; the initial rule model includes a plurality of preset rules, each of which includes a plurality of feature variables, and each of which corresponds to a feature regular expression; A result generation module, used to obtain the matching result corresponding to the first sample set based on the characteristic regular expression, and generate a matching result set; A sample acquisition module, used to generate a second sample set according to all the characteristic regular expressions and the matching result set; A model training module is used to train the initial rule model based on the second sample set to obtain the regular expression rule model.
8. The data processing system based on regular expressions as claimed in claim 7, characterized in that: The model training module includes: A determination unit, used to determine an initial training set and an initial test set in the second sample set; An adjusting unit, configured to adjust the quantity of the initial training set and the initial test set according to the hit rate of the matching result of the characteristic regular expression, so as to generate a target training set and a target test set; A training unit is used to train the initial rule model based on the target training set and the target test set to obtain model accuracy, and adjust the feature variables according to the model accuracy to generate the regular expression rule model.
9. An electronic device, characterized in that: The invention comprises a processor, a memory and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed by the processor, the data processing method based on regular expressions as claimed in any one of claims 1 to 4 is implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the regular expression-based data processing method according to any one of claims 1 to 4 is implemented.
Citation Information
Cited By
Method and device for extracting medical variables in medical record text, equipment and storage medium
CN118760757A
Variable extraction method, device and equipment based on large model and storage medium
CN118782263A
Automatic generation method and device of regular expression and storage medium
CN118861829A
