A method for processing a combined word defined position disassembly
By constructing a combined word library and setting the line break position according to the semantic structure, the problem of inaccurate line break of combined words in the existing technology is solved, which improves the accuracy and readability of text typesetting and is suitable for scenarios such as documents and news.
Patent Information
- Application Number
- CN202510368657.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-27
- Publication Date
- 2026-01-27
- Estimated Expiration
- 2045-03-27
AI Technical Summary
Existing text typesetting algorithms fail to adequately consider semantic integrity and specific positional constraints when processing compound words, resulting in inaccurate line splitting and affecting the accuracy and readability of the text.
By constructing a combined lexicon, analyzing the semantic structure of combined words, setting limited line break positions, and performing precise matching and line breakage based on the combined lexicon and text position information during line breakage processing, the line break positions are ensured to conform to semantic logic.
It improves the accuracy and readability of text layout, avoids semantic ambiguity, is suitable for high-requirement scenarios such as document layout and news publishing, and has flexibility and scalability.
Smart Images

Figure CN119903836B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of text processing technology, specifically to a method for splitting lines by limiting the position of compound words. Background Technology
[0002] In text typesetting, especially for text containing specific compound words, proper line splitting is crucial. For example, arbitrarily splitting compound words like "Xinjiang Uygur Autonomous Region" can lead to semantic difficulties and even ambiguity. Currently, most common text typesetting line splitting algorithms are based on punctuation prohibition rules, failing to fully consider the semantic integrity of compound words and the need for line splitting at specific positions. Consequently, when processing text containing such compound words, they cannot meet the requirements of accuracy and readability in practical applications. Summary of the Invention
[0003] The technical problem to be solved by the present invention is to provide a method for splitting text into lines based on the above-mentioned deficiencies, which can accurately split text into lines according to the preset deficiencies of the words, thereby improving the accuracy and readability of text typesetting.
[0004] To solve the above technical problems, the present invention adopts the following technical solution:
[0005] A method for splitting compound words into lines based on their positional constraints includes the following steps:
[0006] Step 1: Construct the combined thesaurus; Step 2: Obtain the text to be judged; Step 3: Determine the line break position and perform line break processing;
[0007] Step 1 includes the following steps:
[0008] Step 1.1, collecting compound words;
[0009] Step 1.2, Semantic Structure Analysis and Information Setting;
[0010] Step 3 includes the following steps:
[0011] Step 3.1, Initialization: Initialize the matching start position Ps=0 for the character sequence of the text S to be judged;
[0012] Step 3.2, word matching;
[0013] Step 3.3, determine the position of line splitting;
[0014] Step 3.4: Perform row splitting;
[0015] Step 3.5, default line splitting;
[0016] Step 3.6, row splitting completed.
[0017] Furthermore, step 1.2 includes the following steps:
[0018] For each collected compound word, its semantic structure is analyzed in depth, and reasonable line break positions are determined based on the semantic structure. At the same time, the line break position information of the compound word is set, and the maximum length of the compound word is recorded as Lmax. The starting index value of the compound word library is index=0. This step provides basic data support for subsequent text line break, ensuring that the line break position conforms to the semantic logic of the compound word.
[0019] Furthermore, step 2 includes the following steps:
[0020] When the text to be processed needs to be split into lines at the end of a line, take Lmax-1 characters from the end of the line forward, denoted as S1, and take Lmax-1 characters from the end of the line, denoted as S2. Combine S1 and S2 to obtain the text to be judged, and at the same time, record the position of the end of the line in the text to be judged, denoted as P0, where P0=Lmax-1. In this way, a text segment with the end of the line position information and a suitable length is obtained, so as to perform matching and line split position judgment in the combined dictionary.
[0021] Furthermore, step 3.2 includes the following steps:
[0022] Combination word matching: Determine whether the combination word index value is equal to the length of the combination word library. If the combination word index value is equal to the length of the combination word library, that is, the combination word library query is completed, then proceed to step 3.5; if the combination word index value is less than the length of the combination word library, then take the word from the index, record the taken word as the string to be matched W, the length of the string to be matched W is recorded as Lw, and the combination word index value is incremented by 1, that is, index = index + 1.
[0023] Furthermore, step 3.3 includes the following steps:
[0024] Starting from the matching start position Ps of the character sequence of the text S to be judged, compare the character sequence in the text S to be judged with the character sequence of the string W to be matched one by one in character order. If, after traversing the entire text S to be judged, no character sequence that is exactly the same and continuous as the string W to be matched is found, it is determined that the match fails, and step 3.1 is repeated; when there is a character sequence in the text S to be judged that is exactly the same and continuous as the string W to be matched, it is determined that the match is successful, and record the position of the string W to be matched in the text S to be judged as P1. If P1 >= P0, that is, the entire word of the string W to be matched is after the end position of the line, then step 3.1 is repeated. If P1 + Lw <= P0, that is, the entire word of the string W to be matched is before the end position of the line, then Ps is set to P1 + Lw, and step 3.3 is repeated. At this time, the end position of the line falls in the middle of the character sequence of the string W to be matched, that is, it satisfies P1 < P0 and P1 + Lw > P0. This step provides a basis for determining the line break position by matching the position of the combined word in the text to be judged and judging the position of the end position of the line in the character sequence of the combined word.
[0025] Further, step 3.4 includes the following steps:
[0026] Looking forward from the position P0 - P1 in the string W to be matched, search for the defined line break position Pw in the string W to be matched; if the defined line break position Pw is found, then break the line at P1 + Pw; if the defined line break position Pw is not found, then break the line at P1, and go to step 3.6; this step accurately judges and determines the final line break position based on the position of the combined word in the text to be judged, the position of the end position of the line in the character sequence of the combined word, and the defined line break position information of the combined word itself.
[0027] Further, step 3.5 includes the following steps:
[0028] Default line break: If no suitable line break basis is found after querying the combined word library, then break the line at P0. This is the default line break method when there is no other better line break option.
[0029] The present invention adopts the above technical solutions. Compared with the prior art, it has the following technical effects:
[0030] Improve typesetting accuracy: By presetting the defined line break position of the combined word, it avoids semantic ambiguity or understanding difficulties caused by breaking the line at non-defined positions of the combined word, ensuring the accuracy of the text after typesetting.
[0031] Enhance readability: Reasonable line break processing makes the text more in line with people's reading habits when presented, improving the readability of the text, especially suitable for scenarios with high requirements for text normativity, such as document typesetting, news release, etc.
[0032] Flexibility and scalability: The combined word library can be dynamically updated and expanded according to actual needs, and can adapt to the requirements of word splitting in different fields and of different types, thus having strong flexibility and scalability. Attached Figure Description
[0033] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the accompanying drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. In all the drawings, similar elements or parts are generally identified by similar reference numerals. In the drawings, the elements or parts are not necessarily drawn to scale.
[0034] Figure 1 Flowchart of the method for splitting lines to limit the position of compound words;
[0035] Figure 2 This is a diagram illustrating the combined thesaurus.
[0036] Figure 3 To obtain a schematic diagram of the text to be judged;
[0037] Figure 4 This is a diagram illustrating word retrieval from a combined lexicon.
[0038] Figure 5 This is a diagram illustrating the determination of row splitting positions.
[0039] Figure 6 This is a diagram showing the completion of row splitting. Detailed Implementation
[0040] Examples, such as Figure 1 As shown, a method for splitting compound words into lines based on their position includes the following steps:
[0041] Step 1, constructing the combined thesaurus;
[0042] Step 1.1, Collection of compound words: Common compound words from different fields are collected manually. These compound words cover various types such as geographical names, professional terms, and organizational names.
[0043] Step 1.2, Semantic Structure Analysis and Information Setting: For each collected compound word, its semantic structure is analyzed in depth, and reasonable line break positions are determined based on the semantic structure. Simultaneously, the line break position information for the compound word is set, and the maximum length of the compound word is recorded as Lmax. The initial index value of the compound word database is index=0. See the diagram below. Figure 2 This step provides basic data support for subsequent text splitting, ensuring that the splitting positions conform to the semantic logic of the compound words.
[0044] Step 2, obtain the text to be judged;
[0045] When the text to be processed needs to be split at the end of a line, take Lmax - 1 characters from the end of the line towards the front, denoted as S1, and take Lmax - 1 characters towards the back, denoted as S2. Combine S1 + S2 to obtain the text S to be judged. At the same time, record the position of the end of the line in the text S to be judged, denoted as P0 (P0 = Lmax - 1). For a schematic diagram, see Figure 3 , in this way, obtain a text segment with appropriate length that contains the position information of the end of the line, so as to perform matching and split-line position judgment in the combined vocabulary.
[0046] Step 3, Split-line position judgment, perform split-line processing;
[0047] Step 3.1, Initialization: Initialize the starting position Ps = 0 for matching the character sequence of the text S to be judged.
[0048] Step 3.2, Combined-word matching: Judge whether the combined-word index value index is equal to the length of the combined vocabulary. If the combined-word index value index is equal to the length of the combined vocabulary, that is, the combined vocabulary query is completed, then enter Step 3.5; if the combined-word index value index is less than the length of the combined vocabulary, then take the word from index, record the taken word as the string W to be matched, denote the length of the string W to be matched as Lw, and increment the combined-word index value index by 1, that is, index = index + 1.
[0049] Step 3.3, Split-line position judgment: Starting from the starting position Ps for matching the character sequence of the text S to be judged, compare the character sequence in the text S to be judged with the character sequence of the string W to be matched one by one in character order. If after traversing the entire text S to be judged, no character sequence that is exactly the same and continuous as the string W to be matched is found, then it is determined as a matching failure, and repeat Step 3.1; when there is a character sequence in the text S to be judged that is exactly the same and continuous as the string W to be matched, it is determined as a matching success, record the position of the string W to be matched in the text S to be judged as P1. If P1 >= P0, that is, the entire word of the string W to be matched is after the end-of-line position, then repeat Step 3.1. If P1 + Lw <= P0, that is, the entire word of the string W to be matched is before the end-of-line position, then set Ps to P1 + Lw and repeat Step 3.3. At this time, the end-of-line position falls in the middle of the character sequence of the string W to be matched, that is, it satisfies P1 < P0 and P1 + Lw > P0. For a schematic diagram, see Figure 4 , this step provides a basis for determining the split-line position by matching the position of the combined word in the text to be judged and judging the position of the end-of-line in the character sequence of the combined word.
[0050] Step 3.4, perform line splitting: Starting from positions P0-P1 in the string W to be matched, search for the specified line splitting position Pw in the string W to be matched; if the specified line splitting position Pw is found, then split the line at P1+Pw; if the specified line splitting position Pw is not found, then split the line at P1 and go to step 3.6; see the diagram. Figure 5 This step accurately determines the final line break position based on the position of the compound word in the text to be judged, the position of the end of the line in the character sequence of the compound word, and the limited line break position information of the compound word itself.
[0051] Step 3.5, Default line splitting: If no suitable line splitting basis is found after the combined word library query is completed, the line splitting will start from P0. This is the default line splitting method when there are no other better line splitting options.
[0052] Step 3.6, Line splitting completed: After completing the above line splitting operations, the line splitting process is finished. See the diagram below. Figure 6 .
[0053] The description of this invention is given for illustrative and descriptive purposes only and is not intended to be exhaustive or to limit the invention to the forms disclosed. Many modifications and variations will be apparent to those skilled in the art. The embodiments were chosen and described to better illustrate the principles and practical application of the invention and to enable those skilled in the art to understand the invention and design various embodiments with various modifications suitable for a particular purpose.
Claims
1. A method for splitting compound words into lines based on their position, characterized in that: It includes the following steps: Step 1, constructing a combined word library; The said Step 1 includes the following steps: Step 1.1, collecting combined words; Step 1.2, semantic structure analysis and information setting; For each collected combined word, deeply analyze its semantic structure, and determine a reasonable line-breaking position according to the semantic structure; Meanwhile, set the line-breaking position information of the combined word, and record the maximum length of the combined word, denoted as Lmax, the starting index value of the combined word library index = 0. This step provides basic data support for subsequent text line-breaking to ensure that the line-breaking position conforms to the semantic logic of the combined word; Step 2, obtaining the text to be judged; When the text to be processed needs to be line-broken at the end of the line, take Lmax - 1 characters from the end of the line forward, denoted as S1, and take Lmax - 1 characters backward, denoted as S2. Combine S1 + S2 to obtain the text to be judged S. Meanwhile, record the position of the end of the line in S, denoted as P0, P0 = Lmax - 1. In this way, obtain a text segment with appropriate length containing the end-of-line position information for matching and line-breaking position judgment in the combined word library; Step 3, line-breaking position judgment, perform line-breaking processing; The said Step 3 includes the following steps: Step 3.1, initialization: initialize the matching start position Ps of the S character sequence to 0; Step 3.2, combined word matching; Combined word matching: judge whether the combined word index value index is equal to the length of the combined word library. If the combined word index value index is equal to the length of the combined word library, that is, the combined word library query is completed, then enter Step 3.5; if the combined word index value index is less than the length of the combined word library, then take the word from index, record the taken word as W, the length of W is denoted as Lw, and the combined word index value index is incremented by 1, that is, index = index + 1; Step 3.3, line-breaking position judgment; Starting from the matching start position Ps of the character sequence of the text to be judged S, compare the character sequence in S with the character sequence of the string to be matched W one by one in character order. If after traversing the entire S, no character sequence that is exactly the same and continuous as the string to be matched W is found, it is determined as a matching failure, and repeat Step 3.1; when there is a character sequence in S that is exactly the same and continuous as the string to be matched W, it is determined as a matching success, record the position of W in S as P1. If P1 >= P0, that is, the entire word W is after the end-of-line position, then repeat Step 3.
1. If P1 + Lw <= P0, that is, the entire word W is before the end-of-line position, then set Ps to P1 + Lw and repeat Step 3.
3. At this time, the end-of-line position falls in the middle of the character sequence of W, that is, it satisfies P1 < P0 and P1 + Lw > P0. This step provides a basis for determining the line-breaking position by matching the position of the combined word in the text to be judged and judging the position of the end-of-line in the character sequence of the combined word; Step 3.4, perform line-breaking processing; Starting from position P0-P1 in W, search for the limited line break position Pw in W; if the limited line break position Pw is found, break the line at P1+Pw; if the limited line break position Pw is not found, break the line at P1 and go to step 3.6; this step accurately judges and determines the final line break position based on the position of the compound word in the text to be judged, the position of the end of the line in the character sequence of the compound word, and the limited line break position information of the compound word itself. Step 3.5 defaults to line splitting; Default line splitting: If a suitable line splitting basis is not found after the combined word library query is completed, the line splitting will start from P0. This is the default line splitting method when there are no other better line splitting options. Step 3.6: Row splitting completed.
Citation Information
Patent Citations
Method and device for line non-breaking processing based of special words
CN104572750A