CN114168808A - Regular expression-based document character string coding identification method and device - Google Patents

Regular expression-based document character string coding identification method and device Download PDF

Info

Publication number
CN114168808A
CN114168808A CN202111387759.6A CN202111387759A CN114168808A CN 114168808 A CN114168808 A CN 114168808A CN 202111387759 A CN202111387759 A CN 202111387759A CN 114168808 A CN114168808 A CN 114168808A
Authority
CN
China
Prior art keywords
regular expression
determining
character string
optimal
factor
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111387759.6A
Other languages
Chinese (zh)
Inventor
姚昊
富会佳
胡文勇
任宇阳
史亚琛
楼宝川
潘炼
汤奔
李志鹏
胡琛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
CNNC Nuclear Power Operation Management Co Ltd
Original Assignee
CNNC Nuclear Power Operation Management Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by CNNC Nuclear Power Operation Management Co Ltd filed Critical CNNC Nuclear Power Operation Management Co Ltd
Priority to CN202111387759.6A priority Critical patent/CN114168808A/en
Publication of CN114168808A publication Critical patent/CN114168808A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/903Querying
    • G06F16/90335Query processing
    • G06F16/90344Query processing by using string matching techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/12Use of codes for handling textual entities
    • G06F40/126Character encoding

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Data Mining & Analysis (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The disclosure belongs to the technical field of nuclear power, and particularly relates to a document character string code identification method and device based on a regular expression. The present disclosure determines an optimal factor set from a regular expression; determining the document record with the optimal factor in the optimal factor set by adopting a CW algorithm, and adding the determined document record into a candidate set; and verifying the character string of the optimal factor in the candidate set according to the DFA automaton determined by the regular expression to obtain the successfully matched character string. An optimal factor is defined when the regular expression is queried, and the mode of querying by using the regular expression is simplified. And selecting a CW algorithm according to the number of the optimal factors to quickly inquire the extracted optimal factor set, effectively filtering out the character string set which does not contain the optimal factors to obtain candidate character strings, and further verifying the character string codes in the candidate set by using a DFA (distributed feed algorithm) automaton, thereby improving the overall inquiry performance.

Description

Regular expression-based document character string coding identification method and device
Technical Field
The invention belongs to the technical field of nuclear power, and particularly relates to a document character string code identification method and device based on a regular expression.
Background
Database technology has evolved rapidly, solving many existing problems, and is being utilized in many areas. But as the database stores more data, the data query of the database becomes more difficult. Simple string queries have not been able to satisfy the requirements of human queries. Regular expression (regular expression) describes a pattern (pattern) for matching a character string, which can be used to check whether a string contains a certain substring, replace the matched substring, or extract a substring meeting a certain condition from a certain string, but in the prior art, in the face of massive data, the problem of low retrieval efficiency often occurs when a regular expression is simply adopted for retrieval, and therefore how to efficiently and accurately execute the character string coding identification based on the regular expression becomes a problem to be solved urgently.
Disclosure of Invention
In order to overcome the problems in the related art, a document character string coding and identifying method and a document character string coding and identifying device based on regular expressions are provided.
According to an aspect of the embodiments of the present disclosure, a method for identifying document string codes based on regular expressions is provided, where the method includes:
determining an optimal factor set according to the regular expression;
determining the document record with the optimal factor in the optimal factor set by adopting a CW algorithm, and adding the determined document record into a candidate set;
and verifying the character string of the optimal factor in the candidate set according to the DFA automaton determined by the regular expression to obtain the successfully matched character string.
In one possible implementation, the method further includes:
determining the regular expression according to an encoding rule, the encoding rule including normalized encoded data.
In one possible implementation, determining the optimal factor set according to a regular expression includes:
determining one or more query segments according to the regular expression;
for each query segment, determining all possible character strings of the query segment, wherein the all possible character strings form a character string set;
taking the longest character string in the character strings matched with the regular expression as a necessary factor;
and selecting the character strings with the length larger than the necessary factor in the character string set to form an optimal factor set.
In one possible implementation, determining a document record in which the best factor in the best factor set occurs by using a CW algorithm, and adding the determined document record to a candidate set includes:
determining the length of a sliding window required to be used for inquiring the text sequence according to a CW algorithm;
traversing in a preset direction on a text sequence by using sliding windows, sequentially comparing each character in each sliding window in a direction opposite to the preset direction, reporting a successful match if a longest suffix of a certain query is inquired, adding a record into a candidate set, and continuing sliding the windows backwards until the traversal is finished.
In a possible implementation manner, the DFA automaton determined according to the regular expression verifies the character strings of the optimal factors in the candidate set, and successfully matched character strings are obtained, including
Constructing a corresponding DFA automaton according to the regular expression;
and matching the candidate set by adopting a DFA (deterministic finite automaton) to obtain a successfully matched character string.
According to another aspect of the embodiments of the present disclosure, there is provided a regular expression-based document string encoding and recognizing apparatus, the apparatus including:
the first determining module is used for determining an optimal factor set according to the regular expression;
a second determining module, configured to determine, by using a CW algorithm, a document record in which an optimal factor in the optimal factor set occurs, and add the determined document record to the candidate set;
and the third determining module is used for verifying the character string of the optimal factor in the candidate set according to the DFA automaton determined by the regular expression to obtain the successfully matched character string.
In one possible implementation, the apparatus further includes:
a fourth determination module to determine the regular expression according to an encoding rule, the encoding rule including normalized encoded data.
In one possible implementation manner, the first determining module includes:
the first determining submodule is used for determining one or more query segments according to the regular expression;
the second determining sub-module is used for determining all possible character strings of each query segment, and the all possible character strings form a character string set;
a third determining submodule, configured to use the longest character string in the character strings matched with the regular expression as a necessary factor;
and the fourth determining submodule is used for selecting the character strings with the length larger than the necessary factor in the character string set to form an optimal factor set.
In one possible implementation manner, the second determining module includes:
a fifth determining submodule, configured to determine, according to a CW algorithm, a length of a sliding window that is required to be used for querying the text sequence;
and the sixth determining submodule is used for traversing in a preset direction by using sliding windows on the text sequence, sequentially comparing each character in each sliding window in a direction opposite to the preset direction, reporting a successful matching if a longest suffix of a certain query is queried, adding the record into the candidate set, and continuing to slide the window backwards until the traversal is finished.
In one possible implementation, the third determining module includes
The seventh determining submodule is used for constructing a corresponding DFA automaton according to the regular expression;
and the eighth determining submodule is used for matching the candidate set by adopting a DFA (deterministic finite automaton) to obtain a successfully matched character string.
According to another aspect of the embodiments of the present disclosure, there is provided a regular expression-based document string encoding and recognizing apparatus, the apparatus including:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to perform the method described above.
According to another aspect of embodiments of the present disclosure, there is provided a non-transitory computer-readable storage medium having stored thereon computer program instructions which, when executed by a processor, implement the above-described method.
The beneficial effect of this disclosure lies in: the present disclosure determines an optimal factor set from a regular expression; determining the document record with the optimal factor in the optimal factor set by adopting a CW algorithm, and adding the determined document record into a candidate set; and verifying the character string of the optimal factor in the candidate set according to the DFA automaton determined by the regular expression to obtain the successfully matched character string. An optimal factor is defined when the regular expression is queried, and the mode of querying by using the regular expression is simplified. And selecting a CW algorithm according to the number of the optimal factors to quickly inquire the extracted optimal factor set, effectively filtering out the character string set which does not contain the optimal factors to obtain candidate character strings, and further verifying the character string codes in the candidate set by using a DFA (distributed feed algorithm) automaton, thereby improving the overall inquiry performance.
Drawings
FIG. 1 is a flowchart illustrating a regular expression based document string code recognition method according to an exemplary embodiment.
FIG. 2 is a diagram illustrating DFA auto-match based regular expression matching according to an example embodiment.
FIG. 3 is a block diagram illustrating a regular expression based document string encoding recognition apparatus according to an example embodiment.
FIG. 4 is a block diagram illustrating a regular expression based document string encoding recognition apparatus according to an example embodiment.
Detailed Description
The invention is described in further detail below with reference to the figures and the embodiments.
FIG. 1 is a flowchart illustrating a regular expression based document string code recognition method according to an exemplary embodiment. The method may be executed by a terminal device, for example, the terminal device may be a server, a desktop computer, a notebook computer, a tablet computer, or the like, and the terminal device may also be a user device, a vehicle-mounted device, or a wearable device, or the like, and the type of the terminal device is not limited in the embodiment of the present disclosure. As shown in fig. 1, the method includes:
step 100, determining an optimal factor set according to a regular expression;
step 101, determining a document record with the optimal factor in the optimal factor set by adopting a CW algorithm, and adding the determined document record into a candidate set;
and 102, verifying the character string of the optimal factor in the candidate set according to the DFA automaton determined by the regular expression, and obtaining the successfully matched character string.
In one possible implementation, the method further includes:
determining the regular expression according to an encoding rule, the encoding rule including normalized encoded data.
In one possible implementation, step 100 includes:
step 1000, determining one or more query segments according to a regular expression;
step 1001, determining all possible character strings of each query segment, wherein the all possible character strings form a character string set;
step 1002, using the longest character string in the character strings matched with the regular expression as a necessary factor;
and 1003, selecting the character strings with the length larger than the necessary factor in the character string set to form an optimal factor set.
In one possible implementation, step 101 includes:
step 1010, determining the length of a sliding window required to be used for inquiring the text sequence according to a CW algorithm;
and step 1011, traversing the text sequence by using sliding windows in a preset direction, sequentially comparing each character in each sliding window in a direction opposite to the preset direction, reporting a successful match if a longest suffix of a certain query is queried, adding the record into the candidate set, and continuing sliding the windows backwards until the traversal is finished.
In one possible implementation, step 102 includes
Step 1020, constructing a corresponding DFA automaton according to the regular expression;
and step 1021, matching the candidate set by adopting a DFA (distributed feed back) automaton to obtain a successfully matched character string.
In one application example, the method of the present disclosure is explained as follows:
firstly, an encoding set database can be created, a rule file of strict specification encoding or an encoding list Excel form file is used for creating the encoding set database, and a Mysql relational database is adopted for storing encoding data. Such as device code, which can be defined as a combination of system code and device identification number;
then, the optimal factors can be extracted, and a regular expression is constructed according to the code set in the manifest file; selecting a candidate optimal factor: a regular expression RE is given, and the processed sub-expression query fragment REi corresponding to it. For each query fragment, all possible string combinations are listed, so that the query fragment becomes in the form of a string set, which may be expressed by { S1, S2, … …, St }, and | REi | represents the number of strings included in the string set. Defining the longest substring which can exist in all character strings matched with RE as the necessary factor of the regular expression, and marking as must. For example, for regular expression (C | a) × GA (T | C), GA is its essential factor. The selection of the necessary factor is not only an accurate substring, but also a sub-expression of the regular expression. If RE satisfies the condition | Si | > | must |, namely the length of each character string in the character string set is greater than the length of the necessary factor must, REi is a candidate optimal factor set, wherein i is greater than or equal to 1 and less than or equal to t;
determining an optimal factor: when the candidate optimal factor set is empty, defining the optimal factor as the regular expression RE; when the query segment meeting the condition is unique, the query segment set is the optimal factor set; if there are a plurality of query segments that satisfy the condition, a candidate optimal factor set containing the least number of character strings, each of which is an optimal factor, is defined as an optimal factor set. For example, a regular expression (AT | CG | TA) T ((CA | GC) C) with two query segments RE1 ═ AT | CG | TA, RE2 ═ C, (CA | GC) C, a string set corresponding to RE1 is { AT, CG, TA }, a string set corresponding to RE2 is { CAC, GCC }, and a necessary factor of the regular expression is string C, and the lengths of the strings and the necessary factor in each query segment are compared, and since the lengths of all the strings in RE1 and RE2 are greater than the length of the necessary factor, RE1 and RE2 are both candidate optimal factors. Because | RE1| > | RE2|, the final optimal necessary factor set is { CAC, GCC }, wherein both character strings are optimal factors;
obtaining a candidate set comprising:
the CW (Commentz-Walter) string matching method is based on the AC (Aho-Corasick) automaton, and introduces the multi-mode extension of the BM (Boyer-Moore) algorithm, so the method is also called ACBM algorithm. The method realizes efficient multi-mode matching and is one of algorithms capable of carrying out multi-string query. To use the CW algorithm to perform multi-string query, the distance of the sliding window needed to be used for querying the text sequence needs to be first determined according to the CW algorithm.
Defining a multi-query set P ═ { P1, P2, … …, Pr }, for the text sequence T of the window, assuming that k characters are read in from the text position pos from back to front, the longest suffix P 'of a certain query is found, the length of the suffix is k, and the position of P' in the text T is pos-k + 1. The distance of the sliding window is determined by three functions: d1, d2 and d3, the unmatched character is x in T, corresponding to pos-k in T, which corresponds to three cases:
if this substring of P' also exists in a certain query Pi, d1 is the minimum distance moved to align the suffix in the text with that substring;
if a query Pi has the longest prefix that is the same as a suffix of P', d2 is the minimum distance moved to align the prefix with the suffix in T that it matches;
if a character x has appeared somewhere in the query Pi, then the location T where the character appeared in the query is found, d3 being the minimum distance that would make the character x align with the unmatched location pos-k in the text T with 1.
The final sliding window has a moving distance of
Figure BDA0003367669350000081
Traversing by using sliding windows from left to right on a text sequence, sequentially comparing characters from right to left in each sliding window, reporting a successful match if a longest suffix of a certain query is found, adding a record into a candidate set, and continuing sliding the windows backwards until all texts are traversed to obtain a candidate data set;
finally, performing verification matching on the character string, including:
constructing a corresponding DFA automaton according to the regular expression;
the structure of the DFA automata is based on the structure of the NFA automata, and two common methods for constructing the NFA exist, namely a Thompson structure method and a Glushkov structure method. Therefore, a thompson NFA or a gloshkov NFA can be created first and then converted into a DFA, where the only current state of the DFA is the set of current active states of the NFA. Because the state transition is performed every time a character is input, the search time of the DFA is linear o (n), where n is the length of the text T to be queried. FIG. 2 is a diagram illustrating DFA auto-match based regular expression matching according to an example embodiment. Fig. 2 is a schematic diagram of a DFA converted from an NFA of a regular expression RE ═ ATC (CT | TG), for a text agacttg, characters in the text are sequentially read, when a is read, the active state is shifted from 0 to l, when G is read, the active state returns to 0 again, and so on, when the 6 th character T in the text is read, the termination state 5 of the automaton is reached, which indicates that a match is found, the text position 6 is returned, the search is continued, the 7 th character G is read, a termination state 6 is reached again, at this time, the text position 7 is also returned as a result, the end of the text is reached, and the search is ended. A total of two matches are found, the end positions being 6 and 7 respectively.
And the matching data set of the DFA automaton is a candidate data set in the third step, and the successfully matched character codes are obtained after the matching of the data set.
In one possible implementation, an apparatus for identifying document string codes based on regular expressions is provided, the apparatus including:
the first determining module is used for determining an optimal factor set according to the regular expression;
a second determining module, configured to determine, by using a CW algorithm, a document record in which an optimal factor in the optimal factor set occurs, and add the determined document record to the candidate set;
and the third determining module is used for verifying the character string of the optimal factor in the candidate set according to the DFA automaton determined by the regular expression to obtain the successfully matched character string.
In one possible implementation, the apparatus further includes:
a fourth determination module to determine the regular expression according to an encoding rule, the encoding rule including normalized encoded data.
In one possible implementation manner, the first determining module includes:
the first determining submodule is used for determining one or more query segments according to the regular expression;
the second determining sub-module is used for determining all possible character strings of each query segment, and the all possible character strings form a character string set;
a third determining submodule, configured to use the longest character string in the character strings matched with the regular expression as a necessary factor;
and the fourth determining submodule is used for selecting the character strings with the length larger than the necessary factor in the character string set to form an optimal factor set.
In one possible implementation manner, the second determining module includes:
a fifth determining submodule, configured to determine, according to a CW algorithm, a length of a sliding window that is required to be used for querying the text sequence;
and the sixth determining submodule is used for traversing in a preset direction by using sliding windows on the text sequence, sequentially comparing each character in each sliding window in a direction opposite to the preset direction, reporting a successful matching if a longest suffix of a certain query is queried, adding the record into the candidate set, and continuing to slide the window backwards until the traversal is finished.
In one possible implementation, the third determining module includes
The seventh determining submodule is used for constructing a corresponding DFA automaton according to the regular expression;
and the eighth determining submodule is used for matching the candidate set by adopting a DFA (deterministic finite automaton) to obtain a successfully matched character string.
The description of the above apparatus has been detailed in the description of the above method, and is not repeated here.
FIG. 3 is a block diagram illustrating a regular expression based document string encoding recognition apparatus according to an example embodiment. For example, the apparatus 800 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, an exercise device, a personal digital assistant, and the like.
Referring to fig. 3, the apparatus 800 may include one or more of the following components: processing component 802, memory 804, power component 806, multimedia component 808, audio component 810, input/output (I/O) interface 812, sensor component 814, and communication component 816.
The processing component 802 generally controls overall operation of the device 800, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing components 802 may include one or more processors 820 to execute instructions to perform all or a portion of the steps of the apparatus described above. Further, the processing component 802 can include one or more modules that facilitate interaction between the processing component 802 and other components. For example, the processing component 802 can include a multimedia module to facilitate interaction between the multimedia component 808 and the processing component 802.
The memory 804 is configured to store various types of data to support operations at the apparatus 800. Examples of such data include instructions for any application or device operating on device 800, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 804 may be implemented by any type or combination of volatile or non-volatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
Power components 806 provide power to the various components of device 800. The power components 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the apparatus 800.
The multimedia component 808 includes a screen that provides an output interface between the device 800 and the user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front facing camera and/or a rear facing camera. The front camera and/or the rear camera may receive external multimedia data when the device 800 is in an operating mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 810 is configured to output and/or input audio signals. For example, the audio component 810 includes a Microphone (MIC) configured to receive external audio signals when the apparatus 800 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may further be stored in the memory 804 or transmitted via the communication component 816. In some embodiments, audio component 810 also includes a speaker for outputting audio signals.
The I/O interface 812 provides an interface between the processing component 802 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
The sensor assembly 814 includes one or more sensors for providing various aspects of state assessment for the device 800. For example, the sensor assembly 814 may detect the open/closed status of the device 800, the relative positioning of the components, such as a display and keypad of the device 800, the sensor assembly 814 may also detect a change in the position of the device 800 or a component of the device 800, the presence or absence of user contact with the device 800, the orientation or acceleration/deceleration of the device 800, and a change in the temperature of the device 800. Sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 816 is configured to facilitate communications between the apparatus 800 and other devices in a wired or wireless manner. The device 800 may access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, communications component 816 further includes a Near Field Communications (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the apparatus 800 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In an exemplary embodiment, a non-transitory computer-readable storage medium, such as the memory 804, is also provided that includes computer program instructions executable by the processor 820 of the device 800 to perform the above-described methods.
FIG. 4 is a block diagram illustrating a regular expression based document string encoding recognition apparatus according to an example embodiment. For example, the apparatus 1900 may be provided as a server. Referring to fig. 4, the device 1900 includes a processing component 1922 further including one or more processors and memory resources, represented by memory 1932, for storing instructions, e.g., applications, executable by the processing component 1922. The application programs stored in memory 1932 may include one or more modules that each correspond to a set of instructions. Further, the processing component 1922 is configured to execute instructions to perform the above-described method.
The device 1900 may also include a power component 1926 configured to perform power management of the device 1900, a wired or wireless network interface 1950 configured to connect the device 1900 to a network, and an input/output (I/O) interface 1958. The device 1900 may operate based on an operating system stored in memory 1932, such as Windows Server, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, or the like.
In an exemplary embodiment, a non-transitory computer readable storage medium, such as the memory 1932, is also provided that includes computer program instructions executable by the processing component 1922 of the apparatus 1900 to perform the above-described methods.
The present disclosure may be systems, methods, and/or computer program products. The computer program product may include a computer-readable storage medium having computer-readable program instructions embodied thereon for causing a processor to implement various aspects of the present disclosure.
The computer readable storage medium may be a tangible device that can hold and store the instructions for use by the instruction execution device. The computer readable storage medium may be, for example, but not limited to, an electronic memory device, a magnetic memory device, an optical memory device, an electromagnetic memory device, a semiconductor memory device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a Static Random Access Memory (SRAM), a portable compact disc read-only memory (CD-ROM), a Digital Versatile Disc (DVD), a memory stick, a floppy disk, a mechanical coding device, such as punch cards or in-groove projection structures having instructions stored thereon, and any suitable combination of the foregoing. Computer-readable storage media as used herein is not to be construed as transitory signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through a waveguide or other transmission medium (e.g., optical pulses through a fiber optic cable), or electrical signals transmitted through electrical wires.
The computer-readable program instructions described herein may be downloaded from a computer-readable storage medium to a respective computing/processing device, or to an external computer or external storage device via a network, such as the internet, a local area network, a wide area network, and/or a wireless network. The network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers and/or edge servers. The network adapter card or network interface in each computing/processing device receives computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in a computer-readable storage medium in the respective computing/processing device.
The computer program instructions for carrying out operations of the present disclosure may be assembler instructions, Instruction Set Architecture (ISA) instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source or object code written in any combination of one or more programming languages, including an object oriented programming language such as Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The computer-readable program instructions may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider). In some embodiments, the electronic circuitry that can execute the computer-readable program instructions implements aspects of the present disclosure by utilizing the state information of the computer-readable program instructions to personalize the electronic circuitry, such as a programmable logic circuit, a Field Programmable Gate Array (FPGA), or a Programmable Logic Array (PLA).
Various aspects of the present disclosure are described herein with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the disclosure. It will be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer-readable program instructions.
These computer-readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks. These computer-readable program instructions may also be stored in a computer-readable storage medium that can direct a computer, programmable data processing apparatus, and/or other devices to function in a particular manner, such that the computer-readable medium storing the instructions comprises an article of manufacture including instructions which implement the function/act specified in the flowchart and/or block diagram block or blocks.
The computer readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other devices to cause a series of operational steps to be performed on the computer, other programmable apparatus or other devices to produce a computer implemented process such that the instructions which execute on the computer, other programmable apparatus or other devices implement the functions/acts specified in the flowchart and/or block diagram block or blocks.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of instructions, which comprises one or more executable instructions for implementing the specified logical function(s). In some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
Having described embodiments of the present disclosure, the foregoing description is intended to be exemplary, not exhaustive, and not limited to the disclosed embodiments. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The terms used herein were chosen in order to best explain the principles of the embodiments, the practical application, or technical improvements to the techniques in the marketplace, or to enable others of ordinary skill in the art to understand the embodiments disclosed herein.

Claims (12)

1. A document character string coding and identifying method based on regular expressions is characterized by comprising the following steps:
determining an optimal factor set according to the regular expression;
determining the document record with the optimal factor in the optimal factor set by adopting a CW algorithm, and adding the determined document record into a candidate set;
and verifying the character string of the optimal factor in the candidate set according to the DFA automaton determined by the regular expression to obtain the successfully matched character string.
2. The method of claim 1, further comprising:
determining the regular expression according to an encoding rule, the encoding rule including normalized encoded data.
3. The method of claim 1, wherein determining the optimal set of factors according to a regular expression comprises:
determining one or more query segments according to the regular expression;
for each query segment, determining all possible character strings of the query segment, wherein the all possible character strings form a character string set;
taking the longest character string in the character strings matched with the regular expression as a necessary factor;
and selecting the character strings with the length larger than the necessary factor in the character string set to form an optimal factor set.
4. The method of claim 1, wherein determining document records in which the best factors in the set of best factors occur using a CW algorithm and adding the determined document records to a candidate set comprises:
determining the length of a sliding window required to be used for inquiring the text sequence according to a CW algorithm;
traversing in a preset direction on a text sequence by using sliding windows, sequentially comparing each character in each sliding window in a direction opposite to the preset direction, reporting a successful match if a longest suffix of a certain query is inquired, adding a record into a candidate set, and continuing sliding the windows backwards until the traversal is finished.
5. The method of claim 1, wherein the DFA automaton determined from the regular expression verifies that strings of best factors in the candidate set will result in successfully matched strings, including
Constructing a corresponding DFA automaton according to the regular expression;
and matching the candidate set by adopting a DFA (deterministic finite automaton) to obtain a successfully matched character string.
6. A regular expression-based document string coding and recognition device, the device comprising:
the first determining module is used for determining an optimal factor set according to the regular expression;
a second determining module, configured to determine, by using a CW algorithm, a document record in which an optimal factor in the optimal factor set occurs, and add the determined document record to the candidate set;
and the third determining module is used for verifying the character string of the optimal factor in the candidate set according to the DFA automaton determined by the regular expression to obtain the successfully matched character string.
7. The apparatus of claim 6, further comprising:
a fourth determination module to determine the regular expression according to an encoding rule, the encoding rule including normalized encoded data.
8. The apparatus of claim 6, wherein the first determining module comprises:
the first determining submodule is used for determining one or more query segments according to the regular expression;
the second determining sub-module is used for determining all possible character strings of each query segment, and the all possible character strings form a character string set;
a third determining submodule, configured to use the longest character string in the character strings matched with the regular expression as a necessary factor;
and the fourth determining submodule is used for selecting the character strings with the length larger than the necessary factor in the character string set to form an optimal factor set.
9. The apparatus of claim 6, wherein the second determining module comprises:
a fifth determining submodule, configured to determine, according to a CW algorithm, a length of a sliding window that is required to be used for querying the text sequence;
and the sixth determining submodule is used for traversing in a preset direction by using sliding windows on the text sequence, sequentially comparing each character in each sliding window in a direction opposite to the preset direction, reporting a successful matching if a longest suffix of a certain query is queried, adding the record into the candidate set, and continuing to slide the window backwards until the traversal is finished.
10. The apparatus of claim 6, wherein the third determining module comprises
The seventh determining submodule is used for constructing a corresponding DFA automaton according to the regular expression;
and the eighth determining submodule is used for matching the candidate set by adopting a DFA (deterministic finite automaton) to obtain a successfully matched character string.
11. A regular expression-based document string coding and recognition device, the device comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to perform the method of any one of claims 1 to 5.
12. A non-transitory computer readable storage medium having computer program instructions stored thereon, wherein the computer program instructions, when executed by a processor, implement the method of any of claims 1 to 5.
CN202111387759.6A 2021-11-22 2021-11-22 Regular expression-based document character string coding identification method and device Pending CN114168808A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111387759.6A CN114168808A (en) 2021-11-22 2021-11-22 Regular expression-based document character string coding identification method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111387759.6A CN114168808A (en) 2021-11-22 2021-11-22 Regular expression-based document character string coding identification method and device

Publications (1)

Publication Number Publication Date
CN114168808A true CN114168808A (en) 2022-03-11

Family

ID=80480000

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111387759.6A Pending CN114168808A (en) 2021-11-22 2021-11-22 Regular expression-based document character string coding identification method and device

Country Status (1)

Country Link
CN (1) CN114168808A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115292558A (en) * 2022-08-12 2022-11-04 苏州浪潮智能科技有限公司 Regular expression-based pattern matching method, system, storage medium and equipment
CN117493622A (en) * 2023-12-28 2024-02-02 苏州元脑智能科技有限公司 Method and device for inquiring character strings based on field programmable array device

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110258210A1 (en) * 2010-04-20 2011-10-20 International Business Machines Corporation Dual dfa decomposition for large scale regular expression matching
US20150324457A1 (en) * 2014-05-09 2015-11-12 Dell Products, Lp Ordering a Set of Regular Expressions for Matching Against a String
CN106959977A (en) * 2016-01-12 2017-07-18 广州市动景计算机科技有限公司 Candidate collection computational methods and device, word error correction method and device in word input
CN108563795A (en) * 2018-05-04 2018-09-21 西安交通大学 A kind of Pairs methods accelerating compression flow regular expression matching
CN112214653A (en) * 2020-10-29 2021-01-12 Oppo广东移动通信有限公司 Character string recognition method and device, storage medium and electronic equipment
CN112784127A (en) * 2021-03-12 2021-05-11 清华大学 Multi-string pattern matching method and device, computer equipment and storage medium
CN113239245A (en) * 2021-05-19 2021-08-10 北京明略昭辉科技有限公司 Method and device for information query, electronic equipment and readable storage medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110258210A1 (en) * 2010-04-20 2011-10-20 International Business Machines Corporation Dual dfa decomposition for large scale regular expression matching
US20150324457A1 (en) * 2014-05-09 2015-11-12 Dell Products, Lp Ordering a Set of Regular Expressions for Matching Against a String
CN106959977A (en) * 2016-01-12 2017-07-18 广州市动景计算机科技有限公司 Candidate collection computational methods and device, word error correction method and device in word input
CN108563795A (en) * 2018-05-04 2018-09-21 西安交通大学 A kind of Pairs methods accelerating compression flow regular expression matching
CN112214653A (en) * 2020-10-29 2021-01-12 Oppo广东移动通信有限公司 Character string recognition method and device, storage medium and electronic equipment
CN112784127A (en) * 2021-03-12 2021-05-11 清华大学 Multi-string pattern matching method and device, computer equipment and storage medium
CN113239245A (en) * 2021-05-19 2021-08-10 北京明略昭辉科技有限公司 Method and device for information query, electronic equipment and readable storage medium

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115292558A (en) * 2022-08-12 2022-11-04 苏州浪潮智能科技有限公司 Regular expression-based pattern matching method, system, storage medium and equipment
CN115292558B (en) * 2022-08-12 2024-01-26 苏州浪潮智能科技有限公司 Regular expression-based pattern matching method, system, storage medium and equipment
CN117493622A (en) * 2023-12-28 2024-02-02 苏州元脑智能科技有限公司 Method and device for inquiring character strings based on field programmable array device
CN117493622B (en) * 2023-12-28 2024-03-29 苏州元脑智能科技有限公司 Method and device for inquiring character strings based on field programmable array device

Similar Documents

Publication Publication Date Title
CN109089133B (en) Video processing method and device, electronic equipment and storage medium
US20210232847A1 (en) Method and apparatus for recognizing text sequence, and storage medium
CN110472091B (en) Image processing method and device, electronic equipment and storage medium
CN110781957B (en) Image processing method and device, electronic equipment and storage medium
WO2021036382A1 (en) Image processing method and apparatus, electronic device and storage medium
US20200012701A1 (en) Method and apparatus for recommending associated user based on interactions with multimedia processes
CN111581488A (en) Data processing method and device, electronic equipment and storage medium
CN111259967B (en) Image classification and neural network training method, device, equipment and storage medium
CN114168808A (en) Regular expression-based document character string coding identification method and device
WO2022247128A1 (en) Image processing method and apparatus, electronic device, and storage medium
JP2022533065A (en) Character recognition methods and devices, electronic devices and storage media
CN114090575A (en) Data storage method and retrieval method based on key value database and corresponding devices
CN114168798A (en) Text storage management and retrieval method and device
CN110232181B (en) Comment analysis method and device
CN112269904B (en) Data processing method and device
CN113987128A (en) Related article searching method and device, electronic equipment and storage medium
CN110955800A (en) Video retrieval method and device
CN111625671A (en) Data processing method and device, electronic equipment and storage medium
CN114168809A (en) Similarity-based document character string code matching method and device
CN112131999B (en) Identity determination method and device, electronic equipment and storage medium
CN106959970B (en) Word bank, processing method and device of word bank and device for processing word bank
CN113988011A (en) Document content identification method and device
CN114298227A (en) Text duplicate removal method, device, equipment and medium
WO2021082461A1 (en) Storage and reading method and apparatus, electronic device, and storage medium
CN110019928B (en) Video title optimization method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination