Text conversion method, text conversion apparatus, text conversion device, and storage medium

By automatically identifying the text to be converted using preset conversion information and compilation language when a conversion instruction is detected, the problem of inaccurate text conversion in existing technologies is solved, and efficient conversion from Android.mk to Android.bp files is achieved.

CN112988164BActive Publication Date: 2026-04-28SHENZHEN SKYWORTH RGB ELECTRONICS CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SHENZHEN SKYWORTH RGB ELECTRONICS CO LTD
Filing Date
2021-04-06
Publication Date
2026-04-28

AI Technical Summary

Technical Problem

Existing text conversion methods cannot achieve fast and accurate text conversion, especially when converting Android.mk files to Android.bp files. Manual compilation is prone to errors and tool conversion is incomplete.

Method used

When a conversion instruction is detected, the text to be converted is determined using preset conversion information, and the target text is determined based on a preset conversion table, keywords, and compilation language, thus achieving automatic conversion between texts.

Benefits of technology

It improves the efficiency and accuracy of text conversion, ensures the automation and accuracy of the conversion process, and reduces human error.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112988164B_ABST
    Figure CN112988164B_ABST
Patent Text Reader

Abstract

The application discloses a text conversion method, a text conversion device, a text conversion equipment and a storage medium, and the method comprises the following steps: when a conversion instruction is detected, determining text content needing to be converted in the text to be converted according to preset conversion information, and then determining the target text finally needed according to the text content needing to be converted. According to the application, when the text conversion instruction is detected, the text to be converted provided by the user is converted into the target text needed by the user, so that the automatic conversion between texts is realized, the text to be converted can be accurately recognized according to the preset conversion information, and the efficiency and accuracy of the text conversion are greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] It should be noted that during the program compilation process, different program files require different code to achieve the same function. However, sometimes it is necessary to convert one type of compiled file into another type of compiled file. In this case, it is necessary to perform certain conversions on the code text in the original file so that the converted code text can meet the requirements of the new file.

[0003] Existing text conversion methods typically require users to manually compile the code or use conversion tools to perform the conversion. For example, when converting an Android.mk file to an Android.bp file, the code in the Android.mk file contains content that cannot run in the Android.bp file. Therefore, the conversion process requires obtaining the code text from the Android.mk file and converting the incompatible parts into executable code for the Android.bp file. Manually compiling the code is time-consuming and may lead to errors. Using tools like androidmk, which only perform simple conversions, often results in incomplete conversions or even errors, preventing successful conversion. Summary of the Invention

[0004] The main objective of this invention is to provide a text conversion method, a text conversion device, a text conversion equipment, and a storage medium, aiming to solve the technical problem that existing text conversion technologies cannot achieve text conversion quickly and accurately.

[0005] To achieve the above objectives, the present invention provides a text conversion method, which includes the following steps:

[0006] When a conversion instruction is detected, the text to be converted in the text to be converted is determined according to the preset conversion information;

[0007] The target text is determined based on the text to be converted.

[0008] Optionally, the text to be converted includes a first text to be converted, the preset conversion information includes a preset conversion table, and the step of determining the text to be converted in the text to be converted includes:

[0009] The first text to be converted in the text to be converted is determined according to the preset conversion table;

[0010] The target text includes a first target text, and the step of determining the target text based on the text to be converted includes:

[0011] The first target text is determined based on the first text to be converted.

[0012] Optionally, the step of determining the first target text based on the first text to be converted includes:

[0013] The first converted text is determined based on the first text to be converted and the preset conversion table;

[0014] The first text to be converted in the text to be converted is replaced with the first converted text to obtain the first target text.

[0015] Optionally, the preset conversion information includes preset keywords, the text to be converted includes a second text to be converted, and the step of determining the text to be converted in the text to be converted includes:

[0016] The second text to be converted in the text to be converted is determined based on the preset keywords;

[0017] The target text includes a second target text, and the step of determining the target text based on the text to be converted includes:

[0018] The second target text is determined based on the second text to be converted.

[0019] Optionally, the step of determining the second target text based on the second text to be converted includes:

[0020] The target compiled text is determined based on the second text to be converted and the preset compilation language;

[0021] The target compiled text is added to the text to be converted to obtain the second pre-target text;

[0022] The calling statement is determined based on the target compiled text, and the second text to be converted in the second pre-target text is replaced with the calling statement to obtain the second target text.

[0023] Optionally, the preset conversion information includes a preset conversion table and preset keywords, the text to be converted includes a first text to be converted and a second text to be converted, and the step of determining the text to be converted in the text to be converted includes:

[0024] The first text to be converted in the text to be converted is determined according to the preset conversion table;

