Text processing method and device, electronic equipment and computer readable storage medium

By serializing and deserializing the text to be processed and rendering the intermediate text, the problem of difficulty in generating rich text in the existing technology is solved, and the rich text generation effect is achieved with simple syntax rules, fewer marks, and high generality.

CN119720938APending Publication Date: 2025-03-28BOE TECHNOLOGY GROUP CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411897378.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-20
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

The prior art is difficult to effectively generate rich text from code annotations, and the existing rich text generation methods have complex syntax and large number of tags, which are difficult to correct errors, and are not universal enough.

Method used

By responding that the pending text complies with the preset syntax rules, it is serialized and deserialized to obtain the intermediate text, and then render the intermediate text to generate the target text in rich text format.

Benefits of technology

The goal of generating rich text with extremely simple syntax rules, very few tags, and extremely high versatility is achieved, and the automation level of rich text generation is improved, making the generated text more rich and intuitive.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119720938A_ABST
    Figure CN119720938A_ABST
Patent Text Reader

Abstract

The invention provides a text processing method and device, electronic equipment and a computer readable storage medium, and can be applied to the technical field of computers and software. The text processing method comprises the steps that a to-be-processed text is responded to conform to a preset grammar rule, serialization and deserialization processing is conducted on the to-be-processed text, an intermediate text is obtained, the to-be-processed text comprises multiple object types, and the preset grammar rule defines text formats corresponding to the object types respectively; and rendering the intermediate text to obtain a target text which is in a rich text format and has different rendering effects according to different object types.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the fields of computer technology and software technology, and more specifically, to a text processing method and device, an electronic device, and a computer-readable storage medium. Background Art

[0002] Rich text refers to text in Rich Text Format (RTF), which contains information in various formats and styles. Therefore, how to generate rich text from code comments is an urgent problem to be solved. Summary of the invention

[0003] In view of this, the present disclosure provides a text processing method and device, an electronic device, and a computer-readable storage medium.

[0004] According to one aspect of the present disclosure, a text processing method is provided, including: in response to a text to be processed conforming to preset grammatical rules, serializing and deserializing the text to be processed to obtain an intermediate text, wherein the text to be processed includes a plurality of object types, and the preset grammatical rules define the text formats corresponding to the object types; and, rendering the intermediate text to obtain a target text, wherein the target text is in a rich text format and has different rendering effects according to different object types.

[0005] According to another aspect of the present disclosure, a text processing device is provided, including: a processing module, used for serializing and deserializing the text to be processed in response to the text to be processed conforming to preset grammar rules to obtain an intermediate text, wherein the text to be processed includes multiple object types, and the preset grammar rules define the text formats corresponding to the above object types; and a rendering module, used for rendering the intermediate text to obtain a target text, wherein the target text is in a rich text format and has different rendering effects according to different object types.

[0006] According to another aspect of the present disclosure, an electronic device is provided, comprising: one or more processors; and a memory for storing one or more instructions, wherein when the one or more instructions are executed by the one or more processors, the one or more processors implement the method described in the present disclosure.

[0007] According to another aspect of the present disclosure, a computer-readable storage medium is provided, on which executable instructions are stored. When the executable instructions are executed by a processor, the processor implements the method described in the present disclosure.

[0008] According to another aspect of the present disclosure, a computer program product is provided. The computer program product includes computer executable instructions. When the computer executable instructions are executed, they are used to implement the method described in the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] The above and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:

[0010] Figure 1 The system architecture to which the text processing method according to the embodiment of the present disclosure can be applied is schematically shown;

[0011] Figure 2 A flowchart of a text processing method according to an embodiment of the present disclosure is schematically shown;

[0012] Figure 3 An example schematic diagram of a process for obtaining a verification result according to an embodiment of the present disclosure is schematically shown;

[0013] Figure 4 An example schematic diagram schematically shows a text format according to an embodiment of the present disclosure;

[0014] Figure 5 An example schematic diagram schematically shows a target text obtaining process according to an embodiment of the present disclosure;

[0015] Fig. 6A An example schematic diagram schematically shows the rendering effect of a text object according to an embodiment of the present disclosure;

[0016] Figure 6B An example schematic diagram schematically shows a rendering effect of a link object according to an embodiment of the present disclosure;

[0017] Figure 6C An example schematic diagram schematically shows the rendering effect of an image object according to an embodiment of the present disclosure;

[0018] Fig.6D An example schematic diagram schematically shows the rendering effect of a title object according to an embodiment of the present disclosure;

[0019] Fig. 6E An example schematic diagram schematically shows a rendering effect of an event object according to an embodiment of the present disclosure;

[0020] Fig. 6F An example schematic diagram schematically shows the rendering effect of a code object according to an embodiment of the present disclosure;

[0021] Figure 6G An example schematic diagram schematically shows a rendering effect of a term object according to an embodiment of the present disclosure;

[0022] Figure 6H An example schematic diagram schematically shows a rendering effect of a jump object according to an embodiment of the present disclosure;

[0023] Figure 7 A block diagram schematically shows a text processing device according to an embodiment of the present disclosure; and

[0024] Figure 8 A block diagram of an electronic device suitable for implementing a text processing method according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION

[0025] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.

[0026] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.

[0027] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification, and should not be interpreted in an idealized or overly rigid manner.

[0028] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).

[0029] In the technical solution of the present invention, the user information (including but not limited to user personal information, user image information, user device information, such as location information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved are all information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of relevant data comply with relevant laws, regulations and standards, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0030] In one example, the method of generating rich text from code comments may include at least one of the following: XML (Extensible Markup Language) comment syntax based on C language, custom syntax based on open source tools (such as Doxygen), markdown comment syntax based on static programming languages ​​(such as Swift or Kotlin), etc.

[0031] However, the syntax of the above-mentioned various rich text generation methods is relatively complex, the number of tags is too large, and a lot of content related to format adjustment is mixed in the code, so it is difficult to correct errors; and because the above-mentioned various rich text generation methods are not universal enough.

[0032] To this end, the present disclosure provides a text processing method and device, an electronic device, and a computer-readable storage medium, which can be applied to the fields of computer technology and software technology. The text processing method includes: in response to the text to be processed conforming to a preset grammar rule, serializing and deserializing the text to be processed to obtain an intermediate text, wherein the text to be processed includes multiple object types, and the preset grammar rule defines the text format corresponding to each object type; and rendering the intermediate text to obtain a target text, wherein the target text is in a rich text format and has different rendering effects according to different object types.

[0033] Figure 1 The system architecture to which the text processing method according to the embodiment of the present disclosure can be applied is schematically shown. It should be noted that: Figure 1 What is shown is merely an example of a system architecture to which the embodiments of the present disclosure can be applied, in order to help those skilled in the art understand the technical content of the present disclosure, but it does not mean that the embodiments of the present disclosure cannot be used in other devices, systems, environments or scenarios.

[0034] like Figure 1 As shown, the system architecture 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104 and a server 105. The network 104 is a medium for providing a communication link between different devices.

[0035] It should be noted that the text processing method provided in the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, the text processing device provided in the embodiment of the present disclosure can generally be set in the server 105.

[0036] Alternatively, the text processing method provided in the embodiment of the present disclosure may also be executed by the first terminal device 101, the second terminal device 102 or the third terminal device 103. Accordingly, the text processing apparatus provided in the embodiment of the present disclosure may also be arranged in the first terminal device 101, the second terminal device 102 or the third terminal device 103.

[0037] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0038] It should be noted that the sequence numbers of the operations in the following method are only used as representations of the operations for the purpose of description, and should not be regarded as representing the execution order of the operations. Unless explicitly stated, the method does not need to be executed completely in the order shown.

[0039] The above describes the system architecture to which the text processing method provided by the present disclosure can be applied. Figure 2 For example, the text processing process of the present disclosure is further explained.

[0040] Figure 2 The flowchart of the text processing method according to the embodiment of the present disclosure is schematically shown.

[0041] like Figure 2 As shown, the text processing method 200 includes operations S210 to S220.

[0042] In operation S210, in response to the text to be processed conforming to the preset grammar rules, the text to be processed is serialized and deserialized to obtain an intermediate text, wherein the text to be processed includes multiple object types, and the preset grammar rules define the text formats corresponding to the multiple object types.

[0043] In operation S220 , the intermediate text is rendered to obtain a target text, wherein the target text is in a rich text format and has different rendering effects according to different object types.

[0044] The file type of the text to be processed can be configured according to actual business needs and is not limited here. For example, the file type of the text to be processed may include at least one of the following: .h, .c, .hpp, .cc, .cpp, .cs, .js, .ts, .go, .java, .vue, .rs, .py, .sh, .sql, .lua, and .txt, etc.

[0045] The text to be processed may include multiple starting characters and multiple first sub-texts obtained by dividing the starting characters, and each first sub-text has an object type. The target text includes rendering objects of multiple first sub-texts, and each rendering object of each first sub-text has a rendering effect corresponding to the object type. The first sub-text is a code segment for defining the rendering object. The object type is used to characterize the function implemented by the first sub-text. For example, the first sub-text is a code segment divided by the starting characters " / / / ": / / / @content{This is a comment, the function is.....}. Before processing the text to be processed, the text to be processed can be verified according to pre-configured preset grammar rules, and the text processing method provided by the present disclosure can be executed after the verification passes.

[0046] In one example, the object type may include at least one of the following: a text object (content), a link object (href), an image object (img), a title object (title1, title2, title3, title4, title5), an event object (todo), a code object (range), a term object (term), and a jump object (jumpto).

[0047] The text object is used to represent a piece of text. It can be any type of text content, such as articles, instructions, and descriptions. The link object is used to represent an external link. The target URL of the link can be specified. The image object is used to represent a picture link. The URL of the picture can be specified. The event object is used to represent some to-do items. It is usually used in task lists or to-do lists to mark tasks that need to be completed. The code object is used to represent a piece of code. It may be used for code blocks or references to specific code segments. The term object is used to represent a term, which is usually used to define or explain professional terms, keywords or important concepts. The jump object is used to jump to another content page within the project. It may be an internal link or anchor, allowing users to quickly navigate to different parts of the document.

[0048] Title objects are used to describe titles of different levels. For example, title1 is used to describe the first-level title, which is the highest-level title in the document and is used to summarize the main content. title2 is used to describe the second-level title, which is used for subtopics or main parts under the first-level title. title3 is used to describe the third-level title, which is used for more specific content under the second-level title. title4 is used to describe the fourth-level title, which is used for more detailed content under the third-level title. title5 is used to describe the fifth-level title, which is used for further subdivision under the fourth-level title.

[0049] In one example, the preset grammar rules define the text formats corresponding to the object types. For each first subtext in the text to be processed, the first subtext can be checked according to the object type of the first subtext using the text format used for the object type to determine whether each first subtext conforms to the corresponding text format, thereby determining whether the text to be processed conforms to the preset grammar rules.

[0050] After the text to be processed conforms to the preset grammatical rules, the text to be processed can be serialized and deserialized to obtain the intermediate text. Serialization refers to the process of converting a data structure or object state into a format that can be stored (such as saved in a file) or transmitted (such as sent over a network), and deserialization refers to the process of converting a format that can be stored or transmitted into a format that can be used.

[0051] After obtaining the intermediate text, each sub-text can be rendered according to the rendering effect used for the object type to obtain the target text in rich text format. Rich text format allows formatting information to be included in the text, such as font style, color, size, pictures and links, that is, the target text contains not only plain text content, but also instructions on how to display these contents.

[0052] It should be noted that the text processing method provided by the present invention can be applied to various design and content creation scenarios. By utilizing the text processing method to render the text to be processed into a target text in a rich text format, developers can use different fonts, colors, and styles to highlight the key information of different object types and build content-rich documents.

[0053] The specific application scenarios of the text processing method can be configured according to actual business needs and are not limited here. In one example, the specific application scenarios of the text processing method can include at least one of the following: web design scenarios, email marketing scenarios, and online document scenarios.

[0054] For example, in a web design scenario, the text processing method provided by the present disclosure can be used to render text content such as articles and news on a web page, so that rich formats and images can be displayed. Alternatively, in an email marketing scenario, the text processing method provided by the present disclosure can be used to render text content such as product details in an email, so that the email content is more attractive to users and improves the user's reading experience. Alternatively, in an online document scenario, the text processing method provided by the present disclosure can be used to render text content in an online document, so that users can edit and share documents online more easily.

[0055] It should be noted that the specific implementation form of the text processing method can be configured according to the actual application scenario and is not limited here. In one example, for an application scenario that requires high performance and stability, the text processing method can be implemented in the form of hardware. In another example, for an application scenario that requires flexibility and rapid development, the text processing method can be implemented in the form of software.

[0056] The hardware form may include electronic readers, mobile devices, vehicle-mounted terminals, and wearable devices. For example, the text processing method may be encapsulated in an electronic reader, so that the electronic reader can provide clear typesetting and font selection to enhance the user experience. Alternatively, the text processing method may be encapsulated in a mobile device, so that the mobile device can support high-quality text rendering based on the equipped touch screen and high-performance processor. Alternatively, the text processing method may be encapsulated in a vehicle-mounted terminal and a wearable device, so that the specific user interface requirements of these devices can be met, thereby improving the display effect of these devices.

[0057] Software forms may include Web applications, browser plug-ins, desktop applications (exe files), and mobile applications (APPs), etc. For example, a text processing method may exist as a Web application, so that an online text processing application may be accessed through a browser to design and generate a target text in a rich text format. Alternatively, the text processing method may be encapsulated as a browser plug-in, so that a text processing interface supported by embedded browser technology may be used to design and generate a target text in a rich text format. Alternatively, the text processing method may exist as a desktop application, so that an exe file may be downloaded and run on a local computer to design and generate a target text in a rich text format. Alternatively, the text processing method may be used as part of a mobile application, so that a target text in a rich text format may be designed and generated by using a mobile application on a mobile terminal. According to an embodiment of the present disclosure, the text to be processed is serialized and deserialized according to its object type and preset grammar rules, and the obtained intermediate text is rendered to convert the intermediate text into a target text in rich text format, and a specific rendering effect is given according to its object type. This achieves extremely simple grammar rules, a very small number of tags, and extremely high versatility, making the target text visually richer and more intuitive, thereby improving the level of automation of rich text generation.

