A document processing method, apparatus, device, and storage medium
By performing word segmentation and semantic similarity calculation on the text in the front-end system, and automatically grouping and replacing inconsistent words, the problem of low efficiency in the consistency check of the front-end system text is solved, and efficient and accurate text consistency correction is achieved.
Patent Information
- Application Number
- CN202411696567.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-25
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2044-11-25
AI Technical Summary
In existing technologies, the consistency check of front-end system copy is inefficient and prone to missed detections and misjudgments, especially as the system size and complexity increase, making it difficult to guarantee consistency.
By segmenting the text, calculating the semantic similarity between words, grouping words with similar semantics, and finding and replacing words that are inconsistent with the preset correct words, consistency correction of the text is achieved.
It improved the efficiency and accuracy of the front-end system's copy consistency check, saving manpower and time costs.
Smart Images

Figure CN119692348B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a document processing method and apparatus, an electronic device, and a storage medium. Background Technology
[0002] In today's digital age, front-end systems have become one of the primary ways for businesses and individuals to interact with users. However, the management of copy in front-end systems often faces the serious challenge of ensuring consistency. Due to the complexity of the system structure and the inherent limitations of manual checks, traditional copy consistency checking methods are often inefficient and prone to omissions and misjudgments.
[0003] Traditional methods for checking copy consistency in related technologies typically rely on manual review. This approach is not only time-consuming and labor-intensive but also susceptible to human factors such as fatigue and lack of concentration. As the scale and complexity of front-end systems continue to increase, the quantity and variety of copy are also growing rapidly, making manual review even more difficult and unreliable. Furthermore, front-end systems often consist of multiple modules and pages, which may be the responsibility of different development teams or individuals, further complicating copy consistency management.
[0004] Therefore, there is an urgent need in this field for a front-end system document consistency check and processing method that can significantly improve the efficiency and accuracy of the inspection. Summary of the Invention
[0005] This application provides a document processing method to address the problem of how to provide a front-end system document consistency checking and processing method that can significantly improve the efficiency and accuracy of inspection.
[0006] Accordingly, embodiments of this application also provide a document processing device, an electronic device, and a storage medium to ensure the implementation and application of the above methods.
[0007] To address the aforementioned problems, this application discloses a document processing method, the method comprising:
[0008] The text is segmented into words to obtain several words to be grouped.
[0009] Calculate the first semantic similarity between the words to be grouped;
[0010] Based on the first semantic similarity, the words to be grouped are grouped into word combinations, and the word combinations contain words to be grouped with similar semantics;
[0011] In the word combination, find words that do not match the preset correct words and use them as words to be replaced;
[0012] The target word combination is obtained by replacing the word to be replaced with the preset correct word.
[0013] The target word combination is used to correct the word combination in the copy to obtain the target copy.
[0014] Optionally, calculating the first semantic similarity between the words to be grouped includes:
[0015] Convert the words to be grouped into word vectors;
[0016] Calculate the first semantic similarity between each of the word vectors and the remaining word vectors.
[0017] Optionally, grouping the words to be grouped into word combinations based on the first semantic similarity includes:
[0018] For the target word vectors corresponding to the target words to be grouped, obtain the first semantic similarity between the target word vectors and the remaining word vectors;
[0019] The remaining word vectors of the target are obtained by filtering out those whose first semantic similarity to the target is higher than a preset similarity threshold;
[0020] The words to be grouped corresponding to the remaining word vectors of the target are regarded as similar semantic words;
[0021] The target words to be grouped are divided into word groups with the words with similar semantic meanings.
[0022] Optionally, the step of searching for words in the word combination that do not match the preset correct words as words to be replaced includes:
[0023] Combine the preset correct words into a set of correct words;
[0024] Obtain the target preset correct words from the set of correct words;
[0025] Calculate the second semantic similarity between the target preset correct word and the words to be grouped in each word combination;
[0026] Based on the second semantic similarity, select target word combinations;
[0027] In the target word combination, find words that are inconsistent with the target preset correct words and use them as the words to be replaced.
[0028] Optionally, the step of replacing the word to be replaced with the preset correct word to obtain the target word combination includes:
[0029] Determine whether the first semantic similarity corresponding to the word to be replaced is higher than the replacement threshold;
[0030] When the first semantic similarity corresponding to the word to be replaced is higher than the replacement threshold, the preset correct word is used to replace the word to be replaced.
[0031] Optionally, the text is segmented to obtain several words to be grouped, including:
[0032] The text extraction expression is used to traverse the code that needs to be processed to obtain the text;
[0033] The text is segmented into words to obtain several segmented words;
[0034] The segmented words are filtered to obtain the words to be grouped.
[0035] Optionally, the method includes:
[0036] Detect the target code corresponding to the target text;
[0037] If the target code does not contain the word to be replaced, then the target code can be submitted.
[0038] If the target code contains the word to be replaced, then the submission of the target code is paused.
[0039] This application also discloses a document processing device, the device comprising:
[0040] The word segmentation module is used to segment the text into words to obtain several words to be grouped.
[0041] The first semantic similarity calculation module is used to calculate the first semantic similarity between the words to be grouped;
[0042] The word grouping module is used to group the words to be grouped into word combinations based on the first semantic similarity, wherein the word combinations contain words to be grouped with similar semantics;
[0043] The word to be replaced module is used to find words in the word combination that are inconsistent with the preset correct words as words to be replaced;
[0044] The word replacement module is used to replace the word to be replaced with the preset correct word to obtain the target word combination;
[0045] A consistency processing module is used to correct the word combination in the copy using the target word combination to obtain the target copy.
[0046] This application also discloses an electronic device, including: a processor; and a memory storing executable code thereon, which, when executed, causes the processor to perform one or more of the document processing methods described in this application.
[0047] This application also discloses one or more machine-readable media storing executable code thereon, which, when executed, causes a processor to perform one or more of the document processing methods described in this application.
[0048] Compared with the prior art, the embodiments of this application have the following advantages:
[0049] In this embodiment, the text is segmented to obtain several words to be grouped; the first semantic similarity between the words to be grouped is calculated; the words to be grouped are grouped into word combinations based on the first semantic similarity, and each word combination contains words to be grouped with similar semantics; words in the word combinations that are inconsistent with the preset correct words are searched as words to be replaced; the words to be replaced are replaced with the preset correct words to obtain the target word combination; the word combinations in the text are corrected using the target word combination to obtain the target text. This embodiment automatically performs consistency checks and processing on the text of the front-end system based on the first semantic similarity, improving the efficiency and accuracy of the consistency checks of the front-end system, thereby saving manpower and time costs. Attached Figure Description
[0050] Figure 1 This is a flowchart illustrating the steps of an embodiment of a document processing method according to this application;
[0051] Figure 2 This is a flowchart illustrating an embodiment of a document processing method according to this application;
[0052] Figure 3 This is a structural block diagram of an embodiment of a document processing device according to this application;
[0053] Figure 4 This is a schematic diagram of the structure of a device provided in an embodiment of this application. Detailed Implementation
[0054] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0055] Reference Figure 1 This is a flowchart illustrating the steps of an embodiment of a document processing method according to this application, including the following steps:
[0056] Step 101: Perform word segmentation on the text to obtain several words to be grouped.
[0057] In this embodiment of the application, the text needs to be extracted from the target code before the text is segmented.
[0058] In one embodiment, the target code can be code used by the front-end system. If users want the copy in the front-end system to be consistent in semantics and style, that is, to use the same vocabulary to describe the same things, so that customers browsing the front-end system can easily understand the copy content, then the copy can be extracted from the target code of the front-end system for consistency processing, so that the same vocabulary is used to describe the same things in the copy.
[0059] Before step 101, in one embodiment, regular expressions can be used to extract the text string from the target code as the text of the target code.
[0060] In step 101, the text is segmented into words, converted into a unified word format, resulting in several words to be grouped. In an optional embodiment, the Chinese text can be segmented using the Jieba word segmentation dictionary. Jieba is a Chinese word segmentation tool that uses a dictionary to assist in word segmentation.
[0061] Step 102: Calculate the first semantic similarity between the words to be grouped.
[0062] In one embodiment, the words to be grouped can be first converted into corresponding word vectors, and then the first semantic similarity between each pair of words to be grouped can be calculated based on the word vectors.
[0063] In one embodiment, for each word to be grouped, a first semantic similarity between the word vectors of each word to be grouped can be calculated using methods such as cosine similarity.
[0064] Step 103: Group the words to be grouped into word combinations based on the first semantic similarity, wherein the word combinations contain words to be grouped with similar semantics.
[0065] In step 103, based on the first semantic similarity, words with similar semantics are grouped into the same word combination, thereby obtaining one or more word combinations.
[0066] In one embodiment, several first semantic similarities corresponding to each word to be grouped are filtered, and words with first semantic similarities higher than a preset similarity threshold are regarded as words with similar semantics to the word to be grouped, and are grouped into the same word group with the word to be grouped.
[0067] For example, if the current word to be grouped is "network management method", and the first semantic similarity between "network management policy", "network management plan", "network management program", "network management means" and "network management method" is higher than the preset similarity threshold, then "network management policy, network management plan, network management program, network management method, network management means" will be grouped as a single word combination.
[0068] In one example, word combinations can be displayed on the results page.
[0069] Step 104: Find words in the word combination that are inconsistent with the preset correct words as words to be replaced.
[0070] In step 104, preset correct words can be set in advance for each word combination to replace the words to be replaced in the word combination. The words to be replaced are words in the word combination that are inconsistent with the preset correct words. Therefore, words that are inconsistent with the preset correct words can be searched in the word combination as words to be replaced.
[0071] For example, if a word combination is obtained as "network management policy, network management scheme, network management plan, network management method, network management means", and the default correct word for this word combination is "network management method", then "network management policy, network management scheme, network management plan, network management means" will be used as the words to be replaced.
[0072] Step 105: Replace the word to be replaced with the preset correct word to obtain the target word combination.
[0073] Replace the word to be replaced in the word combination with the preset correct word to obtain the target word combination.
[0074] In one example, if a word combination is “network management policy, network management scheme, network management plan, network management method, network management means”, and the default correct word for this word combination is “network management method”, then the target word combination after replacement is “network management method, network management method, network management method, network management method, network management method”, so that the same vocabulary is used to describe the same thing.
[0075] Step 106: Correct the word combination in the copy using the target word combination to obtain the target copy.
[0076] After obtaining the target word combination, the word combinations in the original copy are corrected using the target word combination. Specifically, words in the original copy that correspond to the words to be replaced in the target word combination are replaced with the words corresponding to the target word combination, thus obtaining the target copy. The target copy is copy that, after consistency processing, uses the same vocabulary to describe the same things.
[0077] Furthermore, the code used by the front-end system can be corrected based on the target text to achieve consistency in the text used in the front-end system code. In one embodiment, the code file can be scanned and the replaceAll function in JavaScript (a scripting language widely used in client-side development) can be executed for global replacement, automatically correcting inconsistent text in the code.
[0078] In this embodiment, the text is segmented to obtain several words to be grouped; the first semantic similarity between the words to be grouped is calculated; the words to be grouped are grouped into word combinations based on the first semantic similarity, and each word combination contains words to be grouped with similar semantics; words in the word combinations that are inconsistent with the preset correct words are searched as words to be replaced; the words to be replaced are replaced with the preset correct words to obtain the target word combination; the word combinations in the text are corrected using the target word combination to obtain the target text. This embodiment automatically performs consistency checks and processing on the text of the front-end system based on the first semantic similarity, improving the efficiency and accuracy of the consistency checks of the front-end system, thereby saving manpower and time costs.
[0079] In an optional embodiment of this application, step 102, calculating the first semantic similarity between the words to be grouped, includes:
[0080] Convert the words to be grouped into word vectors;
[0081] Calculate the first semantic similarity between each of the word vectors and the remaining word vectors.
[0082] In this embodiment, the words to be grouped can be converted into word vectors before calculating the first semantic similarity. In one embodiment, a pre-trained word vector model, such as Word2Vec (a word embedding technique), GloVe (Global Vectors for Word Representation, a word embedding technique), or BERT (Bidirectional Encoder Representations from Transformers, a pre-trained language model), can be used to convert each word to be grouped into word vector form.
[0083] For each word vector, calculate the first semantic similarity between each word vector and the other word vectors, thereby obtaining the first semantic similarity between each pair of words to be grouped.
[0084] In this embodiment, the words to be grouped are first converted into word vectors, and then the first semantic similarity between the words to be grouped is calculated. The first semantic similarity can be used to group the words to be grouped in the future.
[0085] In an optional embodiment of this application, in step 103, grouping the words to be grouped into word combinations based on the first semantic similarity includes:
[0086] For the target word vectors corresponding to the target words to be grouped, obtain the first semantic similarity between the target word vectors and the remaining word vectors;
[0087] The remaining word vectors of the target are obtained by filtering out those whose first semantic similarity to the target is higher than a preset similarity threshold;
[0088] The words to be grouped corresponding to the remaining word vectors of the target are regarded as similar semantic words;
[0089] The target words to be grouped are divided into word groups with the words with similar semantic meanings.
[0090] In this embodiment, the words to be grouped can be grouped into word combinations using the following method.
[0091] The words to be grouped are traversed, and the currently traversed word to be grouped is taken as the target word to be grouped. For the target word vector corresponding to the target word to be grouped, the first semantic similarity between the target word vector and the remaining word vectors corresponding to the other words to be grouped is obtained.
[0092] The remaining word vectors with a first semantic similarity to the target higher than a preset similarity threshold are selected to obtain the remaining word vectors of the target. In one embodiment, the remaining word vectors can also be sorted from high to low according to the first semantic similarity to the target, and the top N remaining word vectors are selected as the remaining word vectors of the target, where N is an integer.
[0093] The words to be grouped corresponding to the remaining word vectors of the target are treated as similar semantic words, thus dividing the target words to be grouped into word combinations with similar semantic words. By processing each word to be grouped in turn, one or more word combinations can be obtained.
[0094] This application embodiment groups words with similar semantics into the same word combination, thereby obtaining one or more word combinations. Subsequently, the words to be replaced in the word combination can be replaced using preset correct words, which improves the efficiency and accuracy of the front-end system's text consistency check, thereby saving manpower and time costs.
[0095] In an optional embodiment of this application, in step 104, the step of searching for words in the word combination that are inconsistent with the preset correct words as words to be replaced includes:
[0096] Combine the preset correct words into a set of correct words;
[0097] Obtain the target preset correct words from the set of correct words;
[0098] Calculate the second semantic similarity between the target preset correct word and the words to be grouped in each word combination;
[0099] Based on the second semantic similarity, select target word combinations;
[0100] In the target word combination, find words that are inconsistent with the target preset correct words and use them as the words to be replaced.
[0101] In this embodiment, preset correct words can be combined into a set of correct words, and then a group of semantically similar word combinations can be automatically analyzed and replaced. In one embodiment, commas or spaces can be used to distinguish different preset correct words, thereby obtaining a set of correct words.
[0102] The set of correct words is traversed, and the currently traversed preset correct word is taken as the target preset correct word. In this way, the target preset correct word is obtained from the set of correct words.
[0103] Calculate the second semantic similarity between the target preset correct word and the words to be grouped in each word combination. In an optional embodiment, methods such as cosine similarity can be used to calculate the second semantic similarity between the target preset correct word and the words to be grouped in each word combination. Further, the second semantic similarity between the target preset correct word and the words to be grouped in each word combination can be summarized according to word combinations to obtain the second semantic similarity corresponding to each word combination.
[0104] Target word combinations are selected based on semantic similarity. In one example, word combinations can be sorted from high to low semantic similarity, and the top-ranked combination is selected as the target word combination. After obtaining the target word combinations, words that do not match the preset correct words are identified as replacement words and then replaced.
[0105] This application embodiment can first pre-set correct word combinations into a correct word set, and automatically analyze a group of semantically similar word combinations for replacement, thereby improving the efficiency of the front-end system's text consistency check and saving manpower and time costs.
[0106] In an optional embodiment of this application, step 105, which involves replacing the word to be replaced with the preset correct word to obtain the target word combination, includes:
[0107] Determine whether the first semantic similarity corresponding to the word to be replaced is higher than the replacement threshold;
[0108] When the first semantic similarity corresponding to the word to be replaced is higher than the replacement threshold, the preset correct word is used to replace the word to be replaced.
[0109] In this embodiment, a replacement threshold can be preset. When replacing a word, it is first determined whether the first semantic similarity of the word to be replaced is higher than the replacement threshold. If the first semantic similarity of the word to be replaced is higher than the replacement threshold, a preset correct word is used to replace the word to be replaced; if the first semantic similarity of the word to be replaced is lower than the replacement threshold, no replacement is performed.
[0110] In one optional embodiment, multiple preset correct words and multiple corresponding replacement thresholds can be set for the same word combination. Once the first semantic similarity of the word to be replaced meets a certain replacement threshold, the preset correct word corresponding to that replacement threshold is used to replace the word to be replaced.
[0111] This application embodiment pre-sets a replacement threshold. When replacing a word, it first determines whether the first semantic similarity of the word to be replaced is higher than the replacement threshold before performing the replacement, thereby improving the accuracy of the front-end system's text consistency check.
[0112] In an optional embodiment of this application, in step 101, the text is segmented to obtain several words to be grouped, including:
[0113] The text extraction expression is used to traverse the code that needs to be processed to obtain the text;
[0114] The text is segmented into words to obtain several segmented words;
[0115] The segmented words are filtered to obtain the words to be grouped.
[0116] In this embodiment of the application, the text needs to be segmented and filtered before consistency processing is performed.
[0117] Specifically, before performing word segmentation on the text, a text extraction expression can be used to traverse the code that needs to be processed and obtain the text. For example, the text extraction expression can be a regular expression. Taking a Chinese sentence as an example, the corresponding regular expression can be ^[\u4e00-\u9fa5\uff01-\uff5e 0-9,。 、? ! ;:]+$.
[0118] The text is segmented into words, resulting in several segmented terms. These segmented terms can then be filtered to obtain a number of terms to be grouped. In one example, filtering the segmented terms can remove meaningless words such as stop words, thus reducing noise.
[0119] Before performing consistency processing on the text, this application embodiment first obtains the text from the code that needs to be processed, and performs word segmentation and filtering, thereby improving the accuracy of the text consistency check in the front-end system.
[0120] In one optional embodiment of this application, the method includes:
[0121] Detect the target code corresponding to the target text;
[0122] If the target code does not contain the word to be replaced, then the target code can be submitted.
[0123] If the target code contains the word to be replaced, then the submission of the target code is paused.
[0124] In this embodiment of the application, before code merging, that is, before the CI (Continuous Integration) phase of code repository merging, a consistency check can be performed on the code to find out whether there are still words to be replaced.
[0125] Specifically, the target code corresponding to the target text is detected. If the target code does not contain any words to be replaced, the submission of the target code is allowed; if the target code contains words to be replaced, the submission of the target code is suspended, and the target text in the target code is processed for consistency according to one of the text processing methods in the above embodiment before the detection is performed again.
[0126] In one embodiment, the target code corresponding to the target text can be detected through a git hook (a mechanism provided by Git).
[0127] Before merging the code, this application embodiment performs a consistency check on the code to find out if there are still words to be replaced, which improves the accuracy of the copy consistency check in the front-end system.
[0128] In one optional embodiment of this application, a vscode (Visual Studio Code, a code editor) plugin can be set up to automatically perform validation actions in the current system root directory. The results page will display the results in groups based on synonyms. For each group of words, if the correct text is entered, a replacement action will be performed to automatically replace the relevant text, thereby further improving the efficiency of the front-end system's text consistency check and saving manpower and time costs.
[0129] In this embodiment, the text is segmented to obtain several words to be grouped; the first semantic similarity between the words to be grouped is calculated; the words to be grouped are grouped into word combinations based on the first semantic similarity, and each word combination contains words to be grouped with similar semantics; words in the word combinations that are inconsistent with the preset correct words are searched as words to be replaced; the words to be replaced are replaced with the preset correct words to obtain the target word combination; the word combinations in the text are corrected using the target word combination to obtain the target text. This embodiment automatically performs consistency checks and processing on the text of the front-end system based on the first semantic similarity, improving the efficiency and accuracy of the consistency checks of the front-end system, thereby saving manpower and time costs.
[0130] Reference Figure 2 This is a flowchart illustrating an embodiment of a document processing method of this application.
[0131] like Figure 2 The diagram illustrates the complete flow of an embodiment of a document processing method provided in this application.
[0132] Step 1: Extract all text data from the code.
[0133] Step 2: Preprocess and segment the text data to convert it into standardized word format.
[0134] Step 3: Group and display words with similar meanings by similarity calculation.
[0135] Step 4: Input the correct set of text, and the system will automatically correct any inconsistencies in the code.
[0136] Step 5: Integrate this feature into the front-end development environment.
[0137] In this embodiment, the text is segmented to obtain several words to be grouped; the first semantic similarity between the words to be grouped is calculated; the words to be grouped are grouped into word combinations based on the first semantic similarity, and each word combination contains words to be grouped with similar semantics; words in the word combinations that are inconsistent with the preset correct words are searched as words to be replaced; the words to be replaced are replaced with the preset correct words to obtain the target word combination; the word combinations in the text are corrected using the target word combination to obtain the target text. This embodiment automatically performs consistency checks and processing on the text of the front-end system based on the first semantic similarity, improving the efficiency and accuracy of the consistency checks of the front-end system, thereby saving manpower and time costs.
[0138] It should be noted that, for the sake of simplicity, the method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments of this application are not limited to the described order of actions, because according to the embodiments of this application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of this application.
[0139] Based on the above embodiments, this embodiment also provides a document processing device that can be applied to electronic devices such as terminal devices and servers.
[0140] Reference Figure 3 The diagram shows a structural block diagram of an embodiment of a document processing device according to this application, which may specifically include the following modules:
[0141] The word segmentation module 301 is used to segment the text to obtain several words to be grouped.
[0142] The first semantic similarity calculation module 302 is used to calculate the first semantic similarity between the words to be grouped;
[0143] The word grouping module 303 is used to group the words to be grouped into word combinations based on the first semantic similarity, wherein the word combinations contain words to be grouped with similar semantics;
[0144] The word-to-be-replaced module 304 is used to find words in the word combination that are inconsistent with the preset correct words as words to be replaced;
[0145] The word replacement module 305 is used to replace the word to be replaced with the preset correct word to obtain the target word combination;
[0146] The consistency processing module 306 is used to correct the word combination in the copy using the target word combination to obtain the target copy.
[0147] In an optional embodiment of this application, the first semantic similarity calculation module 302 includes:
[0148] The vector transformation submodule is used to convert the words to be grouped into word vectors;
[0149] The first similarity calculation submodule is used to calculate the first semantic similarity between each word vector and the remaining word vectors.
[0150] In an optional embodiment of this application, the word grouping module 303 includes:
[0151] The target first semantic similarity acquisition submodule is used to acquire the target first semantic similarity between the target word vector and the other word vectors for the target word vectors corresponding to the target words to be grouped;
[0152] The word vector filtering submodule is used to filter the remaining word vectors whose first semantic similarity to the target is higher than a preset similarity threshold, so as to obtain the remaining word vectors of the target;
[0153] The similar semantic word determination submodule is used to identify the words to be grouped corresponding to the remaining word vectors of the target as similar semantic words.
[0154] The combination segmentation submodule is used to group the target words to be grouped with the words with similar semantic meanings into word combinations.
[0155] In one optional embodiment of this application, the word-to-be-replaced search module 304 includes:
[0156] The correct word set setting submodule is used to combine the preset correct words into a correct word set;
[0157] The target preset correct word acquisition submodule is used to acquire the target preset correct words from the set of correct words;
[0158] The second similarity calculation submodule is used to calculate the second semantic similarity between the target preset correct word and the words to be grouped in each word combination;
[0159] The target word combination filtering submodule is used to filter target word combinations based on the second semantic similarity.
[0160] The submodule for determining words to be replaced is used to find words in the target word combination that are inconsistent with the target preset correct words as the words to be replaced.
[0161] In one optional embodiment of this application, the word replacement module 305 includes:
[0162] The similarity determination submodule is used to determine whether the first semantic similarity corresponding to the word to be replaced is higher than the replacement threshold;
[0163] The word replacement submodule is used to replace the word to be replaced with the preset correct word when the first semantic similarity corresponding to the word to be replaced is higher than the replacement threshold.
[0164] In one optional embodiment of this application, the word segmentation module 301 includes:
[0165] The code traversal submodule is used to extract expressions from the text by traversing the code that needs to be processed to obtain the text.
[0166] The word segmentation processing submodule is used to segment the text to obtain several segmented words;
[0167] The word filtering submodule is used to filter the several segmented words to obtain the several words to be grouped.
[0168] In one optional embodiment of this application, the apparatus includes:
[0169] The target code detection module is used to detect the target code corresponding to the target text.
[0170] The target code submission module is used to allow the submission of the target code if the target code does not contain the word to be replaced.
[0171] The target code pause submission module is used to pause the submission of the target code if the target code contains the word to be replaced.
[0172] In this embodiment, the text is segmented to obtain several words to be grouped; the first semantic similarity between the words to be grouped is calculated; the words to be grouped are grouped into word combinations based on the first semantic similarity, and each word combination contains words to be grouped with similar semantics; words in the word combinations that are inconsistent with the preset correct words are searched as words to be replaced; the words to be replaced are replaced with the preset correct words to obtain the target word combination; the word combinations in the text are corrected using the target word combination to obtain the target text. This embodiment automatically performs consistency checks and processing on the text of the front-end system based on the first semantic similarity, improving the efficiency and accuracy of the consistency checks of the front-end system, thereby saving manpower and time costs.
[0173] This application also provides a non-volatile readable storage medium storing one or more modules (programs). When these modules are applied to a device, they enable the device to execute the instructions for the method steps in this application.
[0174] This application provides one or more machine-readable media storing instructions that, when executed by one or more processors, cause an electronic device to perform one or more of the methods described in the above embodiments. In this application, the electronic device includes various types of devices such as terminal devices and servers (clusters).
[0175] The embodiments of this disclosure can be implemented as an apparatus configured as desired using any suitable hardware, firmware, software, or any combination thereof, including electronic devices such as terminal devices, servers (clusters), etc. Figure 4 An exemplary apparatus 400 is schematically shown that can be used to implement the various embodiments described in this application.
[0176] In one embodiment, Figure 4 An exemplary device 400 is shown, which includes one or more processors 402, a control module (chipset) 404 coupled to at least one of the processors 402, a memory 406 coupled to the control module 404, a non-volatile memory (NVM) / storage device 408 coupled to the control module 404, one or more input / output devices 410 coupled to the control module 404, and a network interface 412 coupled to the control module 404.
[0177] Processor 402 may include one or more single-core or multi-core processors, and processor 402 may include any combination of general-purpose processors or special-purpose processors (e.g., graphics processors, application processors, baseband processors, etc.). In some embodiments, device 400 can serve as a terminal device, server (cluster), or other device as described in the embodiments of this application.
[0178] In some embodiments, the apparatus 400 may include one or more computer-readable media (e.g., memory 406 or NVM / storage device 408) having instructions 414 and one or more processors 402 that are combined with the one or more computer-readable media and configured to execute the instructions 414 to implement the module and thus perform the actions described in this disclosure.
[0179] In one embodiment, the control module 404 may include any suitable interface controller to provide any suitable interface to at least one of the processors 402 and / or any suitable device or component communicating with the control module 404.
[0180] The control module 404 may include a memory controller module to provide an interface to the memory 406. The memory controller module may be a hardware module, a software module, and / or a firmware module.
[0181] Memory 406 may be used, for example, to load and store data and / or instructions 414 for device 400. In one embodiment, memory 406 may include any suitable volatile memory, such as suitable DRAM. In some embodiments, memory 406 may include double data rate type quad synchronous dynamic random access memory (DDR4 SDRAM).
[0182] In one embodiment, the control module 404 may include one or more input / output controllers to provide an interface to the NVM / storage device 408 and (one or more) input / output devices 410.
[0183] For example, NVM / storage device 408 may be used to store data and / or instructions 414. NVM / storage device 408 may include any suitable non-volatile memory (e.g., flash memory) and / or may include any suitable (one or more) non-volatile storage devices (e.g., one or more hard disk drives (HDDs), one or more optical disc drives (CDs), and / or one or more digital universal optical disc (DVD) drives).
[0184] NVM / storage device 408 may include storage resources that are physically part of a device on which device 400 is mounted, or that can be accessed by the device but do not necessarily have to be part of the device. For example, NVM / storage device 408 may be accessed via a network via one or more input / output devices 410.
[0185] One or more input / output devices 410 may provide an interface for device 400 to communicate with any other suitable device. Input / output devices 410 may include communication components, audio components, sensor components, etc. Network interface 412 may provide an interface for device 400 to communicate via one or more networks. Device 400 may wirelessly communicate with one or more components of a wireless network according to any of one or more wireless network standards and / or protocols, such as accessing wireless networks based on communication standards, such as WiFi, 2G, 3G, 4G, 5G, etc., or combinations thereof.
[0186] In one embodiment, at least one of the processors 402 may be logically packaged with one or more controllers (e.g., memory controller modules) of the control module 404. In one embodiment, at least one of the processors 402 may be logically packaged with one or more controllers of the control module 404 to form a system-in-package (SiP). In one embodiment, at least one of the processors 402 may be integrated with the logic of one or more controllers of the control module 404 on the same die. In one embodiment, at least one of the processors 402 may be integrated with the logic of one or more controllers of the control module 404 on the same die to form a system-on-a-chip (SoC).
[0187] In various embodiments, device 400 may be, but is not limited to, a server, desktop computing device, or mobile computing device (e.g., laptop, handheld computing device, tablet, netbook, etc.). In various embodiments, device 400 may have more or fewer components and / or different architectures. For example, in some embodiments, device 400 includes one or more cameras, a keyboard, a liquid crystal display (LCD) screen (including a touchscreen display), a non-volatile memory port, multiple antennas, a graphics chip, an application-specific integrated circuit (ASIC), and a speaker.
[0188] The detection device can use a main control chip as a processor or control module, and sensor data, position information, etc. can be stored in a memory or NVM / storage device. The sensor group can be used as an input / output device, and the communication interface can include a network interface.
[0189] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.
[0190] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0191] This application describes embodiments with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable document processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable document processing terminal device, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0192] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable document processing terminal device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0193] These computer program instructions can also be loaded onto a computer or other programmable document processing terminal device, causing a series of operational steps to be performed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal device for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0194] Although preferred embodiments of the present application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present application.
[0195] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.
[0196] The foregoing has provided a detailed description of a document processing method and apparatus, an electronic device, and a storage medium provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A document processing method, characterized in that, The method includes: The text is segmented into words to obtain several words to be grouped. Calculate the first semantic similarity between the words to be grouped; Based on the first semantic similarity, the words to be grouped are grouped into word combinations, and the word combinations contain words to be grouped with similar semantics; In the word combination, find words that do not match the preset correct words and use them as words to be replaced; The target word combination is obtained by replacing the word to be replaced with the preset correct word. The target word combination is used to correct the word combination in the copy to obtain the target copy.
2. The method according to claim 1, characterized in that, The calculation of the first semantic similarity between the words to be grouped includes: Convert the words to be grouped into word vectors; Calculate the first semantic similarity between each of the word vectors and the remaining word vectors.
3. The method according to claim 2, characterized in that, The step of grouping the words to be grouped into word combinations based on the first semantic similarity includes: For the target word vectors corresponding to the target words to be grouped, obtain the first semantic similarity between the target word vectors and the remaining word vectors; The remaining word vectors of the target are obtained by filtering out those whose first semantic similarity to the target is higher than a preset similarity threshold; The words to be grouped corresponding to the remaining word vectors of the target are regarded as similar semantic words; The target words to be grouped are divided into word groups with the words with similar semantic meanings.
4. The method according to claim 1, characterized in that, The step of searching for words in the word combination that do not match the preset correct words as words to be replaced includes: Combine the preset correct words into a set of correct words; Obtain the target preset correct words from the set of correct words; Calculate the second semantic similarity between the target preset correct word and the words to be grouped in each word combination; Based on the second semantic similarity, select target word combinations; In the target word combination, find words that are inconsistent with the target preset correct words and use them as the words to be replaced.
5. The method according to claim 1, characterized in that, The step of replacing the word to be replaced with the preset correct word to obtain the target word combination includes: Determine whether the first semantic similarity corresponding to the word to be replaced is higher than the replacement threshold; When the first semantic similarity corresponding to the word to be replaced is higher than the replacement threshold, the preset correct word is used to replace the word to be replaced.
6. The method according to claim 1, characterized in that, The text is segmented to obtain several words to be grouped, including: The text extraction expression is used to traverse the code that needs to be processed to obtain the text; The text is segmented into words to obtain several segmented words; The segmented words are filtered to obtain the words to be grouped.
7. The method according to claim 1, characterized in that, The method includes: Detect the target code corresponding to the target text; If the target code does not contain the word to be replaced, then the target code can be submitted. If the target code contains the word to be replaced, then the submission of the target code is paused.
8. A document processing device, characterized in that, The device includes: The word segmentation module is used to segment the text into words to obtain several words to be grouped. The first semantic similarity calculation module is used to calculate the first semantic similarity between the words to be grouped; The word grouping module is used to group the words to be grouped into word combinations based on the first semantic similarity, wherein the word combinations contain words to be grouped with similar semantics; The word to be replaced module is used to find words in the word combination that are inconsistent with the preset correct words as words to be replaced; The word replacement module is used to replace the word to be replaced with the preset correct word to obtain the target word combination; A consistency processing module is used to correct the word combination in the copy using the target word combination to obtain the target copy.
9. An electronic device, characterized in that, include: processor; and A memory having executable code stored thereon, which, when executed, causes the processor to perform a text processing method as described in one or more of claims 1-7.
10. One or more machine-readable media having executable code stored thereon, which, when executed, causes a processor to perform the text processing method as described in one or more of claims 1-7.
Citation Information
Patent Citations
Text correcting method and device
CN106250364A
Secret communication method and device applied to text carrier
CN108809919A