Text processing method and device, equipment, medium and program product

By constructing a dictionary tree in the target field for text matching, the problem of low accuracy of the existing technical Chinese text error correction is solved, and the high accuracy of the text of the professional field is realized.

CN119337863APending Publication Date: 2025-01-21BEIJING JINGDONG TUOXIAN TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202310898557.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-07-20
Publication Date
2025-01-21

AI Technical Summary

Technical Problem

In the prior art, the accuracy of text error correction in professional fields is low, and it is difficult to meet the high accuracy needs of medical and other fields.

Method used

By constructing a dictionary tree in the target area, each word to be corrected to be corrected to match the words corresponding to the nodes in the dictionary tree to form multiple candidate text paths, and select the most suitable target text path according to the overall similarity as amendments as amendments as amendments as amendments as amendments. result.

Benefits of technology

The accuracy of text error correction can be improved, which can more accurately correct the text to be corrected in the professional field and meet the high accuracy needs in the field of medical treatment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119337863A_ABST
    Figure CN119337863A_ABST
Patent Text Reader

Abstract

The invention provides a text processing method and device, equipment, a medium and a program product. In some embodiments of the invention, a to-be-corrected text of a target field is obtained; each word in the to-be-corrected text is matched with a word corresponding to a node in a created dictionary tree, a target text path is obtained, the dictionary tree is constructed through vocabularies of a target field, and each node in the dictionary tree is associated with the corresponding word in the vocabularies; taking a text corresponding to the target text path as a corrected target text; the matching operation is performed on the dictionary tree constructed by the vocabularies of the target field and the to-be-corrected text of the target field, so that error correction can be performed on the to-be-corrected text of the target field more accurately, and the accuracy of text error correction is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the fields of natural language processing technology and medical health technology, and in particular to a text processing method, device, equipment, medium and program product. Background Art

[0002] With the development of information technology, more and more documents are presented in electronic form, and the number of documents is also growing explosively. Proofreading and correcting these documents will consume a lot of manpower and time. On the other hand, thanks to the electronicization of documents, people can use text automatic correction technology to speed up the proofreading and correction of texts, greatly improving work efficiency.

[0003] Especially in some professional fields such as medical treatment, there are many professional vocabulary in the text and the probability of typos is also relatively high, which will hinder subsequent medical diagnosis. Therefore, text error correction in natural language processing technology is very necessary.

[0004] Currently, the accuracy of text correction in professional fields is low. Summary of the invention

[0005] The present disclosure provides a text processing method, apparatus, device, medium and program product to at least solve the problem of low accuracy of existing text error correction.

[0006] The technical solution of the present disclosure is as follows:

[0007] The present disclosure provides a text processing method, including:

[0008] Get the text to be revised in the target area;

[0009] Matching each word in the text to be corrected with the word corresponding to the node in the already created dictionary tree to obtain the target text path; wherein the dictionary tree is constructed by the vocabulary of the target field, and each node in the dictionary tree is associated with the corresponding word in the vocabulary;

[0010] The text corresponding to the target text path is used as the corrected target text.

[0011] Optionally, before using the dictionary tree, the method further includes:

[0012] collecting the vocabulary of the target domain;

[0013] For any of the words, in the order of the characters in the word, the first character is used as the parent node, and the other characters are used as child nodes in turn, and directed edges are added between the parent node and the child nodes in turn to obtain the constructed dictionary tree, wherein the other characters are the characters of any of the words except the first character.

[0014] Optionally, matching each word in the text to be corrected with the word corresponding to the node in the already created dictionary tree to obtain the target text path includes:

[0015] Matching the characters in the text to be corrected with the characters corresponding to the first-layer nodes in the dictionary tree in sequence;

[0016] If the i-th word in the text to be corrected and the word corresponding to at least one target node in the first layer of nodes meet the preset matching condition, then the i+1-th word in the text to be corrected is matched with the word corresponding to the next layer of nodes associated with the target node, until all the words in the text to be corrected are matched, and the word corresponding to the matching node in the dictionary tree is obtained; wherein i is the position order of the word in the text to be corrected;

[0017] According to the directed edges between the nodes, the unmatched characters in the text to be corrected are connected with the characters corresponding to the matching nodes to form a plurality of candidate text paths;

[0018] According to the overall similarities of the plurality of candidate text paths, a target text path that meets the similarity condition is selected from the plurality of candidate text paths.

[0019] Optionally, matching the characters in the text to be corrected with the characters corresponding to the first-layer nodes in the dictionary tree respectively includes:

[0020] For the i-th word in the text to be corrected, respectively calculate the similarity between the i-th word and each word corresponding to the first layer node;

[0021] Selecting candidate nodes whose similarity is greater than a set similarity threshold from the first layer nodes;

[0022] According to the order of the similarity from large to small, the target node of the similarity order is selected from the candidate nodes.

[0023] Optionally, the similarity is cosine similarity, and the calculating the similarity between the i-th word and each word corresponding to the first layer node includes:

[0024] For a first node in the first layer of nodes, vectorize the i-th word and the word corresponding to the first node to obtain a first character vector corresponding to the i-th word and a second character vector of the word corresponding to the first node;

[0025] Normalizing the first character vector and the second character vector respectively to obtain a first normalized vector and a second normalized vector;

[0026] The cosine similarity between the first normalized vector and the second normalized vector is calculated as the similarity between the i-th word and the word corresponding to the first node.

[0027] Optionally, before selecting a target text path satisfying a similarity condition from the plurality of candidate text paths according to the overall similarities of the plurality of candidate text paths, the method further comprises:

[0028] The product of the similarities on each of the candidate text paths is calculated as the overall similarity of each of the candidate text paths.

[0029] Optionally, selecting a target text path that meets a similarity condition from the plurality of candidate text paths according to the overall similarities of the plurality of candidate text paths includes:

[0030] According to the overall similarities of the plurality of candidate text paths, a target text path with the greatest overall similarity is selected from the plurality of candidate text paths.

[0031] The present disclosure also provides a text processing device, including:

[0032] An acquisition module, used for acquiring the text to be corrected in the target field;

[0033] A matching module, used for matching each word in the text to be corrected with the word corresponding to the node in the already created dictionary tree to obtain a target text path; wherein the dictionary tree is constructed by the vocabulary of the target field, and each node in the dictionary tree is associated with a corresponding word in the vocabulary;

[0034] The correction module is used to use the text corresponding to the target text path as the corrected target text.

[0035] Optionally, before using the dictionary tree, the matching module may also be used to:

[0036] collecting the vocabulary of the target domain;

[0037] For any of the words, in the order of the characters in the word, the first character is used as the parent node, and the other characters are used as child nodes in turn, and directed edges are added between the parent node and the child nodes in turn to obtain the constructed dictionary tree, wherein the other characters are the characters of any of the words except the first character.

[0038] Optionally, the matching module performs a matching operation on each word in the text to be corrected with the word corresponding to the node in the created dictionary tree to obtain a target text path, which is used to:

[0039] Matching the characters in the text to be corrected with the characters corresponding to the first-layer nodes in the dictionary tree in sequence;

[0040] If the i-th word in the text to be corrected and the word corresponding to at least one target node in the first layer of nodes meet the preset matching condition, then the i+1-th word in the text to be corrected is matched with the word corresponding to the next layer of nodes associated with the target node, until all the words in the text to be corrected are matched, and the word corresponding to the matching node in the dictionary tree is obtained; wherein i is the position order of the word in the text to be corrected;

[0041] According to the directed edges between the nodes, the unmatched characters in the text to be corrected are connected with the characters corresponding to the matching nodes to form a plurality of candidate text paths;

[0042] According to the overall similarities of the plurality of candidate text paths, a target text path that meets the similarity condition is selected from the plurality of candidate text paths.

[0043] Optionally, when matching the characters in the text to be corrected with the characters corresponding to the first-layer nodes in the dictionary tree respectively, the matching module is used to:

[0044] For the i-th word in the text to be corrected, respectively calculate the similarity between the i-th word and each word corresponding to the first layer node;

[0045] Selecting candidate nodes whose similarity is greater than a set similarity threshold from the first layer nodes;

[0046] According to the order of the similarity from large to small, the target node of the similarity order is selected from the candidate nodes.

[0047] Optionally, the similarity is cosine similarity, and when calculating the similarity between the i-th word and each word corresponding to the first layer node, the matching module is used to:

[0048] For a first node in the first layer of nodes, vectorize the i-th word and the word corresponding to the first node to obtain a first character vector corresponding to the i-th word and a second character vector of the word corresponding to the first node;

[0049] Normalizing the first character vector and the second character vector respectively to obtain a first normalized vector and a second normalized vector;

[0050] The cosine similarity between the first normalized vector and the second normalized vector is calculated as the similarity between the i-th word and the word corresponding to the first node.

[0051] Optionally, before selecting a target text path satisfying a similarity condition from the plurality of candidate text paths according to the overall similarities of the plurality of candidate text paths, the matching module may further be used to:

[0052] The product of the similarities on each of the candidate text paths is calculated as the overall similarity of each of the candidate text paths.

[0053] Optionally, when selecting a target text path satisfying a similarity condition from the plurality of candidate text paths according to the overall similarities of the plurality of candidate text paths, the matching module is configured to:

[0054] According to the overall similarities of the plurality of candidate text paths, a target text path with the greatest overall similarity is selected from the plurality of candidate text paths.

[0055] The present disclosure also provides an electronic device, including:

[0056] processor;

[0057] a memory for storing instructions executable by the processor;

[0058] The processor is configured to execute the instructions to implement each step in the above method.

[0059] The embodiment of the present disclosure also provides a computer-readable storage medium, wherein the computer instructions are used to enable the computer to execute each step in the above method.

[0060] The embodiment of the present disclosure further provides a computer program product, including a computer program / instruction, characterized in that the computer program / instruction implements each step of the above method when executed by a processor.

