CN112988164A - Text conversion method, text conversion device, and storage medium - Google Patents

Text conversion method, text conversion device, and storage medium Download PDF

Info

Publication number
CN112988164A
CN112988164A CN202110376448.3A CN202110376448A CN112988164A CN 112988164 A CN112988164 A CN 112988164A CN 202110376448 A CN202110376448 A CN 202110376448A CN 112988164 A CN112988164 A CN 112988164A
Authority
CN
China
Prior art keywords
converted
text
determining
target
conversion
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110376448.3A
Other languages
Chinese (zh)
Inventor
纪煜宇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Skyworth RGB Electronics Co Ltd
Original Assignee
Shenzhen Skyworth RGB Electronics Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Skyworth RGB Electronics Co Ltd filed Critical Shenzhen Skyworth RGB Electronics Co Ltd
Priority to CN202110376448.3A priority Critical patent/CN112988164A/en
Publication of CN112988164A publication Critical patent/CN112988164A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/12Use of codes for handling textual entities
    • G06F40/126Character encoding

Abstract

The invention discloses a text conversion method, a text conversion device, text conversion equipment and a storage medium. According to the method and the device, when the text conversion instruction is detected, the text to be converted provided by the user is converted into the target text required by the user, so that automatic conversion among the texts is realized, meanwhile, the characters to be converted can be accurately identified according to the preset conversion information, and the efficiency and the accuracy of text conversion are greatly improved.

Description

Text conversion method, text conversion device, and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a text conversion method, a text conversion apparatus, a text conversion device, and a storage medium.
Background
It should be noted that, in the process of compiling a program, codes required for different program files to achieve the same function are different, but sometimes people need to convert a certain compiled file into another compiled file, and at this time, people need to convert the code text in the original file to a certain extent, so that the converted code text can meet the requirements of a new file.
When converting code text, the existing text conversion method is generally implemented by a user manually compiling code for conversion or by using a corresponding conversion tool. For example, for the android.mk file to the android.bp file, since the codes in the android.mk file include some contents that cannot be run in the android.bp file, when performing conversion, a code text of the android.mk needs to be acquired, and a part of codes in the code text that are incompatible with the android.bp file are converted into specific codes that can be executed by the android.bp file. If the user manually compiles the codes for conversion, the time of the user is wasted, and errors can be caused; if the android tool is used for conversion, the tool can only perform simple conversion, so that the conversion is incomplete in most cases, and even the conversion cannot be successfully performed due to the phenomena of error reporting and the like.
Disclosure of Invention
The invention mainly aims to provide a text conversion method, a text conversion device, text conversion equipment and a storage medium, and aims to solve the technical problem that the existing text conversion technology cannot realize text conversion quickly and accurately.
In order to achieve the above object, the present invention provides a text conversion method, including the steps of:
when a conversion instruction is detected, determining characters to be converted in the text to be converted according to preset conversion information;
and determining a target text according to the characters to be converted.
Optionally, the words to be converted include a first word to be converted, the preset conversion information includes a preset conversion table, and the step of determining the words to be converted in the text to be converted includes:
determining the first characters to be converted in the text to be converted according to the preset conversion table;
the target text comprises a first target text, and the step of determining the target text according to the words to be converted comprises the following steps:
and determining the first target text according to the first character to be converted.
Optionally, the step of determining the first target text according to the first to-be-converted word includes:
determining the first converted characters according to the first characters to be converted and the preset conversion table;
and replacing the first characters to be converted in the text to be converted with the first converted characters to obtain the first target text.
Optionally, the preset conversion information includes a preset keyword, 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 a second character to be converted in the text to be converted according to the preset keyword;
the target text comprises a second target text, and the step of determining the target text according to the words to be converted comprises the following steps:
and determining the second target text according to the second character to be converted.
Optionally, the step of determining the second target text according to the second word to be converted includes:
determining target compiled characters according to the second characters to be converted and a preset compiled language;
adding the target compiled characters into the text to be converted to obtain a second pre-target text;
determining a calling statement according to the target compiled words, and replacing the second words to be converted in the second pre-target text with the calling statement to obtain the second target text.
Optionally, the preset conversion information includes a preset conversion table and preset keywords, the words to be converted include a first word to be converted and a second word to be converted, and the step of determining the words to be converted in the text to be converted includes:
determining the first characters to be converted in the text to be converted according to the preset conversion table;
determining the second characters to be converted in the text to be converted according to the preset keywords;
the target text comprises a third target text, and the step of determining the target text according to the words to be converted comprises the following steps:
and determining the third target text according to the first character to be converted and the second character to be converted.
Optionally, the step of determining the third target text according to the first word to be converted and the second word to be converted includes:
determining a first converted character according to the first character to be converted and the preset conversion table, and replacing the first character to be converted in the text to be converted with the first converted character to obtain a first target text;
determining target compiled characters according to the second characters to be converted and a preset compiled language, and adding the target compiled characters into the first target text to obtain a third preset target text;
determining a calling statement according to the target compiled words, and replacing the second words to be converted in the third pre-target text with the calling statement to obtain the third target text.
Further, to achieve the above object, the present invention also provides a text conversion apparatus, including:
the detection module is used for determining characters to be converted in the text to be converted according to preset conversion information when the conversion instruction is detected;
and the determining module is used for determining a target text according to the characters to be converted.
Further, to achieve the above object, the present invention also provides a text conversion device, which includes a memory, a processor, and a text conversion program stored on the memory and operable on the processor, wherein the text conversion program, when executed by the processor, implements the steps of the text conversion method as described above.
Further, to achieve the above object, the present invention also provides a storage medium having a text conversion program stored thereon, which when executed by a processor implements the steps of the text conversion method as described above.
When a conversion instruction is detected, the text content needing to be converted in the text to be converted is determined according to the preset conversion information, and the finally needed target text is determined according to the text content needing to be converted. According to the method and the device, when the text conversion instruction is detected, the text to be converted provided by the user is converted into the target text required by the user, so that automatic conversion among the texts is realized, meanwhile, the characters to be converted can be accurately identified according to the preset conversion information, and the efficiency and the accuracy of text conversion are greatly improved.
Drawings
FIG. 1 is a schematic structural diagram of a hardware operating environment of a device according to an embodiment of the text conversion device of the present invention;
FIG. 2 is a flowchart illustrating a text conversion method according to a first embodiment of the present invention;
FIG. 3 is a functional block diagram of a text conversion apparatus according to a preferred embodiment of the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
It should be noted that, in the process of compiling a program, codes required for different program files to achieve the same function are different, but sometimes people need to convert a certain compiled file into another compiled file, and at this time, people need to convert the code text in the original file to a certain extent, so that the converted code text can meet the requirements of a new file.
When converting code text, the existing text conversion method is generally implemented by a user manually compiling code for conversion or by using a corresponding conversion tool. For example, for the android.mk file to the android.bp file, since the codes in the android.mk file include some contents that cannot be run in the android.bp file, when performing conversion, a code text of the android.mk needs to be acquired, and a part of codes in the code text that are incompatible with the android.bp file are converted into specific codes that can be executed by the android.bp file. If the user manually compiles the codes for conversion, the time of the user is wasted, and errors can be caused; if the android tool is used for conversion, the tool can only perform simple conversion, so that the conversion is incomplete in most cases, and even the conversion cannot be successfully performed due to the phenomena of error reporting and the like.
Based on the above-mentioned defects, the present invention provides a text conversion device, and referring to fig. 1, fig. 1 is a schematic structural diagram of a device hardware operating environment according to an embodiment of the text conversion device of the present invention.
As shown in fig. 1, the text conversion apparatus 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. Wherein a communication bus 1002 is used to enable connective communication between these components. The user interface 1003 may include a Display screen (Display), an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory (e.g., a magnetic disk memory). The memory 1005 may alternatively be a memory device separate from the processor 1001 described above.
Those skilled in the art will appreciate that the hardware configuration of the text conversion device shown in fig. 1 does not constitute a limitation of the text conversion device, and may include more or less components than those shown, or combine certain components, or a different arrangement of components.
As shown in fig. 1, a memory 1005, which is a storage medium, may include therein an operating system, a network communication module, a user interface module, and a text conversion program. The operating system is a program for managing and controlling the text conversion equipment and software resources, and supports the operation of a network communication module, a user interface module, a text conversion program and other programs or software; the network communication module is used to manage and control the network interface 1004; the user interface module is used to manage and control the user interface 1003.
In the hardware structure of the text conversion device shown in fig. 1, the network interface 1004 is mainly used for connecting to a background server and performing data communication with the background server; the user interface 1003 is mainly used for connecting a client and performing data communication with the client; the processor 1001 may call a text conversion program stored in the memory 1005 and perform the following operations:
when a conversion instruction is detected, determining characters to be converted in the text to be converted according to preset conversion information;
and determining a target text according to the characters to be converted.
Further, the preset conversion information includes a preset conversion table, the words to be converted include first words to be converted, and the step of determining the words to be converted in the text to be converted includes:
determining the first characters to be converted in the text to be converted according to the preset conversion table;
the target text comprises a first target text, and the step of determining the target text according to the words to be converted comprises the following steps:
and determining the first target text according to the first character to be converted.
Further, the step of determining the first target text according to the first to-be-converted word includes:
determining the first converted characters according to the first characters to be converted and the preset conversion table;
and replacing the first characters to be converted in the text to be converted with the first converted characters to obtain the first target text.
Further, the preset conversion information includes a preset keyword, 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 a second character to be converted in the text to be converted according to the preset keyword;
the target text comprises a second target text, and the step of determining the target text according to the words to be converted comprises the following steps:
and determining the second target text according to the second character to be converted.
Further, the step of determining the second target text according to the second word to be converted includes:
determining target compiled characters according to the second characters to be converted and a preset compiled language;
adding the target compiled characters into the text to be converted to obtain a second pre-target text;
determining a calling statement according to the target compiled words, and replacing the second words to be converted in the second pre-target text with the calling statement to obtain the second target text.
Further, the preset conversion information includes a preset conversion table and preset keywords, the words to be converted include a first word to be converted and a second word to be converted, and the step of determining the words to be converted in the text to be converted includes:
determining the first characters to be converted in the text to be converted according to the preset conversion table;
determining the second characters to be converted in the text to be converted according to the preset keywords;
the target text comprises a third target text, and the step of determining the target text according to the words to be converted comprises the following steps:
and determining the third target text according to the first character to be converted and the second character to be converted.
Further, the step of determining the third target text according to the first word to be converted and the second word to be converted includes:
determining a first converted character according to the first character to be converted and the preset conversion table, and replacing the first character to be converted in the text to be converted with the first converted character to obtain a first target text;
determining target compiled characters according to the second characters to be converted and a preset compiled language, and adding the target compiled characters into the first target text to obtain a third preset target text;
determining a calling statement according to the target compiled words, and replacing the second words to be converted in the third pre-target text with the calling statement to obtain the third target text.
The specific implementation of the text conversion device of the present invention is substantially the same as the following text conversion method, and is not described herein again.
The invention also provides a text conversion method based on the text conversion equipment.
Referring to fig. 2, fig. 2 is a flowchart illustrating a text conversion method according to a first embodiment of the present invention.
While a logical order is shown in the flow chart, in some cases, the steps shown or described may be performed in an order different than presented herein.
In various embodiments of the text conversion method, the execution subject is a text conversion device.
The text conversion method is applied to a text conversion device, and comprises the following steps:
step S10, when a conversion instruction is detected, determining characters to be converted in the text to be converted according to preset conversion information;
when converting code text, the existing text conversion method is generally implemented by a user manually compiling code for conversion or by using a corresponding conversion tool. For example, for the android.mk file to the android.bp file, since the codes in the android.mk file include some contents that cannot be run in the android.bp file, when performing conversion, a code text of the android.mk needs to be acquired, and a part of codes in the code text that are incompatible with the android.bp file are converted into specific codes that can be executed by the android.bp file. If the user manually compiles the codes for conversion, the time of the user is wasted, and errors can be caused; if the android tool is used for conversion, the tool can only perform simple conversion, so that the conversion is incomplete in most cases, and even the conversion cannot be successfully performed due to the phenomena of error reporting and the like.
In order to solve the technical problem that the conventional text conversion technology cannot realize text conversion quickly and accurately, the embodiment of the invention provides a text conversion method, which aims to determine text contents to be converted in a text to be converted according to preset conversion information when a conversion instruction is detected, and then determine a finally required target text according to the text contents to be converted. According to the method and the device, when the text conversion instruction is detected, the text to be converted provided by the user is converted into the target text required by the user, so that automatic conversion among the texts is realized, meanwhile, the characters to be converted can be accurately identified according to the preset conversion information, and the efficiency and the accuracy of text conversion are greatly improved.
The text conversion method in this embodiment is applicable to a device having a text conversion function.
In this embodiment, when the conversion instruction is detected, the text to be converted that needs to be converted in the text to be converted is determined according to the preset conversion information. The preset conversion information contains various character identification marks including preset conversion tables, preset keywords and the like, which can determine which characters in the text to be converted are the characters to be converted, the text to be converted is the original text to be converted by the user, and the user converts the text to be converted, namely the original text, into the required new text by using a text conversion device. For example, if a conversion instruction is detected, when a user converts a text to be converted "text 1" by using a text conversion device, it may be determined that characters to be converted in the text to be converted "text 1" are "LOCAL _ MODULE", "LOCAL _ SRC _ filters _ extract", and "LOCAL _ HEADER _ LIBRARIES", etc. according to preset conversion information; the word to be converted in the text to be converted can also be determined to be 'statement 1' and the like.
And step S20, determining a target text according to the characters to be converted.
In this embodiment, after determining the text to be converted in the text to be converted, a target text is determined according to the text to be converted, where the target text is a new text obtained by converting the text to be converted by the text conversion device, and may be one text or multiple texts. For example, if it is determined that the word to be converted in the text "text 1" to be converted is "LOCAL _ MODULE", and the word obtained after the conversion is "name", the word "LOCAL _ MODULE" in the text to be converted is replaced by "name", so as to obtain the target text.
When a conversion instruction is detected, the text content needing to be converted in the text to be converted is determined according to the preset conversion information, and the finally needed target text is determined according to the text content needing to be converted. According to the method and the device, when the text conversion instruction is detected, the text to be converted provided by the user is converted into the target text required by the user, so that automatic conversion among the texts is realized, meanwhile, the characters to be converted can be accurately identified according to the preset conversion information, and the efficiency and the accuracy of text conversion are greatly improved.
Further, a second embodiment of the text conversion method according to the present invention is provided, where the preset conversion information includes a preset conversion table, the text to be converted includes a first text to be converted, and in the step S10, the step of determining the text to be converted in the text to be converted includes:
step a1, determining the first to-be-converted characters in the to-be-converted text according to the preset conversion table;
the target text includes a first target text, and the step S20 includes:
step b1, determining the first target text according to the first character to be converted.
In this embodiment, the preset conversion information includes a preset conversion table, the words to be converted include first words to be converted, and the step of determining, by the text conversion apparatus, the first words to be converted in the text to be converted is specifically that the text conversion apparatus determines the first words to be converted in the text to be converted according to the preset conversion table. The preset conversion table is a preset text conversion table, in which a conversion relationship of text exists, including text to be converted and converted text, for example, the conversion relationship included in the preset conversion table may be: "LOCAL _ MODULE" is converted into "name", "LOCAL _ SRC _ filters" is converted into "SRC", "LOCAL _ SRC _ filters" is converted into "excclose _ SRC", "LOCAL _ HEADER _ lists" is converted into "HEADER _ lists", the words to be converted are "LOCAL _ MODULE", "LOCAL _ SRC _ filters" and "LOCAL _ HEADER _ lists", and the words to be converted are "name", "SRC", "excclose _ SRC" and "HEADER _ lists".
Determining the characters in the text to be converted, which are the same as the characters to be converted in the preset conversion table, wherein the characters in the text to be converted are the first characters to be converted. For example, the words to be converted in the preset variable conversion table are "LOCAL _ MODULE", "LOCAL _ SRC _ filters _ outside", "LOCAL _ HEADER _ words", and if "LOCAL _ MODULE" and "LOCAL _ SRC _ filters" exist in the text to be converted, then "LOCAL _ MODULE" and "LOCAL _ SRC _ filters" are the first words to be converted.
According to the embodiment, the first to-be-converted characters needing to be converted in the text are determined according to the preset conversion table, the to-be-converted characters can be quickly and accurately identified, and the efficiency and the accuracy of text conversion are improved.
Further, a third embodiment of the text conversion method according to the present invention is provided, wherein the step b1 includes:
step b11, determining the first converted characters according to the first characters to be converted and the preset conversion table;
step b12, replacing the first to-be-converted character in the to-be-converted text with the first converted character to obtain the first target text.
In this embodiment, after determining the first to-be-converted word in the text to be converted, the text conversion apparatus determines the first target text according to the first to-be-converted word. First, the text conversion device determines a first converted word according to a preset conversion table and a first word to be converted, where the converted word corresponding to the first word to be converted in the preset conversion table is the first converted word, for example, if the conversion relationship in the preset conversion table is: the "LOCAL _ MODULE" is converted into "name", and the first to-be-converted character determined in the text to be converted is "LOCAL _ MODULE", and then the text conversion device determines that the first converted character is "name" according to the preset conversion table and the first to-be-converted character "LOCAL _ MODULE".
And after the first converted character is obtained, replacing the first to-be-converted character in the text to be converted by the text conversion device with the first converted character, wherein the text to be converted is the first target text after being replaced. For example, if the first to-be-converted word in the to-be-converted text is "LOCAL _ MODULE", and the first to-be-converted word determined by the text conversion device according to the preset conversion table is "name", the text conversion device replaces "LOCAL _ MODULE" in the to-be-converted text with "name", so as to obtain the first target text.
It should be noted that, in addition to determining the first to-be-converted word in the to-be-converted text according to the preset conversion table, the user may also provide the conversion table, and if the user provides the conversion table, the text conversion apparatus may determine the first to-be-converted word in the to-be-converted text according to the conversion table provided by the user, and then determine the first converted word according to the conversion table provided by the user.
According to the embodiment, the first to-be-converted character in the to-be-converted text is converted according to the preset conversion table, so that the first target text is obtained, the to-be-converted character is accurately converted, and the efficiency and the accuracy of text conversion are improved.
Further, a fourth embodiment of the text conversion method according to the present invention is provided, where the preset conversion information includes a preset keyword, the text to be converted includes a second text to be converted, and in step S10, the step of determining the text to be converted in the text to be converted includes:
step c1, determining a second character to be converted in the text to be converted according to the preset keyword;
the target text includes a second target text, and the step S20 includes:
and d1, determining the second target text according to the second character to be converted.
In this embodiment, the preset conversion information includes a preset keyword, 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 a second word to be converted in the text to be converted according to a preset keyword, wherein the preset keyword is a preset specific word and can be one or more compiling key words, and specific compiling statements including conditional compiling statements, cyclic compiling statements and the like in the text to be converted can be identified through the compiling key words. For example, the preset keywords may include the compiling keywords "ifeq", "ifneq", "ifdef", and "ifndef", which can be used to identify the conditional compiling statement; the preset keyword may also include a compiling keyword "for" and the like, which can be used to identify the loop compiling sentence.
The method for determining the second character to be converted in the text to be converted by the text conversion device according to the preset keyword may be: and directly determining a corresponding compiling statement in the text to be converted according to the compiling key words in the preset key words. For example, if the preset keywords are "ifeq" and "ifneq", 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', directly determining a loop compiling statement in the text to be converted, wherein the determined loop compiling statement is the second text to be converted.
The method for determining the second character to be converted in the text to be converted by the text conversion device according to the preset keyword may also be: in the text to be converted, the compiled keyword in the preset keyword is taken as a starting point, the preset end point closest to the starting point is taken as an end point, all characters between the starting point and the end point are second characters to be converted, and the second characters to be converted comprise the starting point and the end point. For example, the preset end point mark may be "endif" or "}", and when the compiling key word in the preset key word is "ifeq", the compiling key word "ifeq" is taken as a starting point, and the "endif" closest to the "ifeq" is taken as an end point, all words between the "ifeq" and the "endif" are the second word to be converted, and the second word to be converted includes "ifeq" and "endif", such as "ifeq ($ (VALUE), X) do _ yes else do _ no endif"; when the compiling key word in the preset key word is ' for ', taking ' for ' as a starting point, taking ' as an end point, and taking all words between ' for ' and ' as second words to be converted, wherein the second words to be converted comprise ' for ' and ' for ', for example, ' for (int i: mDatas) { log.d (' i ═ i + '); }".
According to the embodiment, the second character to be converted in the text to be converted is determined through the preset keywords, the character to be converted can be accurately identified, and the accuracy of determining the character to be converted is improved.
Further, a fifth embodiment of the text conversion method according to the present invention is provided, wherein the step d2 includes:
d21, determining target compiled characters according to the second characters to be converted and a preset compiled language;
d22, adding the target compiled characters into the text to be converted to obtain a second pre-target text;
in this embodiment, after determining the second to-be-converted word in the to-be-converted text according to the preset keyword, the text conversion apparatus determines the target compiled word according to the second to-be-converted word and the preset compiling language. The preset compiling language is a compiling language for compiling the second character to be converted, for example, the compiling language represented by the preset compiling language may be "Golang language", "C language", and the like.
And the text conversion device converts and compiles the second character to be converted according to a preset compiling language and generates a target compiling character according to the character obtained after conversion and compilation. For example, after a second character to be converted in the text to be converted is determined, if the preset compiling language is the "gold language", the "gold language" is used for converting and compiling the second character to be converted, and a target compiling character is generated according to the character obtained after the conversion and compiling.
And after the target compiled characters are determined, adding the target compiled characters into the text to be converted to obtain a second pre-target text.
It should be noted that, in addition to determining the second to-be-converted word in the to-be-converted text according to the preset keyword, the user may also provide the keyword, and similarly, the user may also provide the compiling language, and if the user provides the keyword and the compiling language, the text conversion device may determine the second to-be-converted word in the to-be-converted text according to the keyword provided by the user, and then determine the target compiling word according to the compiling language provided by the user and the second to-be-converted word.
Step d23, determining a calling statement according to the target compiled word, and replacing the second word to be converted in the second pre-target text with the calling statement to obtain the second target text.
And determining a calling statement according to the target compiled word, wherein the calling statement refers to a statement which is generated according to a specific file in the compiling process and is used for calling the file, namely when the compiled file is generated according to the target compiled word, the statement of the compiled file can be called. For example, if a target compiled word "compiled word 1" is generated according to the "gold language" and the second word to be converted, when the "gold" script file "go" is generated according to the "compiled word 1", the calling sentence is the sentence used for calling the "go script file.
And the text conversion device replaces the second character to be converted in the second pre-target text with the calling sentence to obtain a second target text.
It should be noted that, after the target compiled characters are obtained, in addition to adding the target compiled characters into the text to be converted, a new text may be generated according to the target compiled characters, and then the second text to be converted in the text to be converted is replaced by the calling sentence, at this time, the finally obtained second target text includes a plurality of texts.
In the embodiment, the target compiled characters are determined according to the preset keywords and the preset compiled language, and then the calling statement is determined according to the target compiled characters, so that the second target text is determined, the accurate conversion of the characters to be converted is realized, and the efficiency and the accuracy of text conversion are improved.
Further, a sixth embodiment of the text conversion method according to the present invention is provided, wherein the preset conversion information includes a preset conversion table and preset keywords, the text characters to be converted include a first character to be converted and a second character to be converted, and in the step S10, the step of determining the character to be converted in the text to be converted includes:
step e1, determining the first to-be-converted characters in the to-be-converted text according to the preset conversion table;
step e2, determining the second character to be converted in the text to be converted according to the preset keyword;
the target text includes a third target text, and the step S20 includes:
step f1, determining the third target text according to the first character to be converted and the second character to be converted.
In this embodiment, the preset conversion information includes a preset conversion table and a preset keyword, the words to be converted include a first word to be converted and a second word to be converted, the text conversion apparatus determines the first word to be converted in the text to be converted according to the preset conversion table, and determines the second word to be converted in the text to be converted according to the preset keyword, and the manner of determining the first word to be converted by the text conversion apparatus according to the preset conversion table and the manner of determining the second word to be converted according to the preset keyword are the same as those in the above embodiments. For example, if the conversion relationship in the preset conversion table is: the method for determining the second character to be converted comprises the steps of directly determining a conditional compilation statement in the text to be converted or taking the "ifeq" as a starting point and taking the "endif" as an end point, wherein all characters between the starting point and the end point are the second character to be converted.
In the embodiment, the words to be converted in the text to be converted are determined through the preset conversion table and the preset compiling keyword table, so that the words to be converted can be accurately identified, and the accuracy of text conversion is improved.
Further, a seventh embodiment of text conversion according to the present invention is proposed, and the step S20 includes:
step g1, determining a first converted character according to the first character to be converted and the preset conversion table, and replacing the first character to be converted in the text to be converted with the first converted character to obtain a first target text;
step g2, determining target compiled characters according to the second characters to be converted and a preset compiled language, and adding the target compiled characters into the first target text to obtain a third preset target text;
step g3, determining a calling statement according to the target compiled words, and replacing the second words to be converted in the third pre-target text with the calling statement to obtain the third target text.
In this embodiment, the manner of determining the first converted word by the text conversion apparatus according to the first to-be-converted word and the preset conversion table, the manner of determining the target compiled word according to the second to-be-converted word and the preset compiling language, and the manner of determining the call statement according to the target compiled word are the same as those in the above embodiments. For example, the conversion relationship in the preset conversion table is: the method comprises the steps of converting LOCAL _ Module into ' name ', ' LOCAL _ SRC _ FILES ' into ' SRC ', ' LOCAL _ SRC _ FILES _ EXCLUDE into ' excclose _ SRC ', ' LOCAL _ HEADER _ LIBRARIES ' into ' head _ libs ', presetting a compiling language as ' Golang language ', if a first character to be converted in a text ' text 1 ' to be converted is ' LOCAL _ Module ' and ' LOCAL _ SRC _ FILES ', the first converted character is ' name ' and ' SRC ', meanwhile, a text conversion device carries out conversion compiling on a second character to be converted according to the preset compiling language ' Golang language ', target compiling characters are generated according to the characters obtained after conversion compiling, and when the target compiling characters are used for generating ' script FILES ', statements of ' go FILES '.
After determining a first character to be converted and a second character to be converted in a text to be converted, the text conversion device determines the first converted character according to 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 character to obtain a first target text, determines a target compiled character according to the second character to be converted and a preset compiling language, adds the target compiled character into the first target text to obtain a third preset target text, determines a calling sentence according to the target compiled character, and replaces the second character to be converted in the third preset target text with the calling sentence to obtain a third target text. For example, if the first to-be-converted characters in the text to be converted are "LOCAL _ MODULE" and "LOCAL _ SRC _ FILES", and the first converted characters are "name" and "SRC", the text conversion device replaces "LOCAL _ MODULE" in the text to be converted with "name" and "LOCAL _ file" with "SRC" to obtain the first target text, generates target compiled characters according to the second to-be-converted characters and the "gold language", adds the target compiled characters into the first target text to obtain a third pre-target text, determines a call statement according to the target compiled characters, and replaces the second to-be-converted characters in the third pre-target text with the call statement to obtain the third target text.
The step of obtaining the third target text according to the text to be converted may further be: firstly, determining target compiled characters according to second characters to be converted and preset compiled sentences, adding the target compiled characters into a text to be converted to obtain a second preset target text, then determining calling sentences according to the target compiled characters, replacing the second characters to be converted in the second preset target text with the calling sentences to obtain a second target text, and replacing the first characters to be converted in the second target text with the first converted characters to obtain a third target text. It should be noted that the sequence of various word replacements or text conversions is not limited here, and only the first word to be converted in the text to be converted is replaced with the first converted word, the target compiled word is added to the text to be converted, and the second word to be converted is replaced with the calling sentence.
It should be noted that the conversion method herein may also be applied to conversion between compiled files, for example, an android.mk file is converted into an android.bp file, and the specific steps may be that the android.mk file is used to obtain a code text of the mk file through corresponding compiling software or other methods, the text conversion device determines code words to be converted in the code text, and then obtains a target code text according to the code words to be converted. For example, when an android.mk file is converted, a code text in the android.mk file is obtained through a corresponding compiler, a text conversion device determines a first to-be-converted character "LOCAL _ MODULE" and a second to-be-converted character "conditional compilation statement" in the code text according to a preset conversion table and a preset keyword "ifeq", then determines a first converted character "name" according to the first to-be-converted character "LOCAL _ MODULE", determines a corresponding target compiled character according to the "conditional compilation statement" and a preset compilation language "gold language", generates a script text according to the target compiled character, then generates a corresponding go script file "go script", determines to call a "go script", and then replaces the first to-be-converted character "LOCAL _ MODULE" in the to-be-converted text with the first converted character "name", and the first converted character "name" and the second name "in the to-go script file, And replacing the conditional compiling statement of the second character to be converted with a calling statement to obtain a target code text, and then generating an android.bp file according to the target code text by using a compiler to obtain a go script file and an android.bp file.
In the embodiment, the third target text is determined by determining the first converted characters and the target compiled characters according to the preset conversion table and the preset compiling language, so that the accurate conversion of the characters to be converted is realized, and the efficiency and the accuracy of text conversion are improved.
The invention also provides a text conversion device.
Referring to fig. 3, fig. 3 is a functional block diagram of a text conversion apparatus according to a first embodiment of the present invention. The text conversion apparatus includes:
the detection module is used for determining characters to be converted in the text to be converted according to preset conversion information when the conversion instruction is detected;
and the determining module is used for determining a target text according to the characters to be converted.
In addition, the embodiment of the invention also provides a storage medium.
The storage medium has stored thereon a text conversion program which, when executed by the processor, implements the steps of the text conversion method as described above.
The specific implementation of the storage medium of the present invention is substantially the same as the embodiments of the text conversion method, and will not be described herein again.
The present invention is described in connection with the accompanying drawings, but the present invention is not limited to the above embodiments, which are only illustrative and not restrictive, and those skilled in the art can make various changes without departing from the spirit and scope of the invention as defined by the appended claims, and all changes that come within the meaning and range of equivalency of the specification and drawings that are obvious from the description and the attached claims are intended to be embraced therein.

Claims (10)

1. A text conversion method, characterized by comprising the steps of:
when a conversion instruction is detected, determining characters to be converted in the text to be converted according to preset conversion information;
and determining a target text according to the characters to be converted.
2. The method of converting text according to claim 1, wherein the predetermined conversion information includes a predetermined conversion table, the words to be converted include first words to be converted, and the step of determining the words to be converted in the text to be converted includes:
determining the first characters to be converted in the text to be converted according to the preset conversion table;
the target text comprises a first target text, and the step of determining the target text according to the words to be converted comprises the following steps:
and determining the first target text according to the first character to be converted.
3. The text conversion method according to claim 2, wherein the step of determining the first target text based on the first word to be converted includes:
determining the first converted characters according to the first characters to be converted and the preset conversion table;
and replacing the first characters to be converted in the text to be converted with the first converted characters to obtain the first target text.
4. The text conversion method according to claim 1, wherein the preset conversion information includes a preset keyword, 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 a second character to be converted in the text to be converted according to the preset keyword;
the target text comprises a second target text, and the step of determining the target text according to the words to be converted comprises the following steps:
and determining the second target text according to the second character to be converted.
5. The text conversion method according to claim 4, wherein the step of determining the second target text from the second word to be converted comprises:
determining target compiled characters according to the second characters to be converted and a preset compiled language;
adding the target compiled characters into the text to be converted to obtain a second pre-target text;
determining a calling statement according to the target compiled words, and replacing the second words to be converted in the second pre-target text with the calling statement to obtain the second target text.
6. The method of claim 1, wherein the predetermined conversion information includes a predetermined conversion table and a predetermined keyword, the words to be converted include a first word to be converted and a second word to be converted, and the step of determining the words to be converted in the text to be converted includes:
determining the first characters to be converted in the text to be converted according to the preset conversion table;
determining the second characters to be converted in the text to be converted according to the preset keywords;
the target text comprises a third target text, and the step of determining the target text according to the words to be converted comprises the following steps:
and determining the third target text according to the first character to be converted and the second character to be converted.
7. The text conversion method according to claim 6, wherein the step of determining the third target text based on the first word to be converted and the second word to be converted includes:
determining a first converted character according to the first character to be converted and the preset conversion table, and replacing the first character to be converted in the text to be converted with the first converted character to obtain a first target text;
determining target compiled characters according to the second characters to be converted and a preset compiled language, and adding the target compiled characters into the first target text to obtain a third preset target text;
determining a calling statement according to the target compiled words, and replacing the second words to be converted in the third pre-target text with the calling statement to obtain the third target text.
8. A text conversion apparatus, characterized in that the text conversion apparatus comprises:
the detection module is used for determining characters to be converted in the text to be converted according to preset conversion information when the conversion instruction is detected;
and the determining module is used for determining a target text according to the characters to be converted.
9. A text conversion device, characterized in that the text conversion device comprises a memory, a processor and a text conversion program stored on the memory and executable on the processor, which when executed by the processor implements the steps of the text conversion method according to any of claims 1-7.
10. A storage medium having stored thereon a text conversion program which, when executed by a processor, implements the steps of the text conversion method according to any one of claims 1-7.
CN202110376448.3A 2021-04-06 2021-04-06 Text conversion method, text conversion device, and storage medium Pending CN112988164A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110376448.3A CN112988164A (en) 2021-04-06 2021-04-06 Text conversion method, text conversion device, and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110376448.3A CN112988164A (en) 2021-04-06 2021-04-06 Text conversion method, text conversion device, and storage medium