[0058] It can be understood that the above is a preliminary description of the text processing method provided by the present disclosure. In the embodiment of the present disclosure, before processing the text to be processed, the text to be processed can also be verified based on the preset grammar rules. Figure 3 How to obtain the verification result of the present disclosure is further explained.

[0059] Figure 3 An example schematic diagram of a process for obtaining a verification result according to an embodiment of the present disclosure is schematically shown.

[0060] like Figure 3 As shown, in 300, the text to be processed 302 can be matched with at least one preset character 301 to obtain multiple first sub-texts 303. At least one preset character can be used to detect the starting character to divide the first sub-text based on the starting character. The preset character 301 can be configured according to actual business needs and is not limited here. The preset character 301 can include at least one of the following: " / / / ", "###" and "---". For example, "###" can be used for comments in source codes such as python and bash, and "---" can be used for comments in source codes such as sql and lua.

[0061] In one example, each first subtext 303 includes a starting character 303_1 that matches the preset character 301, an object name 303_2, and a content text 303_3. The object name 303_2 can be used to characterize the object type of the first subtext. By using the preset character 301, character matching is performed one by one on each character in the to-be-processed text 302, and the text content in the to-be-processed text 302 starting from a character that matches the preset character 301 and ending with the next character that matches the preset character 301 is determined as the first subtext 303.

[0062] For example, the first subtext 303 may be in the form of "[starting character]@[object name]{content text}", that is, the character "@" is used to distinguish the starting character from the object name, and the character "{}" is used to represent the content text. Taking the preset character 301 as " / / / " and the to-be-processed text 302 as " / / / @content{This is a comment, its function is.....} / / / @img{.. / images / xxx.png}" as an example, the first first subtext " / / / @content{This is a comment, its function is.....}" and the second first subtext " / / / @img{.. / images / xxx.png}" can be obtained.

[0063] In one example, the text format 304 can be used to define the relative position relationship between the starting character 303_1, the object name 303_2 and the content text 303_3. The relative position relationship refers to how the starting character 303_1, the object name 303_2 and the content text 303_3 are arranged and related to each other in the first subtext 303.

[0064] According to the embodiments of the present disclosure, by matching the text to be processed with the preset characters, multiple first subtexts can be intelligently identified and segmented. On this basis, by checking the relative position relationship between the starting characters, object name and content text included in each first subtext according to the text format used for the object type, the format correctness of the first subtexts of different object types can be verified, thereby improving the accuracy and efficiency of text processing.

[0065] After obtaining the plurality of first subtexts 303, for each first subtext 303, each first subtext 303 may be verified according to the text format 304 for the object type to obtain a respective sub-verification result 305 for each first subtext 303. After obtaining the respective sub-verification results 305 for the plurality of first subtexts 303, operation S310 may be performed.

[0066] In operation S310, do the plurality of sub-verification results 305 all indicate that the first sub-text 303 passes verification? If not, a verification result 306 indicating that the text to be processed does not conform to the preset grammar rule can be determined. If so, a verification result 307 indicating that the text to be processed conforms to the preset grammar rule can be determined.

[0067] According to an embodiment of the present disclosure, by verifying the first subtext according to the text format used for the object type, the format correctness of each first subtext is ensured. On this basis, by synthesizing multiple sub-verification results, a verification result can be obtained that characterizes whether the text to be processed conforms to the preset grammatical rules.

[0068] It can be understood that the above describes how to obtain the verification results. Figure 4 The text format of the present disclosure is exemplified.

[0069] Figure 4 An example diagram of a text format according to an embodiment of the present disclosure is schematically shown.

[0070] like Figure 4 As shown, in 400, the text format used for the object type can be configured according to actual business needs and is not limited here.

[0071] For example, text format 401 may be that the starting characters, object name and content text are located in the same row. Text format 402 may be that there is cross-line text in the content text that is located in a different row from the starting characters and object name, and there is a new starting character before the cross-line text. Text format 403 may be that there is cross-line text in the content text that is located in a different row from the starting characters and object name, and the cross-line text includes question text. In this case, the question text refers to an invalid row that does not contain the starting characters and can be ignored. Text format 404 may be that the content text is located in a different row from the starting characters and object name. Text format 405 may be that there is question text before the starting characters or after the object name. In this case, the question text refers to illegal content or missing spaces. Text format 406 may include multiple object names.