[0061] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects:

[0062] In some embodiments of the present disclosure, a text to be corrected in a target field is obtained; each character in the text to be corrected is matched with a character corresponding to a node in a dictionary tree that has been created to obtain a target text path, wherein the dictionary tree is constructed by using the vocabulary of the target field, and each node in the dictionary tree is associated with a corresponding character in the vocabulary; the text corresponding to the target text path is used as the corrected target text; the dictionary tree constructed by using the vocabulary of the target field is matched with the text to be corrected in the target field, so that the text to be corrected in the target field can be corrected more accurately, thereby improving the accuracy of text correction.

[0063] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0064] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.

[0065] Figure 1 A flowchart of a text processing method provided for an exemplary embodiment of the present disclosure;

[0066] Figure 2 A schematic diagram of a partial dictionary tree provided for an exemplary embodiment of the present disclosure;

[0067] Figure 3 A schematic diagram of a matching process between a text to be corrected and a dictionary tree provided in an embodiment of the present disclosure;

[0068] Figure 4 A structural schematic diagram of a text processing device provided for an exemplary embodiment of the present application;

[0069] Figure 5 A schematic structural diagram of an electronic device provided for an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0070] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.

[0071] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0072] It should be noted that the user information involved in this disclosure includes but is not limited to: user device information and user personal information; the collection, storage, use, processing, transmission, provision and disclosure of user information in this disclosure are in compliance with the relevant laws and regulations and do not violate public order and good morals.

[0073] At present, text error correction generally adopts deep learning model error correction or rule error correction. The error correction method based on deep learning model has the problems of long calculation time, large consumption of computing resources, and inability to perform large-scale and rapid error correction. For medical scenarios, the real-time requirements for calculation are high, which cannot meet the needs of medical scenarios. In addition, the error correction results based on deep learning models may not be consistent with the field, and the accuracy of text error correction is low. Error correction based on rules also has the problem of low accuracy of text error correction.

[0074] In response to the above-mentioned technical problems, in some embodiments of the present disclosure, a text to be corrected in a target field is obtained; each character in the text to be corrected is matched with a character corresponding to a node in a dictionary tree that has been created to obtain a target text path, wherein the dictionary tree is constructed by the vocabulary of the target field, and each node in the dictionary tree is associated with a corresponding character in the vocabulary; the text corresponding to the target text path is used as the corrected target text; the dictionary tree constructed by the vocabulary of the target field is matched with the text to be corrected in the target field, so that the text to be corrected in the target field can be corrected more accurately, thereby improving the accuracy of text correction.

[0075] Figure 1 The flowchart of a text processing method provided by the exemplary embodiment of the present disclosure is as follows. Figure 1 As shown, the method includes:

[0076] S101: Obtain the text to be revised in the target field;

[0077] S102: Matching each word in the text to be corrected with the word corresponding to the node in the created dictionary tree to obtain the target text path; wherein the dictionary tree is constructed by the vocabulary of the target field, and each node in the dictionary tree is associated with the corresponding word in the vocabulary;

[0078] S103: Using the text corresponding to the target text path as the corrected target text.

[0079] In this embodiment, the execution subject of the above method may be a server or a terminal device.

[0080] When the execution subject is a server, the implementation form of the server is not limited. For example, the server can be a conventional server, a cloud server, a cloud host, a virtual center, and other server devices. Among them, the composition of the server mainly includes a processor, a hard disk, a memory, a system bus, etc., and a general computer architecture type.

[0081] In this embodiment, a text to be corrected in a target field is obtained; each character in the text to be corrected is matched with a character corresponding to a node in a dictionary tree that has been created to obtain a target text path, wherein the dictionary tree is constructed by the vocabulary of the target field, and each node in the dictionary tree is associated with a corresponding character in the vocabulary; the text corresponding to the target text path is used as the corrected target text; the dictionary tree constructed by the vocabulary of the target field is matched with the text to be corrected in the target field, so that the text to be corrected in the target field can be corrected more accurately, thereby improving the accuracy of text correction.

[0082] It should be noted that the embodiments of the present disclosure do not limit the target fields, and the target fields include but are not limited to the following: medical field, mathematical field, legal field and biological field.

[0083] It should be noted that the dictionary tree of the present disclosure is a tree structure constructed by the vocabulary of the target field. The dictionary tree of the target field is used to perform text correction operations on the text to be corrected in the target field. The dictionary tree of the target field is used to correct the text to be corrected in the target field to improve the accuracy of text error correction. The dictionary tree in the embodiment of the present disclosure is a tree structure in a professional field. The number of nodes in the dictionary tree is small, which can improve the efficiency of text error correction. After the dictionary tree is created, it can be reused, and new vocabulary can be added to the dictionary tree for maintenance.

