Text processing method and device, equipment and storage medium

By automatically recognizing and processing preset text, and using preset inline elements and cascading style sheets, the problem of unreasonable text wrapping in front-end text rendering is solved, improving user experience and processing efficiency. It has a wide range of applications and is compatible with existing systems.

CN121598902APending Publication Date: 2026-03-03SHENZHEN KANGBIDA CONTROL TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511683827.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-17
Publication Date
2026-03-03

AI Technical Summary

Technical Problem

In current front-end text rendering, unreasonable line breaks lead to a poor user reading experience, and developers manually inserting tags is inefficient and prone to omissions.

Method used

By automatically recognizing preset text, the preset inline elements and cascading style sheets are used to process the preset text without breaking lines, including combinations of numbers and units. Regular expressions are used for text recognition and non-breaking space concatenation.

Benefits of technology

It improves the user reading experience, enhances processing efficiency and accuracy, has a wide range of applications, and can be integrated into existing systems with zero intrusion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121598902A_ABST
    Figure CN121598902A_ABST
Patent Text Reader

Abstract

The invention provides a text processing method and device, equipment and a storage medium, and relates to the technical field of computers. The method comprises the steps of obtaining an original text; identifying the original text, and determining whether the original text contains a preset text or not; wherein the preset text is a unit or a combination of a number and at least one of the unit and a preset symbol; if it is determined that the original text contains the preset text, text continuous processing is carried out on the preset text; and obtaining a target text based on the processed preset text and the remaining texts of the original text except the preset text. According to the method and the device, the preset text can be automatically identified, and the text continuous processing is performed on the preset text, so that the processing efficiency and the accuracy are effectively improved while the readability and the reading experience of a user are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a text processing method, apparatus, device, and storage medium. Background Technology

[0002] In terms of front-end visualization, front-end text rendering refers to the process of presenting text in a visual way on a display device. The text layout and display effect directly affect the user experience.

[0003] However, in existing front-end text rendering, unreasonable line breaks often occur, requiring users to read the complete information across two lines. For example, in "kWh", the "k" is on the previous line and "Wh" is on the next line, resulting in a poor reading experience for users.

[0004] In related technologies, developers can manually insert or... <nobr>Tags are used to prevent unreasonable line breaks in text, but they are inefficient and easy to miss. Summary of the Invention

[0005] This invention provides a text processing method, apparatus, device, and storage medium to address the problems in related technologies where developers manually insert tags to avoid unreasonable line breaks, resulting in low efficiency and easy omissions.

[0006] In a first aspect, embodiments of the present invention provide a text processing method, including: Get the original text; The original text is identified to determine whether it contains preset text; wherein the preset text is a unit, or a combination of at least one of a number and a unit and a preset symbol. If it is determined that the original text contains the preset text, then the preset text is processed to prevent it from running out of lines. The target text is obtained based on the processed preset text and the remaining text of the original text excluding the preset text.

[0007] In one possible implementation, the preset text is processed to prevent it from running continuously, including: Wrap the preset text with the preset inline element; The preset text wrapped in Cascading Style Sheets (CSS) is styled and rendered; CSS is used to prevent the preset text from wrapping.

[0008] In one possible implementation, before wrapping the preset text based on a preset inline element, the following is also included: If the preset text is a combination of numbers and units, then the numbers will be set as a continuous line unit, the units will be set as a continuous line unit, and the numbers and units will be connected by non-breaking spaces.

[0009] In one possible implementation, numbers and units are connected by non-breaking spaces, including: If there is a space character between the number and the unit, replace the space character with a non-breaking space; If there is no space character between the number and the unit, then insert a non-breaking space between the number and the unit.

[0010] In one possible implementation, the original text is identified to determine whether it contains preset text, including: The original text is identified using regular expressions to obtain the preset text contained in the original text; Regular expressions extract text that matches the features of the original text based on preset string matching rules.

[0011] In one possible implementation, before recognizing the original text, the following is also included: Preprocessing of the original text; preprocessing includes at least one of the following: removal of invalid characters and uniform character encoding.

[0012] In one possible implementation, the above text processing method further includes: Format the processed preset text; the formatting marks are used to indicate the font style, font size or color when the preset text is displayed.