[0072] According to the embodiments of the present disclosure, by setting a variety of text formats, it is possible to adapt to a variety of complex text structures and layout requirements, thereby meeting the text layout and format requirements in different scenarios and ensuring the standardization and readability of the text.

[0073] In one example, taking the object type as a text object and the object name as "content", the content text is identified as "This is a comment, the function is ...", and the text format for the text object may include at least one of the following:

[0074]

[0075] In another example, taking the object type as a link object and the object name as "href" as an example, the content text is identified as "https: / / www.X.com.cn", and the text format for the link object may include at least one of the following:

[0076]

[0077] In another example, taking the object type as an image object and the object name as "img" as an example, the content text is identified as a relative path ".. / images / X.png" or a remote image path, and the text format for the image object may include at least one of the following:

[0078]

[0079]

[0080] In another example, taking the object type as a title object, the object names as "title1", "title2", "title3", "title4" and "title5", the content text is identified as "This is a title...", and the text format for the title object may include at least one of the following:

[0081]

[0082] In another example, taking the object type as an event object and the object name as "todo", the content text is recognized as "This is a todo...", and consecutive todo tags are regarded as multiple to-do items. The text format for the event object may include at least one of the following:

[0083]

[0084] In another example, taking the object type as code object and the object name as "range" as an example, the content text is identified as "line number" or "starting line number-ending line number", which can be used to output the source file content of the specified range of the content text, thereby being used to generate a code example. The text format for the code object may include at least one of the following:

[0085]

[0086] In another example, taking the object type as a term object and the object name as "term" as an example, the content text is identified as "This is a term...", and the text format for the term object may include at least one of the following:

[0087]

[0088] In another example, taking the object type as a jump object and the object name as "jumpto", the content text is identified as "... / X / test.h", and the text format for the jump object may include at least one of the following:

[0089]

[0090] After determining that the text to be processed conforms to the preset grammatical rules, the text to be processed can be serialized and deserialized to obtain the intermediate text, and the intermediate text is rendered to obtain the target text. Figure 5 The target text obtaining process of the present disclosure is further explained.

[0091] Figure 5 An example schematic diagram of a target text obtaining process according to an embodiment of the present disclosure is schematically shown.

[0092] like Figure 5 As shown, in 500, the text to be processed 502 can be serialized using an interpretation tool 501 to obtain serialized data 505. The specific method of serialization can be configured according to actual business needs and is not limited here. For example, for each first subtext 502_1, the object name can be used as the key and the content text can be used as the value to obtain a key-value pair 503 in JSON format.

[0093] In one example, the key-value pair 503 in JSON format may be {"tag":"object name","content":"content text"}. It should be noted that for a code object, the content text (i.e., "line number" or "starting line number-ending line number") will be replaced with a specific code string.

[0094] After obtaining the key-value pair 503 of each first subtext 502_1, the key-value pairs 503 of the plurality of first subtexts 502_1 can be encrypted based on the preset encryption method 504 to obtain serialized data 505 to ensure data security. The preset encryption method 504 can be configured according to actual business needs and is not limited here. For example, the preset encryption method 504 can include at least one of the following: a symmetric encryption method and an asymmetric encryption method.

[0095] After obtaining the serialized data 505, the rendering tool 508 can be used to deserialize the serialized data 505 to obtain the intermediate text 509. The specific method of deserialization can be configured according to actual business needs and is not limited here. For example, for the serialized data 505, the interface 506 for providing a preset decryption method corresponding to the preset encryption method can be used to decrypt the serialized data 505 to obtain a key-value pair 507. In one example, the interface 506 can be provided to the outside in the form of a dynamic library combined with a header file. After obtaining each key-value pair 507, for each key-value pair 507, the key in the key-value pair 507 can be filled into the first field of the structure, and the value in the key-value pair can be filled into the second field of the structure to obtain a parsable structure object 509_1.

[0096] According to the embodiments of the present disclosure, the serialized data is obtained by serializing the text to be processed using an interpretation tool, thereby improving the readability and operability of the data. On this basis, the intermediate text is obtained by deserializing the serialized data using a rendering tool, thereby realizing the conversion from the original text to the structured data, making the data more efficient and orderly in the further processing and rendering process.

[0097] After obtaining the structure objects 509_1 of each of the multiple key-value pairs 507, for each structure object 509_1, the structure object 509_1 can be rendered in sequence according to the position order of the first subtext 502_1 corresponding to the structure object 509_1 in the to-be-processed text 502, and according to the rendering effect 510 for the object type, to obtain the target text 511. The specific rendering method can be configured according to actual business needs and is not limited here. For example, the structure objects 509_1 can be rendered as rendering objects according to the rendering effect 510 for the object type, and then the target text 511 is generated according to the rendering object of each structure object.

