Method and device for extracting alarm text address based on regular expression
By automatically extracting the address in the alert text using a method based on regular expressions, the problems of high manual extraction cost and low efficiency in the existing technology are solved, and an efficient address extraction process is realized.
Patent Information
- Application Number
- CN202010307079.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2020-02-13
- Filing Date
- 2020-04-17
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2040-04-17
AI Technical Summary
In the existing technology, the process of extracting addresses from police text received by public security agencies has problems such as high labor cost, reliance on experience and high difficulty, resulting in low efficiency.
A method based on regular expressions is used to extract regular expressions by obtaining and training addresses, and automatically matches the alert text to extract addresses, reducing manual intervention.
It realizes the automatic extraction of the text address for receiving the alarm, reduces the cost, and improves the extraction speed and efficiency.
Smart Images

Figure CN113111232B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present disclosure relate to the field of computer technology, and in particular to a method and device for extracting an address from a police call text based on regular expressions. Background Art
[0002] At present, the 110 police dispatchers of the public security organs will enter the police call text when receiving the call. The police handling officers will enter the police handling text after handling the call. The police call text includes the above-mentioned call text and the police handling text. In practice, the police call text often involves descriptions of various addresses. For example, the police call text may involve the following address information: the trajectory of the persons involved in the case, the place of residence of the registered permanent residence, and the place where the case occurred. Based on the various address information in the police call text, the case analyst can analyze the same or similar addresses that appear in different police call texts in order to discover a series of cases or related cases, or can also count the occurrence of the same or the same type of addresses (for example, the number of cases of different types or the incidence rate, etc.), so it is very important to extract the addresses in the police call text.
[0003] However, currently most of the addresses in the police call texts are extracted manually, which has high labor costs and depends on personal experience. Summary of the invention
[0004] The disclosed embodiments provide a method and device for extracting an address from a police call text based on regular expressions.
[0005] In a first aspect, an embodiment of the present disclosure provides a method for extracting addresses from alarm call text based on regular expressions, the method comprising: obtaining an alarm call text with an address to be extracted; matching the alarm call text with an address to be extracted with an address extraction regular expression to extract the address from the alarm call text with an address to be extracted.
[0006] In some embodiments, the address extraction regular expression is pre-trained through the following first training step: obtaining a training sample set and a test sample set, wherein both the training sample and the test sample include historical alarm receiving and handling texts and corresponding annotated address information sequences, wherein the annotated address information includes a starting position and an ending position, and the annotated address information is used to characterize that the address is between the starting position and the ending position in the historical alarm receiving and handling text; using each training sample in the training sample set whose annotated address information sequence is not empty to generate a positive sample set; selecting positive samples from the positive sample set to form a target number of positive sample subsets; for each positive sample subset in the target number of positive sample subsets, based on each positive sample in the positive sample subset, generating a candidate regular expression corresponding to the positive sample subset; testing each generated candidate regular expression based on the test sample set to determine the accuracy corresponding to each generated candidate regular expression; determining the candidate regular expression with the highest accuracy among the generated candidate regular expressions as the address extraction regular expression.
[0007] In some embodiments, positive samples are selected from a positive sample set to form a target number of positive sample subsets, including: executing a target number of positive sample subset generation operations to generate a target number of positive sample subsets, the positive sample subset generation operation including: randomly selecting N positive samples from the positive sample set to form a positive sample subset, wherein N is an integer obtained by rounding down the quotient of L divided by M, L is the number of positive samples in the positive sample set, and M is a positive integer greater than or equal to 2 and less than L.
[0008] In some embodiments, the address extraction regular expression is pre-trained through the following second training step: obtaining a training sample set, wherein the training sample includes a historical police call text and a marked address information sequence, wherein the marked address information includes a starting position and an ending position, and the marked address information is used to characterize that the address is between the starting position and the ending position in the historical police call text; generating a positive sample set using each training sample in the training sample set whose marked address information sequence is not empty; and generating an address extraction regular expression based on the positive sample set.
[0009] In the second aspect, an embodiment of the present disclosure provides an apparatus for extracting an address from an alarm call text based on a regular expression, the apparatus comprising: an acquisition unit, configured to acquire an address alarm call text to be extracted; and an extraction unit, configured to match the address alarm call text to be extracted with an address extraction regular expression to extract the address from the address alarm call text to be extracted.
[0010] In some embodiments, the address extraction regular expression is pre-trained through the following first training step: obtaining a training sample set and a test sample set, wherein both the training sample and the test sample include historical alarm receiving and handling texts and corresponding annotated address information sequences, wherein the annotated address information includes a starting position and an ending position, and the annotated address information is used to characterize that the address is between the starting position and the ending position in the historical alarm receiving and handling text; using each training sample in the training sample set whose annotated address information sequence is not empty to generate a positive sample set; selecting positive samples from the positive sample set to form a target number of positive sample subsets; for each positive sample subset in the target number of positive sample subsets, based on each positive sample in the positive sample subset, generating a candidate regular expression corresponding to the positive sample subset; testing each generated candidate regular expression based on the test sample set to determine the accuracy corresponding to each generated candidate regular expression; determining the candidate regular expression with the highest accuracy among the generated candidate regular expressions as the address extraction regular expression.
[0011] In some embodiments, positive samples are selected from a positive sample set to form a target number of positive sample subsets, including: executing a target number of positive sample subset generation operations to generate a target number of positive sample subsets, the positive sample subset generation operation including: randomly selecting N positive samples from the positive sample set to form a positive sample subset, wherein N is an integer obtained by rounding down the quotient of L divided by M, L is the number of positive samples in the positive sample set, and M is a positive integer greater than or equal to 2 and less than L.
[0012] In some embodiments, the address extraction regular expression is pre-trained through the following second training step: obtaining a training sample set, wherein the training sample includes a historical police call text and a marked address information sequence, wherein the marked address information includes a starting position and an ending position, and the marked address information is used to characterize that the address is between the starting position and the ending position in the historical police call text; generating a positive sample set using each training sample in the training sample set whose marked address information sequence is not empty; and generating an address extraction regular expression based on the positive sample set.
[0013] In a third aspect, an embodiment of the present disclosure provides an electronic device, comprising: one or more processors; a storage device on which one or more programs are stored, and when the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any implementation manner in the first aspect.
[0014] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by one or more processors, implements the method described in any implementation manner in the first aspect.
[0015] In the prior art, addresses are generally extracted by manually connecting to police call texts, which may have the following problems: (1) There are a large number of police call texts from history that have not been extracted, and as time goes by, police officers enter a large number of new police call texts every day, resulting in a large amount of data to be extracted from the police call texts, and the manpower and time costs required for manual extraction are too high; (2) Most police call texts are described in natural language, and the expression is highly colloquial and irregular, making it difficult to extract addresses manually; (3) There are many types of addresses, and the methods for extracting different types of addresses are different, which depends on manual experience, that is, the learning cost in the manual extraction process is high.
[0016] The embodiments of the present invention provide a method and device for extracting addresses from alarm call texts based on regular expressions. By matching the alarm call texts with addresses to be extracted with address extraction regular expressions, the addresses in the alarm call texts with addresses to be extracted are extracted, thereby effectively utilizing the address extraction regular expressions and realizing automatic address extraction from alarm call texts without manual operation, thereby reducing the cost of extracting addresses from alarm call texts and improving the speed of extracting addresses from alarm call texts. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Other features, objects and advantages of the present disclosure will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:
[0018] Figure 1 is an exemplary system architecture diagram in which an embodiment of the present disclosure may be applied;
[0019] Figure 2 It is a flowchart of an embodiment of a method for extracting an address from a police call text based on regular expressions according to the present disclosure;
[0020] Figure 3 is a flowchart of an embodiment of a first training step according to the present disclosure;
[0021] Figure 4 is a flowchart of an embodiment of the second training step according to the present disclosure;
[0022] Figure 5 It is a structural schematic diagram of an embodiment of a device for extracting an address of a police call text based on a regular expression according to the present disclosure;
[0023] Figure 6 It is a schematic diagram of the structure of a computer system suitable for implementing the electronic device of the embodiment of the present disclosure. DETAILED DESCRIPTION
[0024] The present disclosure is further described in detail below in conjunction with the accompanying drawings and embodiments. It is understood that the specific embodiments described herein are only used to explain the relevant invention, rather than to limit the invention. It is also necessary to explain that, for ease of description, only the parts related to the relevant invention are shown in the accompanying drawings.
[0025] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present disclosure may be combined with each other. The present disclosure will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0026] Figure 1 An exemplary system architecture 100 is shown to which an embodiment of the method for extracting an address from an alarm text based on a regular expression or an apparatus for extracting an address from an alarm text based on a regular expression of the present disclosure can be applied.
[0027] like Figure 1 As shown, system architecture 100 may include terminal device 101, network 102 and server 103. Network 102 is used to provide a medium for a communication link between terminal device 101 and server 103. Network 102 may include various connection types, such as wired, wireless communication links or optical fiber cables.
[0028] The user can use the terminal device 101 to interact with the server 103 through the network 102 to receive or send messages, etc. Various communication client applications can be installed on the terminal device 101, such as alarm record applications, alarm text address extraction applications, web browser applications, etc.
[0029] The terminal device 101 can be hardware or software. When the terminal device 101 is hardware, it can be various electronic devices with a display screen and supporting text input, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, etc. When the terminal device 101 is software, it can be installed in the electronic devices listed above. It can be implemented as multiple software or software modules (for example, used to provide alarm text address extraction services), or it can be implemented as a single software or software module. No specific limitation is made here.
[0030] The server 103 may be a server providing various services, such as a background server providing address extraction for the alarm text sent by the terminal device 101. The background server may analyze the received alarm text and feed back the processing result (eg, address) to the terminal device.
[0031] In some cases, the method for extracting the address of the alarm text based on regular expressions provided in the embodiments of the present disclosure can be performed jointly by the terminal device 101 and the server 103. For example, the step of "obtaining the alarm text with the address to be extracted" can be performed by the terminal device 101, and the remaining steps can be performed by the server 103. The present disclosure does not limit this. Accordingly, the apparatus for extracting the address of the alarm text based on regular expressions can also be respectively set in the terminal device 101 and the server 103.
[0032] In some cases, the regular expression-based alarm text address extraction method provided in the embodiment of the present disclosure can be executed by the server 103. Correspondingly, the regular expression-based alarm text address extraction device can also be set in the server 103. In this case, the system architecture 100 may not include the terminal device 101.
[0033] In some cases, the regular expression-based alarm text address extraction method provided in the embodiment of the present disclosure can be executed by the terminal device 101. Correspondingly, the regular expression-based alarm text address extraction device can also be set in the terminal device 101. In this case, the system architecture 100 may not include the server 103.
[0034] It should be noted that the server 103 can be hardware or software. When the server 103 is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or it can be implemented as a single server. When the server 103 is software, it can be implemented as multiple software or software modules (for example, for providing a text address extraction service for receiving and handling alarms), or it can be implemented as a single software or software module. No specific limitation is made here.
[0035] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0036] Continue to refer Figure 2 , which shows a process 200 of an embodiment of a method for extracting an address of a police call text based on a regular expression according to the present disclosure. The method for extracting an address of a police call text based on a regular expression comprises the following steps:
[0037] Step 201, obtaining the alarm text of the address to be extracted.
[0038] In this embodiment, the execution body of the method for extracting the address of the alarm text based on regular expressions (for example, Figure 1 The server shown in the figure can obtain the locally stored address receiving and handling alarm text to be extracted, or the above-mentioned execution subject can also remotely obtain the address receiving and handling alarm text from other electronic devices (for example, Figure 1 The terminal device shown in the figure) obtains the alarm text of the address to be extracted.
[0039] Here, the address receiving and handling text to be extracted can be text data compiled by the police receiver according to the content of the alarm call or text data compiled by the police handler according to the alarm handling process. The address receiving and handling text to be extracted can also be an alarm text received from the terminal device and input by the user in an alarm application installed on the terminal device or a web page with an alarm function.
[0040] Step 202: Match the address receiving and handling text to be extracted with the address extraction regular expression to extract the address in the address receiving and handling text to be extracted.
[0041] In this embodiment, a regular expression is a logical formula for string operations, that is, a "regular string" is formed by using some pre-defined specific characters and the combination of these specific characters. This "regular string" is used to express a filtering logic for the string. Given a regular expression and another string, it can be determined whether the given string matches the filtering logic of the regular expression, and by giving a regular expression, a specific part that is desired to be extracted can be obtained from the string. Therefore, the above execution subject (for example, Figure 1 The server shown in the figure can match the address reception and processing text to be extracted with the address extraction regular expression to extract the address in the address reception and processing text to be extracted. How to determine whether a regular expression matches another string and how to extract the desired part through a regular expression are existing technologies widely studied and applied in this field, and will not be described in detail here.
[0042] In some optional implementations, the preset address extraction regular expression may be a logical formula for extracting addresses, which is formulated by a technician based on statistical analysis of the address portion in a large amount of historical police call handling texts including address information and operates on character strings.
[0043] In some optional implementations, the address extraction regular expression can also be obtained by Figure 3 The first training step shown is pre-trained. Please refer to Figure 3 , Figure 3 A process 300 of an embodiment of a first training step according to the present disclosure is shown. The process 300 of the first training step may include the following steps:
[0044] Step 301: Obtain a training sample set and a test sample set.
[0045] Here, the execution subject of the first training step can be the same as the execution subject of the above-mentioned method for extracting addresses from police call texts based on regular expressions. In this way, after the execution subject of the first training step obtains the address extraction regular expression through training, the address extraction regular expression can be stored locally in the above-mentioned execution subject, and the address extraction regular expression obtained through training can be read during the execution of the above-mentioned method for extracting addresses from police call texts based on regular expressions.
[0046] Here, the execution subject of the first training step may also be different from the execution subject of the above-mentioned method for extracting the address of the alarm text based on regular expressions. In this way, after the execution subject of the first training step obtains the address extraction regular expression through training, the execution subject of the above-mentioned method for extracting the address of the alarm text based on regular expressions may send the address extraction regular expression to the execution subject of the above-mentioned method for extracting the address of the alarm text based on regular expressions. In this way, the execution subject of the above-mentioned method for extracting the address of the alarm text based on regular expressions may read the above-mentioned address extraction regular expression received from the execution subject of the first training step during the execution of the above-mentioned method for extracting the address of the alarm text based on regular expressions.
[0047] Here, the execution subject of the first training step may first obtain a training sample set and a test sample set. Among them, the training samples and the test samples may both include historical police texts and corresponding annotated address information sequences, wherein the annotated address information may include a starting position and an ending position, and the annotated address information may be used to characterize that the address is between the starting position and the ending position in the annotated address information in the historical police text corresponding to the annotated address information. For ease of understanding, the following example is given. For example, the training sample may include a historical police text "Zhang San beat Li Si in Community C, City B, Province A, and then Li Si went to Hospital D, City B, Province A for medical treatment", and the above historical police text may correspond to an annotated address information sequence {"starting position: 4, ending position: 10", "starting position: 21, ending position: 27"}, and it can be seen from the above annotated address information sequence that "Community C, City B, Province A" and "Hospital D, City B, Province A" are both addresses.
[0048] Here, the annotated address information sequences in the training samples and the test samples may be obtained by manually annotating the corresponding historical police call handling texts.
[0049] In practice, in order to improve the matching degree of the trained address extraction regular expression to the address, the historical police call texts in each training sample obtained here may not include invalid police call texts. For example, some police call texts do not include any addresses and have no actual value for extracting addresses. Such police call texts can be considered invalid police call texts.
[0050] In some optional implementations, the ratio of the number of positive samples to the number of negative samples in the training sample set may be within a first preset ratio range, that is, there cannot be too many positive samples and too few negative samples, or there cannot be too many negative samples and too few positive samples. As an example, the first preset ratio range may be between greater than or equal to 0.6 and less than or equal to 1.6. The positive samples are the training samples whose corresponding labeled address information sequences in the training sample set are not empty, and correspondingly, the negative samples are the training samples whose corresponding labeled address information sequences in the training sample set are empty.
[0051] In some optional implementations, the ratio of the number of positive samples to the number of negative samples in the test sample set may be within a second preset ratio range, that is, there cannot be too many positive samples and too few negative samples, or there cannot be too many negative samples and too few positive samples. As an example, the second preset ratio range may be between greater than or equal to 0.6 and less than or equal to 1.6. The positive samples are the training samples whose corresponding labeled address information sequences in the test sample set are not empty, and correspondingly, the negative samples are the training samples whose corresponding labeled address information sequences in the test sample set are empty.
[0052] In some optional implementations, the ratio of the number of positive samples in the training sample set to the number of positive samples in the test sample set may be within a third preset ratio range. Here, generally speaking, the number of positive samples in the training sample set is greater than the number of positive samples in the test sample set, because a large number of positive samples are used for training and a small number of positive samples are used for testing, which is consistent with reducing the total number of samples required to a greater extent, thereby reducing the labor cost of annotating training samples and test samples.
[0053] Step 302: Generate a positive sample set using each training sample in the training sample set whose marked address information sequence is not empty.
[0054] If the labeled address information sequence of the training sample in the training sample set is not empty, it indicates that the historical alarm text of the training sample includes at least one address, and the training sample is a positive sample. Therefore, the positive sample set can be generated by using each training sample in the training sample set whose labeled address information sequence is not empty.
[0055] Step 303: Select positive samples from the positive sample set to form a target number of positive sample subsets.
[0056] After obtaining the positive sample set in step 302, the execution subject of the first training step can select positive samples from the positive sample set to form a target number of positive sample subsets. The target number here can be pre-set, or the target number can be determined by receiving user input via the interface provided in the above execution subject.
[0057] In some optional implementations, step 303 may be performed as follows: perform a target number of positive sample subset generation operations to generate a target number of positive sample subsets. The positive sample subset generation operation includes: randomly selecting N positive samples from the positive sample set to form a positive sample subset. N is an integer obtained by rounding down the quotient of L divided by M, L is the number of positive samples in the positive sample set, and M is a positive integer greater than or equal to 2 and less than L. For example, for example, the positive sample set includes 569 positive samples, the target number is 5, M is 2, L is 569, and N is a positive integer 285 rounded down from the quotient of 569 divided by 2. Here, the following operation is performed 5 times: randomly select 285 positive samples from the positive sample set including 569 positive samples to form a positive sample subset. Finally, 5 positive sample subsets can be obtained, and each positive sample subset includes 285 positive samples.
[0058] In some optional implementations, step 303 may also be performed as follows:
[0059] The positive sample set is divided into a target number of positive sample subsets, where the number of positive samples in each positive sample subset is as close as possible. Specifically, suppose the positive sample set includes L positive samples, the target number is T, Q is a positive integer obtained by rounding down the quotient of L divided by T, and R is the remainder of L divided by T. Then when R is zero, the positive sample set can be evenly divided into T positive sample subsets, and the number of positive samples in each positive sample subset is Q. When R is greater than zero, the positive sample set can be evenly divided into T positive sample subsets, where T-1 positive sample subsets include Q positive samples, and the other positive sample subset includes Q+R positive samples.
[0060] Step 304 : for each positive sample subset in the target number of positive sample subsets, based on each positive sample in the positive sample subset, generate a candidate regular expression corresponding to the positive sample subset.
[0061] After step 303, positive samples have been selected from the positive sample set to form a target number of positive sample subsets. Here, the execution subject of the first training step can generate candidate regular expressions in various implementation methods for each positive sample subset in the target number of positive sample subsets generated above, based on each positive sample in the positive sample subset. Specifically, for each positive sample in the positive sample subset, the corresponding address in the historical alarm receiving and handling text of the positive sample can be obtained according to the starting position and the ending position in each marked address information in the marked address information sequence of the positive sample. Then, based on the addresses obtained for each positive sample in the positive sample subset, a candidate regular expression corresponding to the positive sample subset is generated. It should be noted that various implementation methods can be used to generate a regular expression based on at least one text. For example, the target repeated content can be used as the content in the regular expression, and the target variable content can be represented by a wildcard in the regular expression, wherein the repetition ratio of the target repeated content in at least one text is greater than or equal to the preset ratio, and the repetition ratio of the target variable content in at least one text is less than the above preset ratio. As an example, a candidate regular expression may be: *province*city*district, where * is a wildcard for any character.
[0062] After step 304 , a maximum target number of candidate regular expressions may be generated.
[0063] Step 305 : Testing each generated candidate regular expression based on the test sample set to determine the accuracy rate corresponding to each generated candidate regular expression.
[0064] Specifically, the execution subject of the first training step can perform the following accuracy determination operation for each candidate regular expression generated in step 304: First, for each test sample in the test sample set obtained in step 301, determine whether the historical alarm text in the test sample matches the candidate regular expression; if it is determined to be matched, it indicates that the historical alarm text in the test sample includes an address, and it can be determined that the test sample is a positive sample relative to the candidate regular expression; if it is determined not to be matched, it indicates that the historical alarm text in the test sample does not include an address, and it can be determined that the test sample is a negative sample relative to the candidate regular expression. Finally, the ratio of the number of test samples in the test sample set that are positive samples relative to the candidate regular expression divided by the total number of test samples in the test sample set is determined as the accuracy corresponding to the candidate regular expression.
[0065] Step 306: Determine the candidate regular expression with the highest accuracy among the generated candidate regular expressions as the address extraction regular expression.
[0066] In some optional implementations, the address extraction regular expression can also be obtained by Figure 4 The second training step shown is pre-trained. Please refer to Figure 4 , Figure 4 A process 400 of an embodiment of a second training step according to the present disclosure is shown. The process 400 of the second training step may include the following steps:
[0067] Step 401: Obtain a training sample set.
[0068] Here, the execution subject of the second training step can be specifically referred to Figure 3 The relevant description of step 301 in the embodiment shown is not repeated here. In addition, for a detailed description of how to obtain a training sample set and training samples, please refer to Figure 3 The relevant description in step 301 in the illustrated embodiment will not be repeated here.
[0069] Step 402: Generate a positive sample set using each training sample in the training sample set whose marked address information sequence is not empty.
[0070] Here, the specific operation of step 402 and the technical effect brought about by it are similar to Figure 3 The corresponding description in step 302 in the illustrated embodiment is substantially the same and will not be repeated here.
[0071] Step 403: Generate an address extraction regular expression based on the positive sample set.
[0072] Specifically, the execution subject of the second training step can first obtain the corresponding address in the historical alarm text of the positive sample according to the starting position and the ending position of each annotated address information in the annotated address information sequence of the positive sample for each positive sample in the positive sample set. Then, based on the addresses obtained for each positive sample in the positive sample set, a regular expression corresponding to the positive sample set is generated, and the generated regular expression is determined as an address extraction regular expression. It should be noted that various implementation methods can be used to generate a regular expression based on at least one text.
[0073] The address extraction regular expression obtained by training in the second training step shown in the above process 400 uses the training sample set to train the regular expression, and can automatically generate the address extraction regular expression, thereby reducing the labor cost of generating the address extraction regular expression. The address extraction regular expression obtained by training in the first training step shown in the above process 300 first uses the training sample set to train the target number of candidate regular expressions, and then uses the test sample set to test the generated candidate regular expressions, and selects the candidate regular expression with the highest accuracy as the address extraction regular expression. In addition to automatically generating the address extraction regular expression, the expression matching degree of the address extraction regular expression to the address can be improved because it has been tested by the test sample set.
[0074] The method provided by the above-mentioned embodiment of the present disclosure realizes automatic address extraction from the police text by utilizing the address extraction regular expression without manual operation, thereby reducing the cost of address extraction from the police text and improving the extraction speed of address extraction from the police text.
[0075] Further references Figure 5 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a device for extracting an address of a police call text based on a regular expression. Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0076] like Figure 5 As shown, the regular expression-based alarm text address extraction device 500 of this embodiment includes: an acquisition unit 501 and an extraction unit 502. The acquisition unit 501 is configured to acquire the address alarm text to be extracted; the extraction unit 502 is configured to match the address alarm text to be extracted with the address extraction regular expression to extract the address in the address alarm text to be extracted.
[0077] In this embodiment, the specific processing of the acquisition unit 501 and the extraction unit 502 of the regular expression-based alarm text address extraction device 500 and the technical effects thereof can be referred to in Figure 2 The relevant descriptions of step 201 and step 202 in the corresponding embodiment are not repeated here.
[0078] In some optional implementations of the present embodiment, the address extraction regular expression is pre-trained through the following first training step: obtaining a training sample set and a test sample set, wherein both the training sample and the test sample include historical police call texts and corresponding annotated address information sequences, wherein the annotated address information includes a starting position and an ending position, and the annotated address information is used to characterize that the address is between the starting position and the ending position in the historical police call text; generating a positive sample set using each training sample in the training sample set whose annotated address information sequence is not empty; selecting positive samples from the positive sample set to form a target number of positive sample subsets; for each positive sample subset in the target number of positive sample subsets, generating a candidate regular expression corresponding to the positive sample subset based on each positive sample in the positive sample subset; testing each generated candidate regular expression based on the test sample set to determine the accuracy corresponding to each generated candidate regular expression; determining the candidate regular expression with the highest accuracy among the generated candidate regular expressions as the address extraction regular expression.
[0079] In some optional implementations of the present embodiment, the above-mentioned selecting positive samples from the above-mentioned positive sample set to form a target number of positive sample subsets includes: executing the above-mentioned target number of positive sample subset generation operations to generate the above-mentioned target number of positive sample subsets, and the above-mentioned positive sample subset generation operation includes: randomly selecting N positive samples from the above-mentioned positive sample set to form a positive sample subset, wherein the above-mentioned N is an integer obtained by rounding down the quotient of L divided by M, the above-mentioned L is the number of positive samples in the above-mentioned positive sample set, and the above-mentioned M is a positive integer greater than or equal to 2 and less than the above-mentioned L.
[0080] In some optional implementations of the present embodiment, the above-mentioned address extraction regular expression is pre-trained through the following second training step: obtaining a training sample set, wherein the training sample includes a historical police call text and a marked address information sequence, wherein the marked address information includes a starting position and an ending position, and the marked address information is used to characterize that the address is between the starting position and the ending position in the historical police call text; generating a positive sample set using each training sample in the above-mentioned training sample set whose marked address information sequence is not empty; and generating the above-mentioned address extraction regular expression based on the above-mentioned positive sample set.
[0081] It should be noted that the implementation details and technical effects of each unit in the regular expression-based alarm text address extraction device provided in the embodiment of the present disclosure can be referred to the description of other embodiments in the present disclosure, and will not be repeated here.
[0082] Reference below Figure 6 , which shows a schematic diagram of the structure of a computer system 600 suitable for implementing an electronic device of an embodiment of the present disclosure. Figure 6The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0083] like Figure 6 As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 602 or the program loaded from the storage part 608 to the random access memory (RAM) 603. Various programs and data required for the operation of the system 600 are also stored in the RAM 603. The CPU 601, the ROM 602 and the RAM 603 are connected to each other through a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0084] The following components are connected to the I / O interface 605: an input section 606 including a touch screen, a handwriting tablet, a keyboard, or a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet.
[0085] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609. When the computer program is executed by the central processing unit (CPU) 601, the above functions defined in the method of the present disclosure are executed. It should be noted that the computer-readable medium described in the present disclosure can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, - but not limited to - an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to, an electrical connection with one or more conductors, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device, or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in combination with an instruction execution system, device, or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0086] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving 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 may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0087] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0088] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware. The units described may also be set in a processor, for example, it may be described as: a processor includes an acquisition unit and an extraction unit. The names of these units do not constitute a limitation on the units themselves in some cases, for example, the acquisition unit may also be described as a "unit for acquiring the alarm text of the address to be extracted".
[0089] As another aspect, the present disclosure further provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by the device, the device: obtains the address receiving and handling text to be extracted; matches the above address receiving and handling text to be extracted with the address extraction regular expression to extract the address in the above address receiving and handling text to be extracted.
[0090] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of the invention involved in the present disclosure is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above invention concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other.
Claims
1. A method for extracting the address of police call text based on regular expressions. include: Get the alarm text of the address to be extracted; Matching the address receiving and handling text to be extracted with an address extraction regular expression to extract the address in the address receiving and handling text to be extracted; The address extraction regular expression is pre-trained through the following first training step: Obtain a training sample set and a test sample set, wherein both the training sample and the test sample include a historical police receiving and handling text and a corresponding annotated address information sequence, wherein the annotated address information includes a start position and an end position, and the annotated address information is used to indicate that the address is between the start position and the end position in the historical police receiving and handling text; Generate a positive sample set using each training sample in the training sample set whose marked address information sequence is not empty; Selecting positive samples from the positive sample set to form a target number of positive sample subsets; For each positive sample subset in the target number of positive sample subsets, generating a candidate regular expression corresponding to the positive sample subset based on each positive sample in the positive sample subset; Testing each generated candidate regular expression based on the test sample set to determine the accuracy rate corresponding to each generated candidate regular expression; Determine the candidate regular expression with the highest accuracy among the generated candidate regular expressions as the address extraction regular expression; Wherein, the selecting positive samples from the positive sample set to form a target number of positive sample subsets includes: performing the target number of positive sample subset generation operations to generate the target number of positive sample subsets, and the positive sample subset generation operation includes: randomly selecting N positive samples from the positive sample set to form a positive sample subset, wherein N is an integer obtained by rounding down the quotient of L divided by M, L is the number of positive samples in the positive sample set, and M is a positive integer greater than or equal to 2 and less than L; The ratio of the number of positive samples to the number of negative samples in the training sample set is within a first preset ratio range, which is greater than or equal to 0.6 and less than or equal to 1.6; the ratio of the number of positive samples to the number of negative samples in the test sample set is within a second preset ratio range, which is greater than or equal to 0.6 and less than or equal to 1.6; the number of positive samples in the training sample set is greater than the number of positive samples in the test sample set; Wherein, the method of generating a candidate regular expression corresponding to the positive sample subset based on each positive sample in the positive sample subset includes: first, for each positive sample in the positive sample subset, obtaining the corresponding address in the historical alarm receiving and handling text of the positive sample according to the starting position and the ending position in each annotated address information in the annotated address information sequence of the positive sample; then, based on the addresses obtained for each positive sample in the positive sample subset, generating a candidate regular expression corresponding to the positive sample subset; wherein the target repeated content is used as the content in the regular expression, and the target variable content is represented by a wildcard in the regular expression, wherein the repetition ratio of the target repeated content in at least one text is greater than or equal to a preset ratio, and the repetition ratio of the target variable content in at least one text is less than the above preset ratio.
2. A device for extracting the address of a police call text based on regular expressions, include: An acquisition unit is configured to acquire the alarm receiving and handling text of the address to be extracted; An extraction unit is configured to match the address receiving and handling text to be extracted with an address extraction regular expression to extract the address in the address receiving and handling text to be extracted; The address extraction regular expression is pre-trained through the following first training step: Obtain a training sample set and a test sample set, wherein both the training sample and the test sample include a historical police receiving and handling text and a corresponding annotated address information sequence, wherein the annotated address information includes a start position and an end position, and the annotated address information is used to indicate that the address is between the start position and the end position in the historical police receiving and handling text; Generate a positive sample set using each training sample in the training sample set whose marked address information sequence is not empty; Selecting positive samples from the positive sample set to form a target number of positive sample subsets; For each positive sample subset in the target number of positive sample subsets, generating a candidate regular expression corresponding to the positive sample subset based on each positive sample in the positive sample subset; Testing each generated candidate regular expression based on the test sample set to determine the accuracy rate corresponding to each generated candidate regular expression; Determine the candidate regular expression with the highest accuracy among the generated candidate regular expressions as the address extraction regular expression; Wherein, the selecting positive samples from the positive sample set to form a target number of positive sample subsets includes: performing the target number of positive sample subset generation operations to generate the target number of positive sample subsets, and the positive sample subset generation operation includes: randomly selecting N positive samples from the positive sample set to form a positive sample subset, wherein N is an integer obtained by rounding down the quotient of L divided by M, L is the number of positive samples in the positive sample set, and M is a positive integer greater than or equal to 2 and less than L; The ratio of the number of positive samples to the number of negative samples in the training sample set is within a first preset ratio range, which is greater than or equal to 0.6 and less than or equal to 1.6; the ratio of the number of positive samples to the number of negative samples in the test sample set is within a second preset ratio range, which is greater than or equal to 0.6 and less than or equal to 1.6; the number of positive samples in the training sample set is greater than the number of positive samples in the test sample set; Wherein, the method of generating a candidate regular expression corresponding to the positive sample subset based on each positive sample in the positive sample subset includes: first, for each positive sample in the positive sample subset, obtaining the corresponding address in the historical alarm receiving and handling text of the positive sample according to the starting position and the ending position in each annotated address information in the annotated address information sequence of the positive sample; then, based on the addresses obtained for each positive sample in the positive sample subset, generating a candidate regular expression corresponding to the positive sample subset; wherein the target repeated content is used as the content in the regular expression, and the target variable content is represented by a wildcard in the regular expression, wherein the repetition ratio of the target repeated content in at least one text is greater than or equal to a preset ratio, and the repetition ratio of the target variable content in at least one text is less than the above preset ratio.
3. An electronic device, include: one or more processors; A storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors are caused to implement the method according to claim 1 .
4. A computer readable medium having a computer program stored thereon, in, When the program is executed by a processor, the method according to claim 1 is implemented.