[0025] The second text to be converted in the text to be converted is determined according to the preset keywords;

[0026] The target text includes a third target text, and the step of determining the target text based on the text to be converted includes:

[0027] The third target text is determined based on the first text to be converted and the second text to be converted.

[0028] Optionally, the step of determining the third target text based on the first text to be converted and the second text to be converted includes:

[0029] Based on the first text to be converted and the preset conversion table, the first converted text is determined, and the first text to be converted in the text to be converted is replaced with the first converted text to obtain the first target text;

[0030] The target compiled text is determined based on the second text to be converted and the preset compilation language. The target compiled text is then added to the first target text to obtain the third pre-target text.

[0031] The calling statement is determined based on the target compiled text, and the second text to be converted in the third pre-target text is replaced with the calling statement to obtain the third target text.

[0032] Furthermore, to achieve the above objectives, the present invention also provides a text conversion device, the text conversion device comprising:

[0033] The detection module is used to determine the text to be converted in the text to be converted based on preset conversion information when a conversion instruction is detected.

[0034] The determination module is used to determine the target text based on the text to be converted.

[0035] Furthermore, to achieve the above objectives, the present invention also provides a text conversion device, the text conversion device including a memory, a processor, and a text conversion program stored in the memory and executable on the processor, wherein the text conversion program, when executed by the processor, implements the steps of the text conversion method as described above.

[0036] Furthermore, to achieve the above objectives, the present invention also provides a storage medium storing a text conversion program, which, when executed by a processor, implements the steps of the text conversion method as described above.

[0037] This invention determines the text content to be converted from the target text based on preset conversion information when a conversion command is detected, and then determines the final target text based on the required text content. By converting the user-provided text into the user-required target text when a text conversion command is detected, this invention achieves automatic text conversion. Simultaneously, it accurately identifies the text to be converted based on preset conversion information, greatly improving the efficiency and accuracy of text conversion. Attached Figure Description

[0038] Figure 1 This is a schematic diagram of the hardware operating environment of the text conversion device according to an embodiment of the present invention;

[0039] Figure 2 This is a flowchart illustrating the first embodiment of the text conversion method of the present invention;

[0040] Figure 3 This is a schematic diagram of the functional modules of a preferred embodiment of the text conversion device of the present invention.

[0041] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0042] It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of the invention.

[0043] It should be noted that during the program compilation process, different program files require different code to achieve the same function. However, sometimes it is necessary to convert one type of compiled file into another type of compiled file. In this case, it is necessary to perform certain conversions on the code text in the original file so that the converted code text can meet the requirements of the new file.

[0044] Existing text conversion methods typically require users to manually compile the code or use conversion tools to perform the conversion. For example, when converting an Android.mk file to an Android.bp file, the code in the Android.mk file contains content that cannot run in the Android.bp file. Therefore, the conversion process requires obtaining the code text from the Android.mk file and converting the incompatible parts into executable code for the Android.bp file. Manually compiling the code is time-consuming and may lead to errors. Using tools like androidmk, which only perform simple conversions, often results in incomplete conversions or even errors, preventing successful conversion.

[0045] In view of the above-mentioned deficiencies, the present invention provides a text conversion device, with reference to Figure 1 , Figure 1 This is a schematic diagram of the hardware operating environment of the text conversion device according to an embodiment of the present invention.

[0046] like Figure 1 As shown, the text conversion device may include: a processor 1001, such as a CPU; a communication bus 1002; a user interface 1003; a network interface 1004; and a memory 1005. The communication bus 1002 is used to enable communication between these components. The user interface 1003 may include a display screen and an input unit such as a keyboard; optionally, the user interface 1003 may also include a standard wired interface or a wireless interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface). The memory 1005 may be high-speed RAM or non-volatile memory, such as a disk drive. Optionally, the memory 1005 may also be a storage device independent of the aforementioned processor 1001.

[0047] Those skilled in the art will understand that Figure 1 The hardware structure of the text conversion device shown does not constitute a limitation on the text conversion device, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0048] like Figure 1 As shown, the memory 1005, which serves as a storage medium, may include an operating system, a network communication module, a user interface module, and a text conversion program. The operating system is a program that manages and controls the text conversion device and software resources, supporting the operation of the network communication module, the user interface module, the text conversion program, and other programs or software. The network communication module manages and controls the network interface 1004; the user interface module manages and controls the user interface 1003.

[0049] exist Figure 1 In the hardware structure of the text conversion device shown, the network interface 1004 is mainly used to connect to the backend server and communicate data with it; the user interface 1003 is mainly used to connect to the client and communicate data with it; the processor 1001 can call the text conversion program stored in the memory 1005 and perform the following operations:

[0050] When a conversion instruction is detected, the text to be converted in the text to be converted is determined according to the preset conversion information;

[0051] The target text is determined based on the text to be converted.

[0052] Furthermore, the preset conversion information includes a preset conversion table, the text to be converted includes a first text to be converted, and the step of determining the text to be converted in the text to be converted includes:

[0053] The first text to be converted in the text to be converted is determined according to the preset conversion table;

[0054] The target text includes a first target text, and the step of determining the target text based on the text to be converted includes:

[0055] The first target text is determined based on the first text to be converted.

[0056] Further, the step of determining the first target text based on the first text to be converted includes:

[0057] The first converted text is determined based on the first text to be converted and the preset conversion table;

[0058] The first text to be converted in the text to be converted is replaced with the first converted text to obtain the first target text.

[0059] Furthermore, the preset conversion information includes preset keywords, the text to be converted includes a second text to be converted, and the step of determining the text to be converted in the text to be converted includes:

[0060] The second text to be converted in the text to be converted is determined based on the preset keywords;

[0061] The target text includes a second target text, and the step of determining the target text based on the text to be converted includes:

[0062] The second target text is determined based on the second text to be converted.

[0063] Further, the step of determining the second target text based on the second text to be converted includes:

[0064] The target compiled text is determined based on the second text to be converted and the preset compilation language;

[0065] The target compiled text is added to the text to be converted to obtain the second pre-target text;

[0066] The calling statement is determined based on the target compiled text, and the second text to be converted in the second pre-target text is replaced with the calling statement to obtain the second target text.

[0067] Furthermore, the preset conversion information includes a preset conversion table and preset keywords, the text to be converted includes a first text to be converted and a second text to be converted, and the step of determining the text to be converted in the text to be converted includes:

[0068] The first text to be converted in the text to be converted is determined according to the preset conversion table;

[0069] The second text to be converted in the text to be converted is determined according to the preset keywords;

[0070] The target text includes a third target text, and the step of determining the target text based on the text to be converted includes:

[0071] The third target text is determined based on the first text to be converted and the second text to be converted.

[0072] Further, the step of determining the third target text based on the first text to be converted and the second text to be converted includes:

[0073] Based on the first text to be converted and the preset conversion table, the first converted text is determined, and the first text to be converted in the text to be converted is replaced with the first converted text to obtain the first target text;

[0074] The target compiled text is determined based on the second text to be converted and the preset compilation language. The target compiled text is then added to the first target text to obtain the third pre-target text.

[0075] The calling statement is determined based on the target compiled text, and the second text to be converted in the third pre-target text is replaced with the calling statement to obtain the third target text.

[0076] The specific implementation of the text conversion device of the present invention is basically the same as the embodiments of the text conversion method described below, and will not be repeated here.

[0077] The present invention also provides a text conversion method based on the above-mentioned text conversion device.

[0078] Reference Figure 2 , Figure 2 This is a flowchart illustrating the first embodiment of the text conversion method of the present invention.

[0079] This invention provides an embodiment of a text conversion method. It should be noted that although the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than that shown here.

[0080] In various embodiments of the text conversion method, the execution entity is a text conversion device.

[0081] The text conversion method is applied to a text conversion device, and the text conversion method includes:

[0082] Step S10: When a conversion instruction is detected, determine the text to be converted in the text to be converted according to preset conversion information;

[0083] Existing text conversion methods typically require users to manually compile the code or use conversion tools to perform the conversion. For example, when converting an Android.mk file to an Android.bp file, the code in the Android.mk file contains content that cannot run in the Android.bp file. Therefore, the conversion process requires obtaining the code text from the Android.mk file and converting the incompatible parts into executable code for the Android.bp file. Manually compiling the code is time-consuming and may lead to errors. Using tools like androidmk, which only perform simple conversions, often results in incomplete conversions or even errors, preventing successful conversion.

[0084] To address the technical problem that existing text conversion technologies cannot achieve fast and accurate text conversion, this invention proposes a text conversion method. This method aims to determine the text content to be converted from the target text based on preset conversion information when a conversion command is detected, and then determine the final target text based on the required text content. This invention achieves automatic text conversion by converting user-provided text into the user-required target text when a text conversion command is detected. Simultaneously, it accurately identifies the text to be converted based on preset conversion information, significantly improving the efficiency and accuracy of text conversion.

[0085] The text conversion method in this embodiment is applicable to devices with text conversion capabilities.