Publications (1)

Publication Number Publication Date
CN112988164A true CN112988164A (en) 2021-06-18

Family

ID=76339464

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110376448.3A Pending CN112988164A (en) 2021-04-06 2021-04-06 Text conversion method, text conversion device, and storage medium

Country Status (1)

Country Link
CN (1) CN112988164A (en)

Similar Documents

Publication Publication Date Title
US6799718B2 (en) Development assistance for mixed-language sources
US20240045850A1 (en) Systems and methods for database orientation transformation
US8806452B2 (en) Transformation of computer programs and eliminating errors
EP0827072A1 (en) Correcting program porting errors
CN110673854A (en) SAS language compiling method, device, equipment and readable storage medium
KR100853933B1 (en) Migration apparatus which convert application program of mainframe system into application program of open system and method for thereof
CN109857389B (en) Model data generation method and device, computer equipment and storage medium
US9678856B2 (en) Annotated test interfaces
US20130185698A1 (en) Simplifying analysis of software code used in software systems
CN112988164A (en) Text conversion method, text conversion device, and storage medium
CN111078217A (en) Brain graph generation method, apparatus and computer-readable storage medium
US8108828B2 (en) System for generating optimized computer data field conversion routines
CN109597638B (en) Method and device for solving data processing and equipment linkage based on real-time computing engine
CN110515653B (en) Document generation method and device, electronic equipment and computer readable storage medium
CN110245333B (en) Font type detection method and device, electronic equipment and storage medium
CN114328572A (en) Data query method, device, system and medium based on SQL parser
CN111639504A (en) Multi-language translation method, device and equipment for webpage
CN112052012B (en) XSLT and XSD-based code automatic generation method and equipment
CN112286784A (en) Test case generation method and device, server and storage medium
JP2006079484A (en) Source program conversion program for system migration
CN111279350B (en) System and method for providing globalization features in service management application interfaces
CN116954609A (en) Code conversion method, device, equipment and storage medium
CN113408250A (en) Project file processing method and device
KR100747910B1 (en) Apparatus and method for auto generating interface function in agent system
CN113626390A (en) BB file generation method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination