A text processing method, apparatus, electronic device, and storage medium
By constructing and parsing format dictionaries, personalized format conversion of multi-format text is realized, solving the problem that cannot meet configuration operations in the existing technology, and is suitable for multi-format text processing in iOS and Android systems.
Patent Information
- Application Number
- CN202110054186.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-15
- Publication Date
- 2025-07-11
- Estimated Expiration
- 2041-01-15
AI Technical Summary
The existing multi-format text processing methods cannot meet the configuration operation requirements, especially in Android systems, where a simplified multi-format text processing solution is lacking.
By pre-constructing the first format dictionary, parsing the format properties of the pending text, and encapsulating it into multi-format text that is adapted to the native system, personalized format conversion is realized.
It realizes multi-format text processing in various configuration scenarios, simplifies the operation process, and enables both iOS and Android systems to support dynamic generation of multi-format text.
Smart Images

Figure CN114764562B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of computer technology, and in particular, to a text processing method, apparatus, electronic device, and storage medium. Background Art
[0002] In the development of practical applications, it is often necessary to perform multi-format processing on text to obtain multi-format text. Among them, multi-format text refers to a segment of text composed of various different formats of text. For example, in a segment of multi-format text, the colors and font sizes of some texts are different from those of other texts.
[0003] Currently, the commonly used method for processing multi-format text is to use the method provided by the system (such as the Android system). However, the method provided by the system cannot meet some configured scenarios. Therefore, it is necessary to find a simplified multi-format text processing solution to facilitate various configured operations. Summary of the Invention
[0004] Embodiments of the present invention provide a text processing method, apparatus, electronic device, and storage medium, which realize personalized format conversion for the text to be processed.
[0005] In a first aspect, an embodiment of the present invention provides a text processing method, including:
[0006] Pre-constructing a first format dictionary for the text to be processed;
[0007] When it is necessary to perform format conversion on the text to be processed, parsing the first format dictionary to obtain the text to be processed and the format attributes corresponding to the text to be processed;
[0008] Encapsulating the text to be processed and the corresponding format attributes to complete the format conversion for the text to be processed.
[0009] In a second aspect, an embodiment of the present invention further provides a text processing apparatus, including:
[0010] A construction module, configured to pre-construct a first format dictionary for the text to be processed;
[0011] An analysis module, configured to parse the first format dictionary to obtain the text to be processed and the format attributes corresponding to the text to be processed when it is necessary to perform format conversion on the text to be processed;
[0012] An encapsulation module, configured to encapsulate the text to be processed and the corresponding format attributes to complete the format conversion for the text to be processed.
[0013] In a third aspect, an embodiment of the present invention further provides an electronic device, where the electronic device includes:
[0014] One or more processors;
[0015] A memory for storing one or more programs;
[0016] When the one or more programs are executed by the one or more processors, the one or more processors implement the text processing method steps provided in any embodiment of the present invention.
[0017] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, it implements the text processing method steps provided in any embodiment of the present invention.
[0018] The embodiments in the above-mentioned invention have the following advantages or beneficial effects:
[0019] By pre-constructing a first format dictionary for the text to be processed, when it is necessary to perform format conversion on the text to be processed, the first format dictionary is parsed to obtain the text to be processed and the format attributes corresponding to the text to be processed; the text to be processed and the corresponding format attributes are encapsulated to complete the format conversion for the text to be processed, realizing personalized format conversion for the text to be processed. This text processing method can be applied to various configured application scenarios, facilitating the completion of various configured operations. Description of the Drawings
[0020] Figure 1 is a flowchart of a text processing method provided in Embodiment 1 of the present invention;
[0021] Figure 2 is a schematic structural diagram of a text processing device provided in Embodiment 2 of the present invention;
[0022] Figure 3 is a schematic structural diagram of an electronic device provided in Embodiment 3 of the present invention. Detailed Embodiments
[0023] The present invention will be further described in detail below with reference to the drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the present invention, rather than limiting the present invention. Additionally, it should be noted that for the sake of description, only parts related to the present invention are shown in the drawings, rather than all the structures.
[0024] Embodiment 1
[0025] Figure 1The flowchart of a text processing method provided in the first embodiment of the present invention. The text processing method provided in this embodiment is applicable to scenarios that require the use of multi-format text in actual development. This method can be executed by a text processing device, which can be implemented in software and / or hardware, and is usually integrated into a terminal.
[0026] As Figure 1 shown, the method specifically includes the following steps:
[0027] Step 110: Pre-build a first format dictionary for the text to be processed.
[0028] Specifically, use JavaScript to pre-build a first format dictionary for the text to be processed, so as to complete the processing of the text to be processed through a json or a string. Specifically, convert the text to be processed into multi-format text. The first format dictionary is specifically the mapping relationship between the text to be processed and the corresponding format attributes. The format attributes are, for example, font size, font color, etc.
[0029] Exemplarily, pre-building a first format dictionary for the text to be processed through JavaScript on the JS side can specifically be:
[0030]
[0031] Among them, the key value of contentStrDic corresponds to a format dictionary, and inside this format dictionary is another format dictionary. It represents setting the format attributes of the first line of text corresponding to line1 (i.e., the text to be processed) to a font size of 12 and a color of '678888'. child is an array constructed by a system method that converts an array of methods into an array of dictionaries. There are multiple dictionaries in this array, and each dictionary consists of text and the format attributes corresponding to the text. For example, if the text to be processed is: "I love sunflowers", where the font size of "love" is set to 12 and the font size of the rest of the text is set to 8, then the format attributes of "love" can be personalized through the above-mentioned child, and the format attributes of the rest of the text are set through the above-mentioned "size".
[0032] The above-mentioned first format dictionary is the dictionary data constructed on the JS side, which can be passed to the Native side of the native system through bridging for processing. The dictionary data constructed on the JS side can be used across multiple platforms, so as to realize the multi-format conversion of the text to be processed through a json, simplify the processing solution of multi-format text, be applicable to various development scenarios, and can dynamically generate multi-format text, enabling both iOS and Android systems to use it.
[0033] Step 120: When format conversion needs to be performed on the text to be processed, parse the first format dictionary to obtain the text to be processed and the format attributes corresponding to the text to be processed.
[0034] Specifically, during actual development on the Native side, it is often necessary to perform multi-format conversion on text to implement specific business functions.
[0035] Exemplarily, when format conversion needs to be performed on the text to be processed, parsing the first format dictionary to obtain the text to be processed and the format attributes corresponding to the text to be processed includes:
[0036] Bridge the first format dictionary to the native system Native side through a first function, and convert the data of the first format dictionary into a second format dictionary adapted to the Native side through a second function;
[0037] Parse the second format dictionary to obtain the text to be processed and the format attributes corresponding to the text to be processed.
[0038] The first function example is a macro for a native call to an RN method, and this function is a system function. The second function example can be NSDictionary *params = DYBridgeParam(params, NSDictionary, YES). DYBridgeParam is a function to obtain bridge parameters. This function requires three parameters. The first parameter is the incoming param, the second parameter is the dictionary type, and the third parameter indicates whether to use the default value. When the third parameter is "YES", it means to use the default value. When the third parameter is "NO", it means not to use the default value. Finally, a return value is obtained, and this return value is a dictionary-type parameter params. The specific function of the second function is to parse the first format dictionary constructed on the JS side and convert it into a second format dictionary adapted to the Native side, specifically changing the syntax format of the dictionary data. Among them, the first format dictionary is the dictionary data constructed on the JS side, and its syntax format is adapted to the JS side. The second format dictionary is the dictionary obtained by bridging and converting the first format dictionary, and the syntax format of the second format dictionary is adapted to the Native side. The first format dictionary is of a literal type with fixed parameters, and the second format dictionary is of a fixed type. Specifically, the second format dictionary is, for example, in the following data form:
[0039]
[0040] Among them, the second format dictionary is parsed to obtain the text to be processed and the format attributes corresponding to the text to be processed, which can be specifically implemented through a parsing function. For example, the parsing function attributesFromDictionary, which is a custom function. This function requires one parameter, which is the second format dictionary, so that the format attribute mainAttr corresponding to the text to be processed can be obtained.
[0041] For example, call the parsing function attributesFromDictionary(@"line2"). Among them, attributesFromDictionary is the function name of the parsing function, and the input parameter of this function is the identifier @"line2" of the second format dictionary. By calling the parsing function attributesFromDictionary(@"line2"), the format attribute mainAttr corresponding to the text to be processed can be obtained. Taking the above second format dictionary as an example, the format attribute mainAttr corresponding to the text to be processed is: the font size "size" is 12, and the font color "color" is the color corresponding to the encoding "378888". The operation essence of step 120 is to convert the first format dictionary constructed on the JS side into a second format dictionary adapted to the Native side, realizing the unification of dictionary data and laying a foundation for subsequent implementation of multi-format conversion of text.
[0042] Step 130: Package the text to be processed and the corresponding format attributes to complete the format conversion for the text to be processed.
[0043] Optionally, since the second format dictionary is constructed as a tree structure (such as a binary tree structure), and the data of this structure cannot be directly used by the Native-side program, before packaging the text to be processed and the corresponding format attributes, the method further includes:
[0044] Store the text to be processed in a string array;
[0045] Store the format attributes corresponding to the text to be processed in an attribute array.
[0046] Specifically, after obtaining the above-mentioned second-format dictionary, a string array and an attribute array need to be created. The string array is used to store the text to be processed parsed from the second-format dictionary, and the attribute array is used to store the format attributes parsed from the second-format dictionary. Specifically, the following method is used to parse the format attributes from the second-format dictionary: The parsing method is to take out the content with the key of "child" from the format dictionary, and this content is of array type. The content obtained in this way is an array. Traverse this array. For each array element traversed, it is a dictionary. Use the method of converting the system dictionary into a format text to convert the system dictionary into the format attributes of the corresponding multi-format text for each obtained dictionary. This format attribute is defined as "attr", and all these "attr" are added to a new array, that is, the attribute array, and the attribute array is defined as "attrArr".
[0047] Exemplarily, the encapsulation of the text to be processed and the corresponding format attributes to complete the format conversion for the text to be processed includes:
[0048] Construct a multi-format text based on the format attributes corresponding to the text to be processed in the attribute array, and store the multi-format text in the synthesis array.
[0049] Specifically, use the function "attributedStringWithMainAttributes" to encapsulate the text to be processed and the corresponding format attributes.
[0050] The internal implementation process of this function is as follows:
[0051] This function requires one parameter, which is an array of strings of multi-format text and an array of attributes (NSArray*) attrArr corresponding to each multi-format text array. First, if ([strArr count] && [attrArr count]) { Use a function to determine whether the string array strArr and the attribute array of multi-format text exist. If they do not exist, directly return null. If they exist, continue with the subsequent operations. Use NSParagraphStyle* paraStyle = [[NSParagraphStyle alloc] init] to construct a paragraph of multi-format text. Among them, NSParagraphStyle is a system function for constructing paragraphs, alloc is an object creation, and init is to initialize this paragraph. Finally, an object paraStyle of type NSParagraphStyle is created. When obtaining the format attributes of the multi-format text, reconstruct a paragraph of multi-format text, and the constructed multi-format text is mainAttrs. Use while (i < [strArr count]) { to perform a while operation on the array of multi-format text. Inside this operation, use the function NSString* subStr = [strArr objectAtIndex:i], where Str is the array of multi-format text, ArrobjectAtIndex means to obtain a value from the array Str, and i represents the index of the array value. Finally, a string object subStr is obtained. Perform a string value extraction on the string object subStr to obtain the outer format attribute maitAttrs. Further, call the function [subAttr setValuesForKeysWithDictionary:attrs] to set attributes for the string object subStr. Among them, subAttr represents the string object, setValuesForKeysWithDictionary: represents the function name for setting attributes for the string, and attrs represents the attributes to be set. In this way, the format attributes are set for the string object subAttr.Construct a multi-format text, and finally obtain NSAttributedString *attrStr = [[NSAttributedString alloc] initWithString:subStr attributes:subAttr]. Here, NSAttributedString represents an object of a mutable string type, alloc means to create a mutable string, initWithString is to assign an initial value to this mutable string, subStr is the initial value of this mutable string, and subAttr is the format attribute of this mutable string, which refers to information such as the font size and font color of the string. Finally, a multi-format text is constructed through the function [attr appendAttributedString:attrStr]. Here, appendAttributedString represents the name of the string concatenation function, and its function is to concatenate the constructed string attrStr to the string attr and store the concatenated string in the synthesized array.
[0052] Further, the encapsulation of the text to be processed and the corresponding format attributes to complete the format conversion for the text to be processed further includes:
[0053] Concatenate the corresponding multi-format texts in the synthesized array according to the positional relationship between the texts to be processed.
[0054] Specifically, use the function +(NSAttributedString *)appentAttributedStringWithDic:(NSDictionary *)dic to perform concatenation processing on the corresponding multi-format texts in the synthesized array. This function is a function for processing data. This function requires a dictionary of type (NSDictionary *)dic. The implementation scheme inside this function is: First, use the system method for creating a string to create a string for the multi-format text, which is str. The function needs to perform a cutting operation on the above-mentioned dic dictionary. The cutting operation is specifically using the system functions of iOS. After the cutting is completed, a mutable string object is obtained, which is lineDicStr. Parse the text data of the first line from dic, and this lineDicStr is the text data of the first line. Use the same cutting method to cut out the text data of the second line, line2DicStr. Perform the assembly of the text data of lineDicStr and line2DicStr. The assembly process is as follows:
[0055] First, determine whether the type of lineDicStr is a dictionary. If it is a dictionary type, use the string concatenation function to concatenate lineDicStr to str. Similarly, judge the text type of line2DicStr. If it is a dictionary type, use the method of string concatenation to splice line2DicStr to str. Thus, the construction of string concatenation is completed, that is, according to the positional relationship between the texts to be processed, the corresponding multi-format texts in the synthesis array are concatenated.
[0056] The technical solution of this embodiment pre-constructs a first format dictionary for the text to be processed. When the format conversion of the text to be processed is required, the first format dictionary is parsed to obtain the text to be processed and the format attributes corresponding to the text to be processed; the text to be processed and the corresponding format attributes are encapsulated to complete the format conversion of the text to be processed, realizing personalized format conversion for the text to be processed. This text processing method can be applied to various configured application scenarios, facilitating the completion of various configured operations. The text processing method provided in this embodiment can convert a json string and dictionary into a multi-format text content, which is applicable to various configured application scenarios, simplifies the processing scheme of multi-format texts, and can realize the dynamic generation of multi-format texts, enabling both ios systems and android systems to use.
[0057] The following is an embodiment of the text processing device provided by the embodiment of the present invention. This device and the text processing method of the above embodiments belong to the same inventive concept. For the details not described in detail in the embodiment of the text processing device, reference can be made to the embodiment of the text processing method.
[0058] Embodiment Two
[0059] Figure 2 FIG. is a schematic structural diagram of a text processing device provided by Embodiment Two of the present invention. The device specifically includes: a construction module 210, an analysis module 220, and an encapsulation module 230.
[0060] Among them, the construction module 210 is used to pre-construct a first format dictionary for the text to be processed; the analysis module 220 is used to parse the first format dictionary when the format conversion of the text to be processed is required to obtain the text to be processed and the format attributes corresponding to the text to be processed; the encapsulation module 230 is used to encapsulate the text to be processed and the corresponding format attributes to complete the format conversion of the text to be processed.
[0061] Based on the technical solution of the above embodiment, the construction module 210 is specifically used to: pre-construct a first format dictionary for the text to be processed through JavaScript.
[0062] Based on the technical solutions of the above embodiments, the parsing module 220 includes:
[0063] A bridging unit, configured to bridge the first format dictionary to the Native side of the native system through a first function, and convert the data of the first format dictionary into a second format dictionary adapted to the Native side through a second function;
[0064] A parsing unit, configured to parse the second format dictionary to obtain the text to be processed and the format attributes corresponding to the text to be processed.
[0065] Based on the technical solutions of the above embodiments, the device further includes:
[0066] A storage module, configured to store the text to be processed in a string array and store the format attributes corresponding to the text to be processed in an attribute array before encapsulating the text to be processed and the corresponding format attributes.
[0067] Based on the technical solutions of the above embodiments, the encapsulation module 230 includes:
[0068] A construction unit, configured to construct a multi-format text based on the format attributes corresponding to the text to be processed in the attribute array and store the multi-format text in a synthesis array.
[0069] Based on the technical solutions of the above embodiments, the encapsulation module 230 further includes:
[0070] A splicing unit, configured to splice the corresponding multi-format texts in the synthesis array according to the positional relationship between the texts to be processed.
[0071] Based on the technical solutions of the above embodiments, the format attributes include at least one of the following: font size and font color.
[0072] The technical solution of this embodiment pre - constructs a first format dictionary for the text to be processed. When format conversion of the text to be processed is required, the first format dictionary is parsed to obtain the text to be processed and the format attributes corresponding to the text to be processed; the text to be processed and the corresponding format attributes are encapsulated to complete the format conversion of the text to be processed, realizing personalized format conversion of the text to be processed. This text processing method can be applied to various configured application scenarios, facilitating the completion of various configured operations. The text processing method provided in this embodiment can convert a JSON string and dictionary into a multi - format text content, is applicable to a variety of configured application scenarios, simplifies the processing solution of multi - format texts, can dynamically generate multi - format texts, and can be used on both iOS and Android systems.
[0073] The text processing device provided by the embodiment of the present invention can execute the text processing method provided by any embodiment of the present invention, and has corresponding functional modules and beneficial effects for executing the text processing method.
[0074] Embodiment III
[0075] Figure 3 It is a schematic structural diagram of an electronic device provided by Embodiment III of the present invention. Figure 3 It shows a block diagram of an exemplary device 12 suitable for implementing the embodiments of the present invention. Figure 3 The shown device 12 is only an example and should not bring any limitation to the functions and usage scope of the embodiments of the present invention.
[0076] As Figure 3 shown, the device 12 is presented in the form of a general - purpose computing device. The components of the device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 connecting different system components (including the system memory 28 and the processing unit 16).
[0077] The bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the multiple bus structures. For example, these architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
[0078] The device 12 typically includes a variety of computer system - readable media. These media can be any available media accessible by the device 12, including volatile and non - volatile media, removable and non - removable media.
[0079] System memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. Device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, storage system 34 may be used for reading and writing on non-removable, non-volatile magnetic media ( Figure 3 not shown, commonly referred to as a "hard disk drive"). Although Figure 3 not shown in the figure, a disk drive for reading and writing on removable non-volatile disks (such as a "floppy disk"), and an optical disk drive for reading and writing on removable non-volatile optical disks (such as a CD-ROM, DVD-ROM or other optical media) may be provided. In these cases, each drive may be connected to bus 18 through one or more data media interfaces. System memory 28 may include at least one program product having a set of program modules (such as construction module 210, parsing module 220, and encapsulation module 230 of a text processing device), which are configured to perform the functions of various embodiments of the present invention.
[0080] A program / utility 40 having a set of program modules 42 (such as construction module 210, parsing module 220, and encapsulation module 230 of a text processing device) may be stored, for example, in system memory 28. Such program modules 42 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include the implementation of a network environment. Program modules 42 generally perform the functions and / or methods in the embodiments described in the present invention.
[0081] Device 12 may also communicate with one or more external devices 14 (such as a keyboard, a pointing device, a display 24, etc.), and may also communicate with one or more devices that enable a user to interact with the device 12, and / or communicate with any device that enables the device 12 to communicate with one or more other computing devices (such as a network card, a modem, etc.). Such communication may be carried out through an input / output (I / O) interface 22. In addition, device 12 may also communicate with one or more networks (such as a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter 20. As shown in the figure, network adapter 20 communicates with other modules of device 12 through bus 18. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in combination with device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.
[0082] The processing unit 16 executes various functional applications and data processing by running the programs stored in the system memory 28, for example, implementing the steps of a text processing method provided by the present embodiment. The method includes:
[0083] Pre - construct a first format dictionary for the text to be processed;
[0084] When it is necessary to perform format conversion on the text to be processed, parse the first format dictionary to obtain the text to be processed and the format attributes corresponding to the text to be processed;
[0085] Package the text to be processed and the corresponding format attributes to complete the format conversion for the text to be processed.
[0086] In one embodiment, the pre - constructing a first format dictionary for the text to be processed includes:
[0087] Pre - construct a first format dictionary for the text to be processed through JavaScript.
[0088] In another embodiment, when it is necessary to perform format conversion on the text to be processed, parsing the first format dictionary to obtain the text to be processed and the format attributes corresponding to the text to be processed includes:
[0089] Bridge the first format dictionary to the native system Native side through a first function, and convert the data of the first format dictionary into a second format dictionary adapted to the Native side through a second function;
[0090] Parse the second format dictionary to obtain the text to be processed and the format attributes corresponding to the text to be processed.
[0091] In another embodiment, before packaging the text to be processed and the corresponding format attributes, it further includes:
[0092] Store the text to be processed into a string array;
[0093] Store the format attributes corresponding to the text to be processed into an attribute array.
[0094] In another embodiment, the packaging the text to be processed and the corresponding format attributes to complete the format conversion for the text to be processed includes:
[0095] Construct a multi - format text based on the format attributes corresponding to the text to be processed in the attribute array, and store the multi - format text into a synthesis array.
[0096] In another embodiment, encapsulating the text to be processed and the corresponding format attributes to complete the format conversion of the text to be processed further includes:
[0097] Splicing the corresponding multi-format texts in the synthesis array according to the positional relationship between the texts to be processed.
[0098] In another embodiment, the format attribute includes at least one of the following: font size and font color.
[0099] Of course, those skilled in the art can understand that the processor can also implement the technical solutions of the text processing method provided in any embodiment of the present invention.
[0100] Embodiment 4
[0101] Embodiment 4 of the present invention provides a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, it implements the steps of the text processing method provided in any embodiment of the present invention. The method includes:
[0102] Pre-constructing a first format dictionary for the text to be processed;
[0103] When it is necessary to perform format conversion on the text to be processed, parsing the first format dictionary to obtain the text to be processed and the format attributes corresponding to the text to be processed;
[0104] Encapsulating the text to be processed and the corresponding format attributes to complete the format conversion of the text to be processed.
[0105] In one embodiment, pre-constructing the first format dictionary for the text to be processed includes:
[0106] Pre-constructing a first format dictionary for the text to be processed through JavaScript.
[0107] In another embodiment, when it is necessary to perform format conversion on the text to be processed, parsing the first format dictionary to obtain the text to be processed and the format attributes corresponding to the text to be processed includes:
[0108] Bridging the first format dictionary to the native system Native side through a first function, and converting the data of the first format dictionary into a second format dictionary adapted to the Native side through a second function;
[0109] Parsing the second format dictionary to obtain the text to be processed and the format attributes corresponding to the text to be processed.
[0110] In another embodiment, before encapsulating the text to be processed and the corresponding format attributes, the following steps are further included:
[0111] Store the text to be processed in a string array;
[0112] Store the format attributes corresponding to the text to be processed in an attribute array.
[0113] In another embodiment, the encapsulation of the text to be processed and the corresponding format attributes to complete the format conversion for the text to be processed includes:
[0114] Construct a multi-format text based on the format attributes corresponding to the text to be processed in the attribute array, and store the multi-format text in a synthesis array.
[0115] In another embodiment, the encapsulation of the text to be processed and the corresponding format attributes to complete the format conversion for the text to be processed further includes:
[0116] Splice the corresponding multi-format texts in the synthesis array according to the positional relationship between the texts to be processed.
[0117] In another embodiment, the format attributes include at least one of the following: font size and font color.
[0118] The computer storage medium of the embodiments of the present invention may adopt any combination of one or more computer-readable media. The computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples (non-exhaustive list) of the computer-readable storage medium include: an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, the computer-readable storage medium may be any tangible medium that contains or stores a program, which can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0119] A computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device.
[0120] The program code contained on a computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0121] The computer program code for performing the operations of the present invention may be written in one or more programming languages or combinations thereof. The programming languages include object-oriented programming languages such as Java, Smalltalk, C++, and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, executed as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., by using an Internet service provider to connect through the Internet).
[0122] Those of ordinary skill in the art should understand that the various modules or steps of the present invention described above may be implemented using a general-purpose computing device. They may be centralized on a single computing device or distributed across a network composed of multiple computing devices. Optionally, they may be implemented using program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, or they may be separately fabricated into individual integrated circuit modules, or multiple modules or steps among them may be fabricated into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0123] Note that the above is only a preferred embodiment of the present invention and the technical principles applied. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, re-adjustments, and substitutions can be made by those skilled in the art without departing from the protection scope of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments only. Without departing from the concept of the present invention, more other equivalent embodiments can be included, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A text processing method, characterized in that, Including: Pre - construct a first format dictionary for the text to be processed; When format conversion of the text to be processed is required, parse the first format dictionary to obtain the text to be processed and the format attributes corresponding to the text to be processed; Package the text to be processed and the corresponding format attributes to complete the format conversion of the text to be processed; The pre - constructing a first format dictionary for the text to be processed includes: Pre - construct a first format dictionary for the text to be processed through JavaScript; wherein, the first format dictionary is a mapping relationship between the text to be processed and the corresponding format attributes; The when format conversion of the text to be processed is required, parse the first format dictionary to obtain the text to be processed and the format attributes corresponding to the text to be processed includes: Bridge the first format dictionary to the Native side of the native system through a first function, and convert the data of the first format dictionary into a second format dictionary adapted to the Native side through a second function; Parse the second format dictionary to obtain the text to be processed and the format attributes corresponding to the text to be processed.
2. The method according to claim 1, wherein Before packaging the text to be processed and the corresponding format attributes, it further includes: Store the text to be processed in a string array; Store the format attributes corresponding to the text to be processed in an attribute array.
3. The method according to claim 2, wherein The packaging the text to be processed and the corresponding format attributes to complete the format conversion of the text to be processed includes: Construct a multi - format text based on the format attributes corresponding to the text to be processed in the attribute array, and store the multi - format text in a synthesis array.
4. The method according to claim 3, wherein The packaging the text to be processed and the corresponding format attributes to complete the format conversion of the text to be processed further includes: Stitch the corresponding multi - format texts in the synthesis array according to the positional relationship between the texts to be processed.
5. The method according to any one of claims 1-4, characterized in that, The format attributes include at least one of the following: font size and font color.
6. A text processing device, characterized in that, Including: A construction module for pre - constructing a first format dictionary for the text to be processed; An analysis module for parsing the first format dictionary to obtain the text to be processed and the format attributes corresponding to the text to be processed when format conversion of the text to be processed is required; A packaging module for packaging the text to be processed and the corresponding format attributes to complete the format conversion of the text to be processed; The construction module is specifically used for: pre - constructing a first format dictionary for the text to be processed through JavaScript; wherein, the first format dictionary is a mapping relationship between the text to be processed and the corresponding format attributes; The analysis module includes: A bridging unit for bridging the first format dictionary to the Native side of the native system through a first function, and converting the data of the first format dictionary into a second format dictionary adapted to the Native side through a second function; An analysis unit for parsing the second format dictionary to obtain the text to be processed and the format attributes corresponding to the text to be processed.
7. An electronic device, characterized in that, The electronic device includes: One or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the text processing method steps described in any one of claims 1-5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the text processing method steps described in any one of claims 1-5.
Citation Information
Patent Citations
Method and relevant device for obtaining data format
CN108628900A
Evaluation method and device for application program testing, server and storage medium
CN110399289A
Text processing method and device
CN111125998A