[0084] Before using the trie, it is necessary to pre-create the trie for the target domain. One feasible way is to collect the vocabulary in the target domain; for any vocabulary, in the order of the characters in the vocabulary, use the first character as the parent node, and the other characters as child nodes in sequence, and add directed edges between the parent node and the child nodes in sequence to obtain the completed trie. Here, the other characters are the characters in any vocabulary except the first character. It should be noted that each node in the trie is associated with the corresponding character in the vocabulary, and each node represents the information of a character.

[0085] Figure 2 This is a schematic diagram of a partial trie provided by an exemplary embodiment of the present disclosure. As Figure 2 shown, collect the vocabulary in the medical field, such as: cough, expectoration, vaccine, and vaccination. Among them, in the order of the characters in the vocabulary, use the first character as the parent node, and the upper layer of the parent node is uniformly the root node, and the other characters are used as child nodes in sequence; among them, add a directed edge pointing to the child node between the parent node and the child node, and add a directed edge pointing to the parent node between the root node and the parent node. For example, when constructing the trie for "vaccination", the nodes of the trie have been constructed for "vaccine". Then, on the node path corresponding to "vaccine", continue to construct the nodes of "receive" and "vaccinate". At the same time, the child node corresponding to the last character of each vocabulary is used as the node of the vocabulary, and a word end flag is added to this node to indicate that the current node is the end position of the vocabulary, until a complete trie is constructed.

[0086] In some embodiments of the present disclosure, the domain corresponding to the text to be corrected is the same as the domain corresponding to the trie. After obtaining the text to be corrected in the target domain, perform a matching operation on each character in the text to be corrected with the characters corresponding to the nodes in the already created trie to obtain the target text path. One feasible way is to sequentially match the characters in the text to be corrected with the characters corresponding to the nodes in the first layer of the trie; if the i-th character in the text to be corrected satisfies the preset matching condition with the characters corresponding to at least one target node in the first layer of nodes, then match the (i + 1)-th character in the text to be corrected with the characters corresponding to the next layer of nodes associated with the target node until all the characters in the text to be corrected are matched, and obtain the characters corresponding to the matching nodes in the trie; where i is the position order of the characters in the text to be corrected; connect the characters in the text to be corrected that are not successfully matched with the characters corresponding to the matching nodes according to the directed edges between the nodes to form multiple candidate text paths; select the target text path that meets the similarity condition from the multiple candidate text paths according to the overall similarity of each of the multiple candidate text paths.

[0087] In some embodiments of the present disclosure, the characters in the text to be corrected are matched with the characters corresponding to the first-layer nodes in the dictionary tree. One achievable method is to calculate the similarity between the i-th character in the text to be corrected and each character corresponding to the first-layer nodes; select candidate nodes whose similarity is greater than the set similarity threshold from the first-layer nodes; and select target nodes of similarity order from the candidate nodes in descending order of similarity. It should be noted that the embodiments of the present disclosure do not limit the setting of the similarity threshold, and the similarity threshold can be adjusted according to actual conditions, for example, 0.5 and 0.6. The embodiments of the present disclosure do not limit the similarity order, and the similarity order can be adjusted according to actual conditions. Similarity order, for example, the first two with the largest similarity, the first three with the largest similarity, etc.

[0088] It should be noted that the vectorized objects of each character include but are not limited to: Chinese pinyin, glyph structure, strokes and Wubi structure.

[0089] In the above embodiment, the similarity between the i-th word and each word corresponding to the first layer node is calculated. One achievable method is that, for the first node in the first layer node, the i-th word and the word corresponding to the first node are vectorized to obtain the first character vector corresponding to the i-th word and the second character vector of the word corresponding to the first node; the first character vector and the second character vector are standardized respectively to obtain the first standardized vector and the second standardized vector; the cosine similarity between the first standardized vector and the second standardized vector is calculated as the similarity between the i-th word and the word corresponding to the first node. Among them, the Chinese pinyin, glyph structure, strokes and Wubi structure of each word are vectorized respectively and then spliced ​​together to obtain the character vector of the word. After the first character vector and the second character vector are squared and summed, a square root operation is performed to obtain the first standardized vector corresponding to the first character vector and the second standardized vector corresponding to the second character vector. The cosine similarity between the first standardized vector and the second standardized vector is calculated as the similarity between the i-th word and the word corresponding to the first node. The calculation formula is as follows:

[0090]

[0091] Where similarity represents the similarity between the i-th word and the word corresponding to the first node, A is the first normalized vector, and B is the second normalized vector. Since both A and B are unit vectors, the denominator on the right side of the equal sign is 1, and the similarity is equal to the sum of the bitwise products of each element of A and B.

[0092] In some embodiments of the present disclosure, the product of the similarities on each candidate text path is calculated as the overall similarity of each candidate text path. For example, in the candidate text path "I have a little cough", the similarity of "cough" is 1, and the similarity of "phlegm" is 0.6, then the overall similarity of the candidate text path is 1*0.6=0.6.

[0093] In some embodiments of the present disclosure, a target text path that meets a similarity condition is selected from the multiple candidate text paths according to their respective overall similarities. One achievable method is to select a target text path with the greatest overall similarity from the multiple candidate text paths according to their respective overall similarities.

[0094] Figure 3 A schematic diagram of a matching process between a text to be corrected and a dictionary tree provided in an embodiment of the present disclosure. Figure 3 The specific matching process between the text to be corrected and the dictionary tree is described. It should be noted that when there is only one candidate text path, the candidate text path is used as the target text path. The following takes the text to be corrected as "I have a cough" as an example, and there are multiple candidate text paths for explanation.

[0095] like Figure 3 As shown, if the first word input does not match successfully with all nodes in the first layer, it is considered that the first character does not belong to any word that needs to be corrected, and the second word input is matched with all nodes in the first layer, and so on for subsequent unsuccessful matches. If the i-th character input matches with the first-layer node, it is considered that the i-th character may be the first character of a correcting word in the dictionary; if the i-th word in the text to be corrected and the word corresponding to at least one target node in the first-layer node meet the preset matching conditions, then the i+1-th word in the text to be corrected is matched with the word corresponding to the next layer node associated with the target node, until all words in the text to be corrected are matched, and the word corresponding to the matching node in the dictionary tree is obtained; where i is the position order of the word in the text to be corrected.

[0096] The first three characters in the text to be corrected "I have a little cough" are not matched successfully with the characters corresponding to the nodes in the dictionary tree. The character "cough" matches the word in the dictionary. The similarity between the character "cough" and the "cough" in the dictionary tree is 1, and the similarity between the character "cough" and the "wash" in the dictionary tree is 0.5. Only the two largest paths are retained. That is, there are two possible matching paths, namely "I have a little cough" and "I have a little wash", with overall similarities of 1 and 0.5 respectively; in the case of retaining the two largest paths, both paths are retained and enter the next round of matching; in the case of matching the text to be corrected "Swish", the two largest paths mentioned above need to be matched separately. First, match the "I have a little cough" path, and the similarities of the text to be corrected "Swish" matching "Tan" and "Swoosh" are 0.6 and 0.8 respectively; the subsequent paths of this path "I have a little cough Swoosh" and "I have a little cough phlegm" have overall similarities of 0.8 and 0.6; then, match the "I have a little wash" path, the similarity of the "Swish" character matching is 1, and the overall similarity of "I have a little wash Swoosh" is 0.5; retain the two candidate text paths with the largest overall similarity "I have a little cough Swoosh" and "I have a little cough phlegm", and perform subsequent matching; after completing the matching of all characters of the input text, take the candidate path with the largest overall similarity "I have a little cough Swoosh", and the overall similarity score is 0.8. The error correction result of "I have a little cough" is output as "I have a little cough", and the error correction process ends.

[0097] In the above method embodiment of the present disclosure, a text to be corrected in a target field is obtained; each character in the text to be corrected is matched with the character corresponding to the node in the dictionary tree that has been created to obtain a target text path, wherein the dictionary tree is constructed by the vocabulary of the target field, and each node in the dictionary tree is associated with the corresponding character in the vocabulary; the text corresponding to the target text path is used as the corrected target text; the dictionary tree constructed by the vocabulary of the target field is matched with the text to be corrected in the target field, so that the text to be corrected in the target field can be corrected more accurately, thereby improving the accuracy of text correction.

[0098] Figure 4 FIG. 4 is a schematic diagram of a text processing device 40 provided in an exemplary embodiment of the present application. Figure 4 As shown, the text processing device 40 includes: an acquisition module 41, a matching module 42 and a correction module 43.

[0099] Wherein, the acquisition module 41 is used to acquire the text to be corrected in the target field;

[0100] A matching module 42 is used to match each word in the text to be corrected with the word corresponding to the node in the already created dictionary tree to obtain a target text path; wherein the dictionary tree is constructed by the vocabulary of the target field, and each node in the dictionary tree is associated with the corresponding word in the vocabulary;

[0101] The correction module 43 is used to use the text corresponding to the target text path as the corrected target text.

[0102] Optionally, before using the dictionary tree, the matching module 42 may also be used to:

[0103] Collect vocabulary in the target area;

[0104] For any word, according to the order of the characters in the word, the first character is used as the parent node, and the other characters are used as child nodes in turn. Directed edges are added between the parent node and the child node in turn to obtain the constructed dictionary tree, where the other characters are any characters in the word except the first character.

[0105] Optionally, the matching module 42 performs a matching operation on each word in the text to be corrected with the word corresponding to the node in the already created dictionary tree to obtain a target text path for:

[0106] Match the words in the text to be corrected with the words corresponding to the first-level nodes in the dictionary tree in turn;

[0107] If the i-th word in the text to be corrected and the word corresponding to at least one target node in the first layer of nodes meet the preset matching condition, then the i+1-th word in the text to be corrected is matched with the word corresponding to the next layer of nodes associated with the target node until all the words in the text to be corrected are matched, and the word corresponding to the matching node in the dictionary tree is obtained; wherein i is the position order of the word in the text to be corrected;