[0086] In this embodiment, when a conversion command is detected, the text to be converted in the text to be converted is determined according to preset conversion information. The preset conversion information contains various text recognition identifiers, including preset conversion tables and preset keywords, which can determine which text in the text to be converted needs to be converted. The text to be converted is the original text that the user needs to convert. The user uses the text conversion device to convert the original text into the desired new text. For example, if a conversion command is detected, when the user uses the text conversion device to convert the text to be converted, "Text 1", the preset conversion information can determine that the text to be converted in "Text 1" is "LOCAL_MODULE", "LOCAL_SRC_FILES", "LOCAL_SRC_FILES_EXCLUDE", and "LOCAL_HEADER_LIBRARIES", etc.; it can also determine that the text to be converted is "Statement 1", etc.

[0087] Step S20: Determine the target text based on the text to be converted.

[0088] In this embodiment, after determining the text to be converted in the text to be converted, the target text is then determined based on the text to be converted. The target text is the new text obtained by the text conversion device after converting the text to be converted. It can be a single text or multiple texts. For example, if the text to be converted in the text to be converted, "Text 1", is determined to be "LOCAL_MODULE", and the text obtained after converting it is "name", then "LOCAL_MODULE" in the text to be converted is replaced with "name" to obtain the target text.

[0089] This invention determines the text content to be converted from the target text based on preset conversion information when a conversion command is detected, and then determines the final target text based on the required text content. By converting the user-provided text into the user-required target text when a text conversion command is detected, this invention achieves automatic text conversion. Simultaneously, it accurately identifies the text to be converted based on preset conversion information, greatly improving the efficiency and accuracy of text conversion.

[0090] Furthermore, a second embodiment of the text conversion method of the present invention is proposed, wherein the preset conversion information includes a preset conversion table, the text to be converted includes a first text to be converted, and in step S10 above, the step of determining the text to be converted in the text to be converted includes:

[0091] Step a1: Determine the first text to be converted in the text to be converted according to the preset conversion table;

[0092] The target text includes a first target text, and step S20 above includes:

[0093] Step b1: Determine the first target text based on the first text to be converted.

[0094] In this embodiment, the preset conversion information includes a preset conversion table, the text to be converted includes a first text to be converted, and the step of the text conversion device determining the first text to be converted in the text to be converted specifically involves the text conversion device determining the first text to be converted in the text to be converted according to the preset conversion table. The default conversion table is a pre-set text conversion table that contains the conversion relationships between text, including the text to be converted and the converted text. For example, the conversion relationships included in the default conversion table could be: "LOCAL_MODULE" to "name", "LOCAL_SRC_FILES" to "srcs", "LOCAL_SRC_FILES_EXCLUDE" to "exclude_srcs", and "LOCAL_HEADER_LIBRARIES" to "header_libs". In this case, the text to be converted would be "LOCAL_MODULE", "LOCAL_SRC_FILES", "LOCAL_SRC_FILES_EXCLUDE", and "LOCAL_HEADER_LIBRARIES", and the converted text would be "name", "srcs", "exclude_srcs", and "header_libs".

[0095] The first text to be converted is identified as containing characters in the text to be converted that are identical to the characters in the preset conversion table. For example, if the characters to be converted in the preset variable conversion table are "LOCAL_MODULE", "LOCAL_SRC_FILES", "LOCAL_SRC_FILES_EXCLUDE", and "LOCAL_HEADER_LIBRARIES", then if "LOCAL_MODULE" and "LOCAL_SRC_FILES" exist in the text to be converted, then "LOCAL_MODULE" and "LOCAL_SRC_FILES" are the first text to be converted.

[0096] This embodiment determines the first text to be converted in the text according to a preset conversion table, which can quickly and accurately identify the text to be converted, thus improving the efficiency and accuracy of text conversion.

[0097] Furthermore, a third embodiment of the text conversion method of the present invention is proposed, wherein step b1 above includes:

[0098] Step b11: Determine the first converted text based on the first text to be converted and the preset conversion table;

[0099] Step b12: Replace the first text to be converted in the text to be converted with the first converted text to obtain the first target text.

[0100] In this embodiment, after determining the first text to be converted in the text to be converted, the text conversion device determines the first target text based on the first text to be converted. First, the text conversion device determines the first converted text based on a preset conversion table and the first text to be converted. The converted text corresponding to the first text to be converted in the preset conversion table is the first converted text. For example, if the conversion relationship in the preset conversion table is: "LOCAL_MODULE" is converted to "name", and the first text to be converted in the text to be converted is "LOCAL_MODULE", then the text conversion device will determine the first converted text as "name" based on the preset conversion table and the first text to be converted, "LOCAL_MODULE".

[0101] After obtaining the first converted text, the text conversion device replaces the first text to be converted in the text to be converted with the first converted text. The text to be converted after replacement becomes the first target text. For example, if the first text to be converted in the text to be converted is "LOCAL_MODULE", and the text conversion device determines the first converted text as "name" according to a preset conversion table, then the text conversion device replaces "LOCAL_MODULE" in the text to be converted with "name" to obtain the first target text.

[0102] It should be noted that, in addition to determining the first text to be converted in the text to be converted according to the preset conversion table, the user can also provide a conversion table. If the user provides a conversion table, the text conversion device will determine the first text to be converted in the text to be converted according to the conversion table provided by the user, and then determine the first converted text according to the conversion table provided by the user.

[0103] This embodiment converts the first text to be converted in the text to be converted according to a preset conversion table, thereby obtaining the first target text, achieving accurate conversion of the text to be converted and improving the efficiency and accuracy of text conversion.

[0104] Furthermore, a fourth embodiment of the text conversion method of the present invention is proposed, wherein the preset conversion information includes preset keywords, the text to be converted includes a second text to be converted, and in step S10 above, the step of determining the text to be converted in the text to be converted includes:

[0105] Step c1: Determine the second text to be converted in the text to be converted based on the preset keywords;

[0106] The target text includes a second target text, and step S20 above includes:

[0107] Step d1: Determine the second target text based on the second text to be converted.

[0108] In this embodiment, the preset conversion information includes preset keywords, the text to be converted includes a second text to be converted, and the target text includes a second target text. The text conversion device determines the second text to be converted in the text to be converted based on the preset keywords. The preset keywords are specific characters that are set in advance, and can be one or more compilation keywords. These compilation keywords can be used to identify specific compilation statements in the text to be converted, including conditional compilation statements, loop compilation statements, etc. For example, the preset keywords may contain compilation keywords such as "ifeq", "ifneq", "ifdef", and "ifndef", which can be used to identify conditional compilation statements; the preset keywords may also contain compilation keywords such as "for", which can be used to identify loop compilation statements.

[0109] The text conversion device can determine the second text to be converted from the text to be converted based on preset keywords in one of the following ways: It can directly determine the corresponding compilation statement in the text to be converted based on the compilation key text in the preset keywords. For example, if the preset keywords are "ifeq" and "ifneq", then the conditional compilation statement in the text to be converted is directly determined, and the determined conditional compilation statement is the second text to be converted; if the preset keyword is "for", then the loop compilation statement in the text to be converted is directly determined, and the determined loop compilation statement is the second text to be converted.

[0110] The text conversion device can also determine the second text to be converted in the text to be converted based on preset keywords in the following way: take the compilation key text in the preset keywords as the starting point in the text to be converted, take the preset end point mark closest to the starting point as the end point, and all the text between the starting point and the end point is the second text to be converted. The second text to be converted includes the starting point and the end point themselves. For example, the default endpoint marker can be "endif" or "}". When the compilation key text in the default keyword is "ifeq", the starting point is the compilation key text "ifeq" and the ending point is the "endif" closest to "ifeq". Then, all the text between "ifeq" and "endif" is the second text to be converted. The second text to be converted includes "ifeq" and "endif", such as "ifeq($(VALUE),X) do_yes else do_no endif". When the compilation key text in the default keyword is "for", the starting point is "for" and the ending point is "}". All the text between "for" and "}" is the second text to be converted. The second text to be converted includes "for" and "}", such as "for (int i:mDatas) {Log.d("i=",i+");}".

[0111] This embodiment determines the second text to be converted in the text to be converted by preset keywords, which can accurately identify the text to be converted and improve the accuracy of determining the text to be converted.

[0112] Furthermore, a fifth embodiment of the text conversion method of the present invention is proposed, wherein step d2 above includes:

[0113] Step d21: Determine the target compiled text based on the second text to be converted and the preset compilation language;

[0114] Step d22: Add the target compiled text to the text to be converted to obtain the second pre-target text;

[0115] In this embodiment, after determining the second text to be converted in the text to be converted based on preset keywords, the text conversion device determines the target compiled text based on the second text to be converted and a preset compilation language. The preset compilation language refers to the compilation language used to compile the second text to be converted; for example, the preset compilation language could be "Golang" or "C".

[0116] The text conversion device converts and compiles the second text to be converted according to a preset compilation language, and generates the target compiled text based on the text obtained after conversion and compilation. For example, after determining the second text to be converted in the text to be converted, if the preset compilation language is "Golang", then the second text to be converted is converted and compiled using "Golang", and the target compiled text is generated based on the text obtained after conversion and compilation.

[0117] After determining the target compiled text, the target compiled text is added to the text to be converted to obtain the second pre-target text.

[0118] It should be noted that, in addition to determining the second text to be converted in the text to be converted based on preset keywords, the user can also provide keywords. Similarly, the user can also provide the compilation language. If the user provides keywords and compilation language, the text conversion device will determine the second text to be converted in the text to be converted based on the keywords provided by the user, and then determine the target compilation text based on the compilation language provided by the user and the second text to be converted.

