Text detection method, device, electronic device and storage medium
By performing entity extraction and character conversion on character strings in the network platform, the problem of low detection accuracy caused by character transformation is solved, accurate detection and timely interception of diversion information are achieved, and the security of the network platform is improved.
Patent Information
- Application Number
- CN202411819687.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-11
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2044-12-11
AI Technical Summary
Existing technologies have difficulty accurately detecting whether strings posted by users on online platforms contain additional information used to divert traffic, especially since there are many ways to transform characters and the transformation speed is fast, resulting in low detection accuracy.
By performing entity extraction on the original string, the target string and its category are obtained, and the target characters are converted into the characters before the variant based on the similarity and entity category of the candidate characters to obtain the converted string, and finally the detection result is determined.
It improves the accuracy and precision of detecting whether a string contains diversion information, can intercept diversion information in a timely manner, reduce the risk of users being deceived, and improve the security of the network platform.
Smart Images

Figure CN119647477B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of artificial intelligence technology, in particular to the fields of deep learning and knowledge graphs. More specifically, the present disclosure provides a text detection method, device, electronic device, storage medium, and computer program product. Background Art
[0002] On online platforms like video sites, forums, and shopping platforms, some users include additional information like URLs and phone numbers in their posted strings to attract traffic. They also sometimes use similar-sounding or similar-looking character variants to circumvent machine review. Because characters can change in many ways and quickly, it's difficult to accurately detect whether a string contains additional information intended for traffic diversion. Summary of the Invention
[0003] The present disclosure provides a text detection method, apparatus, electronic device, storage medium, and computer program product.
[0004] According to one aspect of the present disclosure, a text detection method is provided, comprising: performing entity extraction on an original character string to be detected based on features of each character in the original character string to obtain a target character string that has undergone a variant in the original character string, and obtaining an entity category of the target character string; converting the target character into a character before the variant based on the entity category and the similarity between each candidate character in a candidate character set and the target character to obtain a converted character string; wherein the target character is a character in the target character string; and determining a detection result of the original character string based on the converted character string.
[0005] According to another aspect of the present disclosure, a text detection device is provided, comprising: an entity extraction module, a conversion module, and a result determination module. The entity extraction module is used to perform entity extraction on the original character string to be detected based on the features of each character in the original character string, obtain a target character string that has undergone a variant in the original character string, and obtain an entity category of the target character string. The conversion module is used to convert the target character into a character before the variant based on the entity category and the similarity between each candidate character in the candidate character set and the target character, to obtain a converted character string; wherein the target character is a character in the target character string. The result determination module is used to determine the detection result of the original character string based on the converted character string.
[0006] According to another aspect of the present disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the method provided by the present disclosure.
[0007] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause a computer to execute the method provided by the present disclosure.
[0008] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, which implements the method provided in the present disclosure when executed by a processor.
[0009] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] The accompanying drawings are used to better understand the present invention and do not constitute a limitation of the present invention.
[0011] Figure 1 is a schematic diagram of an application scenario of the text detection method and device according to an embodiment of the present disclosure;
[0012] Figure 2 is a schematic flow chart of a text detection method according to an embodiment of the present disclosure;
[0013] Figure 3 is a schematic diagram of a point-edge graph according to an embodiment of the present disclosure;
[0014] Figure 4 is a schematic diagram of a deep learning model for determining character vector representation according to an embodiment of the present disclosure;
[0015] Figure 5 is a schematic diagram of the entity extraction process according to an embodiment of the present disclosure;
[0016] Figure 6 is a schematic structural block diagram of a text detection device according to an embodiment of the present disclosure; and
[0017] Figure 7 It is a structural block diagram of an electronic device used to implement the text detection method of an embodiment of the present disclosure. DETAILED DESCRIPTION
[0018] The following description of exemplary embodiments of the present disclosure is made in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding. These details should be considered as merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0019] In the technical solutions disclosed herein, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0020] In the technical solution disclosed herein, the user's authorization or consent is obtained before obtaining or collecting the user's personal information.
[0021] In related technologies, a variant word library is first constructed, and then variant words are replaced and restored based on the variant word library to obtain the restored text, which is then used for entity extraction. On the one hand, variant words can be transformed in many ways and the transformation speed is fast, so the accuracy of rule-based variant word restoration is poor. On the other hand, the processing order is restoration first, followed by entity extraction. Inaccurate restoration directly affects the results of entity extraction, resulting in low detection accuracy.
[0022] The embodiments of the present disclosure aim to provide a text detection method that can detect an original character string, extract a target character string that has undergone a variant, then restore the target character string to obtain a converted character string, and then determine whether the original character string contains malicious traffic based on the converted character string.
[0023] It can be seen that the method provided by the embodiment of the present disclosure first performs entity extraction to obtain the target character string, and then restores the target character string that has undergone a variant, and during the restoration process, the target characters in the target character string can be constrained based on the entity category of the variant character, thereby improving the accuracy of the restoration. The target character string after restoration is called the converted character string. Since the restoration is more accurate, the detection result determined based on the converted character string will also be more accurate, thereby achieving the effect of improving the detection accuracy. The method provided by the embodiment of the present disclosure can be used to detect the content posted by the user, and intercept it in time after determining that it contains drainage information, thereby reducing the risk of other users being deceived by drainage information and improving the security of the network platform.
[0024] The technical solutions provided by the present disclosure will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0025] Figure 1 Schematic diagram of an application scenario of the text detection method and device according to an embodiment of the present disclosure.
[0026] It should be noted that Figure 1 The examples shown are merely examples of system architectures to which the embodiments of the present disclosure may be applied, to help those skilled in the art understand the technical content of the present disclosure, but do not mean that the embodiments of the present disclosure may not be used in other devices, systems, environments or scenarios.
[0027] like Figure 1As shown, the system architecture 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 is used as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired and / or wireless communication links, etc.
[0028] Users can use terminal devices 101, 102, and 103 to interact with server 105 via network 104 to receive or send messages, etc. Terminal devices 101, 102, and 103 can be various electronic devices with display screens and support web browsing, including but not limited to smartphones, tablet computers, laptop computers, and desktop computers, etc.
[0029] Server 105 can be a server that provides various services, such as a backend management server (for example only) that supports websites browsed by users using terminal devices 101, 102, and 103. The backend management server can analyze and process received data, such as user requests, and feed back the results to the terminal devices. For example, it can extract the original string based on the user request, perform a test on the original string to obtain a test result, and then feed back the processing result to the terminal devices based on the test result.
[0030] It should be noted that the text detection method provided in the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, the text detection device provided in the embodiment of the present disclosure can generally be set in the server 105. The text detection method provided in the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105. Accordingly, the text detection device provided in the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105.
[0031] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is merely illustrative. Any number of terminal devices, networks and servers may be provided as required.
[0032] Figure 2 is a schematic flowchart of a text detection method according to an embodiment of the present disclosure.
[0033] like Figure 2 As shown, the text detection method 200 may include operations S210 to S240.
[0034] In operation S210 , entity extraction is performed on the original character string according to features of each character in the original character string to be detected, and a target character string that has been mutated in the original character string is obtained, as well as an entity category of the target character string.
[0035] For example, users can publish data such as text and images online, and raw character strings can be extracted from this data. The raw character strings consist of multiple characters, each of which has features, such as at least one of glyph sub-features, phonetic sub-features, semantic sub-features, and node sub-features. Neural networks can be used to process the characters to obtain their features, or the correspondence between characters and features can be pre-established and stored, allowing the features to be directly retrieved when needed.
[0036] For example, the features of each character in the original string can be input into a trained entity extraction model to extract entities. The extracted entities are called target strings, and the characters in the target string are called target characters. Some or all characters in the target string have been mutated. Furthermore, the target string can be classified to determine the entity category. Entity categories include, for example, mobile phone numbers, WeChat IDs, QQ numbers, and website addresses.
[0037] In operation S220 , the target character is converted into a character before the variant according to the entity category and the similarity between each candidate character in the candidate character set and the target character to obtain a converted character string.
[0038] For example, entity categories can have corresponding constraints. For example, when the entity category is a mobile phone number or QQ number, the constraint can be that all characters must be numbers. For another example, when the entity category is a WeChat ID or a website, the constraint can be that the characters must be numbers, letters, or symbols.
[0039] For example, a candidate character set can be pre-built, comprising multiple candidate characters. The similarity between the features of the candidate characters and the features of the target character can be determined. If a candidate character has a high degree of similarity to the target character, and the character category of the candidate character meets the constraints, the target character can be converted to the candidate character. This conversion is performed on each character in the target string to obtain a converted string.
[0040] In operation S230 , a detection result of the original character string is determined based on the converted character string.
[0041] For example, the target string in the original string may be replaced with the converted string, and then the replaced original string may be classified to determine whether the replaced original string is abnormal, thereby obtaining a detection result.
[0042] The text detection method provided by the embodiments of the present disclosure first performs entity extraction to obtain a target string, and then restores the target string with variants. During the restoration process, the target characters in the target string can be constrained based on the entity categories of the variant characters, thereby improving the accuracy of restoration. The target string after restoration is called the converted string. Since the restoration is relatively accurate, the detection result determined based on the converted string will also be more accurate, thus achieving the effect of improving the detection accuracy.
[0043] According to another embodiment of the present disclosure, the process of converting the target character into the character before the variant based on the entity category and the similarity between each candidate character in the candidate character set and the target character may include the following operations: For each target character in the target string, determine the current character from the candidate characters in the candidate character set according to the similarity between each candidate character in the candidate character set and the target character. Then, determine the target character type according to the entity category. Then, judge whether the character type of the current character is consistent with the target character type. If they are consistent, convert the target character into the current character; if they are inconsistent, delete the current character from the candidate character set, and then re-determine the current character from the candidate characters in the candidate character set.
[0044] For example, taking the candidate character set including 100 characters and the entity category of the target string being a mobile phone number as an example, for a certain target character in the target string, the similarity between the features of the target character and the features of each candidate character can be determined. In this way, multiple similarities can be calculated for multiple candidate characters, and the candidate character with the maximum similarity can be determined as the current character. Next, it can be determined whether the character type of the current character is a number. If it is a number, the target character can be converted into the current character. If the character type of the current character is not a number, the current character is deleted from the candidate character set, and then the candidate character with the maximum similarity is re-selected from the remaining 99 candidate characters as the current character. Then, repeat the operation until a current character with a relatively high similarity and a character type of number is found. If none of the 100 candidate characters meet the requirements after traversal, the target character may not be restored. In this way, each character in the target string can be restored. For example, the target string "① two three" can be restored to "123".
[0045] This embodiment can determine the character that meets the entity category and has the highest similarity with the target character, and then use this character to replace the target character, so the accuracy of character conversion can be improved.
[0046] It should be noted that in other embodiments, the target character type can be first determined based on the entity category, and then the characters that meet the target character type are filtered out from the candidate character set, and then the candidate character with the greatest similarity to the target character is determined from the filtered candidate characters, and then the target character is replaced with the candidate character.
[0047] According to another embodiment of the present disclosure, a feature of a character includes at least one sub-feature, such as at least one of a glyph sub-feature, a phonetic sub-feature, a semantic sub-feature, and a node sub-feature. For example, the feature of a candidate character includes multiple sub-features, and the target character also includes multiple sub-features. The multiple sub-features in the candidate character correspond to the multiple sub-features in the target character, and the correspondence may be one-to-one.
[0048] In the process of determining the similarity between each candidate character in the candidate character set and the target character, multiple sub-similarity between the candidate character and the target character can be determined based on multiple sub-features in the candidate character, multiple sub-features in the target character, and the corresponding relationship, and then the similarity between the candidate character and the target character can be determined based on the multiple sub-similarities. For example, the features of the candidate character include glyph sub-features, pronunciation sub-features, and semantic sub-features. Correspondingly, the features of the target character include glyph sub-features, pronunciation sub-features, and semantic sub-features. A sub-similarity can be calculated using the corresponding sub-features, thus obtaining glyph sub-similarity, pronunciation sub-similarity, and semantic sub-similarity. Then, a weighted operation is performed on the glyph sub-similarity, pronunciation sub-similarity, and semantic similarity to obtain the similarity.
[0049] In this embodiment, the character features include multiple sub-features, and the similarity between these sub-features is calculated, achieving more refined and accurate character matching, thereby improving the comprehensiveness and accuracy of character recognition. In addition, in some embodiments, since multi-dimensional information such as glyph shape, pronunciation, and semantics is taken into account, the overall similarity between the candidate character and the target character can be more reasonably assessed, enhancing the flexibility and adaptability of the matching, thereby more accurately restoring the target character.
[0050] According to another embodiment of the present disclosure, the process of determining the detection result of the original character string based on the converted character string may include: matching the converted character string with multiple predetermined abnormal information to obtain a matching result, and then determining the detection result based on the matching result.
[0051] For example, a database can be pre-constructed, and the database can include multiple pre-collected abnormal information. The target string in the original string can be replaced with the converted string, so as to obtain the replaced original string. Then, it can be determined whether the string (the converted string or the replaced original string) matches a certain abnormal information in the database, and the matching condition can be that the string is the same as the abnormal information or the similarity is greater than a threshold, so as to obtain a matching result. If the matching is successful, it can be determined that the detection result is that the original string is abnormal, and at this time, the original string can be blocked during the display process; otherwise, it can be determined that the detection result is that the original string is normal, and at this time, the original string can be displayed normally.
[0052] In this embodiment, by constructing a database and matching the original string with the database, the accuracy and automation of the detection can be ensured, and the original string containing abnormal information can be discovered and blocked in time, improving the content security and monitoring efficiency. Furthermore, it protects users from being invaded by bad information.
[0053] Figure 3 It is a schematic diagram of a point-edge graph according to an embodiment of the present disclosure.
[0054] It should be noted that in some embodiments, a training sample of an entity extraction model can be constructed based on the point-edge graph, and then the entity extraction process can be realized. This embodiment will explain the point-edge graph.
[0055] Such as Figure 3 As shown, the point-edge graph includes multiple nodes and multiple edges. Each node in the multiple nodes represents a character, and the two characters represented by the two nodes connected by an edge satisfy a phonetic similarity relationship or a glyph similarity relationship. For example, Figure 3 In the partial graph 301 of the exemplary point-edge graph, P represents the phonetic similarity relationship, G represents the glyph similarity relationship, "微" and "薇" satisfy the phonetic similarity relationship, and "微" and "徽" satisfy the glyph similarity relationship.
[0056] Next, the process of constructing the point-edge graph will be described.
[0057] In the process of constructing a point-edge graph, in one example, for any two characters, the two characters are called the first character and the second character, the pinyin of the first character and the pinyin of the second character are determined, for example, the pinyin of the first character is expressed as [a1, a2], and the pinyin of the second character is expressed as [b1, b2, b3], and then the first similarity between the pinyin of the first character and the pinyin of the second character is determined. The first similarity can be the minimum edit distance. If the first similarity is less than or equal to the first threshold, it can be determined that the first character and the second character satisfy the pronunciation similarity relationship, and then a node corresponding to the first character and a node corresponding to the second character are added to the point-edge graph, and an edge is added between the node corresponding to the first character and the node corresponding to the second character.
[0058] In the process of constructing a point-edge graph, in another example, for any two characters, which are referred to as the third character and the fourth character, the image of the third character and the image of the fourth character can be determined, and then a pre-trained deep learning model can be used to determine the second similarity between the image of the third character and the image of the fourth character. If the second similarity is less than or equal to the second threshold, it can be determined that the third character and the fourth character satisfy a glyph similarity relationship, and then a node corresponding to the third character and a node corresponding to the fourth character are added to the point-edge graph, and an edge is formed between the node corresponding to the third character and the node corresponding to the fourth character.
[0059] Figure 4 is a schematic diagram of a deep learning model for determining character vector representation according to an embodiment of the present disclosure.
[0060] like Figure 4 As shown, the deep learning model 402 may include network layers such as a convolution layer, a maximum pooling layer, and an average pooling layer. This embodiment does not limit the structure of the deep learning model 402. In the process of determining the glyph vector representation of a character, the character can be first converted into an image 401 of a predetermined size, and then the image 401 is input into the trained deep learning model 402, and a glyph vector representation 403 is output. For example, for a given third character and fourth character, the third character and the fourth character are first converted into images respectively, and then the images are converted into glyph vector representations through the deep learning model. If the similarity between the glyph vector representation of the third character and the glyph vector representation of the fourth character is less than the second threshold, it is determined that the third character and the fourth character satisfy a glyph similarity relationship.
[0061] It is understandable that the above deep learning model is pre-trained. During the training process, a batch of similar Chinese characters can be collected in advance and annotated by triples. ,in Indicates similar Chinese character pairs, Denote dissimilar Chinese character pairs. The deep learning model is trained by minimizing the following loss function.
[0062]
[0063] Among them, denotes the output glyph vector obtained by inputting the image of character into the deep learning model, denotes the output glyph vector obtained by inputting the image of character into the deep learning model, denotes the output glyph vector obtained by inputting the image of character into the deep learning model.
[0064] The process of constructing the point-edge graph is described above. In some embodiments, after constructing the point-edge graph, the point-edge graph can be used to automatically generate training samples for training the entity extraction model to achieve automated data augmentation. For example, a raw sample with normal annotation of non-variant characters can be given, then characters to be replaced are randomly selected in the raw sample, and then similar characters to the characters to be replaced are selected from the point-edge graph and used to replace the characters to be replaced above, thus obtaining training samples. For example, the raw sample is "Play chess and add WeChat: abc123", the characters to be replaced are randomly selected as "chess", "WeChat", "1", "2", and then similar characters "spleen", "emblem", "", "two" are found in the point-edge graph, and the training sample "Play spleen and add emblem: abc①two3" is obtained after replacement. This embodiment automatically generates a large number of adversarial samples from a small number of samples based on the point-edge graph, increases the robustness of the model, and reduces the annotation cost.
[0065] Next, the process of determining the features of characters is described. The characters in this embodiment can be any one of the characters in the original string, the target string, and the candidate characters above. The features of characters can include at least one sub-feature. For example, the features of characters can include at least one of glyph sub-features, pronunciation sub-features, semantic sub-features, and node sub-features. At least one sub-feature can be fused by concatenation or other means to obtain the features of characters.
[0066] For the glyph sub-feature, the character can be first converted into an image of a predetermined size, and then the deep learning model above is used to determine the glyph vector representation of the character, and this glyph vector representation is the glyph sub-feature.
[0067] For the pronunciation sub-feature, the character can be converted into pinyin, and then the pinyin is input into a pre-trained model to extract the pronunciation representation vector of the pinyin as the pronunciation sub-feature.
[0068] For semantic sub-features, a natural language text sequence with semantic meaning can be obtained, such as "deep learning model is an artificial intelligence model" or other text that generally describes semantic content. Based on this natural language text sequence, a predetermined mapping algorithm is then used to learn semantic vector representations of the characters. Predefined mapping algorithms, such as the Skip-gram algorithm or the Continuous Bag of Words (CBOW) algorithm, are described below. For example, a dictionary with a capacity of 10,000 characters is one-hot encoded, resulting in each character being a 10,000-dimensional vector. Given a natural language text sequence consisting of a central character and context, one of the central character and the context is used as the input character, and the other as the output character. The one-hot encoding of the input character is fed into a first model, which maps the 10,000-dimensional one-hot encoding into an N-dimensional vector, where N is a positive integer, for example, 64. The N-dimensional vector is then used to predict the probability distribution of the output text, and the actual output characters are used as labels to train the first model. This results in the network parameters of the first model, which are a 10,000-by-64 matrix. Then, through the network parameters, the one-hot encoding of each of the above 10,000 words can be mapped to a vector representation, which is the semantic sub-feature.
[0069] For node sub-features, a node-edge graph can be pre-constructed. This graph consists of multiple nodes and multiple edges. Each node represents a character, and the two characters represented by two nodes connected by an edge satisfy a phonetic or glyphic similarity relationship. Node sub-features are then determined based on the node-edge graph.
[0070] For example, a text sequence can be determined from a node-edge graph using methods such as node2vec (Node to Vector) random walks, DeepWalk, LINE (Large-scale Information Network Embedding), and EGES (Edge-based Generalized Embedding). Based on this text sequence, a predetermined mapping algorithm is then used to learn a vector representation of the character. This vector contains information such as the character's pronunciation and glyph. Characters with similar glyphs or pronunciations also have similar vector representations. This vector representation is the node sub-feature. The predetermined mapping algorithm can be referenced above and will not be described in detail in this embodiment. It is understood that the predetermined mapping algorithm used in determining the node sub-feature can be the same as the predetermined mapping algorithm used in determining the semantic sub-feature. The difference between the two lies in the different text sequences. The text sequence used in determining the node sub-feature is determined from the node-edge graph and generally does not have semantics, while the text sequence used in determining the semantic sub-feature is a natural language text with semantics. Different models can then be trained using different text sequences to obtain different network parameters. Then, the same character can be mapped into different semantic sub-features and node sub-features by using different network parameters.
[0071] It's important to note that determining character sub-features is task-independent and can be done offline. Once determined, character sub-features can be reused in any natural language model, enhancing the versatility and effectiveness of variant word defense.
[0072] It should be noted that in related technologies, entity extraction can be performed based on only one sub-feature as a character feature. For example, only the semantic sub-feature can be input into the entity extraction model for entity extraction. However, because malicious traffic diversion information may contain some or all text using variant characters, entity extraction based solely on semantic sub-features is less accurate.
[0073] In this embodiment, entity extraction can be performed based on sub-features related to pronunciation or glyph, which can be applicable to situations where characters undergo variations. In addition, further, multiple sub-features can be used to determine the features of characters and perform entity extraction, which can improve the accuracy of entity extraction compared to a single feature approach. Furthermore, semantic features and features related to pronunciation or glyph can be used to perform entity extraction, which can be applicable to drainage information where some characters undergo variations and another part of the characters do not undergo variations. In practical applications, semantic sub-features and node sub-features can be input into the entity extraction model, or semantic sub-features and pronunciation sub-features can be input into the entity extraction model, or semantic sub-features and glyph sub-features can be input into the entity extraction model, or semantic sub-features, pronunciation sub-features, and glyph sub-features can be input into the entity extraction model, or semantic sub-features, pronunciation sub-features, and glyph sub-features can be input into the entity extraction model, or semantic sub-features, pronunciation sub-features, and glyph sub-features can be input into the entity extraction model.
[0074] Figure 5 It is a schematic diagram of the entity extraction process according to an embodiment of the present disclosure.
[0075] Next, the process of entity extraction from the original string is explained.
[0076] In this embodiment, the attributes of each character in the original string can be determined based on the characteristics of each character in the original string and the entity extraction model, and then the target string can be determined from the original string based on the attributes of each character in the original string.
[0077] For example, Figure 5 As shown, the entity extraction model may include a first sub-model 511 and a second sub-model 512. The first sub-model 511 may be an RNN (Recurrent Neural Network), and the second sub-model 512 may be a CRF (Conditional Random Fields). The entity extraction model may also adopt other structures. This embodiment does not limit the structure of the entity extraction model.
[0078] The input data of the entity extraction model is the features of each character in the original string, and the features of each character can include at least one sub-feature. For example, the original string includes multiple characters, and the features of each character include a node sub-feature 531 and a semantic sub-feature 542. The node sub-feature 531 and the semantic sub-feature 542 of the same character are concatenated to obtain the features of the character, and the features of each character in the original string are input into the entity extraction model. In addition, it should be noted that the node sub-feature 531 of each character in the original string can be determined based on a point-edge graph. For example, the point-edge graph includes multiple sub-graphs 521, 522, and 523, and the node sub-feature 531 can be determined based on these sub-graphs 521, 522, and 523.
[0079] The output data of the entity extraction model is the attributes of each character. These attributes indicate whether a character in the original string is a variant character. Furthermore, if a character in the original string is a variant character, the attributes also indicate the variant position of the variant character, which can include the start, middle, and end of the variant. Furthermore, the output data may also include the entity category. Using this entity extraction model, we can determine the start and end positions of the target string where a variant occurs within the original string, thereby extracting the target string.
[0080] It can be understood that the above-mentioned entity extraction model is pre-trained, and the training process is similar to the inference process. The difference is that the training samples used in the training process have labels. The labels can indicate whether each character in the training sample is a variant character, and the true variant position if it is a variant character. The label can also indicate the true variant category. In this way, the entity extraction model can be trained by the difference between the data output by the entity extraction model and the label.
[0081] Figure 6 4 is a schematic structural block diagram of a text detection device according to an embodiment of the present disclosure.
[0082] like Figure 6 As shown, the text detection device 600 may include an entity extraction module 610 , a conversion module 620 and a result determination module 630 .
[0083] The entity extraction module 610 is used to extract entities from the original character string according to the features of each character in the original character string to be detected, obtain a target character string that has been mutated in the original character string, and obtain an entity category of the target character string.
[0084] The conversion module 620 is used to convert the target character into the character before the variant according to the entity category and the similarity between each candidate character in the candidate character set and the target character, to obtain a converted character string; wherein the target character is the character in the target character string.
[0085] The result determination module 630 is used to determine the detection result of the original character string according to the converted character string.
[0086] According to another embodiment of the present disclosure, the conversion module includes: a current character determination submodule, a type determination submodule, a conversion determination submodule and a processing submodule. The current character determination submodule is used to determine the current character from the candidate characters in the candidate character set according to the similarity between each candidate character in the candidate character set and the target character for each target character in the target character string. The type determination submodule is used to determine the target character type according to the entity category. The conversion determination submodule is used to convert the target character into the current character in response to detecting that the character type of the current character is consistent with the target character type. The processing submodule is used to delete the current character from the candidate character set in response to detecting that the character type of the current character is inconsistent with the target character type, and then re-determine the current character from the candidate characters in the candidate character set.
[0087] According to another embodiment of the present disclosure, multiple sub-features in the candidate character have a corresponding relationship with multiple sub-features in the target character; the conversion module further includes: a sub-similarity determination sub-module and a similarity determination sub-module. The sub-similarity determination sub-module is configured to determine multiple sub-similarities between the candidate character and the target character based on the multiple sub-features in the candidate character, the multiple sub-features in the target character, and the corresponding relationship. The similarity determination sub-module is configured to determine the similarity between the candidate character and the target character based on the multiple sub-similarities.
[0088] According to another embodiment of the present disclosure, the result determination module includes a matching submodule and a result determination submodule. The matching submodule is configured to match the converted character string with a plurality of predetermined anomaly information to obtain a matching result. The result determination submodule is configured to determine a detection result based on the matching result.
[0089] According to another embodiment of the present disclosure, the system further includes: a feature determination module configured to determine, for each character in the original string, a feature of the character based on at least one of the character's glyph sub-features, pronunciation sub-features, semantic sub-features, and node sub-features. The node sub-features are determined based on a node-edge graph, wherein the node-edge graph includes a plurality of nodes and a plurality of edges, wherein each of the plurality of nodes represents a character, and the two characters represented by the two nodes connected by the edge satisfy a pronunciation similarity relationship or a glyph similarity relationship.
[0090] According to another embodiment of the present disclosure, the entity extraction module includes an attribute determination submodule and a string determination submodule. The attribute determination submodule is used to determine the attributes of each character in the original string based on the characteristics of each character in the original string and the entity extraction model. The attributes represent: whether the character in the original string is a variant character; and if the character in the original string is a variant character, the variant position of the variant character. The string determination submodule is used to determine the target string from the original string based on the attributes of each character in the original string.
[0091] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, including at least one processor; and a memory communicatively connected to the at least one processor; the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the above-mentioned text detection method.
[0092] According to an embodiment of the present disclosure, the present disclosure further provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute the above-mentioned text detection method.
[0093] According to an embodiment of the present disclosure, the present disclosure further provides a computer program product, including a computer program, which implements the above text detection method when executed by a processor.
[0094] Figure 7 is a block diagram of an electronic device used to implement the text detection method of an embodiment of the present disclosure. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0095] like Figure 7 As shown, device 700 includes a computing unit 701, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 702 or a computer program loaded from a storage unit 708 into a random access memory (RAM) 703. RAM 703 may also store various programs and data required for the operation of device 700. Computing unit 701, ROM 702, and RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to bus 704.
[0096] Various components in device 700 are connected to I / O interface 705, including an input unit 706, such as a keyboard, mouse, etc.; an output unit 707, such as various types of displays, speakers, etc.; a storage unit 708, such as a magnetic disk, optical disk, etc.; and a communication unit 709, such as a network card, modem, wireless communication transceiver, etc. The communication unit 709 allows device 700 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0097] The computing unit 701 can be any general-purpose and / or specialized processing component with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 701 performs the various methods and processes described above, such as the text detection method. For example, in some embodiments, the text detection method may be implemented as a computer software program tangibly embodied in a machine-readable medium, such as the storage unit 708. In some embodiments, part or all of the computer program may be loaded and / or installed onto the device 700 via the ROM 702 and / or the communication unit 709. When the computer program is loaded into the RAM 703 and executed by the computing unit 701, one or more steps of the text detection method described above may be performed. Alternatively, in other embodiments, the computing unit 701 may be configured to perform the text detection method via any other suitable means (e.g., via firmware).
[0098] Various embodiments of the systems and techniques described above can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-a-chip systems (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0099] The program code for implementing the method of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device so that when the program code is executed by the processor or controller, the functions / operations specified in the flow chart and / or block diagram are implemented. The program code can be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0100] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of machine-readable storage media may include an electrical connection based on one or more wires, 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), optical fibers, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0101] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0102] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), and the Internet.
[0103] Computer systems may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The client and server relationship arises through computer programs running on the respective computers and having a client-server relationship to each other.
[0104] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this disclosure can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved. This is not limited herein.
[0105] The above specific embodiments do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure shall be included within the scope of protection of this disclosure.
Claims
1. A text detection method, comprising: Performing entity extraction on the original character string to be detected based on the characteristics of each character in the original character string to obtain a target character string that has been mutated in the original character string, and obtaining an entity category of the target character string; According to the entity category and the similarity between each candidate character in the candidate character set and the target character, the target character is converted into a character before the variant to obtain a converted character string; the method comprises: for each target character in the target character string, determining a current character from the candidate characters in the candidate character set according to the similarity between each candidate character in the candidate character set and the target character; determining a target character type according to the entity category; in response to detecting that the character type of the current character is consistent with the target character type, converting the target character into the current character; and in response to detecting that the character type of the current character is inconsistent with the target character type, deleting the current character from the candidate character set, and then re-determining the current character from the candidate characters in the candidate character set; A detection result of the original character string is determined according to the converted character string.
2. The method according to claim 1, wherein The plurality of sub-features in the candidate characters correspond to the plurality of sub-features in the target character; and converting the target character into a character before the variant based on the entity category and the similarity between each candidate character in the candidate character set and the target character further comprises: determining a plurality of sub-similarity between the candidate character and the target character according to the plurality of sub-features in the candidate character, the plurality of sub-features in the target character, and the corresponding relationship; and The similarity between the candidate character and the target character is determined based on the multiple sub-similarity levels.
3. The method according to claim 1, wherein Determining the detection result of the original character string according to the converted character string includes: Matching the converted character string with a plurality of predetermined abnormal information to obtain a matching result; and The detection result is determined according to the matching result.
4. The method according to any one of claims 1 to 3, further comprising: For each character in the original character string, determining a feature of the character based on at least one of a shape sub-feature, a pronunciation sub-feature, a semantic sub-feature, and a node sub-feature of the character; Among them, the node sub-features are determined based on a point-edge graph, and the point-edge graph includes multiple nodes and multiple edges, each of the nodes represents a character, and the two characters represented by the two nodes connected by the edge satisfy a phonetic similarity relationship or a glyph similarity relationship.
5. The method according to claim 1, wherein The entity extraction of the original character string to be detected based on the characteristics of each character in the original character string to obtain the target character string that has been modified in the original character string includes: Determining, based on the characteristics of each character in the original string and an entity extraction model, an attribute of each character in the original string, wherein the attribute represents: whether the character in the original string is a variant character; and if the character in the original string is a variant character, the variant position of the variant character; and The target character string is determined from the original character string according to the attributes of each character in the original character string.
6. A text detection device comprising: An entity extraction module is used to extract entities from the original character string according to the characteristics of each character in the original character string to be detected, obtain a target character string that has been mutated in the original character string, and obtain an entity category of the target character string; a conversion module, configured to convert the target character into a character before the variant according to the entity category and the similarity between each candidate character in the candidate character set and the target character, to obtain a converted character string; wherein the target character is a character in the target character string; and A result determination module, configured to determine a detection result of the original character string based on the converted character string; Wherein, the conversion module includes: a current character determination submodule, configured to determine, for each target character in the target character string, a current character from the candidate characters in the candidate character set according to the similarity between each candidate character in the candidate character set and the target character; A type determination submodule, configured to determine a target character type based on the entity category; a conversion determination submodule, configured to, in response to detecting that the character type of the current character is consistent with the target character type, convert the target character into the current character; and The processing submodule is configured to, in response to detecting that the character type of the current character is inconsistent with the target character type, delete the current character from the candidate character set, and then re-determine the current character from the candidate characters in the candidate character set.
7. The device according to claim 6, wherein The plurality of sub-features in the candidate characters have a corresponding relationship with the plurality of sub-features in the target character; the conversion module further includes: a sub-similarity determination submodule, configured to determine a plurality of sub-similarity between the candidate character and the target character based on a plurality of sub-features in the candidate character, a plurality of sub-features in the target character, and the corresponding relationship; and The similarity determination submodule is configured to determine the similarity between the candidate character and the target character according to the multiple sub-similarity.
8. The device according to claim 6, wherein The result determination module includes: a matching submodule, configured to match the converted character string with a plurality of predetermined abnormal information to obtain a matching result; and The result determination submodule is used to determine the detection result according to the matching result.
9. The apparatus according to any one of claims 6 to 8, further comprising: a feature determination module, configured to determine, for each character in the original character string, a feature of the character based on at least one of a shape sub-feature, a phonetic sub-feature, a semantic sub-feature, and a node sub-feature of the character; Among them, the node sub-features are determined based on a point-edge graph, and the point-edge graph includes multiple nodes and multiple edges, each of the nodes represents a character, and the two characters represented by the two nodes connected by the edge satisfy a phonetic similarity relationship or a glyph similarity relationship.
10. The device according to claim 6, wherein The entity extraction module includes: an attribute determination submodule, configured to determine, based on the characteristics of each character in the original string and an entity extraction model, an attribute of each character in the original string, wherein the attribute indicates: whether the character in the original string is a variant character; and if the character in the original string is a variant character, the variant position of the variant character; and The character string determination submodule is configured to determine the target character string from the original character string according to the attributes of each character in the original character string.
11. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 5.
12. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 5.
13. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Text anti-cheating variant restoring method and device and text anti-cheating method and device
CN110298020A
Variant text recognition method and device and electronic equipment
CN113408270A