[0013] Secondly, embodiments of the present invention provide a text processing apparatus, including: The acquisition module is used to acquire the raw text; The processing module is used to identify the original text and determine whether the original text contains preset text; wherein, the preset text is a unit, or a combination of at least one of a number and a unit and a preset symbol; The processing module is also used to perform non-linear processing on the preset text if it is determined that the original text contains preset text. The processing module is also used to obtain the target text based on the processed preset text and the remaining text of the original text excluding the preset text.

[0014] Thirdly, embodiments of the present invention provide an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the method described in the first aspect or any possible implementation thereof.

[0015] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method described in the first aspect or any possible implementation thereof.

[0016] Fifthly, embodiments of the present invention provide a computer program product, including a computer program that, when executed by a processor, implements the method described in the first aspect or any possible implementation thereof.

[0017] This invention provides a text processing method, apparatus, device, and storage medium. After acquiring original text, the method identifies whether it contains preset text. If the original text contains preset text, it performs non-linear processing on the preset text and obtains the target text based on the processed preset text and the remaining text of the original text excluding the preset text. The preset text is a unit, or a combination of at least one of numbers, units, and preset symbols. Because this invention can automatically identify and process preset text without line breaks, readability is improved, thus enhancing the user's reading experience. Furthermore, compared to developers manually inserting tags, it effectively improves processing efficiency and accuracy. Moreover, since the preset text can be units, combinations of numbers and units, combinations of numbers and preset symbols, or combinations of numbers, units, and preset symbols, this invention can process various types of text without line breaks, has a wide range of applications, and effectively improves the user's reading experience. Simultaneously, since this invention does not require modification of the original text, it can adapt to existing systems and achieve zero-intrusion integration. Attached Figure Description

[0018] Figure 1 This is a flowchart illustrating the implementation of a text processing method provided in an embodiment of the present invention; Figure 2 This is a flowchart illustrating the implementation of a text non-linear processing method provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of the structure of a text processing device provided in an embodiment of the present invention; Figure 4 This is a schematic diagram of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0019] The embodiments of the present invention will now be described in detail with reference to the accompanying drawings.

[0020] In front-end text rendering, unreasonable line breaks require users to navigate across two lines to understand the complete information. For example, in "kWh," the "k" might be on the previous line while "Wh" is on the next, resulting in a poor reading experience. Furthermore, splitting information across lines can lead to ambiguity. For instance, splitting the unit "kg" into "k" and "g" can cause misunderstanding, as each of these terms has its own meaning. This also disrupts the visual flow of the text, especially on narrower screens like mobile phones.

[0021] Therefore, in one related technology, developers can manually insert or...< / nobr> <nobr>Tags are used to prevent unreasonable line breaks in text, but they are inefficient and easy to miss.

[0022] Based on this, this application provides a text processing method that automatically identifies preset text in the original text. The preset text can be units, combinations of numbers and units, combinations of numbers and preset symbols, and combinations of numbers, units, and preset symbols, etc. Furthermore, the preset text is processed to prevent it from going further, improving readability and enhancing the user's reading experience. Compared to developers manually inserting tags, this method effectively improves processing efficiency and accuracy. Moreover, this invention can process various types of text without requiring modification of the original text, making it widely applicable and effectively improving the user's reading experience. Additionally, since this invention does not require modification of the original text, it can be adapted to existing systems, achieving zero-intrusion integration.

[0023] See Figure 1 The diagram illustrates a flowchart of a text processing method provided by an embodiment of the present invention, which is described in detail below: S101: Get the original text.

[0024] The original text includes, but is not limited to, web page text, application output text, user input text, or document files. This embodiment acquires the original text through methods such as file reading, API calls, and database queries, thereby meeting the text processing requirements of different application scenarios.

[0025] S102: Recognize the original text and determine whether the original text contains preset text; wherein the preset text is a unit, or a combination of at least one of a number and a unit and a preset symbol.

[0026] In one implementation scenario, when the text is set to units, there are no numbers before the units. For example, "measurement accuracy is based on μm". If μm is on different lines, it will also lead to a poor reading experience. Therefore, it is necessary to process it to be continuous.

[0027] Optionally, the preset text can be a combination of numbers and units, where the units can be Chinese or English units, such as 2 kWh, 10 kilograms, etc.

[0028] In this embodiment, the preset text can also be a combination of numbers and preset symbols, including but not limited to the micro symbol "μ", the ohm symbol "Ω", the degree symbol "°", the percent sign "%", and the square symbol "". 2 ",cube" 3 "Etc., for example, 10 m" 2 , 20Ω, etc.

[0029] In addition, the preset text can also be a combination of numbers, units and preset symbols, such as 10 kg / m³.

[0030] This embodiment can process various types of text without interruption, has a wide range of applications, and can effectively improve the user's reading experience.

[0031] In some embodiments, before recognizing the original text, in order to improve the recognition efficiency and accuracy of the original text, the original text may be preprocessed, including at least one of the following: removing invalid characters and uniform character encoding.

[0032] Invalid characters include, but are not limited to, redundant spaces, extra newlines, special control characters, garbled characters, and other invalid content that does not affect the semantics of the original text.

[0033] Unified character encoding refers to converting raw text into a unified encoding format to avoid recognition errors caused by inconsistent encoding formats and improve recognition accuracy.

[0034] In some embodiments, when identifying the original text to determine whether it contains preset text, the original text can be automatically identified using regular expressions to obtain the preset text contained in the original text; wherein, the regular expression extracts text that matches the characteristics of the preset text from the original text based on preset string matching rules.

[0035] The features of the preset text include, but are not limited to, format, structure, and symbols. In one implementation scenario, a corresponding preset string matching rule can be determined based on the features of the preset text, and a corresponding regular expression can be constructed based on the preset string matching rule to extract the preset text that matches the preset string matching rule from the original text.

[0036] Here, since there are many types of preset text in the original file, this embodiment uses different regular expressions to identify different types of preset text in order to improve the recognition accuracy of preset text. For example, this embodiment can use a first regular expression to identify the original text and obtain a first type of preset text included in the original text; the first type of preset text is a combination of at least one of numbers, English units, and preset symbols. Specifically, the first regular expression extracts text from the original text that matches the characteristics of the first type of preset text based on corresponding string matching rules.

[0037] In addition, this embodiment can also identify the original text using a second regular expression to obtain a second type of preset text included in the original text; the second type of preset text is a combination of numbers and Chinese units. Specifically, the first regular expression extracts text from the original text that matches the characteristics of the second type of preset text based on corresponding string matching rules.

[0038] In one implementation scenario, the first regular expression can be as follows:

[0039] in, Used to identify numbers in the original text. Optionally, \d+ is used to identify one or more numbers, which can be adapted to integers such as 10, 200, etc. Used to identify thousands separators, where The thousands separator can be zero, one, or more, and can be used to match numbers containing thousands separators, such as 1,234, 123,456,789, etc. `(?:\.\d+)?` is used to match numbers with a decimal point, which can appear zero or one time, and must be followed by at least one digit, such as 1000.5.

[0040] As shown above, the first regular expression can recognize various data types, including integers, numbers containing thousands separators, numbers containing decimal points, and numbers containing both thousands separators and decimal points. Among these, numbers containing both thousands separators and decimal points can be, for example, 1,000.5.

[0041] Additionally, in the first regular expression This is used to identify English units and preset symbols. A-ZA-Z are used to identify English letters, such as kg, m, MPa, etc. µΩ°%²³ are some preset symbols shown, representing micro (μ), ohm (Ω), degree (°), percentage (%), and square (%), respectively. 2 ",cube" 3 "etc.; + indicates that the unit must contain at least one of the above characters to avoid the number being missing a unit; \ / ? indicates that " / " is optional and is used to adapt to compound units, such as kg / m³, m / s, etc., and "?" indicates that the " / " symbol may or may not be present; This indicates that there can be zero or more characters from [a-zA-ZµΩ°%²³] after " / ".

[0042] As shown above, the first regular expression can recognize common English units such as kg and m, as well as preset symbols such as μ and Ω, and can also recognize compound units such as kg / m³ and m / s.

[0043] in addition, and The middle It is used to match optional spaces between numbers and units. It can recognize preset text where there are no spaces between numbers and units, such as 2kWh, and it can also recognize preset text where there are spaces between numbers and units, such as 2 kWh.

[0044] The first regular expression mentioned above also includes / gi, where g represents the global matching mode, which means that the original text needs to be recognized globally to obtain all the preset text included in the original text, and i represents the case-insensitive mode, which means that the case of units is not distinguished. For example, KG, Kg and kg can all be recognized, avoiding omissions and improving the recognition accuracy of preset text.

[0045] In one implementation scenario, a second regular expression can be shown as follows:

[0046] in, It is used to identify numbers in raw text, specifically, it can identify various types such as integers, numbers with thousands separators, numbers with decimal points, and numbers with both thousands separators and decimal points. It is also used to match optional spaces between numbers and units. g also indicates global matching mode. The above parts have the same meaning as the corresponding parts in the first regular expression, so they will not be described in detail.

[0047] Additionally, in the second regular expression, Used to identify Chinese units. [\u4e00-\u9fa5] represents the Chinese unit character set, including simplified and traditional Chinese units, such as kilogram, meter, megapascal, second, degree Celsius, ohm, etc. + indicates that at least one Chinese character is required to avoid numbers without a unit. \ / ? represents an optional " / " symbol used to adapt to compound units, such as meters per second, kilograms per cubic meter, etc. The "?" symbol may or may not be present. This indicates that there can be zero or more Chinese characters after " / ".

[0048] As shown above, the second regular expression can recognize combinations of numbers and Chinese units. These Chinese units can be conventional units such as kilograms and meters, or composite units such as meters per second and kilograms per cubic meter.

[0049] It should be noted that different types of preset text can be identified by setting corresponding regular expressions. In addition, the corresponding regular expressions can be modified. Taking the first regular expression as an example, if you need to add or remove preset symbols, you can add or remove preset symbols in [a-zA-ZµΩ°%²³], which is highly flexible.

[0050] S103: If it is determined that the original text contains the preset text, then the preset text is processed to prevent text from running.

[0051] In one implementation scenario, Cascading Style Sheets (CSS) can be used to restrict line breaks of preset text at the style level, so that the preset text is displayed on the same line.

[0052] In another implementation scenario, non-breaking spaces can be inserted into the preset text to restrict line breaks at the character level, so that the preset text is displayed on the same line.

[0053] In another implementation scenario, Cascading Style Sheets (CSS) and non-breaking spaces can be combined. For example, non-breaking spaces can be inserted into the preset text first, and then the CSS can be used to prevent the preset text from breaking. This double protection, which restricts the preset text from breaking at both the style and character levels, improves the reliability of preventing the preset text from breaking.

[0054] As can be seen from the above, the embodiments of the present invention can not only recognize English units, but also Chinese units, units with thousands separators and decimal points, compound units, and units with or without spaces between numbers and units. Therefore, by performing non-linear text processing on various types of preset text, the user's reading experience can be effectively improved.

[0055] In some embodiments, after the preset text is processed to prevent it from running continuously, the processed preset text can also be formatted; the formatting marks are used to indicate the font style, font size or color when the preset text is displayed.

[0056] Here, the font style, size, or color of the preset text should be different from the remaining text to improve the recognizability of the preset text, help users quickly identify the preset text, and improve reading efficiency and user experience.

[0057] The font styles include, but are not limited to, bold and italics. The font size can be determined based on the font size of the remaining text. For example, the font size of the preset text can be one or two sizes larger than the font size of the remaining text. The color of the preset text can be a more eye-catching color, such as blue or red.

[0058] Optionally, this embodiment can utilize Cascading Style Sheets (CSS) to format the processed preset text. CSS is used to format text, which can meet different needs in different scenarios.

[0059] S104: Based on the processed preset text and the remaining text of the original text excluding the preset text, obtain the target text.

[0060] Since the embodiments of the present invention only perform text discontinuation processing on the preset text, without affecting the original layout logic of the remaining text, the processed preset text can be integrated with the remaining text in the original text excluding the preset text to obtain the target text that is semantically complete and reasonably formatted.

[0061] In another implementation scenario, if the original text does not contain the preset text, there is no need to perform text break-line processing; the original text can simply be displayed as the target text.

[0062] This invention provides a text processing method. After obtaining the original text, the method identifies whether it contains preset text. If the original text contains preset text, the preset text is processed without line breaks, and the target text is obtained based on the processed preset text and the remaining text of the original text excluding the preset text. Because this invention can automatically identify and process preset text without line breaks, it significantly improves processing efficiency and accuracy compared to developers manually inserting tags. Furthermore, since this invention does not require modification of the original text, it can be adapted to existing systems. Moreover, because the preset text can be a unit, or a combination of at least one of numbers, units, and preset symbols, this invention can process various types of text without line breaks, making it widely applicable and effectively improving the user's reading experience.

[0063] Based on the above embodiments, this embodiment utilizes preset inline elements, cascading style sheets, etc., to process preset text without line breaks, reducing unreasonable text wrapping.

[0064] Figure 2 This is a flowchart illustrating the implementation of a text non-linear processing method provided in an embodiment of the present invention. (Refer to...) Figure 2 As shown, text discontinuity processing is performed on the preset text, including: S201: Wrap the preset text based on the preset inline element.

[0065] Predefined inline elements must not disrupt the original text layout; that is, the element itself should not produce additional line breaks, spacing offsets, or other effects. In one implementation scenario, the predefined inline element can be a `span` tag in HyperText Markup Language (HTML) or an italic tag. Emphasis on labels <em>wait.

[0066] In another implementation scenario, the default inline element can also be a custom inline tag in Extensible Markup Language (XML), such as... <unit-block> 、 <non-break-text>Alternatively, the default inline element can also be other tags that conform to inline characteristics.

[0067] In some embodiments, before wrapping the preset text based on a preset inline element, the method further includes: if the preset text is a combination of numbers and units, then setting the numbers as a continuous whole and the units as a continuous whole, and connecting the numbers and units with non-breaking spaces.

[0068] Here, numbers are set as a single, continuous unit, preventing them from being split due to line breaks. Numbers can be integers, decimals, and numbers containing thousands separators, etc. Similarly, units are set as a single, continuous unit to prevent them from being split due to line breaks.

[0069] A non-breaking space is a special type of space character. Its core characteristic is that browsers will not perform a line break operation at this location. Therefore, using a non-breaking space to connect numbers and units ensures the integrity of the numbers and units, effectively preventing them from being broken on the same line and improving readability.

[0070] In one implementation scenario, when connecting numbers and units using non-breaking spaces, if there is a space character between the number and the unit, the space character is replaced with a non-breaking space; if there is no space character between the number and the unit, a non-breaking space is inserted between the number and the unit.

[0071] In one implementation scenario, taking the `span` tag as the default inline element, the JavaScript code to wrap a combination of numbers and English units can be as follows: / / Handling English units text = text.replace(englishUnitRegex, (match, num, unit) =>{ return ` ${num}\u00A0${unit} `; }); Wherein, englishUnitRegex represents the first regular expression mentioned in the above embodiment for recognizing the first type of preset text. In ${num}\u00A0${unit}, num represents a number, unit represents a unit, and \u00A0 represents a non-breaking space, indicating that the number and unit are connected by a non-breaking space.

[0072] In another implementation scenario, the JavaScript code that wraps a combination of numbers and Chinese units using a pre-defined inline element as a span tag can be shown below: / / Handle Chinese units (no spaces are needed between Chinese units) text = text.replace(chineseUnitRegex, (match, num, unit) =>{ return ` ${num}${unit} `; }); Here, chineseUnitRegex represents the second regular expression mentioned in the above embodiment for recognizing the second type of preset text, where num in ${num}${unit} represents a number and unit represents a unit.

[0073] It should be noted that, due to Chinese writing habits, spaces are usually not needed between numbers and Chinese units. Therefore, the numbers and Chinese units were directly concatenated in the above example, i.e., ${num}${unit}, without adding a space between the numbers and Chinese units, which conforms to the expression standards of Chinese documents.

[0074] However, in another implementation scenario, an unbreakable space can be added between the numbers and the Chinese units to further ensure that there is no line break between the numbers and the Chinese units. This application does not limit this.

[0075] S202: Render the style of the wrapped preset text using Cascading Style Sheets; where Cascading Style Sheets are used to prevent the preset text from wrapping.

[0076] In one implementation scenario, JavaScript code that uses cascading style sheets to style wrapped preset text to prevent line breaks in the preset text can be shown below:

[0077] Since browsers typically wrap text automatically when it reaches the container boundary, setting `white-space: nowrap` ensures the text is treated as a continuous unit, preventing line breaks even if the container width is insufficient. Setting `display: inline-block` ensures the entire unit is wrapped, meaning `white-space: nowrap` applies to the entire text, not just fragments. It also indicates the text doesn't occupy a single line, allowing it to display on the same line as other text without disrupting the original layout. The `word-break: keep-all` setting primarily prevents forced line breaks between Chinese characters, controlling the display of Chinese characters as a whole.

[0078] In summary, when processing preset text without line breaks, wrapping the preset text with a preset inline element is a lightweight operation that does not disrupt the layout of the original text. After wrapping the preset text, applying styles using Cascading Style Sheets (CSS) prevents line breaks, ensuring the preset text is displayed on a single line, thus improving the user's reading experience. Furthermore, CSS allows for consistent line break processing across all preset text contained within the original text. Adjustments can be made globally simply by modifying the CSS, achieving uniform preset text formatting and offering high scalability and maintainability. Additionally, while CSS prevents line breaks at the style level, it prevents line breaks at the character level by connecting numbers and units with non-breaking spaces. This dual protection of CSS and non-breaking spaces effectively ensures that numbers and units are not split, improving processing reliability.

[0079] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0080] The following are device embodiments of the present invention. For details not described in detail, please refer to the corresponding method embodiments described above.

[0081] Figure 3 This is a schematic diagram of a text processing device provided in an embodiment of the present invention. For ease of explanation, only the parts related to the embodiment of the present invention are shown, and the details are as follows: like Figure 3 As shown, the text processing device 3 includes: Module 31 is used to acquire the original text; Processing module 32 is used to identify the original text and determine whether the original text contains preset text; wherein, the preset text is a unit, or a combination of at least one of a number and a unit and a preset symbol; The processing module 32 is also used to perform text non-linear processing on the preset text if it is determined that the original text contains preset text; The processing module 32 is also used to obtain the target text based on the processed preset text and the remaining text of the original text excluding the preset text.

[0082] In one possible implementation, processing module 32 is specifically used for: Wrap the preset text with the preset inline element; The preset text wrapped in Cascading Style Sheets (CSS) is styled and rendered; CSS is used to prevent the preset text from wrapping.

[0083] In one possible implementation, before wrapping the preset text based on preset inline elements, the processing module 32 is also used to: If the preset text is a combination of numbers and units, then the numbers will be set as a continuous line unit, the units will be set as a continuous line unit, and the numbers and units will be connected by non-breaking spaces.

[0084] In one possible implementation, processing module 32 is specifically used for: If there is a space character between the number and the unit, replace the space character with a non-breaking space; If there is no space character between the number and the unit, then insert a non-breaking space between the number and the unit.

[0085] In one possible implementation, processing module 32 is specifically used for: The original text is identified using regular expressions to obtain the preset text contained in the original text; Regular expressions extract text that matches the features of the original text based on preset string matching rules.

[0086] In one possible implementation, before recognizing the original text, the processing module 32 is also used to: Preprocessing of the original text; preprocessing includes at least one of the following: removal of invalid characters and uniform character encoding.

[0087] In one possible implementation, processing module 32 is further configured to: Format the processed preset text; the formatting marks are used to indicate the font style, font size or color when the preset text is displayed.

[0088] Figure 4 This is a schematic diagram of an electronic device provided in an embodiment of the present invention. For example... Figure 4 As shown, the electronic device 4 in this embodiment includes a processor 40 and a memory 41. The memory 41 stores a computer program 42. When the processor 40 executes the computer program 42, it implements the steps in the various method embodiments described above. Alternatively, when the processor 40 executes the computer program 42, it implements the functions of each module / unit in the various device embodiments described above.

[0089] For example, computer program 42 may be divided into one or more modules / units, which are stored in memory 41 and executed by processor 40 to complete the present invention. The one or more modules / units may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of computer program 42 in electronic device 4.

[0090] Electronic device 4 may include, but is not limited to, processor 40 and memory 41. Those skilled in the art will understand that... Figure 4 This is merely an example of electronic device 4 and does not constitute a limitation on electronic device 4. It may include more or fewer components than shown, or combine certain components, or different components. For example, electronic device 4 may also include input / output devices, network access devices, buses, etc.

[0091] The processor 40 can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.

[0092] The memory 41 can be an internal storage unit of the electronic device 4, such as a hard disk or RAM. The memory 41 can also be an external storage device of the electronic device 4, such as a plug-in hard disk, Smart Media Card (SMC), Secure Digital (SD) card, or Flash Card. Furthermore, the memory 41 can include both internal and external storage units of the electronic device 4. The memory 41 is used to store the computer program 42 and other programs and data required by the electronic device 4. The memory 41 can also be used to temporarily store data that has been output or will be output.

[0093] For the sake of simplicity and clarity, only the above-described functional modules / units are used as examples. In practical applications, the functions described above can be assigned to different functional modules / units as needed. These modules / units can be implemented in hardware, software, or a combination of both.

[0094] This invention also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the methods described in the above-described method embodiments.

[0095] This invention also provides a computer program product, including a computer program. When the computer program is executed by a processor, it implements the methods described in the above-described method embodiments.

[0096] Computer programs include computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. Computer-readable media can include: any entity or device capable of carrying computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc.

[0097] In the above embodiments, the descriptions of each embodiment have their own emphasis. Parts not detailed or described in a particular embodiment can be referred to in the relevant descriptions of other embodiments. Unless otherwise specified or in conflict with logic, the terminology and / or descriptions between different embodiments are consistent and can be referenced interchangeably. Technical features in different embodiments can be combined to form new embodiments based on their inherent logical relationships.

[0098] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included within the protection scope of the present invention. < / unit-block> < / em> < / nobr>

Claims

1. A text processing method, characterized in that, include: Get the original text; The original text is identified to determine whether it contains preset text; wherein the preset text is a unit, or a combination of at least one of a number and a unit and a preset symbol; If it is determined that the original text contains the preset text, then the preset text is processed to prevent text from running out of lines; The target text is obtained based on the processed preset text and the remaining text of the original text excluding the preset text.

2. The text processing method according to claim 1, characterized in that, The step of performing non-linear processing on the preset text includes: The preset text is wrapped based on a preset inline element; The preset text enclosed in Cascading Style Sheets (CSS) is styled using CSS to prevent line breaks in the preset text.

3. The text processing method according to claim 2, characterized in that, Before wrapping the preset text based on preset inline elements, the method further includes: If the preset text is a combination of numbers and units, then the numbers are set as a continuous whole, the units are set as a continuous whole, and the numbers and units are connected by non-breaking spaces.

4. The text processing method according to claim 3, characterized in that, The method of connecting the number and the unit using a non-breaking space includes: If there is a space character between the number and the unit, then the space character is replaced with a non-breaking space; If there is no space character between the number and the unit, then a non-breaking space is inserted between the number and the unit.

5. The text processing method according to any one of claims 1-4, characterized in that, The step of identifying the original text and determining whether the original text contains preset text includes: The original text is identified using regular expressions to obtain the preset text contained in the original text; The regular expression extracts text that matches the features of the preset text from the original text based on preset string matching rules.

6. The text processing method according to any one of claims 1-4, characterized in that, Before recognizing the original text, the process also includes: The original text is preprocessed; the preprocessing includes at least one of the following: removal of invalid characters and uniform character encoding.

7. The text processing method according to any one of claims 1-4, characterized in that, The method further includes: The processed preset text is formatted; the formatting marks are used to indicate the font style, font size or color when the preset text is displayed.

8. A text processing device, characterized in that, include: The acquisition module is used to acquire the raw text; The processing module is used to identify the original text and determine whether the original text contains preset text; wherein, the preset text is a unit, or a combination of at least one of a number and a unit and a preset symbol; The processing module is further configured to perform non-linear processing on the preset text if it is determined that the original text contains the preset text; The processing module is further configured to obtain target text based on the processed preset text and the remaining text of the original text excluding the preset text.

9. An electronic device, characterized in that, It includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the method as described in any one of claims 1 to 7.