[0119] Step d23: Determine the calling statement based on the target compiled text, and replace the second text to be converted in the second pre-target text with the calling statement to obtain the second target text.

[0120] The calling statement is determined based on the target compiled text. The calling statement refers to the statement generated during the compilation process that invokes a specific file. In other words, when a compiled file is generated from the target compiled text, the statement that invokes that compiled file is used. For example, if the target compiled text "compiled text 1" is generated from "Golang language" and the second text to be converted, and a "Golang" script file "go script file.go" is generated from "compiled text 1", the calling statement represents the statement used to invoke "go script file.go" during the compilation process.

[0121] The text conversion device then replaces the second text to be converted in the second target text with the calling statement to obtain the second target text.

[0122] It should be noted that after obtaining the target compiled text, in addition to adding the target compiled text to the text to be converted, a new text can also be generated based on the target compiled text. Then, the second text to be converted in the text to be converted is replaced with the calling statement. At this time, the final second target text will contain multiple texts.

[0123] This embodiment determines the target compiled text based on preset keywords and preset compilation language, and then determines the calling statement based on the target compiled text, thereby determining the second target text. This achieves accurate conversion of the text to be converted and improves the efficiency and accuracy of text conversion.

[0124] Furthermore, a sixth embodiment of the text conversion method of the present invention is proposed, wherein the preset conversion information includes a preset conversion table and preset keywords, and the text to be converted includes a first text to be converted and a second text to be converted. In step S10 above, the step of determining the text to be converted in the text to be converted includes:

[0125] Step e1: Determine the first text to be converted in the text to be converted according to the preset conversion table;

[0126] Step e2: Determine the second text to be converted in the text to be converted based on the preset keywords;

[0127] The target text includes a third target text, and step S20 above includes:

[0128] Step f1: Determine the third target text based on the first text to be converted and the second text to be converted.

[0129] In this embodiment, the preset conversion information includes a preset conversion table and preset keywords. The text to be converted includes a first text to be converted and a second text to be converted. The text conversion device determines the first text to be converted in the text to be converted according to the preset conversion table, and simultaneously determines the second text to be converted in the text to be converted according to the preset keywords. The method by which the text conversion device determines the first text to be converted according to the preset conversion table and the method by which it determines the second text to be converted according to the preset keywords are the same as in the above embodiment. For example, if the conversion relationship in the preset conversion table is: "LOCAL_MODULE" is converted to "name", and the compilation key text in the preset keywords is "ifeq", then "LOCAL_MODULE" in the text to be converted is determined as the first text to be converted, and the second text to be converted in the text to be converted is determined simultaneously according to the compilation key text "ifeq". The method for determining the second text to be converted can be to directly determine the conditional compilation statement in the text to be converted, or it can be to start with "ifeq" and end with "endif", then all the text between the start and end points is the second text to be converted.

[0130] This embodiment uses a preset conversion table and a preset compilation keyword table to determine the text to be converted, which can accurately identify the text to be converted and improve the accuracy of text conversion.

[0131] Furthermore, a seventh embodiment of the text conversion method of the present invention is proposed, wherein the above step S20 includes:

[0132] Step g1: Determine the first converted text based on the first text to be converted and the preset conversion table, and replace the first text to be converted in the text to be converted with the first converted text to obtain the first target text;

[0133] Step g2: Determine the target compiled text based on the second text to be converted and the preset compilation language, and add the target compiled text to the first target text to obtain the third pre-target text;

[0134] Step g3: Determine the calling statement based on the target compiled text, and replace the second text to be converted in the third pre-target text with the calling statement to obtain the third target text.

[0135] In this embodiment, the method by which the text conversion device determines the first converted text based on the first text to be converted and the preset conversion table, determines the target compiled text based on the second text to be converted and the preset compilation language, and determines the calling statement based on the target compiled text is the same as in the above embodiment. For example, the conversion relationships in the preset conversion table are: "LOCAL_MODULE" is converted to "name", "LOCAL_SRC_FILES" is converted to "srcs", "LOCAL_SRC_FILES_EXCLUDE" is converted to "exclude_srcs", and "LOCAL_HEADER_LIBRARIES" is converted to "header_libs". The preset compilation language is "Golang". If the first text to be converted in the text to be converted, "Text 1", is "LOCAL_MODULE" and "LOCAL_SRC_FILES", then the first converted text is "name" and "srcs". At the same time, the text conversion device converts and compiles the second text to be converted according to the preset compilation language "Golang". Based on the text obtained after conversion and compilation, the target compiled text is generated. Then, the call statement of "go script file.go" is determined when "go script file.go" is generated from the target compiled text.

[0136] After determining the first and second characters to be converted in the text to be converted, the text conversion device determines the first converted text based on the first character to be converted and a preset conversion table, replaces the first character to be converted in the text to be converted with the first converted text, and obtains the first target text. At the same time, it determines the target compiled text based on the second character to be converted and a preset compilation language, adds the target compiled text to the first target text, and obtains the third pre-target text. Then, it determines the calling statement based on the target compiled text, replaces the second character to be converted in the third pre-target text with the calling statement, and obtains the third target text. For example, if the first text to be converted in the text to be converted is “LOCAL_MODULE” and “LOCAL_SRC_FILES”, and the first converted text is “name” and “srcs”, then the text conversion device first replaces “LOCAL_MODULE” with “name” and “LOCAL_SRC_FILES” with “srcs” in the text to be converted to obtain the first target text. At the same time, it generates target compiled text based on the second text to be converted and “Golang language”, adds the target compiled text to the first target text to obtain the third pre-target text, and then determines the calling statement based on the target compiled text, replaces the second text to be converted in the third pre-target text with the calling statement to obtain the third target text.

[0137] The steps to obtain the third target text from the text to be converted can also be as follows: First, determine the target compiled text based on the second text to be converted and the preset compilation statement. Add the target compiled text to the text to be converted to obtain the second pre-target text. Then, determine the calling statement based on the target compiled text. Replace the second text to be converted in the second pre-target text with the calling statement to obtain the second target text. Finally, replace the first text to be converted in the second target text with the first converted text to obtain the third target text. It should be noted that the order of various text replacements or text conversions is not limited here. It is sufficient to replace the first text to be converted in the text to be converted with the first converted text, add the target compiled text to the text to be converted, and replace the second text to be converted with the calling statement.

[0138] It should be noted that this text conversion method can also be used for conversion between compiled files, such as converting an Android.mk file to an Android.bp file. The specific steps are as follows: obtain the code text of the Android.mk file through the corresponding compilation software or other means; the text conversion device then determines the code text to be converted in the code text; and then obtains the target code text based on the code text to be converted. For example, when converting an Android.mk file, the corresponding compiler obtains the code text from the Android.mk file. The text conversion device determines the first text to be converted, "LOCAL_MODULE," and the second text to be converted, "conditional compilation statement," based on a preset conversion table and the preset keyword "ifeq." Then, based on the first text to be converted, "LOCAL_MODULE," the first converted text, "name," is determined. Based on the "conditional compilation statement" and the preset compilation language "Golang," the corresponding target compilation text is determined. A script text is generated based on the target compilation text. The compiler then generates the corresponding Go script file, "goscript.go," based on the script text. The call statement for calling "goscript.go" is determined. The first text to be converted, "LOCAL_MODULE," is replaced with the first converted text, "name," and the second text to be converted, "conditional compilation statement," is replaced with the call statement to obtain the target code text. Finally, the compiler generates the Android.bp file based on the target code text, resulting in the Go script file and the Android.bp file.

[0139] This embodiment determines the first converted text and the target compiled text based on a preset conversion table and a preset compilation language, thereby determining the third target text, achieving accurate conversion of the text to be converted, and improving the efficiency and accuracy of text conversion.

[0140] The present invention also provides a text conversion device.

[0141] Reference Figure 3 , Figure 3 This is a functional module diagram of a first embodiment of the text conversion device of the present invention. The text conversion device includes:

[0142] The detection module is used to determine the text to be converted in the text to be converted based on preset conversion information when a conversion instruction is detected.

[0143] The determination module is used to determine the target text based on the text to be converted.

[0144] Furthermore, embodiments of the present invention also propose a storage medium.

[0145] The storage medium stores a text conversion program, which, when executed by the processor, implements the steps of the text conversion method as described above.

[0146] The specific implementation of the storage medium of the present invention is basically the same as the embodiments of the above-described text conversion method, and will not be repeated here.

[0147] The embodiments of the present invention have been described above with reference to the accompanying drawings. However, the present invention is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many modifications under the guidance of the present invention without departing from the spirit and scope of the claims. All equivalent structural or procedural transformations made using the content of the present invention specification and drawings, or direct or indirect applications in other related technical fields, are within the protection scope of the present invention.

Claims