[0108] According to the directed edges between the nodes, the unmatched characters in the text to be corrected are connected with the characters corresponding to the matching nodes to form multiple candidate text paths;

[0109] According to the overall similarities of the multiple candidate text paths, a target text path that meets the similarity condition is selected from the multiple candidate text paths.

[0110] Optionally, when matching the characters in the text to be corrected with the characters corresponding to the first-layer nodes in the dictionary tree respectively, the matching module 42 is used to:

[0111] For the i-th word in the text to be corrected, calculate the similarity between the i-th word and each word corresponding to the first layer node;

[0112] Select candidate nodes whose similarity is greater than the set similarity threshold from the first layer nodes;

[0113] In descending order of similarity, select the target node with the similarity order from the candidate nodes.

[0114] Optionally, the similarity is cosine similarity, and the matching module 42 is used to calculate the similarity between the i-th word and each word corresponding to the first layer node:

[0115] For the first node in the first layer of nodes, the i-th word and the word corresponding to the first node are vectorized to obtain a first character vector corresponding to the i-th word and a second character vector of the word corresponding to the first node;

[0116] Normalize the first character vector and the second character vector respectively to obtain a first normalized vector and a second normalized vector;

[0117] The cosine similarity between the first normalized vector and the second normalized vector is calculated as the similarity between the i-th word and the word corresponding to the first node.

[0118] Optionally, before selecting a target text path satisfying a similarity condition from a plurality of candidate text paths according to the overall similarities of the plurality of candidate text paths, the matching module 42 may also be used to:

[0119] The product of the similarities on each candidate text path is calculated as the overall similarity of each candidate text path.

[0120] Optionally, when selecting a target text path that meets a similarity condition from a plurality of candidate text paths according to the overall similarities of the plurality of candidate text paths, the matching module 42 is configured to:

[0121] According to the overall similarities of the multiple candidate text paths, a target text path with the greatest overall similarity is selected from the multiple candidate text paths.

[0122] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0123] Figure 5 The following is a schematic diagram of the structure of an electronic device provided by an exemplary embodiment of the present application. Figure 5 As shown, the electronic device includes: a memory 51 and a processor 52. In addition, the electronic device also includes a power supply component 53 and a communication component 54.

[0124] The memory 51 is used to store computer programs and can be configured to store various other data to support operations on the electronic device. Examples of such data include instructions for any application program or method operating on the electronic device.

[0125] The memory 51 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0126] The communication component 54 is used for data transmission with other devices.

[0127] The processor 52 can execute computer instructions stored in the memory 51 to: obtain the text to be revised in the target field; match each word in the text to be revised with the word corresponding to the node in the dictionary tree that has been created to obtain the target text path; wherein the dictionary tree is constructed by the vocabulary of the target field, and each node in the dictionary tree is associated with the corresponding word in the vocabulary; and use the text corresponding to the target text path as the revised target text.

[0128] Optionally, before using the dictionary tree, the processor 52 may also be used to:

[0129] Collect vocabulary in the target area;

[0130] For any word, according to the order of the characters in the word, the first character is used as the parent node, and the other characters are used as child nodes in turn. Directed edges are added between the parent node and the child node in turn to obtain the constructed dictionary tree, where the other characters are any characters in the word except the first character.

[0131] Optionally, when the processor 52 performs a matching operation on each word in the text to be corrected with the word corresponding to the node in the already created dictionary tree to obtain the target text path, it is used to:

[0132] Match the words in the text to be corrected with the words corresponding to the first-level nodes in the dictionary tree in turn;

[0133] If the i-th word in the text to be corrected and the word corresponding to at least one target node in the first layer of nodes meet the preset matching condition, then the i+1-th word in the text to be corrected is matched with the word corresponding to the next layer of nodes associated with the target node until all the words in the text to be corrected are matched, and the word corresponding to the matching node in the dictionary tree is obtained; wherein i is the position order of the word in the text to be corrected;

[0134] According to the directed edges between the nodes, the unmatched characters in the text to be corrected are connected with the characters corresponding to the matching nodes to form multiple candidate text paths;

[0135] According to the overall similarities of the multiple candidate text paths, a target text path that meets the similarity condition is selected from the multiple candidate text paths.

[0136] Optionally, matching the characters in the text to be corrected with the characters corresponding to the first-layer nodes in the dictionary tree respectively includes:

[0137] For the i-th word in the text to be corrected, calculate the similarity between the i-th word and each word corresponding to the first layer node;

[0138] Select candidate nodes whose similarity is greater than the set similarity threshold from the first layer nodes;

[0139] In descending order of similarity, select the target node with the similarity order from the candidate nodes.

[0140] Optionally, the similarity is cosine similarity, and the processor 52 is used to calculate the similarity between the i-th word and each word corresponding to the first layer node:

[0141] For the first node in the first layer of nodes, the i-th word and the word corresponding to the first node are vectorized to obtain a first character vector corresponding to the i-th word and a second character vector of the word corresponding to the first node;