[0098] According to an embodiment of the present disclosure, by applying a specific rendering effect to each structure object, efficient conversion from structured data to target text in a rich text format is achieved.

[0099] It can be understood that the above describes the process of obtaining the target text. In the embodiment of the present disclosure, different object types can have different rendering effects. Figure 6A to Figure 6H The rendering effects of different object types of the present disclosure are further described.

[0100] In one example, the type of rendering effect may include at least one of the following: text block position, text block size, image position, image size, text position, text size, text color, background color, and pop-up window position.

[0101] Fig. 6A An example schematic diagram schematically illustrates the rendering effect of a text object according to an embodiment of the present disclosure.

[0102] like Fig. 6A As shown, taking the rendering effect 601 of a text object (i.e., content) as an example, the text object can be rendered as a text block, and the rendering effect for the text object can include the text block position and the text block size. For example, the rendering effect for the text object can be set to a top margin of the outer border of the text block of 12 pixels.

[0103] Figure 6B An example schematic diagram schematically illustrates the rendering effect of a link object according to an embodiment of the present disclosure.

[0104] like Figure 6B As shown, taking the rendering effect 602 of the link object (i.e., href) as an example, the link object can be rendered as a text block and a pop-up window, and the rendering effect for the link object can include the text block position and the pop-up window position. For example, the rendering effect for the link object can be set to pop up a pop-up window prompt after clicking the link object, and jump to an external page after agreeing.

[0105] Figure 6C An example schematic diagram schematically illustrates the rendering effect of an image object according to an embodiment of the present disclosure.

[0106] like Figure 6C As shown, taking the rendering effect 603 of the image object (i.e., img) as an example, the image object can be rendered as a text block and an image, and the rendering effect for the image object can include an image position and an image size. For example, the rendering effect for the image object can be set to an image position of left alignment and an image size of a maximum width of 600 pixels.

[0107] Fig.6D An example schematic diagram schematically shows the rendering effect of a title object according to an embodiment of the present disclosure.

[0108] like Fig.6DAs shown, taking the rendering effect 604 of the title objects (i.e., title1, title2, title3, title4, and title5) as an example, the title objects can be rendered as text, and the rendering effect for the title objects can include the text position and the text size. For example, the text size corresponding to the title object (i.e., title1) can be set to 3.75rem, the text size corresponding to the title object (i.e., title2) can be set to 3rem, the text size corresponding to the title object (i.e., title3) can be set to 2.125rem, the text size corresponding to the title object (i.e., title4) can be set to 1.5rem, and the text size corresponding to the title object (i.e., title5) can be set to 1.25rem.

[0109] Fig. 6E An example schematic diagram schematically illustrates the rendering effect of an event object according to an embodiment of the present disclosure.

[0110] like Fig. 6E As shown, taking the rendering effect 605 of the event object (i.e., todo) as an example, the event object can be rendered as a text box and a pop-up window, and the rendering effect for the event object can include the text box position and the pop-up window position. For example, the rendering effect for the event object can be set to a distance of 12 pixels between the text box position and the pop-up window position.

[0111] Fig. 6F An example schematic diagram schematically shows the rendering effect of a code object according to an embodiment of the present disclosure.

[0112] like Fig. 6F As shown, taking the rendering effect 606 of the code object (i.e., range) as an example, the code object can be rendered as text, and the rendering effect for the code object can include text position, text color, and background color. For example, the rendering effect for the code object can be set to a background color of black and a text color of white.

[0113] Figure 6G An example schematic diagram schematically illustrates the rendering effect of a term object according to an embodiment of the present disclosure.

[0114] like Figure 6G As shown, taking the rendering effect 607 of a term object (i.e., term) as an example, the term object can be rendered as a text box, and the rendering effect for the term object can include the text box position and the background color. For example, the rendering effect for the term object can be set to a gray background color.

[0115] Figure 6H An example schematic diagram schematically illustrates the rendering effect of a jump object according to an embodiment of the present disclosure.

[0116] like Figure 6H As shown, taking the rendering effect 608 of the jump object (i.e., jumpto) as an example, the jump object can be rendered as a text box and text, and the rendering effect for the jump object can include text color and text box position. For example, the rendering effect for the jump object can be set to black text color.

[0117] The above are merely exemplary embodiments, but are not limited thereto, and may also include other text processing methods known in the art, as long as they can improve the automation level of rich text generation.

[0118] It should be noted that in the embodiments of the present invention, certain software, components, models and other existing solutions in the industry may be mentioned, which should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of the present invention, but it does not mean that the present invention has or must use this solution.

[0119] Based on the above text processing method, the present invention also provides a text processing device. Figure 7 The device is described in detail.

[0120] Figure 7 The block diagram of a text processing device according to an embodiment of the present disclosure is schematically shown.