1. A text conversion method, characterized in that, The text conversion method includes the following steps: When a conversion instruction is detected, the text to be converted in the text to be converted is determined according to the preset conversion information; The preset conversion information includes preset keywords, the text to be converted includes a second text to be converted, and the step of determining the text to be converted in the text to be converted includes: Determining the second text to be converted in the text to be converted based on the preset keywords includes: Based on the compilation key text in the preset keywords, determine the corresponding compilation statements in the text to be converted; and / or In the text to be converted, the compilation key text in the preset keywords is taken as the starting point, and the preset end point mark closest to the starting point is taken as the end point. All text between the starting point and the end point is determined as the second text to be converted. Determine the target text based on the text to be converted, wherein the target text includes a second target text, and the step of determining the target text based on the text to be converted includes: determining the second target text based on the second text to be converted; The step of determining the second target text based on the second text to be converted includes: determining the target compiled text based on the second text to be converted and a preset compilation language; The target compiled text is added to the text to be converted to obtain the second pre-target text; The calling statement is determined based on the target compilation text, wherein the calling statement is used to call the compilation file generated by the target compilation text during the compilation process; Replace the second text to be converted in the second target text with the calling statement to obtain the second target text; And / or, after generating a new text file based on the target compiled text, the second text to be converted in the text to be converted is replaced with a calling statement for calling the new text file, so as to obtain a second target text containing multiple texts.

2. The text conversion method as described in claim 1, characterized in that, The preset conversion information includes a preset conversion table, the text to be converted includes a first text to be converted, and the step of determining the text to be converted in the text to be converted includes: The first text to be converted in the text to be converted is determined according to the preset conversion table; The target text includes a first target text, and the step of determining the target text based on the text to be converted includes: The first target text is determined based on the first text to be converted.

3. The text conversion method as described in claim 2, characterized in that, The step of determining the first target text based on the first text to be converted includes: The first converted text is determined based on the first text to be converted and the preset conversion table; The first text to be converted in the text to be converted is replaced with the first converted text to obtain the first target text.

4. The text conversion method as described in claim 1, characterized in that, The preset conversion information includes a preset conversion table and preset keywords; the text to be converted includes a first text to be converted and a second text to be converted; the step of determining the text to be converted in the text to be converted includes: The first text to be converted in the text to be converted is determined according to the preset conversion table; The second text to be converted in the text to be converted is determined according to the preset keywords; The target text includes a third target text, and the step of determining the target text based on the text to be converted includes: The third target text is determined based on the first text to be converted and the second text to be converted.

5. The text conversion method as described in claim 4, characterized in that, The step of determining the third target text based on the first text to be converted and the second text to be converted includes: Based on the first text to be converted and the preset conversion table, the first converted text is determined, and the first text to be converted in the text to be converted is replaced with the first converted text to obtain the first target text; The target compiled text is determined based on the second text to be converted and the preset compilation language. The target compiled text is then added to the first target text to obtain the third pre-target text. The calling statement is determined based on the target compiled text, and the second text to be converted in the third pre-target text is replaced with the calling statement to obtain the third target text.

6. A text conversion device, characterized in that, The text conversion device includes: The detection module is used to determine the text to be converted in the text to be converted based on preset conversion information when a conversion instruction is detected. The preset conversion information includes preset keywords, the text to be converted includes a second text to be converted, and the step of determining the text to be converted in the text to be converted includes: Determining the second text to be converted in the text to be converted based on the preset keywords includes: Based on the compilation key text in the preset keywords, determine the corresponding compilation statements in the text to be converted; and / or In the text to be converted, the compilation key text in the preset keywords is taken as the starting point, and the preset end point mark closest to the starting point is taken as the end point. All text between the starting point and the end point is determined as the second text to be converted. A determining module is configured to determine target text based on the text to be converted, wherein the target text includes a second target text, and the step of determining the target text based on the text to be converted includes: determining the second target text based on the second text to be converted; The step of determining the second target text based on the second text to be converted includes: determining the target compiled text based on the second text to be converted and a preset compilation language; The target compiled text is added to the text to be converted to obtain the second pre-target text; The calling statement is determined based on the target compilation text, wherein the calling statement is used to call the compilation file generated by the target compilation text during the compilation process; Replace the second text to be converted in the second target text with the calling statement to obtain the second target text; And / or, after generating a new text file based on the target compiled text, the second text to be converted in the text to be converted is replaced with a calling statement for calling the new text file, so as to obtain a second target text containing multiple texts.

7. A text conversion device, characterized in that, The text conversion device includes a memory, a processor, and a text conversion program stored in the memory and executable on the processor, wherein the text conversion program, when executed by the processor, implements the steps of the text conversion method as described in any one of claims 1-5.

8. A storage medium, characterized in that, The storage medium stores a text conversion program, which, when executed by a processor, implements the steps of the text conversion method as described in any one of claims 1-5.

Citation Information

Patent Citations

  • Code conversion method, device and apparatus, and storage medium

    CN109271168A

  • Application program code conversion method and device, electronic equipment and storage medium

    CN111708539A