[0142] Normalize the first character vector and the second character vector respectively to obtain a first normalized vector and a second normalized vector;

[0143] The cosine similarity between the first normalized vector and the second normalized vector is calculated as the similarity between the i-th word and the word corresponding to the first node.

[0144] Optionally, before selecting a target text path satisfying a similarity condition from a plurality of candidate text paths according to the overall similarities of the plurality of candidate text paths, the processor 52 is configured to:

[0145] The product of the similarities on each candidate text path is calculated as the overall similarity of each candidate text path.

[0146] Optionally, when selecting a target text path satisfying a similarity condition from a plurality of candidate text paths according to the overall similarities of the plurality of candidate text paths, the processor 52 is configured to:

[0147] According to the overall similarities of the multiple candidate text paths, a target text path with the greatest overall similarity is selected from the multiple candidate text paths.

[0148] Accordingly, an embodiment of the present application further provides a computer-readable storage medium storing a computer program. When the computer-readable storage medium stores the computer program and the computer program is executed by one or more processors, the one or more processors execute Figure 1 Each step in the method embodiment.

[0149] Accordingly, the embodiment of the present application also provides a computer program product, the computer program product includes a computer program / instruction, and the computer program / instruction is executed by a processor. Figure 1 Each step in the method embodiment.

[0150] Above Figure 5 The communication component in is configured to facilitate wired or wireless communication between the device where the communication component is located and other devices. The device where the communication component is located can access a wireless network based on a communication standard, such as WiFi, 2G, 3G, 4G / LTE, 5G and other mobile communication networks, or a combination thereof. In an exemplary embodiment, the communication component receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0151] Above Figure 5 The power supply component in the device provides power to various components of the device where the power supply component is located. The power supply component may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the device where the power supply component is located.

[0152] Above Figure 5 The display screen in the embodiment includes a screen, which may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation.

[0153] The electronic device mentioned above also includes an audio component.

[0154] The audio component may be configured to output and / or input audio signals. For example, the audio component includes a microphone (MIC), and when the device where the audio component is located is in an operating mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal may be further stored in a memory or sent via a communication component. In some embodiments, the audio component also includes a speaker for outputting an audio signal.

[0155] In the embodiments of the above-mentioned apparatus, device, storage medium and computer program product of the present disclosure, a text to be corrected in a target field is obtained; each word in the text to be corrected is matched with the word corresponding to the node in the dictionary tree that has been created to obtain a target text path, wherein the dictionary tree is constructed by the vocabulary of the target field, and each node in the dictionary tree is associated with the corresponding word in the vocabulary; the text corresponding to the target text path is used as the corrected target text; the dictionary tree constructed by the vocabulary of the target field is matched with the text to be corrected in the target field, so that the text to be corrected in the target field can be corrected more accurately, thereby improving the accuracy of text correction.

[0156] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0157] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0158] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0159] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0160] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0161] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0162] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0163] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0164] The above is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to these embodiments herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A text processing method, characterized in that: include: Get the text to be revised in the target area; Matching each word in the text to be corrected with the word corresponding to the node in the already created dictionary tree to obtain the target text path; wherein the dictionary tree is constructed by the vocabulary of the target field, and each node in the dictionary tree is associated with the corresponding word in the vocabulary; The text corresponding to the target text path is used as the corrected target text.

2. The method according to claim 1, characterized in that Before using the dictionary tree, the method further includes: collecting the vocabulary of the target domain; For any of the words, in the order of the characters in the word, the first character is used as the parent node, and the other characters are used as child nodes in turn, and directed edges are added between the parent node and the child nodes in turn to obtain the constructed dictionary tree, wherein the other characters are the characters of any of the words except the first character.

3. The method according to claim 1, characterized in that The step of matching each word in the text to be corrected with the word corresponding to the node in the created dictionary tree to obtain the target text path includes: Matching the characters in the text to be corrected with the characters corresponding to the first-layer nodes in the dictionary tree in sequence; If the i-th word in the text to be corrected and the word corresponding to at least one target node in the first layer of nodes meet the preset matching condition, then the i+1-th word in the text to be corrected is matched with the word corresponding to the next layer of nodes associated with the target node, until all the words in the text to be corrected are matched, and the word corresponding to the matching node in the dictionary tree is obtained; wherein i is the position order of the word in the text to be corrected; According to the directed edges between the nodes, the unmatched characters in the text to be corrected are connected with the characters corresponding to the matching nodes to form a plurality of candidate text paths; According to the overall similarities of the plurality of candidate text paths, a target text path that meets the similarity condition is selected from the plurality of candidate text paths.

4. The method according to claim 3, characterized in that The step of matching the characters in the text to be corrected with the characters corresponding to the first-layer nodes in the dictionary tree respectively includes: For the i-th word in the text to be corrected, respectively calculate the similarity between the i-th word and each word corresponding to the first layer node; Selecting candidate nodes whose similarity is greater than a set similarity threshold from the first layer nodes; According to the order of the similarity from large to small, the target node of the similarity order is selected from the candidate nodes.