[0121] like Figure 7 As shown, the text processing apparatus 700 may include a processing module 710 and a rendering module 720 .

[0122] The processing module 710 is used to serialize and deserialize the text to be processed to obtain an intermediate text in response to the text to be processed conforming to the preset grammar rules, wherein the text to be processed includes multiple object types, and the preset grammar rules define the text formats corresponding to each object type.

[0123] The rendering module 720 is used to render the intermediate text to obtain the target text, wherein the target text is in a rich text format and has different rendering effects according to different object types.

[0124] According to any one or more of the modules of the embodiments of the present disclosure, at least part of the functions of any one of them can be implemented in one module. According to any one or more of the modules of the embodiments of the present disclosure, it can be split into multiple modules for implementation. According to any one or more of the modules of the embodiments of the present disclosure, it can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application-specific integrated circuit (ASIC), or can be implemented by hardware or firmware of any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware and firmware or in any appropriate combination of any of them. Alternatively, according to one or more of the modules of the embodiments of the present disclosure, it can be at least partially implemented as a computer program module, and when the computer program module is run, the corresponding function can be performed.

[0125] It should be noted that the text processing device part in the embodiment of the present disclosure corresponds to the text processing method part in the embodiment of the present disclosure. The description of the text processing device part specifically refers to the text processing method part, which will not be repeated here.

