Wildcard generation method and device
By generating and merging wildcards, the problems of low efficiency and low accuracy in the prior art wildcard acquisition are solved, and the rapid and accurate screening and searching of character strings in the drawings are achieved.
Patent Information
- Application Number
- CN202210017040.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-07
- Publication Date
- 2025-05-13
- Estimated Expiration
- 2042-01-07
AI Technical Summary
In the prior art, wildcard acquisition efficiency is low and the accuracy after acquisition is low, making it difficult to quickly and accurately filter and find a large number of character strings.
By obtaining the string collection, dividing it into string combinations, wildcard characters are generated, and wildcard characters are merged through preset rules to form wildcard combinations to improve the efficiency and accuracy of wildcard characters acquisition.
It realizes the rapid acquisition of string wildcards in drawings, improves work efficiency, and ensures the accuracy of wildcards, and can effectively filter and find required strings.
Smart Images

Figure CN114357257B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a method and device for generating wildcards, and in particular to a method and device for generating wildcards of character strings in engineering drawings in the field of actual measurement and quantity. Background Art
[0002] The actual measurement of construction projects is a method to control the error of project quality data within the allowable range of national housing construction specifications according to relevant quality acceptance specifications. The implementation of this work can better promote the project to do a good job in physical quality. By establishing a product physical quality actual measurement system and implementing it systematically, the project quality level at each stage of the project can be objectively and truly reflected, and the real-time improvement and continuous improvement of physical quality can be promoted, so as to achieve the goal of one-time qualified physical quality. Therefore, the actual measurement system of civil engineering, as an important part of quality control in the Chinese construction market, is playing a significant role in the construction market and has become a hard indicator for quality assurance of construction projects.
[0003] There are many indicators that need to be measured in actual measurement, mainly including: flatness, verticality, hollowing and cracking of the wall, poor parallelism of the ceiling and the ground, bathroom waterproofing, window caulking and gluing, door opening size, window size, height of socket panel, etc. These indicators will form a large number of strings after digitization.
[0004] In the prior art, in order to quickly filter and search for strings, wildcards are usually used to determine whether a string matches it, and the process of establishing wildcards is usually manual judgment and manual input. However, there are disadvantages in manually establishing wildcards. Strings are established by observing the similarities and differences between strings, which often results in omissions or incomplete considerations. Moreover, for a large number of target strings, it is difficult to extract completely correct wildcards for all characters through manual judgment. It is impossible to quickly establish wildcards while ensuring the accuracy of wildcards. Summary of the invention
[0005] The technical problem to be solved by the present invention is to overcome the defects of low efficiency in obtaining wildcards and low accuracy after wildcards are obtained in the prior art, and to provide a wildcard generation method and device that can obtain strings in drawings, obtain wildcards of strings, and quickly extract required strings through wildcards, thereby providing convenience for users and improving work efficiency.
[0006] The present invention solves the above technical problems through the following technical solutions:
[0007] A wildcard generation method, the wildcard generation method comprising:
[0008] Obtain a string set, wherein the string set includes at least 2 strings;
[0009] Dividing the string set into at least one string combination, each string combination including at least two strings;
[0010] For a string combination, obtain all the same characters between the strings in the string combination, and generate a wildcard for the string combination based on the start and end positions and character lengths of the same characters;
[0011] For a wildcard, all strings matching the wildcard in a string set are obtained as a matching set matching the wildcard;
[0012] Merge wildcards according to a preset rule, wherein for any two wildcards, if the matching set of the first wildcard is a subset of the matching set of the second wildcard, the first wildcard is discarded;
[0013] The merged wildcards are obtained as the wildcard combination of the string set.
[0014] Preferably, the wildcard generating method comprises:
[0015] Acquire all character strings of a target layer in a CAD file as the character string collection;
[0016] The strings in the string collection are combined in pairs to generate string combinations, each of which includes 2 strings.
[0017] Preferably, the wildcard generating method comprises:
[0018] Get all wildcards of string combination;
[0019] Determine whether all wildcards are the same. If not, discard the wildcards in the string combination and record the strings that cannot obtain the wildcards.
[0020] Preferably, the wildcard generating method comprises:
[0021] For each wildcard, split the wildcard using matching symbols according to the same characteristics;
[0022] For a wildcard, traverse the string set, split each string according to the wildcard and determine whether the string structure is consistent with the wildcard structure. If so, match the string to the wildcard's matching set;
[0023] Gets the string that fails to match all wildcard characters.
[0024] Preferably, the step of obtaining the merged wildcards as the wildcard combination of the string set includes:
[0025] Determine whether the combination of the matching result and the string that failed to match is a string set. If so, use the target subset as the wildcard combination of the string set, where the target itself is a subset of the wildcard combination, and the matching result is the matching result of matching the string set using the target subset.
[0026] Preferably, the step of obtaining the merged wildcards as the wildcard combination of the string set further comprises:
[0027] Use wildcard combinations to match string sets to obtain wildcard combination matching results;
[0028] Determine whether the wildcard combination matching result and the string that failed to match are a string set. If so, the wildcard combination verification is successful.
[0029] The present invention also provides a wildcard generating device, which includes an acquisition module, a division module, a generation module, a merging module and a processing module.
[0030] The acquisition module is used to acquire a string set, wherein the string set includes at least two strings;
[0031] The division module is used to divide the string set into at least one string combination, each string combination includes at least two strings;
[0032] For a string combination, the generating module is used to obtain all the same characters between the strings in the string combination, and generate a wildcard of the string combination according to the starting and ending positions and character lengths of the same characters;
[0033] For a wildcard, the merging module is used to obtain all the strings matching the wildcard in the string set as a matching set matching the wildcard;
[0034] The merging module is used to merge wildcards according to a preset rule, wherein for any two wildcards, if the matching set of the first wildcard is a subset of the matching set of the second wildcard, the first wildcard is discarded;
[0035] The processing module is used to obtain the merged wildcards as the wildcard combination of the string set.
[0036] Preferably,
[0037] The acquisition module is also used to acquire all character strings of a target layer in a CAD file as the character string collection;
[0038] The partitioning module is used to combine the strings in the string collection in pairs to generate string combinations, each string combination including 2 strings;
[0039] The generating module is used to obtain all wildcards of the string combination;
[0040] The generating module is further used to determine whether all wildcards are the same, if not, discard the wildcards of the string combination and record the string that cannot obtain the wildcards.
[0041] Preferably, the wildcard generating device further comprises a segmentation module.
[0042] For each wildcard, the segmentation module is used to segment the wildcard using matching symbols according to the same characteristics;
[0043] For a wildcard, the segmentation module is also used to traverse the string set, segment each string according to the wildcard and determine whether the string structure is consistent with the wildcard structure, and if so, match the string to the matching set of the wildcard;
[0044] The processing module is also used to obtain character strings that fail to match all wildcards.
[0045] Preferably, the processing module is used to determine whether the combination of the matching result and the string that failed to match is a string set. If so, the target subset is used as a wildcard combination of the string set, wherein the target itself is a subset of the wildcard combination, and the matching result is the matching result of matching the string set using the target subset.
[0046] Based on the common sense in the art, the above-mentioned preferred conditions can be combined arbitrarily to obtain the preferred embodiments of the present invention.
[0047] The positive and progressive effects of the present invention are:
[0048] The present invention can obtain character strings in drawings, obtain wildcards of character strings, and quickly extract required character strings through wildcards, thereby providing convenience for users and improving work efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 This is a flow chart of a wildcard generation method according to Embodiment 1 of the present invention.
[0050] Figure 2 This is a schematic diagram of the structure of a string set and a string combination according to Embodiment 1 of the present invention.
[0051] Figure 3 This is a schematic diagram of the structure of the wildcard in Example 1 of the present invention. DETAILED DESCRIPTION
[0052] The present invention is further described below by way of examples, but the present invention is not limited to the scope of the examples.
[0053] Example 1
[0054] This embodiment provides a wildcard generating device, which includes an acquisition module, a division module, a generation module, a merging module and a processing module.
[0055] The acquisition module is used to acquire a string set, wherein the string set includes at least two strings;
[0056] The division module is used to divide the string set into at least one string combination, each string combination includes at least two strings;
[0057] For a string combination, the generating module is used to obtain all the same characters between the strings in the string combination, and generate a wildcard of the string combination according to the starting and ending positions and character lengths of the same characters;
[0058] For a wildcard, the merging module is used to obtain all the strings matching the wildcard in the string set as a matching set matching the wildcard;
[0059] The merging module is used to merge wildcards according to a preset rule, wherein for any two wildcards, if the matching set of the first wildcard is a subset of the matching set of the second wildcard, the first wildcard is discarded;
[0060] The processing module is used to obtain the merged wildcards as the wildcard combination of the string set.
[0061] Furthermore, the acquisition module is also used to acquire all character strings of a target layer in a CAD file as the character string collection;
[0062] The partitioning module is used to combine the strings in the string collection in pairs by using the combinations algorithm of the python itertools library to generate string combinations, each string combination including 2 strings;
[0063] The generation module is used to obtain all wildcards of the string combination through the get_matching_blocks algorithm of the python difflib library;
[0064] In this embodiment, string combinations are obtained using the combinations algorithm of the python itertools library, but the protection scope of the present application is not limited to this. In this step, algorithms that combine strings in a string set fall within the protection scope of the present application.
[0065] Similarly, the method for obtaining wildcards in this embodiment adopts the get_matching_blocks algorithm of the python difflib library, but the protection scope of this application is not limited to this. In this step, algorithms that can obtain wildcards fall within the protection scope of this application.
[0066] The generating module is further used to determine whether all wildcards are the same, if not, discard the wildcards of the string combination and record the string that cannot obtain the wildcards.
[0067] Specifically, the wildcard generating device further includes a segmentation module.
[0068] For each wildcard, the segmentation module is used to segment the wildcard using matching symbols according to the same characteristics;
[0069] For a wildcard, the segmentation module is also used to traverse the string set, segment each string according to the wildcard and determine whether the string structure is consistent with the wildcard structure, and if so, match the string to the matching set of the wildcard;
[0070] The processing module is also used to obtain character strings that fail to match all wildcards.
[0071] The processing module is further used to determine whether the combination of the matching result and the string that failed to match is a string set. If so, the target subset is used as the wildcard combination of the string set, wherein the target itself is a subset of the wildcard combination, and the matching result is the matching result of matching the string set using the target subset.
[0072] See also Figure 1 , using the above-mentioned wildcard generating device, this embodiment provides a wildcard generating method, including:
[0073] Step 100: Obtain a string set, wherein the string set includes at least two strings;
[0074] Step 101: Divide the string set into at least one string combination, each string combination including at least two strings;
[0075] Step 102: for a string combination, obtain all identical characters between the strings in the string combination, and generate a wildcard for the string combination according to the start and end positions and character lengths of the identical characters;
[0076] Step 103: for a wildcard, obtain all character strings in a character string set that match the wildcard as a matching set that matches the wildcard;
[0077] Step 104: merging wildcards according to a preset rule, wherein for any two wildcards, if the matching set of the first wildcard is a subset of the matching set of the second wildcard, the first wildcard is discarded;
[0078] Step 105: Obtain the merged wildcards as the wildcard combination of the string set.
[0079] See also Figure 2 In this embodiment, a string set 11 is obtained, the string set includes a plurality of strings 111, and the string set is divided into a plurality of string combinations 12, each of which includes two strings 121.
[0080] Specifically, the process before step 100 includes: obtaining all character strings of a target layer in a CAD file as the character string collection;
[0081] Step 101 includes: combining two strings in the string collection by using the combinations algorithm of the python itertools library to generate string combinations, each string combination including two strings.
[0082] Step 102 specifically includes:
[0083] Get all wildcards of string combinations through the get_matching_blocks algorithm of the Python difflib library;
[0084] Determine whether all wildcards are the same. If not, discard the wildcards in the string combination and record the strings that cannot obtain the wildcards.
[0085] See also Figure 3 , the same characters of string 121 in string combination 12 are obtained through an algorithm, where a represents the starting position of the same characters of the first string, b represents the starting position of the same characters of the second string, and size represents the length.
[0086] After getting the same characters, generate wildcards based on the same characters.
[0087] For example, the following are the cases where two wildcards are generated differently:
[0088] String 1: WINDOW.$WINLIB2D$00000001
[0089] String 2: VFDGH.WINDOW
[0090] Same part: WINDOW
[0091] Generate two wildcards by replacing WINDOW with *:
[0092] String 1 is *.$WINLIB2D$00000001
[0093] String 2 is VFDGH.*
[0094] The two wildcards do not produce the same result, so they are discarded.
[0095] Furthermore, this embodiment can also verify the wildcard matching result, which can be specifically applied between steps 102 and 103. The wildcard generation method includes:
[0096] For each wildcard, split the wildcard using matching symbols according to the same characteristics;
[0097] For a wildcard, traverse the string set, split each string according to the wildcard and determine whether the string structure is consistent with the wildcard structure. If so, match the string to the wildcard's matching set;
[0098] Gets the string that fails to match all wildcard characters.
[0099] String: VFDGH.WINDOW
[0100] Wildcard: *WINDOW
[0101] String segmentation result: ['VFDGH.', ''] (will include a null character)
[0102] According to the wildcard structure, WINDOW should contain any string (* in front), and WINDOW should be at the end of the string, and the empty character of the string segmentation result should be at the end, which meets the wildcard and is added to the successfully matched string array.
[0103] String: WINDOW.$WINLIB2D$00000001
[0104] Wildcard: *WINDOW
[0105] String segmentation result: ['', '.$WINLIB2D$00000001']
[0106] The empty string comes first, which means the structures are different and are discarded.
[0107] The wildcard array obtained in the previous step may contain repeated or mutually subset wildcard results. This embodiment mainly combines these redundant results to find the smallest wildcard array.
[0108] The specific implementation method is to calculate the full combination of the wildcard array, where n is the length of the wildcard array, and m is [2, n]. If the matching result of a group of wildcards in the full combination is exactly equal to the required result (except the string that failed to match), then the combination is used as the result of the wildcard calculation.
[0109] The present invention simplifies wildcard combinations, and step 105 includes:
[0110] Determine whether the combination of the matching result and the string that failed to match is a string set. If so, use the target subset as the wildcard combination of the string set, where the target itself is a subset of the wildcard combination, and the matching result is the matching result of matching the string set using the target subset.
[0111] The result of the previous step is [wildcard A, wildcard B, wildcard C, .....]
[0112] The matching result of wildcard A is: [a, b, c]
[0113] The wildcard B matches: [a, b]
[0114] The wildcard C matches: [c, f] ......
[0115] The target result is [a, b, c, f, g]
[0116] Then the wildcard B mentioned above can be omitted.
[0117] The purpose of this step is to find the shortest wildcard combination result through the permutations and combinations of wildcards.
[0118] The present invention also includes a method for verifying a wildcard combination, specifically: obtaining the merged wildcard as the wildcard combination of the string set, and then comprising:
[0119] Use wildcard combinations to match string sets to obtain wildcard combination matching results;
[0120] Determine whether the wildcard combination matching result and the string that failed to match are a string set. If so, the wildcard combination verification is successful.
[0121] Using the wildcard generation method of the present application, the specific method of processing the CAD drawing can be:
[0122] Select some layers in the CAD drawing and use this algorithm to generate wildcards. Next time you want to select these layers, you only need to use the wildcard calculation to select them. For example:
[0123] The layer name of Door is: "DOOR_FIRE.$DorLib2D$00000001"
[0124] "DOOR_FIRE.$DorLib2D$00000114"
[0125] "DOOR_FIRE.$DorLib2D$00000116"
[0126] There are probably hundreds of layer names;
[0127] The wildcard "DOOR_FIRE.$DorLib2D$00000*" can be obtained
[0128] You can directly select the required door layer from hundreds of layers
[0129] Direct manual selection may result in omissions and the speed is limited by human proficiency.
[0130] Although the specific embodiments of the present invention are described above, those skilled in the art should understand that these are only examples, 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 wildcard generation method, characterized in that: The wildcard generating method comprises: Obtain a string set, wherein the string set includes at least 2 strings; Dividing the string set into at least one string combination, each string combination including at least two strings; For a string combination, obtain all the same characters between the strings in the string combination, and generate a wildcard for the string combination based on the start and end positions and character lengths of the same characters; For a wildcard, all strings matching the wildcard in a string set are obtained as a matching set matching the wildcard; Merge wildcards according to a preset rule, wherein for any two wildcards, if the matching set of the first wildcard is a subset of the matching set of the second wildcard, the first wildcard is discarded; Obtain the merged wildcard as the wildcard combination of the string set; The wildcard generating method comprises: Acquire all character strings of a target layer in a CAD file as the character string collection; Combine the strings in the string collection in pairs to generate string combinations, each string combination includes 2 strings; The wildcard generating method comprises: Get all wildcards of string combination; Determine whether all wildcards are the same. If not, discard the wildcards in the string combination and record the string that cannot obtain the wildcard; The wildcard generating method comprises: For each wildcard, split the wildcard using matching symbols according to the same characteristics; For a wildcard, traverse the string set, split each string according to the wildcard and determine whether the string structure is consistent with the wildcard structure. If so, match the string to the wildcard's matching set; Get the string that fails to match all wildcards; The step of obtaining the merged wildcards as a wildcard combination of the string set includes: Determine whether the combination of the matching result and the string that failed to match is a string set. If so, use the target subset as the wildcard combination of the string set, where the target itself is a subset of the wildcard combination, and the matching result is the matching result of matching the string set using the target subset.
2. The wildcard generating method according to claim 1, characterized in that: The step of obtaining the merged wildcard as the wildcard combination of the string set includes: Use wildcard combinations to match string sets to obtain wildcard combination matching results; Determine whether the wildcard combination matching result and the set of strings that failed to match are a string set. If so, the wildcard combination verification is successful.
3. A wildcard generating device, characterized in that: The wildcard generating device comprises an acquisition module, a division module, a generation module, a merging module and a processing module. The acquisition module is used to acquire a string set, wherein the string set includes at least two strings; The division module is used to divide the string set into at least one string combination, each string combination includes at least two strings; For a string combination, the generating module is used to obtain all the same characters between the strings in the string combination, and generate a wildcard of the string combination according to the starting and ending positions and character lengths of the same characters; For a wildcard, the merging module is used to obtain all the strings matching the wildcard in the string set as a matching set matching the wildcard; The merging module is used to merge wildcards according to a preset rule, wherein for any two wildcards, if the matching set of the first wildcard is a subset of the matching set of the second wildcard, the first wildcard is discarded; The processing module is used to obtain the merged wildcard as the wildcard combination of the string set; The acquisition module is also used to acquire all character strings of a target layer in a CAD file as the character string collection; The partitioning module is used to combine the strings in the string collection in pairs to generate string combinations, each string combination including 2 strings; The generating module is used to obtain all wildcards of the string combination; The generating module is also used to determine whether all wildcards are the same, if not, discard the wildcards of the string combination and record the string that cannot obtain the wildcard; The wildcard generating device further includes a segmentation module. For each wildcard, the segmentation module is used to segment the wildcard using matching symbols according to the same characteristics; For a wildcard, the segmentation module is also used to traverse the string set, segment each string according to the wildcard and determine whether the string structure is consistent with the wildcard structure, and if so, match the string to the matching set of the wildcard; The processing module is also used to obtain character strings that fail to match all wildcards; The processing module is used to determine whether the combination of the matching result and the string that failed to match is a string set. If so, the target subset is used as the wildcard combination of the string set, wherein the target itself is a subset of the wildcard combination, and the matching result is the matching result of matching the string set using the target subset.
Citation Information
Patent Citations
Data filtering method and equipment
CN108170812A
Determining best match among a plurality of pattern rules using wildcards with a text string
US20100205135A1