5. The method according to claim 4, characterized in that The similarity is cosine similarity, and the calculating of the similarity between the i-th word and each word corresponding to the first layer node includes: For a first node in the first layer of nodes, vectorize the i-th word and the word corresponding to the first node to obtain a first character vector corresponding to the i-th word and a second character vector of the word corresponding to the first node; Normalizing the first character vector and the second character vector respectively to obtain a first normalized vector and a second normalized vector; The cosine similarity between the first normalized vector and the second normalized vector is calculated as the similarity between the i-th word and the word corresponding to the first node.

6. The method according to claim 3, characterized in that Before selecting a target text path that meets a similarity condition from the plurality of candidate text paths according to the overall similarities of the plurality of candidate text paths, the method further includes: The product of the similarities on each of the candidate text paths is calculated as the overall similarity of each of the candidate text paths.

7. The method according to claim 3, characterized in that The step of selecting a target text path that meets a similarity condition from the plurality of candidate text paths according to the overall similarities of the plurality of candidate text paths comprises: According to the overall similarities of the plurality of candidate text paths, a target text path with the greatest overall similarity is selected from the plurality of candidate text paths.

8. A text processing device, characterized in that: include: An acquisition module, used for acquiring the text to be corrected in the target field; A matching module, used for matching each word in the text to be corrected with the word corresponding to the node in the already created dictionary tree to obtain a target text path; wherein the dictionary tree is constructed by the vocabulary of the target field, and each node in the dictionary tree is associated with a corresponding word in the vocabulary; The correction module is used to use the text corresponding to the target text path as the corrected target text.

9. The device according to claim 8, characterized in that Before using the dictionary tree, the matching module can also be used to: collecting the vocabulary of the target domain; For any of the words, in the order of the characters in the word, the first character is used as the parent node, and the other characters are used as child nodes in turn, and directed edges are added between the parent node and the child nodes in turn to obtain the constructed dictionary tree, wherein the other characters are the characters of any of the words except the first character.

10. The device according to claim 8, characterized in that The matching module performs matching operations on each word in the text to be corrected with the words corresponding to the nodes in the created dictionary tree to obtain a target text path, which is used to: Matching the characters in the text to be corrected with the characters corresponding to the first-layer nodes in the dictionary tree in sequence; If the i-th word in the text to be corrected and the word corresponding to at least one target node in the first layer of nodes meet the preset matching condition, then the i+1-th word in the text to be corrected is matched with the word corresponding to the next layer of nodes associated with the target node, until all the words in the text to be corrected are matched, and the word corresponding to the matching node in the dictionary tree is obtained; wherein i is the position order of the word in the text to be corrected; According to the directed edges between the nodes, the unmatched characters in the text to be corrected are connected with the characters corresponding to the matching nodes to form a plurality of candidate text paths; According to the overall similarities of the plurality of candidate text paths, a target text path that meets the similarity condition is selected from the plurality of candidate text paths.

11. The device according to claim 10, characterized in that When matching the characters in the text to be corrected with the characters corresponding to the first-layer nodes in the dictionary tree respectively, the matching module is used to: For the i-th word in the text to be corrected, respectively calculate the similarity between the i-th word and each word corresponding to the first layer node; Selecting candidate nodes whose similarity is greater than a set similarity threshold from the first layer nodes; According to the order of the similarity from large to small, the target node of the similarity order is selected from the candidate nodes.

12. The device according to claim 11, characterized in that The similarity is cosine similarity, and the matching module is used to calculate the similarity between the i-th word and each word corresponding to the first layer node: For a first node in the first layer of nodes, vectorize the i-th word and the word corresponding to the first node to obtain a first character vector corresponding to the i-th word and a second character vector of the word corresponding to the first node; Normalizing the first character vector and the second character vector respectively to obtain a first normalized vector and a second normalized vector; The cosine similarity between the first normalized vector and the second normalized vector is calculated as the similarity between the i-th word and the word corresponding to the first node.

13. The device according to claim 10, characterized in that Before selecting a target text path that meets a similarity condition from the plurality of candidate text paths according to the overall similarities of the plurality of candidate text paths, the matching module may also be used to: The product of the similarities on each of the candidate text paths is calculated as the overall similarity of each of the candidate text paths.

14. The device according to claim 10, characterized in that When the matching module selects a target text path that meets a similarity condition from the plurality of candidate text paths according to the overall similarities of the plurality of candidate text paths, it is used to: According to the overall similarities of the plurality of candidate text paths, a target text path with the greatest overall similarity is selected from the plurality of candidate text paths.

15. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement each step in the method according to any one of claims 1 to 7.

16. A computer-readable storage medium, characterized in that: The computer instructions are used to enable the computer to execute each step in the method according to any one of claims 1 to 7.

17. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Path positioning method and device based on dictionary tree structure and weight learning and medium

    CN120743791A