Spelling checking method based on XML editor
By loading XML data in the XML editor and parsing it into a tree structure, and using word picker and dictionary matching technology, the problem of inefficient spelling error search and error correction in XML data is solved, and fast and accurate spelling checking and error correction of XML text content is achieved.
Patent Information
- Application Number
- CN202411693297.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-25
- Publication Date
- 2025-04-25
AI Technical Summary
Existing dictionary search methods cannot efficiently search and distinguish node data from text data when processing XML data, resulting in inefficient search and error correction of spelling errors in XML editors.
By loading XML data, parsing it into a tree-structured DOC object, using a word collector to segment the character data in the text type node, and dictionary matching is performed through prefabricated dictionaries, combining binary search method and APHash comparison algorithm to quickly identify and locate spelling errors.
It realizes fast and accurate spelling checking and error correction of XML text content, and improves the efficiency and accuracy of XML data writing.
Smart Images

Figure CN119886117A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a spell checking method based on XML editor, belonging to the technical field of intelligent checking. Background Art
[0002] With the rapid development of the Internet, the demand for XML-based data editing is increasing. XML data is extremely large, and how to quickly and accurately find, locate and correct errors in XML data that includes a large amount of text has become an important issue. The existing dictionary search method cannot efficiently find and distinguish node data from text data when processing XML data. As a result, once the data runs with an error, on the one hand, logical errors must be checked, and on the other hand, spelling errors must be checked. The cycle and workload of troubleshooting are huge, which wastes a lot of manpower, has low work efficiency, and wastes working hours. It can be seen that developing a content product that can accurately find and locate spelling errors in XML editors has become a very necessary and urgent project at present. Summary of the invention
[0003] In order to solve the above problems, the present invention discloses a spelling check method based on an XML editor, which identifies errors in XML text content and suggests replacements through dictionary matching to solve spelling check errors in XML text content. The specific technical solution is as follows: A spell checking method based on an XML editor comprises the following steps: Step (1): Load XML data and determine the integrity of the XML data. If the XML data is incomplete, the process ends and a prompt is given indicating that the XML data is incomplete. If the XML data is complete, the standard XML data is parsed to obtain all text type node data. Step (2): segmenting the character data in the text type node obtained in step (1) through a word extractor; Step (3): Match the segmented data obtained in step (2) one by one through the dictionary, i.e., words, record the data nodes and positions of the missed words, and mark the missed data.
[0004] Furthermore, the step (1) specifically includes: Step (1.1): Parse the local standard XML data and convert it into a tree-structured DOC object; Step (1.2): The Doc object has a root node object. The root node in the DOC object data parsed in step (1.1) is used as the starting node. The text type node containing the data is searched recursively downward. The recursive search is to search for child nodes downward through the root node, and then continue to search downward through the child nodes, and repeat the cycle. The nodes in XML are " <para>data <para>"The node itself is also text information. Here we only get the "data" and do not pay attention to the node itself." <para>"Interference with data; Step (1.3): Store the node data obtained in step (1.2) into the collection, pending processing in step (2).
[0005] Furthermore, the step (2) specifically includes: Step (2.1): Based on the data obtained in step (1), the node data is processed by the word extractor; Step (2.2): The word extractor obtains the boundary position of each word according to the character data. The word extractor obtains the word boundary position based on the specific number of characters, space characters, punctuation marks, and character data whose ASCII values are not in the range of 65-122; Step (2.3): The word data obtained by the word extractor is stored in a KV type container with the Element node in the collection of step (1.3) as the key. The key is the node. The corresponding position information is found through the node object to locate the mark. The KV type container encapsulates the object recording the position information with the node as K and stores it in the collection corresponding to V. K is a text node and V is a collection of position class objects, which will be matched through dictionary data later.
[0006] Furthermore, the step (3) specifically includes: Step (3.1): Sort the prefabricated dictionary data by data length and alphabetical order, i.e., sort by length first, and then sort by alphabetical order for the same length, and then import them into the system; Step (3.2): Obtain the data in step (2.3), and process the character data obtained by the word extractor in sequence according to the key value. The key value is the node with text. At the beginning of the system operation, after obtaining the corresponding dictionary data by data length, a matching operation is performed by combining the binary search method with the APHash comparison algorithm. After matching the data, the word frequency information is accumulated and the hit data is recorded; Step (3.3): Based on the frequency data of the hit words in step (3.2), update and set a new threshold each time the program is started or at a fixed time. The threshold is the highest frequency of the set word. Data above this threshold is taken out separately and matched and checked first to improve operating efficiency.
[0007] Furthermore, the step (3.2) uses a dynamic expansion array to record the data currently processed by the system. The dynamic expansion array is an expandable container, which can greatly improve the processing speed when processing a large amount of text, especially when it includes a lot of repeated data.
[0008] Furthermore, the step (1.2) obtains the root node through the DOC object, starts multiple threads to recursively traverse downward with the root node as the starting node, and processes the node when it is a text type node.
[0009] Furthermore, between step (2) and step (3), there is also a step of determining whether the data processed in step (1.2) is the same as the processed data. If the data is the same, the data value is directly stored in the processed data set and the missed text is marked; if it is different, go to step (3).
[0010] Furthermore, the prefabricated dictionary in step (3.1) includes a general prefabricated dictionary and a user-defined dictionary, wherein the general prefabricated dictionary data includes frequency data recording the number of hit data in addition to text data.
[0011] Furthermore, each time the prefabricated dictionary is loaded, the text content is sorted according to length and alphabetical order, and data with a frequency greater than the maximum frequency value is read by default as hot data for priority verification; After the hotspot data is verified, or there is no hotspot data, the user-defined dictionary data is loaded for verification, and finally the general prefabricated dictionary data is used for verification and matching. If the data is hit, the corresponding frequency data is accumulated upward.
[0012] The beneficial effects of the present invention are: The present invention can verify, locate and correct text data in standard XML data according to specified dictionary data; when processing XML data including a large amount of text data, errors in text content can be quickly and accurately identified and replacements can be suggested through dictionary matching, thereby improving the efficiency and accuracy of writing XML data. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] Figure 1 It is a flowchart of parsing XML data according to the present invention.
[0014] Figure 2 It is a schematic diagram of the steps of running the flowchart program of the present invention.
[0015] Figure 3 It is the XML source data of the embodiment of the present invention.
[0016] Figure 4 This is the XML data after being marked with dictionary positioning in the embodiment of the present invention. DETAILED DESCRIPTION
[0017] The present invention is further explained below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the following specific embodiments are only used to illustrate the present invention and are not used to limit the scope of the present invention.
[0018] Combined with Figure 1 It can be seen that the design logic of the spelling checking method based on the XML editor of the present invention is: 1. Rapidly locate and process text content in standard XML data through dictionaries, including the following steps: 1a) Parse local standard XML data to generate a DOC object with a tree structure; 1b) Get the root node through the DOC object, start multi-threading and recursively traverse downward with the root node as the starting node, and process the node if it is a text type node; 1c) Determine whether the text node contains text data, if it contains data, store the node data in a collection for subsequent verification processing; 2. Process the text data through the word extractor and record relevant information such as the text data, starting position and ending position.
[0019] 2a) Load the node storing the text data and retrieve its text data.
[0020] 2b) The text data is processed by a word extractor, which initializes the start pointer and the end pointer to 0 after obtaining the text data.
[0021] 2c) Split the text data. When the character ASCII value is determined to be in the range of 65-122, the pointer starts recording the position and pauses to wait. When a character ASCII value is not in the range of 65-122 is encountered, determine whether the data before and after the character meets the word formation conditions. If not, the pointer ends recording the position.
[0022] 2d) Record the current start pointer and end pointer positions, encapsulate text and other data into position class objects and store them in a KV type container, where K is a text node and V is a collection of position class objects.
[0023] 2e) Assign the end pointer value to the start pointer and repeat the above steps.
[0024] 3. Load the pre-made dictionary into the system and verify the text data through the dictionary.
[0025] 3a) The pre-made dictionary includes a general pre-made dictionary and a user-defined dictionary, wherein the general pre-made dictionary data includes frequency data recording the number of hit data in addition to text data.
[0026] 3b) Each time the dictionary is loaded, the text content is sorted by length and alphabetical order. By default, data with a frequency greater than 60% of the maximum frequency value (the proportion and quantity can be adjusted as needed) is read as hot data for priority verification.
[0027] 3c) If there is no hotspot data, then load the user-defined dictionary data for verification, and finally verify and match through the general pre-made dictionary data. If the data is hit, the corresponding frequency data is accumulated upward.
[0028] 3d) Store missed hit data for marking, positioning and subsequent operations.
[0029] 3e) Support the above steps to be operated in a multi-threaded manner to improve the processing speed.
[0030] Combined with Figure 2 It can be seen that the operation process of the spelling check method based on the XML editor of the present invention is: 1. First start the XML data editing program.
[0031] 2. After the program starts, it loads the XML data and determines whether it complies with the XML standard. If it complies with the standard XML data format, it will be converted into a DOC object. Otherwise, a prompt will be given to end the program.
[0032] 3. Get the root node according to the DOC object, traverse the nodes downward from the root node, retain the text type nodes and store them for subsequent processing.
[0033] 4. The text type nodes are processed through the word extractor tool class, and the words are mainly judged by combining the characters az and AZ (the values corresponding to uppercase and lowercase letters are different) with regular expressions.
[0034] 5. Use the start pointer and the end pointer to record the location information of each word and encapsulate the object, and store the object in a KV type container, where the object recording the location information is encapsulated with the node K and stored in the collection corresponding to V for subsequent matching operations through dictionary data.
[0035] 6. Load dictionary data, which includes general pre-made dictionary and user-defined dictionary data. General pre-made dictionary data includes text data and frequency data.
[0036] 7. The dictionary search and matching algorithm is as follows: a) Load user-defined data into the system and give priority to matching. If the user data exceeds a certain threshold, the user-defined data can be merged into the general pre-made dictionary.
[0037] b) Load the general prefabricated dictionary data into the system, extract the data with a frequency greater than 60% of the maximum frequency value in the current data and mark it as hot data for priority matching.
[0038] c) After each match hits the data, the corresponding frequency data is incremented to ensure the validity and real-time nature of the hotspot data.
[0039] d) When dealing with large text content tags, you can enable multi-threaded parallel computing to increase the program's search speed and improve efficiency.
[0040] Finally Figure 3 and Figure 4 Display the page displayed after being processed by the method of the present invention, wherein Figure 3 is the original XML source data, Figure 4 The XML data after the dictionary positioning mark of the present invention is hit by words that cannot be matched in the dictionary.
[0041] It will be understood by those skilled in the art that, unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as generally understood by those skilled in the art in the field to which this application belongs. It should also be understood that terms such as those defined in common pre-made dictionaries should be understood to have meanings consistent with the meanings in the context of the prior art, and will not be interpreted with idealized or overly formal meanings unless defined as herein.
[0042] Based on the above ideal embodiments of the present invention, the relevant staff can make various changes and modifications without departing from the technical concept of the present invention through the above description. The technical scope of the present invention is not limited to the contents of the specification, and its technical scope must be determined according to the scope of the claims.< / para> < / para> < / para>
Claims
1. A spell checking method based on XML editor, characterized in that: The following steps are involved: Step (1): Load XML data and determine the integrity of the XML data. If the XML data is incomplete, the process ends and a prompt is given indicating that the XML data is incomplete. If the XML data is complete, the standard XML data is parsed to obtain all text type node data. Step (2): segmenting the character data in the text type node obtained in step (1) through a word extractor; Step (3): Match the segmented data obtained in step (2) one by one through the dictionary, i.e., words, record the data nodes and positions of the missed words and mark the missed data.
2. The XML editor-based spelling checking method according to claim 1, characterized in that: The step (1) specifically includes: Step (1.1): Parse the local standard XML data and convert it into a tree-structured DOC object; Step (1.2): The Doc object has a root node object. The root node in the DOC object data parsed in step (1.1) is used as the starting node, and a text type node including data is recursively searched downward. The recursive search is to search downward through the root node for child nodes, and then continue to search downward through child nodes, and repeat the cycle. In XML, nodes are represented by " <para>data <para>"The node itself is also text information. Here we only get the "data" and do not pay attention to the node itself." <para> "Interference with data;< / para> < / para> < / para> Step (1.3): Store the node data obtained in step (1.2) into the collection, pending processing in step (2).
3. The XML editor-based spelling checking method according to claim 2, characterized in that: The step (2) specifically includes: Step (2.1): Based on the data obtained in step (1), the node data is processed by the word extractor; Step (2.2): The word extractor obtains the boundary position of each word according to the character data. The word extractor obtains the word boundary position based on the specific number of characters, space characters, punctuation marks, and character data whose ASCII values are not in the range of 65-122; Step (2.3): The word data obtained by the word extractor is stored in a KV type container with the Element node in the collection of step (1.3) as the key. The key is the node. The corresponding position information is found through the node object to locate the mark. The KV type container encapsulates the object recording the position information with the node as K and stores it in the collection corresponding to V. K is a text node and V is a collection of position class objects, which will be matched through dictionary data later.
4. The XML editor-based spelling checking method according to claim 3, characterized in that: The step (3) specifically includes: Step (3.1): Sort the prefabricated dictionary data by data length and alphabetical order, i.e., sort by length first, and then sort by alphabetical order for the same length, and then import them into the system; Step (3.2): Obtain the data in step (2.3), and process the character data obtained by the word extractor in sequence according to the key value. The key value is the node with text. At the beginning of the system operation, after obtaining the corresponding dictionary data by data length, a matching operation is performed by combining the binary search method with the APHash comparison algorithm. After matching the data, the word frequency information is accumulated and the hit data is recorded; Step (3.3): Based on the frequency data of the hit words in step (3.2), update and set a new threshold each time the program is started or at a fixed time. The threshold is the highest frequency of the set word. Data above this threshold is taken out separately and matched and checked first to improve operating efficiency.
5. The XML editor-based spelling checking method according to claim 4, characterized in that: The step (3.2) uses a dynamically expanding array to record the data currently processed by the system.
6. The XML editor-based spelling checking method according to claim 2, characterized in that: The step (1.2) obtains the root node through the DOC object, starts multiple threads to recursively traverse downward with the root node as the starting node, and processes the node when it is a text type node.
7. The XML editor-based spelling checking method according to claim 2, characterized in that: Between step (2) and step (3), there is also a step of determining whether the data processed in step (1.2) is the same as the processed data. If the data is the same, the data value is directly stored in the processed data set and the missed text is marked; if it is different, go to step (3).
8. The XML editor-based spelling checking method according to claim 4, characterized in that: The prefabricated dictionary in step (3.1) includes a general prefabricated dictionary and a user-defined dictionary, wherein the general prefabricated dictionary data includes not only text data but also frequency data recording the number of hit data.
9. The XML editor-based spelling checking method according to claim 8, characterized in that: Each time the prefabricated dictionary is loaded, the text content is sorted according to length and alphabetical order, and data greater than the maximum frequency value is read by default as hot data for priority verification; After the hotspot data is verified, or there is no hotspot data, the user-defined dictionary data is loaded for verification, and finally the general prefabricated dictionary data is used for verification and matching. If the data is hit, the corresponding frequency data is accumulated upward.