[0126] Figure 8 A block diagram of an electronic device suitable for implementing a text processing method according to an embodiment of the present disclosure is schematically shown. Figure 8 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0127] like Figure 8 As shown, the computer electronic device 800 according to the embodiment of the present disclosure includes a processor 801, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 802 or the program loaded from the storage part 809 to the random access memory (RAM) 803. The processor 801 may include, for example, a general-purpose microprocessor (such as a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (for example, an application-specific integrated circuit (ASIC)), etc. The processor 801 may also include an onboard memory for caching purposes. The processor 801 may include a single processing unit or multiple processing units for performing different actions of the method flow according to the embodiment of the present disclosure.

[0128] In the RAM 803, various programs and data necessary for the operation of the electronic device 800 are stored. The processor 801, the ROM 802, and the RAM 803 are connected to each other through a bus 804.

[0129] According to an embodiment of the present disclosure, the electronic device 800 may further include an input / output (I / O) interface 805, which is also connected to the bus 804. The electronic device 800 may further include one or more of the following components connected to the input / output (I / O) interface 805: an input portion 806 including a keyboard, a mouse, etc.; an output portion 807 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 808 including a hard disk, etc.; and a communication portion 809 including a network interface card such as a LAN card, a modem, etc. The communication portion 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the input / output (I / O) interface 805 as needed. A removable medium 811, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 810 as needed, so that a computer program read therefrom is installed into the storage portion 808 as needed.

[0130] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the text processing method according to the embodiment of the present disclosure is implemented.

[0131] In the present disclosure, a computer readable storage medium may be any tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device.

[0132] An embodiment of the present disclosure also includes a computer program product, which includes a computer program, and the computer program contains a program code for executing the method provided by the embodiment of the present disclosure. When the computer program product runs on an electronic device, the program code is used to enable the electronic device to implement the text processing method provided by the embodiment of the present disclosure.

[0133] When the computer program is executed by the processor 801, the above functions defined in the system / device of the embodiment of the present disclosure are executed. According to the embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.

[0134] According to the embodiments of the present disclosure, program codes for executing the computer programs provided by the embodiments of the present disclosure may be written in any combination of one or more programming languages.

[0135] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. It should also be noted that in some alternative implementations, the functions marked in the blocks may also occur in an order different from that marked in the accompanying drawings.

[0136] The embodiments of the present disclosure are described above. However, these embodiments are only for the purpose of illustration and are not intended to limit the scope of the present disclosure. Although the embodiments are described above separately, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. The scope of the present disclosure is defined by the attached claims and their equivalents. Without departing from the scope of the present disclosure, those skilled in the art may make various substitutions and modifications, which should all fall within the scope of the present disclosure.

Claims

1. A text processing method, comprising: In response to the text to be processed conforming to the preset grammar rules, serializing and deserializing the text to be processed to obtain an intermediate text, wherein the text to be processed includes a plurality of object types, and the preset grammar rules define the text formats corresponding to the respective object types; and The intermediate text is rendered to obtain a target text, wherein the target text is in a rich text format and has different rendering effects according to different object types.

2. The method according to claim 1, wherein: The to-be-processed text includes a plurality of starting characters and a plurality of first sub-texts obtained by dividing the starting characters, and the target text includes rendering objects of the plurality of first sub-texts respectively; Each of the first subtexts has the object type, and each of the rendering objects of the first subtexts has a rendering effect corresponding to the object type.

3. The method according to claim 2 further comprises, before the text to be processed is serialized and deserialized to obtain the intermediate text in response to the text to be processed conforming to the preset grammar rule: The text to be processed is matched with at least one preset character to obtain the plurality of first subtexts, wherein: The at least one preset character is used to detect the starting character, so as to divide the first subtext based on the starting character; as well as According to the text format of the object type, each of the first subtexts is verified respectively to obtain a verification result.

4. The method according to claim 2, wherein: The first subtext is a code segment for defining the rendering object; The first subtext includes a starting character matching the preset character, an object name, and a content text, and the text format defines a relative position relationship among the starting character, the object name, and the content text.

5. The method according to claim 3, wherein: The checking of each of the first subtexts according to the text format of the object type to obtain the checking result includes: For each of the first subtexts, Verifying the first subtext according to the text format of the object type to obtain a sub-verification result; If the plurality of sub-verification results all indicate that the first sub-text has passed the verification, determining a verification result indicating that the to-be-processed text complies with the preset grammatical rule; and In the case that there is a sub-verification result indicating that the first sub-text fails the verification among the plurality of sub-verification results, a verification result indicating that the to-be-processed text fails to conform to the preset grammatical rule is determined.

6. The method according to any one of claims 1 to 5, wherein: In response to the text to be processed conforming to the preset grammatical rule, serializing and deserializing the text to be processed to obtain the intermediate text includes: Using an interpretation tool, serializing the text to be processed to obtain serialized data, wherein the serialized data includes key-value pairs of the plurality of first subtexts; and The serialized data is deserialized using a rendering tool to obtain the intermediate text, wherein the intermediate text includes structure objects of each of the plurality of key-value pairs.

7. The method according to claim 6, wherein: The interpretation tool is used to serialize the text to be processed, and the serialized data obtained includes: For each of the first subtexts, use the object name as a key and the content text as a value to obtain the key-value pair; The using of a rendering tool to deserialize the serialized data to obtain the intermediate text comprises: For each of the key-value pairs, the key in the key-value pair is filled into the first field of the structure, and the value in the key-value pair is filled into the second field of the structure, so as to obtain the structure object.

8. The method according to claim 7, further comprising: After obtaining the key-value pair by using the object name as the key and the content text as the value: Based on a preset encryption method, encrypt the key-value pairs of the plurality of first subtexts to obtain the serialized data; Before filling the key in the key-value pair into the first field of the structure and the value in the key-value pair into the second field of the structure to obtain the structure object: Using the interface, the serialized data is decrypted to obtain the key-value pair, where: The interface is used to provide a preset decryption method corresponding to the preset encryption method.

9. The method according to claim 6, wherein: The rendering of the intermediate text to obtain the target text comprises: For each of the structure objects, rendering the structure object according to the rendering effect of the object type to obtain the rendered object; and The target text is generated according to the rendering object of each of the structure objects.

10. The method according to claim 1, wherein: The text format includes at least one of the following: The starting character, the object name and the content text are located in the same line; The content text contains cross-line text that is located on a different line from the start character and the object name, and a new start character exists before the cross-line text; The content text contains cross-line text located in a different line from the start character and the object name, and the cross-line text includes question text; The content text is located on a different line from the start character and the object name; There is question text before the starting character or after the object name; and The object name includes multiple ones.

11. The method according to claim 1, wherein: The type of rendering effect includes at least one of the following: text block position, text block size, image position, image size, text position, text size, text color, background color and pop-up window position.

12. The method according to claim 1, wherein: The object type includes at least one of the following: a text object, a link object, an image object, a title object, an event object, a code object, a term object, and a jump object.

13. A text processing device, comprising: a processing module, configured to serialize and deserialize the text to be processed to obtain an intermediate text in response to the text to be processed conforming to a preset grammar rule, wherein the text to be processed includes a plurality of object types, and the preset grammar rule defines a text format corresponding to each of the object types; and The rendering module is used to render the intermediate text to obtain a target text, wherein the target text is in a rich text format and has different rendering effects according to different object types.

14. An electronic device comprising: one or more processors; a memory for storing one or more computer programs, The method comprises the step of executing the one or more computer programs to implement the steps of the method according to any one of claims 1 to 12.

15. A computer-readable storage medium having a computer program or instruction stored thereon, characterized in that: When the computer program or instruction is executed by a processor, the steps of the method according to any one of claims 1 to 12 are implemented.

16. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the steps of the method according to any one of claims 1 to 12 are implemented.

Citation Information

Patent Citations

  • Code text processing method and device, computer equipment and storage medium

    CN112882716A

  • Rich text rendering method and device, electronic equipment and storage medium

    CN113761871A

  • Text rendering method and system, computer equipment and medium

    CN116402035A

  • Text structured processing method and device, electronic equipment and storage medium

    CN118504539A