CN110110299B - Text conversion method, device and server - Google Patents

Text conversion method, device and server Download PDF

Info

Publication number
CN110110299B
CN110110299B CN201910351555.3A CN201910351555A CN110110299B CN 110110299 B CN110110299 B CN 110110299B CN 201910351555 A CN201910351555 A CN 201910351555A CN 110110299 B CN110110299 B CN 110110299B
Authority
CN
China
Prior art keywords
transformation
text
file
event
text object
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.)
Active
Application number
CN201910351555.3A
Other languages
Chinese (zh)
Other versions
CN110110299A (en
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.)
Tencent Technology Shanghai Co Ltd
Original Assignee
Tencent Technology Shanghai 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 Tencent Technology Shanghai Co Ltd filed Critical Tencent Technology Shanghai Co Ltd
Priority to CN201910351555.3A priority Critical patent/CN110110299B/en
Publication of CN110110299A publication Critical patent/CN110110299A/en
Application granted granted Critical
Publication of CN110110299B publication Critical patent/CN110110299B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • 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/151Transformation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/237Lexical tools
    • G06F40/242Dictionaries
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/284Lexical analysis, e.g. tokenisation or collocates
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Document Processing Apparatus (AREA)

Abstract

The embodiment of the application discloses a text transformation method, a text transformation device and a server; the method and the device for converting the current dictionary can obtain the current conversion dictionary and the file to be converted; determining dictionary update information of the current transformation dictionary relative to a historical transformation dictionary; analyzing the content of the file to be converted to obtain a text object in the file to be converted; determining a target text object and a transformation event corresponding to the target text object in the text object based on the dictionary updating information; and calling host software to execute the transformation operation corresponding to the transformation event to obtain a transformed target text object. According to the method and the device, the file to be converted can be obtained and analyzed, and the text object in the file to be converted is automatically converted according to the dictionary updating information. Therefore, the scheme can improve the efficiency of text conversion.

Description

Text conversion method, device and server
Technical Field
The present application relates to the field of computers, and in particular, to a text transformation method, apparatus, and server.
Background
The method for converting the text in the file to be converted is various, for example, format conversion, character color conversion, language translation, artistic style conversion and the like are performed on the text in the file to be converted. The commonly used text conversion method is to open a file to be converted through professional software, edit the text in the file to be converted, and export the text into the converted file to be converted.
However, current text conversion methods are inefficient.
Disclosure of Invention
The embodiment of the application provides a text transformation method, a text transformation device and a server, and the efficiency of text transformation can be improved.
The embodiment of the application provides a text transformation method, which comprises the following steps:
acquiring a current transformation dictionary and a file to be transformed;
determining dictionary update information of the current transformation dictionary relative to a historical transformation dictionary;
analyzing the content of the file to be converted to obtain a text object in the file to be converted;
determining a target text object and a transformation event corresponding to the target text object in the text object based on the dictionary updating information;
and calling host software to execute the transformation operation corresponding to the transformation event to obtain a transformed target text object.
In some embodiments, the transforming event includes at least one transforming sub-event, and the invoking host software executes a transforming operation corresponding to the transforming event to obtain the transformed target text object includes:
pulling the transformation sub-event into host software through a transformation interface;
executing the transformation operation corresponding to the transformation sub-event by adopting host software to obtain a transformed target text object;
acquiring the transformed text object from host software through a transformation interface;
when the transformation sub-event which is not pulled exists, the return execution step pulls the transformation sub-event into the host software through the transformation interface.
In some embodiments, the host software includes a translation component and an execution component, and the executing component executes a transformation operation corresponding to the transformation sub-event by using the host software to obtain a transformed target text object, including:
confirming event handler code in host software corresponding to the transformation subevents;
translating the event handler code into bytecode in the translation component;
and executing the conversion operation corresponding to the byte code by adopting an execution component to obtain a converted target text object.
In some embodiments, the translation component includes a lexical analyzer, a syntax analyzer, and a bytecode generator, in which translating the event handler code into bytecode includes:
performing lexical analysis on the event processing program codes by adopting a lexical analyzer to obtain a word stream;
carrying out syntax analysis on the word stream by adopting a syntax analyzer to obtain a corresponding abstract syntax tree;
and traversing the abstract syntax tree by adopting a byte code generator to obtain byte codes.
In some embodiments, the executing component includes a class loader and an executor, and the executing component is used to execute the transformation operation corresponding to the bytecode, and includes:
loading the byte codes into corresponding memories by adopting a class loader;
after loading is finished, reading a target byte code from a memory by adopting an actuator;
and translating the target bytecode into a machine code, and executing the machine code.
In some embodiments, after obtaining the transformed target text object, the method further includes:
pulling the transformed target text object into a packaging engine;
packaging the transformed current object by adopting the packaging engine to obtain a file to be transformed, which comprises the transformed current object;
and acquiring a transformed file containing the transformed current object from the packaging engine.
In some embodiments, the content parsing the file to be transformed to obtain the text object in the file to be transformed includes:
pulling the file to be transformed into an analysis engine;
analyzing the file to be converted by adopting the engine to obtain at least one text object in the file to be converted;
and acquiring the text object from the analysis engine.
In some embodiments, obtaining the file to be transformed and the current transformation dictionary comprises:
acquiring a file to be transformed through wireless connection;
identifying text information in the file to be converted, wherein the text information comprises text content, text font information and text format information;
performing language translation on the text content to obtain translated text content;
and generating a conversion dictionary according to the translated text content, the text font information and the text format information.
An embodiment of the present application further provides a text conversion apparatus, including:
the obtaining unit is used for obtaining a current transformation dictionary and a file to be transformed;
the updating unit is used for determining dictionary updating information of the current transformation dictionary relative to the historical transformation dictionary;
the analysis unit is used for analyzing the content of the file to be converted to obtain a text object in the file to be converted;
the event unit is used for determining a target text object and a transformation event corresponding to the target text object in the text object based on the dictionary updating information;
and the transformation unit is used for calling host software to execute the transformation operation corresponding to the transformation event to obtain a transformed target text object.
The embodiment of the present application further provides a server, where the server includes a processor and a memory, where the memory stores a plurality of instructions, and the processor loads the instructions from the memory to perform the steps in any one of the text transformation methods provided in the embodiment of the present application.
The method comprises the steps of obtaining a current transformation dictionary and a file to be transformed; determining dictionary update information of the current transformation dictionary relative to a historical transformation dictionary; analyzing the content of the file to be converted to obtain a text object in the file to be converted; determining a target text object and a transformation event corresponding to the target text object in the text object based on the dictionary updating information; and calling host software to execute the transformation operation corresponding to the transformation event to obtain a transformed target text object.
According to the method and the device, the file to be converted can be obtained and analyzed, and the text object in the file to be converted is automatically converted according to the dictionary updating information. Therefore, the scheme can improve the efficiency of text conversion.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1a is a scene schematic diagram of a text transformation method provided in an embodiment of the present application;
fig. 1b is a schematic flowchart of a text transformation method provided in an embodiment of the present application;
FIG. 2a is a schematic view of a scenario of persistent integration provided by an embodiment of the present application;
FIG. 2b is a schematic diagram of a format of a transform dictionary according to an embodiment of the present application;
fig. 2c is a schematic system structure diagram of Jenkins provided in the embodiment of the present application;
FIG. 2d is a schematic diagram of a call relationship between Photoshop and CEP provided in the embodiment of the present application;
FIG. 2e is a schematic diagram of a Java operation flow provided in the embodiment of the present application;
fig. 2f is a schematic diagram illustrating a mechanism for verifying and loading the bytecode by the class loader according to an embodiment of the present application;
fig. 2g is a schematic diagram of a memory structure of a JVM according to an embodiment of the present application;
FIG. 2h is a scene diagram of a text transformation manner based on persistent integration according to an embodiment of the present disclosure;
fig. 3 is a schematic structural diagram of a text conversion apparatus provided in an embodiment of the present application;
fig. 4 is a schematic structural diagram of a server according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be described clearly and completely with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only some embodiments of the present application, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The embodiment of the application provides a text transformation method, a text transformation device and a server.
The text conversion apparatus may be integrated in a server, and the server may be a network server, a Personal Computer (PC), a terminal, or the like.
Fig. 1a is a scene schematic diagram of a text transformation method provided in this embodiment, referring to fig. 1a, the text transformation apparatus may be integrated in a database server, and a person skilled in the art may upload a current transformation dictionary through a terminal a, a terminal B, and a terminal C, where the text transformation apparatus may acquire a to-be-transformed file, then acquire the current transformation dictionary from the terminal a, the terminal B, and the terminal C through a network, and automatically determine dictionary update information of the current transformation dictionary relative to a history transformation dictionary, then perform content analysis on the to-be-transformed file to obtain a text object in the to-be-transformed file, then determine a target text object in the text object based on the dictionary update information, and a transformation event corresponding to the target text object, and finally invoke host software to perform a transformation operation corresponding to the transformation event, so as to obtain a transformed target text object.
The following are detailed descriptions. The numbers in the following examples are not intended to limit the order of preference of the examples.
In this embodiment, a text transformation method is provided, and fig. 1b is a schematic flow chart of the text transformation method, and as shown in fig. 1b, a specific flow of the text transformation method may be as follows:
101. and acquiring a current transformation dictionary and a file to be transformed.
Wherein the file to be transformed may refer to a computer file carrying the text object. For example, the file to be transformed may be a computer file storing Text information, and the Text information may include a Text Object and information such as an Object name, text content, a Text font, a Text format, and a Text style corresponding to the Text Object (Text Object).
The text object may refer to an entity formed by encapsulating text data, and the entity may be a target of an operation. For example, a text object may be a general term for a certain type of text data that may be a target of an operation.
For example, in some embodiments, the file to be transformed may be a PSD (graphics device software Photoshop dedicated format), the PSD file may include information such as a layer, a channel, and a path, the layer may include at least one text object, and by selecting the text object, an object name, a text content, a text font, a text format, and a text style corresponding to the text object may be edited.
The current transformation dictionary may refer to a dictionary (Data dictionary) containing transformation information acquired at the current time, for example, the current transformation dictionary may be a set of transformation information as Data elements acquired at the current time.
The transformation information may include a text object and transformation operation information to be executed corresponding to the text object.
For example, the transformation information may include a text object and transformation operation information such as translated text content, text font, text format, and the like of the text object.
For example, table 1 is a format schematic of a current transformation dictionary, which, as shown in Table 1, may be saved in the form of a spreadsheet file in some embodiments.
Object name Text content transformation operation Operation for changing character font Text format conversion operations
Object 1 A Font 1 Format 1
Object 2 B Font 2 Format 2
Object 3 C Font 3 Format 3
TABLE 1
The text object with the object name of object 1 may include information of the transformation operation to be performed corresponding to object 1. For example, the information about the transformation operation to be performed corresponding to the object 1 is to replace the text content of the object 1 with a, set the font of the text of the object 1 to font 1, and set the text format of the object 1 to format 1.
Similarly, the information of the transformation operation to be performed corresponding to the object 2 and the object 3 may also refer to the information of the transformation operation to be performed corresponding to the object 1, which is not described herein again.
The method for acquiring the current transformation dictionary and the file to be transformed is various, and the acquisition methods of the file to be transformed and the current transformation dictionary can be the same or different.
For example, the file to be transformed and the current transformation dictionary may be directly read from a local memory, or the current transformation dictionary and the file to be transformed may be obtained through a network; or directly reading the file to be transformed from a local memory and currently transforming the dictionary through a network.
For example, the current transformation dictionary is obtained from a client through a network, and the file to be transformed is obtained from a database server through the network.
In some embodiments, compared with manual translation, performing language translation automatically may improve the work efficiency during language translation, and obtaining the current transformation dictionary and the file to be transformed may include the following specific steps:
a. acquiring a file to be transformed;
b. identifying text information in a file to be converted, wherein the text information comprises text content, text font information and text format information;
c. performing language translation on the text content to obtain translated text content;
d. and generating a transformation dictionary according to the translated text content, the text font information and the text format information.
The method for obtaining the file to be transformed includes multiple ways, for example, obtaining the file to be transformed from the client through the network, obtaining the file to be transformed from the database server through the network, directly reading the file to be transformed in the local memory, and the like.
The method for identifying the text information in the file to be converted includes various ways, for example, identifying the text information in the file to be converted by using a character identification model, identifying the text information in the file to be converted by calling character identification software, identifying the text information in the file to be converted by sending the file to be converted to a character identification server through a network, and the like.
The method of translating the text content in the language includes a plurality of ways, for example, translating the text content into the translated text content by using a language translation model, calling language translation software to translate the text content into the translated text content, sending a file to be converted to a language translation server through a network to translate the text content into the translated text content, and the like.
102. Dictionary update information for the current transformed dictionary relative to the historical transformed dictionary is determined.
The history transformation dictionary may refer to a dictionary that contains transformation information and is acquired at a history time. The historical time refers to the time before the current time.
When there is no history transformation dictionary, the current transformation dictionary may be directly used as dictionary update information.
When the history transformation dictionary exists, the content in the current transformation dictionary, which is different from the history transformation dictionary, can be used as dictionary updating information by comparing the content of the current transformation dictionary with the content of the history transformation dictionary.
The dictionary updating information can be stored in the form of tables, images, texts, characters and the like.
For example, table 2 is a format schematic of a history transformation dictionary, and as shown in table 2, the history transformation dictionary may also be saved in the form of a spreadsheet file, similar to the current transformation dictionary shown in table 1.
Object name Text content transformation operation Operation for changing character font Operation for converting text format
Object 1 A Font 1 Format 1
Object 2 b Font 2 Format 2
TABLE 2
As can be seen from the content comparison between table 1 and table 2, the conversion operation of the text content of object 2 in table 1 is changed from B to B, and object 3 and its corresponding conversion operation are added, so that it can be determined that the dictionary update information of the current conversion dictionary relative to the historical conversion dictionary is: the conversion operation of the character content of the object 2 is B, and the object 3 and the corresponding conversion operation thereof are performed; or object 2 and its corresponding transformation operation, and object 3 and its corresponding transformation operation.
In some embodiments, the dictionary update information may also be stored in a spreadsheet file, for example, referring to table 3, the format of the dictionary update information may include object 2 and its corresponding transformation operation, and object 3 and its corresponding transformation operation.
Object name Text content transformation operation Operation for changing character font Operation for converting text format
Object 2 b Font 2 Format 2
Object 3 C Font 3 Format 3
TABLE 3
103. And analyzing the content of the file to be converted to obtain a text object in the file to be converted.
When the text object cannot be directly read from the file to be converted, the content of the file to be converted can be analyzed to obtain the text object in the file to be converted.
Among them, there are various ways of content analysis. For example, the parsing engine is used to perform content parsing on the file to be transformed, the file to be transformed is sent to the parsing server through the network to perform content parsing on the file to be transformed, parsing software is called to perform content parsing on the file to be transformed, and the like.
For example, in some embodiments, native parsing software may be invoked to perform content parsing on the file to be transformed.
For another example, in some embodiments, in order to improve the work efficiency and the analysis accuracy when analyzing the file to be transformed, the content analysis of the file to be transformed to obtain the text object in the file to be transformed may include the following specific steps:
a. pulling a file to be transformed into an analysis engine;
b. analyzing the file to be transformed by adopting an engine to obtain at least one text object in the file to be transformed;
c. the text object is obtained from a parsing engine.
104. And determining a target text object in the text objects based on the dictionary updating information and a transformation event corresponding to the target text object.
The target text object refers to a text object to be converted in the text object.
The transformation Event refers to an Event (Event) that can trigger a transformation operation of the host software, and the transformation Event may include a target text object and information of the transformation operation to be performed on the target text object.
And determining a conversion event corresponding to the target text object according to the state change, wherein the conversion event can trigger the host software to execute a conversion operation corresponding to the conversion event.
There are various mechanisms for triggering a transformation event. For example, a target text object to be solved through an event mechanism in text conversion is registered on host software, and is used for indicating that the target text object is authorized to use the host software to execute corresponding conversion operation on the target text object when the state of the target text object changes; when an event occurs, the target text object calls the host software to perform the corresponding transformation operation on the target text object.
105. And calling host software to execute the transformation operation corresponding to the transformation event to obtain the transformed target text object.
Host software (Host software) refers to software that can provide an operating environment for a Plug-in (Plug-in), for example, a computer program that can install various Plug-ins and provide an operating environment for the Plug-ins.
The plug-in is a program written by an application program interface following a certain specification, and the plug-in can only run under a running environment (such as a system platform, host software and the like) specified by the program and cannot run independently from a specified running environment.
For example, various views and music production software may be installed with various plug-ins, which may be called host software and may call a function library or data provided by the host software.
For example, photoshop (an image processing software) can be used as a host program of the text transformation device in the present application, and a Common Extension Platform (CEP) plug-in can call a function library and data provided by Photoshop.
The transformation operation and the transformation event can be in a mapping relation, and the transformation operation can be a function, code or the like which is well registered in the host program.
For example, in some embodiments, the performing of the transformation operation corresponding to the transformation event may include the following specific steps:
a. searching for a transformation operation mapped to the transformation event;
b. a transformation operation is performed.
The converted target text object may refer to a target text object in which some or all of information such as object name, text content, text font, text format, text style, and the like is converted.
In some embodiments, the information of the target text object, such as object name, text content, text font, text format, text style, etc., may be partially or completely transformed, and at this time, the target text object needs to be transformed for multiple times to obtain the transformed target text object, and the transformation event includes at least one transformation sub-event, and the host software is invoked to execute the transformation operation corresponding to the transformation event, and obtaining the transformed target text object may include the following specific steps:
1. and pulling the transformation sub-event into the host software through the transformation interface.
Wherein, the transformation event can be divided into a plurality of transformation sub-events, for example, the transformation event a can be divided into transformation sub-events a according to different transformation sub-event types 1 Transforming sub-event a 2 Transforming sub-event a 3 . Specifically, for example, the transform event "zoom in rotate" may be split into a transform sub-event "zoom in" and a transform sub-event "rotate".
The transformation interface can be an abstract method containing elements such as methods, attributes, indexers and events as members.
2. And executing the transformation operation corresponding to the transformation sub-event by adopting host software to obtain the transformed target text object.
Wherein, there may be a mapping relationship between the transformation operation and the transformation sub-event.
In some embodiments, the host software includes a translation component and an execution component, and the obtaining of the transformed target text object by using the host software to execute the transformation operation corresponding to the transformation sub-event may include the following specific steps:
(1) Event handler code in the host software corresponding to the transform sub-event is identified.
The event handler code may be a source file written by a technician in a language supported by a development tool, where the source file is a set of human-readable texts composed of characters, symbols or signal symbols, and the human-readable texts may be compiled into computer-executable binary instructions for executing transformation operations corresponding to the transformation sub-events.
(2) The event handler code is translated into bytecode in a translation component.
A Byte-code (Byte-code) is a binary file consisting of a sequence of codes/data that contains the execution program.
In some embodiments, the translation component includes a lexical analyzer, a syntax analyzer, and a bytecode generator, and the translation of the event handler code into bytecode in the translation component may include the following specific steps:
a. performing lexical analysis on the event handler code by adopting a lexical analyzer to obtain a word stream;
b. carrying out syntax analysis on the word stream by adopting a syntax analyzer to obtain a corresponding abstract syntax tree;
c. and traversing the abstract syntax tree by adopting a byte code generator to obtain byte codes.
Among other things, a Lexical analyzer (Lexical analyzer, lexer) may convert a character sequence of a program into a word stream (Token), and the Lexical analyzer generally exists in the form of a function.
Lexical analysis may be based on Finite State Automaton (FSA) to identify all the character sequences (single character sequences are also called morphemes) that may be contained in the tokens that it can handle.
The FSA is a computing model abstracted for researching a computing process with limited memory and certain language classes, the FSA can have a limited number of states, each state can be migrated to zero or more states, and an input string can determine which state the FSA executes the migration.
When lexical analysis is performed, the lexical analyzer can be continuously called by the grammar analyzer, a word is spelled out from the character sequence of the application program to be debugged by calling the lexical analyzer once, the word is stored in a word stream, and the word stream is sent to the grammar analyzer. The lexical analyzer may also scan all words at once and send all word streams to the parser.
For example, the lexical analyzer may scan a current character in the application program to be debugged, determine whether the character is a space, if the character is a space, continue to scan a next character until the scanned character is not a space, determine whether the character is a letter, and if the character is a letter, identify the identifier and the reserved character; then, judging whether the character is a number, if so, judging the number of the character; otherwise, the possible situation of the character is judged in turn, when the situation can not be judged, the character is determined as an error symbol, the error symbol is output, and the scanning is finished.
Each time a word is successfully recognized, the word may be stored in a stream of words (functional token [ ]), and the next word may be recognized after the word's type code is determined.
The specific steps of identification may be: the type code (function type syn) of the word is judged, and different reactions are made for different word types.
Among other things, a Parser (Parser) may perform grammar validation and construct data structures (e.g., construct data structures such as parse trees, abstract syntax trees, etc.) that are composed of the input word stream. The parser may take as its input a stream of words generated by the lexical parser.
Wherein, the Abstract Syntax Tree (AST) is an Abstract representation of the Syntax structure of the application code to be debugged. The AST may represent the syntactic structure of the programming language in the form of a tree, where each node on the tree represents a structure in the application code to be debugged.
The bytecode generator can traverse the abstract syntax tree, and values obtained after traversal can be stored in the bytecode.
(3) And executing the conversion operation corresponding to the byte codes by adopting an execution component to obtain a converted target text object.
In executing the event handler code, the bytecode needs to be compiled into machine code that can be executed by a computer.
For example, in some embodiments, the execution component includes a class loader and an executor, and the specific steps of executing the transformation operation corresponding to the bytecode by using the execution component are as follows:
a. loading the byte codes into corresponding memories by adopting a class loader;
b. after loading is finished, reading a target byte code from a memory by adopting an actuator;
c. the target bytecode is translated into machine code and the machine code is executed.
The class loader is a class used for loading class files, and can load byte codes into a memory.
In some embodiments, in order to quickly start and execute and save compiling time, the byte codes can be interpreted and executed item by item every time one byte code is generated.
In some embodiments, to ensure overall execution speed, the debug component may execute all bytecodes generated at once.
In some embodiments, in order to quickly start, execute and guarantee the overall execution speed, the bytecode in which the execution is interpreted multiple times can be identified as Hot Spot Code (Hot Spot Code), and in order to improve the execution efficiency of the Hot Spot Code, the Code can be compiled into machine Code related to a local platform at runtime, and optimization of each layer is performed.
3. And acquiring the transformed text object from the host software through the transformation interface.
4. When the transformation sub-event which is not pulled exists, the return execution step pulls the transformation sub-event into the host software through the transformation interface.
And (3) executing the steps 1 to 4 once, performing one-time conversion on the target text object, and if the target text object needs to be converted for multiple times to obtain the converted target text object, repeating the steps 1 to 4 once to call the host software to respectively execute conversion operations corresponding to the conversion sub-events to obtain the converted target text object.
In some embodiments, the transformed target text object is obtained by encapsulation, so that after obtaining the transformed target text object, the following steps may be further performed:
pulling the transformed target text object into a packaging engine;
packaging the transformed present object by adopting a packaging engine to obtain a transformed file containing the transformed present object;
and acquiring a transformed file containing the transformed text object from the packaging engine.
The encapsulation engine may encapsulate the target text object as an application resource that may be used directly.
It should be noted that the encapsulation engine may be the same as the parsing engine, or may be two different engines; the encapsulation engine may be a different engine from the parsing engine, integrated in the same software with the parsing engine, integrated in a different software with the parsing engine, respectively, and so on.
The text conversion scheme provided by the embodiment of the application can be applied to various text conversion scenes, for example, taking a text file in a PSD format in a local memory as a file to be converted, a text conversion device can acquire a current conversion dictionary in an EXCEL format sent by a technician through a network, and judges dictionary update information with the historically acquired EXCEL file.
Then, analyzing the content of the file to be converted to obtain a text object in the file to be converted, and determining a target text object and a conversion event corresponding to the target text object in the text object based on the dictionary updating information; and calling host software to execute the transformation operation corresponding to the transformation event to obtain the transformed target text object.
And finally, calling a packaging engine to package the transformed text object to obtain a transformed file containing the transformed text object.
By adopting the scheme provided by the embodiment of the application, the obtained converted file can be directly used as the game resource of the game engine, namely, the converted file is stored in the local memory of the terminal, when the terminal runs a game, the converted text object can be directly seen on a game picture, so that the complex steps of leading the converted target text object into the game engine to generate the game resource are reduced, and the efficiency of text conversion is further improved.
As can be seen from the above, in the embodiment of the present application, a current transformation dictionary and a file to be transformed are obtained; determining dictionary update information of the current transformation dictionary relative to the historical transformation dictionary; analyzing the content of the file to be converted to obtain a text object in the file to be converted; determining a target text object and a transformation event corresponding to the target text object in the text object based on the dictionary updating information; and calling host software to execute the transformation operation corresponding to the transformation event to obtain the transformed target text object. The file to be transformed can be obtained and analyzed, and the text object in the file to be transformed is automatically transformed according to the dictionary updating information. Therefore, the scheme can improve the efficiency of text conversion.
The method described in the above embodiments is further detailed below.
In this embodiment, a method according to an embodiment of the present invention will be described in detail by taking as an example that a file to be transformed in a PSD format carrying UI information of a game is text-transformed in a Continuous Integration (CI) manner, and a transformed file that can be used as a game resource is generated.
Fig. 2a is a schematic view of a continuous integration scenario provided in this embodiment, and as shown in fig. 2a, a conversion dictionary may be frequently collected from a plurality of terminals through a network in a continuous integration manner, a file to be converted is converted into a converted file in a server according to the conversion dictionary, and then the terminal may obtain a feedback result, so that text conversion is efficiently and correctly performed, a situation that a plurality of development members independently convert the file to be converted into an incorrect converted file according to the conversion dictionary when working together is avoided, and working efficiency is improved.
The specific process is as follows:
1. and (4) preprocessing data.
Firstly, a game text source file can be obtained, and the game text source file is preprocessed to generate a file to be transformed.
The game text source file can be obtained by various methods, for example, the game text source file can be read from a local memory, and can be obtained by a game developer through a network.
In this embodiment, the game text source file in the local memory is a text file in PSD format, and the text file in PSD format may carry game text UI information.
The game UI (User Interface) refers to an Interface for man-machine interaction, beautifying a game Interface, and providing game information in a game application, for example, the game UI may include text messages, buttons, text boxes, and the like on the game Interface.
In this embodiment, the game text source file in PSD format carrying the game text UI information may be sorted and provided by a developer, and stored in a local memory.
The game text source file is preprocessed, and the mode of generating the file to be transformed can be that a developer carries out content inspection on the game text source file, specifies the name of the game text source file, and the like.
2. And acquiring a file to be transformed and a current transformation dictionary.
In this embodiment, after the file to be transformed is read from the local memory, the current transformation dictionary also needs to be obtained, and the current transformation dictionary is stored in the local memory.
Fig. 2b is a schematic format diagram of the transformation dictionary provided in this embodiment, and as shown in fig. 2a, the transformation dictionary may include a name of a file to be transformed, a name of a layer where a text object in the file to be transformed is located, text contents of the text object, text contents after being translated into english, a font of the text object, and the like.
In this embodiment, the text transformation apparatus may obtain the current transformation dictionary uploaded by the user through Jenkins (a persistent integration tool).
Jenkins is an open-source software project, is a continuous integration tool developed based on Java, is used for monitoring continuous and repeated work, aims to provide an open and easy-to-use software platform, and enables continuous integration of software to be possible.
Jenkins can deploy a text transformation system to each terminal and server for operation, fig. 2c provides a schematic diagram of a system structure of Jenkins, referring to fig. 2c, the whole system needs one server as a Master device (Master) and a plurality of terminals as Slave devices (Slave), and the Master device and the Slave devices can communicate through a Network Protocol, for example, through a JNLP (Java Network sounding Protocol) Protocol.
The JNLP is a protocol provided by java and capable of directly executing a java application program through a browser, and enables a user to directly open a java application program through a Uniform Resource Locator (url) on a webpage.
Firstly, jenkins need to be installed on the master device in advance, the node information of the slave device can be checked on the installed Jenkins, and when the slave device is not deployed, the node information of the slave device can be displayed to be offline.
A java environment and a microsoft.
The master device can detect regularly or pull the information uploaded by the slave device through a hook (hook) function, so that the master device can acquire the transformation dictionary as long as the slave device uploads the transformation dictionary to the master device in an uploading tool provided by Jenkins.
In some embodiments, to improve text conversion efficiency and reduce the computational resource consumption of the master device, the master device may assign all or part of steps three, four, five, six to a particular slave device, such that the particular slave device performs steps three, four, five, six.
For example, in this embodiment, steps three, four, five, and six may be performed on the master device.
3. Dictionary update information for the current transformed dictionary relative to the historical transformed dictionary is determined.
Each time the host device receives the EXCEL file of the slave device, the EXCEL file can be used as a current transformation dictionary, and the recently received EXCEL file can be used as a history transformation dictionary.
And comparing the content information corresponding to each text object in the current transformation dictionary and the historical transformation dictionary, and taking the text object and the content information corresponding to the text object as dictionary updating information when the content information corresponding to the text object is changed.
4. And performing content analysis on the file to be converted to obtain a text object in the file to be converted, and determining a target text object and a conversion event corresponding to the target text object in the text object based on the dictionary update information.
Firstly, a main device calls a CEP (client side platform) and then calls an ExtendScript (a script engine built in Photoshop) through the CEP, so that a file to be transformed in a PSD (phase-sensitive Detector) format is led into the Photoshop, the content of the file to be transformed is analyzed by adopting the Photoshop file to be transformed, a text object in the file to be transformed is obtained, and text object information is determined.
The text object information may include names of layers, channels, paths, and the like where the text object is located, and information of text content, character fonts, and the like of the text object.
The ExtendScript is a plug-in that encapsulates various operations of PhotoShop into a Document Object Model (DOM) to perform corresponding operations.
Fig. 2d is a schematic diagram of a call relationship between Photoshop and CEP provided in the embodiment of the present application, and as shown in fig. 2d, photoshop is loaded into an application of CEP as a host program, and various built-in functions of Photoshop, such as creating an image layer, setting a background color, and the like, can be called by an extensdscript script engine. Both CEP and ExtendScript may use JavaScript (an transliterated scripting language), but CEP and ExtendScript run in two independent Java Virtual Machines (JVMs), respectively. One CEP may be run by one host program, or may be run by a plurality of host programs at the same time.
JavaScript code in ExtendScript can be parsed in the JVM of the host program, which may be referred to herein as EVM; while the JavaScript code in CEP may be in the JVM of CEP, which may be referred to herein as CVM.
The CVM runs as JavaScript codes in hypertext Markup Language (HTML), and because the CVM and the EVM are independent from each other, a method for parsing in the EVM needs to be executed using a csinterface.
According to the name of the layer where each text object is located in the analysis result, the target text object to be subjected to text conversion and the conversion event corresponding to the target text object can be searched in the dictionary updating information.
5. And calling the host program to execute the transformation operation corresponding to the transformation event to obtain the transformed target text object.
And in the fourth step, a file analysis function of the Photoshop is called by calling the CEP, and a text transformation function of the Photoshop can be called by calling the CEP to execute transformation operation corresponding to the transformation event so as to obtain a transformed target text object.
The CEP sends a self-defined Event through an Event (Event) mechanism, and the Event can also be sent in ExtendScript, so that information and data can be transferred between the ExtendScript and the JavaScript of the CEP by transferring the Event.
The CEP events can be divided into CEP events and ExtendScript events, the CEP events can comprise host program events and custom events, the host program events refer to events with Photoshop types (types) such as Photoshop starting and document opening, and the custom events refer to CEP events created and sent by a user; the extensidscript event is also an event generated by the host activity, but unlike the host program event, the event cannot be identified and captured from a certain type (type), but the event to be monitored needs to be registered, and the extensidscript event is centrally monitored by monitoring the event, and what kind of event is received is judged by the event identification (event ID) of the extensidscript event, which is actually delivered through the CEP event.
In this embodiment, after the text transformation function of PhotoShop is invoked, the specific steps of PhotoShop executing the transformation operation corresponding to the transformation event may refer to a Java operation flow diagram provided in fig. 2e, as follows:
(1) Compiling the program code corresponding to the conversion event into byte codes by adopting a Java compiler;
(2) Verifying and loading the byte codes by adopting a class loader;
(3) The bytecode is executed using a Java Virtual Machine (JVM).
The Java compiler comprises a lexical analyzer, a syntax analyzer and a byte code generator, and the specific steps of compiling the mini game program code into byte codes by adopting the Java compiler are as follows:
a. performing lexical analysis on the code characters of the debugging application by adopting a lexical analyzer to obtain a word stream;
b. carrying out syntax analysis on the word stream by adopting a syntax analyzer to obtain a corresponding abstract syntax tree;
c. and traversing the abstract syntax tree by adopting a byte code generator to obtain byte codes.
The byte code that is finally generated consists of the following parts:
(1) structural information: the method comprises the following steps of (1) including byte code file format version number and information of the number and the size of each part;
(2) metadata: the information corresponding to the statement and the constant in the mini-game code comprises information such as a class, an inherited super class, statement information of an implemented interface, domain and method statement information, a constant pool and the like;
(3) and (4) method information: the information corresponding to the statement and expression in the mini-game code comprises information such as byte codes, an exception handler table, the sizes of an evaluation stack and a local variable area, the type record of the evaluation stack, debugging symbols and the like.
The schematic diagram of the mechanism for verifying and loading the bytecode by using the class loader may refer to fig. 2f, and the hierarchical relationship and the loading order of the class loader are shown in the figure.
The boot class loader (BootstrapClassLoader) is created when the JVM runs and is responsible for loading a class file of jre \ lib stored in a software development kit installation directory of Java language or a class library which is specified by an XbotPasath parameter and can be recognized by a virtual machine.
The Extension class loader (Extension ClassLoader) is responsible for loading the class of \ jre \ lib \ ext in a software development kit installation directory of Java language, or all class libraries in a path specified by a Java.
The application class loader (AppClassLoader) is responsible for loading a class specified by a user class path (Classpath), a developer can directly use the class loader, and if the application does not define a class loader of the developer, the class loader is a default class loader.
The JVM self-contained class loader loads a standard java class file from a local file system, and a User-defined class loader (User classLoader) can automatically verify a digital signature before executing an untrusted code, dynamically create a customized built class meeting the specific needs of a User, and obtain the java class from a specific place (in a database and a network).
In the process of verifying and loading the byte codes by adopting the class loader, whether the class is loaded or not is verified firstly, the verification sequence is from bottom to top, the verification is performed layer by layer from the user-defined class loader to the starting class loader, and the class is considered to be loaded as long as a certain class loader is loaded, so that the class is loaded once. While the order of loading is from top to bottom, i.e. the upper layer tries to load such layer by layer.
Wherein the JVM is a stack-based virtual machine. The JVM allocates a stack for each newly created thread, i.e., for a Java program, its execution is accomplished by operating on the stack. The stack saves the state of the thread in frames. The JVM may perform push and pop operations on the stack in frames.
For example, fig. 2g provides a schematic diagram of a memory structure of a JVM, and as shown in fig. 2g, the memory structure of the JVM may include a method area, a Java heap, a Java stack, a local method stack, an instruction counter, and other hidden registers.
Wherein, the Java heap is created when the virtual machine is started, and can be shared by all threads of the process. The Java heap is used to host object instances, where the object instances can allocate memory.
The method area is used for storing data such as class information, constants, static variables and codes compiled by a just-in-time compiler and loaded by the Java virtual machine.
The local method stack can serve Native methods used by the virtual machine.
When the JVM is adopted to execute the bytecode, the bytecode can be interpreted and executed by an interpreter or selectively converted into machine code execution by an instant code generator, and the specific steps are as follows:
the JVM thread may generate a Program Counter (PC) and a Stack (Stack) after creation. The program counter stores the offset of a next instruction to be executed in the method, stack frames are stored in a stack, and each stack frame corresponds to each call of each method; and the stack frame can be provided with a local variable area and an operand stack, wherein the local variable area is used for storing local variables and parameters in the method, and the operand stack is used for storing intermediate results generated in the execution process of the method.
After passing through the JVM, the bytecode may be executed and the transformed target text object may be obtained by pulling the transformed target text object through the transformation interface in some embodiments.
6. And calling a packaging engine to package the transformed text object to obtain a transformed file containing the transformed text object.
In some embodiments, the transformed text object may be packaged as a packaging engine with the game engine resulting in a transformed file containing the transformed text object.
For example, in this embodiment, unity (a game engine) may be used as a wrapper engine to wrap the transformed text object, so as to obtain a transformed file containing the transformed text object.
Calling a packaging engine to package the transformed text object to obtain a transformed file containing the transformed text object may include the following specific steps:
a. pulling the transformed target text object into a packaging engine;
b. packaging the transformed present object by adopting a packaging engine to obtain a transformed file containing the transformed present object;
c. and acquiring a transformed file containing the transformed text object from the packaging engine.
The specific calling method may refer to step four and step five, which are not described herein.
In summary, the embodiment provides a text transformation method based on persistent integration, and the scene schematic diagram based on the text transformation method based on persistent integration may refer to fig. 2h, as shown in fig. 2h, a technician may access the Jenkins server through a browser of a local operating system of a slave device to obtain Jenkins service.
The Jenkins server can serve as a main device to deliver text conversion work to the text conversion server, the text conversion server can regularly acquire a conversion dictionary used for translating text contents in a file to be converted, call built-in functions of Photoshop by calling CEP to obtain a converted file, the Jenkins server can deliver the converted file to all slave devices, and the slave devices can enable the converted file to cover an original text file.
When the slave device runs the game, the character content on the game UI interface can be visually seen to be converted into translated character content.
As can be seen from the above, in the embodiment of the present application, a file to be transformed and a current transformation dictionary are obtained; determining dictionary update information of the current transformation dictionary relative to the historical transformation dictionary; analyzing the content of the file to be converted to obtain a text object in the file to be converted; determining a target text object and a transformation event corresponding to the target text object in the text object based on the dictionary updating information; and calling the host program to execute the transformation operation corresponding to the transformation event to obtain the transformed target text object. According to the method and the device, the file to be transformed can be obtained and analyzed in a continuous integration mode, and the text object in the file to be transformed is automatically transformed according to the dictionary updating information. Therefore, the scheme can improve the efficiency of text conversion and reduce the error rate of text conversion.
In order to better implement the method, embodiments of the present application further provide a text conversion apparatus, which may be specifically integrated in an electronic device, where the electronic device may be a terminal, a network server, a personal computer, or the like. For example, in the present embodiment, a text conversion device is integrated in a server as an example, and the method according to the present embodiment is described in detail.
For example, as shown in fig. 3, the text transformation apparatus may include an acquisition unit 301, an update unit 302, a parsing unit 303, an event unit 304, and a transformation unit 305 as follows:
the acquisition unit 301:
an obtaining unit 301, configured to obtain a current transformation dictionary and a file to be transformed.
In some embodiments, the obtaining unit 301 may specifically be configured to:
acquiring a file to be transformed through wireless connection;
identifying text information in a file to be converted, wherein the text information comprises text content, text font information and text format information;
performing language translation on the text content to obtain translated text content;
and generating a conversion dictionary according to the translated text content, the text font information and the text format information.
(II) update unit 302:
an updating unit 302, configured to determine dictionary update information of the current transformation dictionary relative to the historical transformation dictionary.
(iii) analysis section 303:
the parsing unit 303 is configured to perform content parsing on the file to be transformed to obtain a text object in the file to be transformed.
In some embodiments, the parsing unit 303 may specifically be configured to:
pulling a file to be transformed into an analysis engine;
analyzing the file to be transformed by adopting an engine to obtain at least one text object in the file to be transformed;
the text object is obtained from a parsing engine.
(IV) event Unit 304:
and the event unit 304 is used for determining a target text object and a transformation event corresponding to the target text object in the text object based on the dictionary updating information.
(v) the transform unit 305:
and the transformation unit 305 is configured to invoke host software to execute a transformation operation corresponding to the transformation event, so as to obtain a transformed target text object.
In some embodiments, the transform event comprises at least one transform sub-event, and the transform unit 305 may comprise a pull sub-unit, a transform sub-unit, a fetch sub-unit, and a return sub-unit:
and the pulling subunit is used for pulling the transformation sub-event into the host software through the transformation interface.
And the transformation subunit is used for executing the transformation operation corresponding to the transformation subevent by adopting the host software to obtain the transformed target text object.
And the acquisition subunit is used for acquiring the transformed text object from the host software through the transformation interface.
And the return sub-unit is used for pulling the transformation sub-event into the host software through the transformation interface in the return execution step when the transformation sub-event which is not pulled exists.
In some embodiments, the host software includes a translation component, an execution component, and the transformation subunit may include a validation submodule, a translation submodule, and an execution submodule:
the confirming submodule is used for confirming the event processing program code corresponding to the transformation subevent in the host software;
the translation submodule is used for translating the event handler code into byte codes in the translation assembly;
and the execution sub-module is used for executing the conversion operation corresponding to the byte code by adopting the execution component to obtain the converted target text object.
In some embodiments, the translation component includes a lexical analyzer, a syntax analyzer, and a bytecode generator, and the translation sub-module may be specifically configured to:
performing lexical analysis on the event handler code by adopting a lexical analyzer to obtain a word stream;
carrying out syntax analysis on the word stream by adopting a syntax analyzer to obtain a corresponding abstract syntax tree;
and traversing the abstract syntax tree by adopting a byte code generator to obtain byte codes.
In some embodiments, the execution component includes a class loader and an executor, and the execution submodule may specifically be configured to:
loading the byte codes into corresponding memories by adopting a class loader;
after loading is finished, reading a target byte code from a memory by adopting an actuator;
the target bytecode is translated into machine code and the machine code is executed.
In some embodiments, the transformation unit 305 may be further specifically configured to:
pulling the transformed target text object into a packaging engine;
packaging the transformed present object by adopting a packaging engine to obtain a file to be transformed, wherein the file to be transformed comprises the transformed present object;
and acquiring a transformed file containing the transformed text object from the packaging engine.
In a specific implementation, the above units may be implemented as independent entities, or may be combined arbitrarily to be implemented as the same or several entities, and the specific implementation of the above units may refer to the foregoing method embodiments, which are not described herein again.
As can be seen from the above, the text transformation apparatus of the present embodiment may obtain the current transformation dictionary and the file to be transformed by the obtaining unit; determining, by an update unit, dictionary update information of a current transformed dictionary relative to a historical transformed dictionary; the analysis unit analyzes the content of the file to be converted to obtain a text object in the file to be converted; determining a target text object and a transformation event corresponding to the target text object in the text object by the event unit based on the dictionary updating information; and calling host software by the transformation unit to execute transformation operation corresponding to the transformation event to obtain a transformed target text object. The file to be transformed can be obtained and analyzed, and the text object in the file to be transformed is automatically transformed according to the dictionary updating information. Therefore, the scheme can improve the efficiency of text conversion.
The embodiment of the application also provides a server, and the server can be an electronic device such as a network server, a mobile terminal, a data storage device, a data collection device and the like. As shown in fig. 4, it shows a schematic structural diagram of a server according to an embodiment of the present application, specifically:
the server may include components such as a processor 401 of one or more processing cores, memory 402 of one or more computer-readable storage media, a power supply 403, an input unit 404, and a communication unit 405. Those skilled in the art will appreciate that the server architecture shown in FIG. 4 is not meant to be limiting, and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components. Wherein:
the processor 401 is a control center of the server, connects various parts of the entire server using various interfaces and lines, performs various functions of the server and processes data by operating or executing software programs and/or modules stored in the memory 402 and calling data stored in the memory 402, thereby performing overall monitoring of the server. In some embodiments, processor 401 may include one or more processing cores; in some embodiments, processor 401 may integrate an application processor, which primarily handles operating systems, user interfaces, applications, etc., and a modem processor, which primarily handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 401.
The memory 402 may be used to store software programs and modules, and the processor 401 executes various functional applications and data processing by operating the software programs and modules stored in the memory 402. The memory 402 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data created according to the use of the server, and the like. Further, the memory 402 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 access to the memory 402.
The server also includes a power supply 403 for supplying power to the various components, and in some embodiments, the power supply 403 may be logically connected to the processor 401 via a power management system, so that the functions of managing charging, discharging, and power consumption are implemented via the power management system. The power supply 403 may also include any component of one or more dc or ac power sources, recharging systems, power failure detection circuitry, power converters or inverters, power status indicators, and the like.
The server may also include an input unit 404, the input unit 404 being operable to receive input numeric or character information and to generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
The server may also include a communication unit 405 through which the server may communicate data, and in some embodiments, the server may also perform short-range wireless transmissions through the communication unit 405 to provide wireless broadband internet access to the user. For example, the communication unit 405 may be used to assist a user in sending and receiving e-mails, browsing web pages, accessing streaming media, and the like.
Although not shown, the server may further include a display unit and the like, which will not be described in detail herein. Specifically, in this embodiment, the processor 401 in the server loads the executable file corresponding to the process of one or more application programs into the memory 402 according to the following instructions, and the processor 401 runs the application program stored in the memory 402, thereby implementing various functions as follows:
acquiring a current transformation dictionary and a file to be transformed;
determining dictionary update information of the current transformation dictionary relative to the historical transformation dictionary;
analyzing the content of the file to be converted to obtain a text object in the file to be converted;
determining a target text object and a transformation event corresponding to the target text object in the text object based on the dictionary updating information;
and calling host software to execute the transformation operation corresponding to the transformation event to obtain the transformed target text object. The above operations can be implemented in the foregoing embodiments, and are not described in detail herein.
As can be seen from the above, in the embodiment of the present application, the current transformation dictionary and the file to be transformed may be obtained; determining dictionary updating information of the current transformation dictionary relative to the historical transformation dictionary; analyzing the content of the file to be converted to obtain a text object in the file to be converted; determining a target text object and a transformation event corresponding to the target text object in the text object based on the dictionary updating information; and calling host software to execute the transformation operation corresponding to the transformation event to obtain the transformed target text object. Therefore, the file to be transformed can be obtained and analyzed, and the text object in the file to be transformed can be automatically transformed according to the dictionary updating information. Therefore, the scheme can improve the efficiency of text conversion.
It will be understood by those skilled in the art that all or part of the steps of the methods of the above embodiments may be performed by instructions, or by instructions controlling associated hardware, which may be stored in a computer-readable storage medium and loaded and executed by a processor.
To this end, embodiments of the present application provide a storage medium, in which a plurality of instructions are stored, and the instructions can be loaded by a processor to execute the steps in any one of the text transformation methods provided in the embodiments of the present application. For example, the instructions may perform the steps of:
acquiring a current transformation dictionary and a file to be transformed;
determining dictionary update information of the current transformation dictionary relative to the historical transformation dictionary;
analyzing the content of the file to be converted to obtain a text object in the file to be converted;
determining a target text object and a transformation event corresponding to the target text object in the text object based on the dictionary updating information;
and calling host software to execute the transformation operation corresponding to the transformation event to obtain a transformed target text object. Wherein the storage medium may include: read Only Memory (ROM), random Access Memory (RAM), magnetic or optical disks, and the like.
Since the instructions stored in the storage medium can execute the steps in any text conversion method provided in the embodiments of the present application, beneficial effects that can be achieved by any text conversion method provided in the embodiments of the present application can be achieved, which are detailed in the foregoing embodiments and will not be described herein again.
The text transformation method, the text transformation device, the text transformation server and the storage medium provided by the embodiments of the present application are described in detail above, and a specific example is applied in the text to explain the principles and the embodiments of the present application, and the description of the above embodiments is only used to help understand the method and the core ideas of the present application; meanwhile, for those skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (10)

1. A method of text conversion, comprising:
acquiring a current transformation dictionary and a file to be transformed;
determining dictionary update information of the current transformation dictionary relative to a historical transformation dictionary;
analyzing the content of the file to be converted to obtain a text object in the file to be converted;
determining a target text object and a transformation event corresponding to the target text object in the text object based on the dictionary updating information, wherein the transformation event comprises at least one transformation sub-event;
calling host software to execute the transformation operation corresponding to the transformation event to obtain a transformed target text object;
the calling host software executes the transformation operation corresponding to the transformation event to obtain a transformed target text object, and the method comprises the following steps:
pulling the transformation sub-event into host software through a transformation interface;
and executing the transformation operation corresponding to the transformation sub-event by adopting host software to obtain a transformed target text object.
2. The text transformation method of claim 1, wherein invoking host software to perform a transformation operation corresponding to the transformation event to obtain a transformed target text object, further comprises:
acquiring the transformed target text object from host software through a transformation interface;
when the transformation sub-event which is not pulled exists, the return execution step pulls the transformation sub-event into the host software through the transformation interface.
3. The text transformation method of claim 2, wherein the host software comprises a translation component and an execution component, and the host software is adopted to execute the transformation operation corresponding to the transformation sub-event to obtain the transformed target text object, and the method comprises the following steps:
confirming event handler code in host software corresponding to the transformation subevents;
translating the event handler code into bytecode in the translation component;
and executing the conversion operation corresponding to the byte code by adopting an execution component to obtain a converted target text object.
4. The method of text conversion according to claim 3, wherein the translation component includes a lexical analyzer, a syntax analyzer, and a bytecode generator, translating the event handler code into bytecode in the translation component, including:
performing lexical analysis on the event processing program codes by adopting a lexical analyzer to obtain a word stream;
carrying out syntax analysis on the word stream by adopting a syntax analyzer to obtain a corresponding abstract syntax tree;
and traversing the abstract syntax tree by adopting a byte code generator to obtain byte codes.
5. The text transformation method of claim 3, wherein the execution component comprises a class loader and an executor, and the executing component is used for executing the transformation operation corresponding to the bytecode and comprises the following steps:
loading the byte codes into corresponding memories by adopting a class loader;
after loading is finished, reading a target byte code from a memory by adopting an actuator;
and translating the target bytecode into machine code, and executing the machine code.
6. The method of text conversion according to claim 1, after obtaining the converted target text object, further comprising:
pulling the transformed target text object into a packaging engine;
adopting the packaging engine to package the converted target text object to obtain a file to be converted containing the converted target text object;
and acquiring a converted file containing the converted target text object from the packaging engine.
7. The method of claim 1, wherein the parsing the content of the file to be transformed to obtain the text object in the file to be transformed comprises:
pulling the file to be transformed into an analysis engine;
analyzing the file to be converted by adopting the engine to obtain at least one text object in the file to be converted;
and acquiring the text object from the analysis engine.
8. The method for converting text according to claim 1, wherein obtaining the file to be converted and the current conversion dictionary comprises:
acquiring a file to be transformed through wireless connection;
identifying text information in the file to be converted, wherein the text information comprises text content, text font information and text format information;
performing language translation on the text content to obtain translated text content;
and generating a conversion dictionary according to the translated text content, the text font information and the text format information.
9. A text conversion apparatus, comprising:
the obtaining unit is used for obtaining a current transformation dictionary and a file to be transformed;
the updating unit is used for determining dictionary updating information of the current transformation dictionary relative to the historical transformation dictionary;
the analysis unit is used for analyzing the content of the file to be converted to obtain a text object in the file to be converted;
the event unit is used for determining a target text object and a transformation event corresponding to the target text object in the text object based on the dictionary updating information, wherein the transformation event comprises at least one transformation sub-event;
the transformation unit is used for calling host software to execute transformation operation corresponding to the transformation event to obtain a transformed target text object;
the calling host software executes the transformation operation corresponding to the transformation event to obtain a transformed target text object, and the method comprises the following steps:
pulling the transformation sub-event into host software through a transformation interface;
and executing the transformation operation corresponding to the transformation sub-event by adopting host software to obtain a transformed target text object.
10. A server comprising a processor and a memory, said memory storing a plurality of instructions, said processor loading instructions from said memory to perform the steps in the text transformation method according to any one of claims 1 to 8.
CN201910351555.3A 2019-04-28 2019-04-28 Text conversion method, device and server Active CN110110299B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910351555.3A CN110110299B (en) 2019-04-28 2019-04-28 Text conversion method, device and server

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910351555.3A CN110110299B (en) 2019-04-28 2019-04-28 Text conversion method, device and server

Publications (2)

Publication Number Publication Date
CN110110299A CN110110299A (en) 2019-08-09
CN110110299B true CN110110299B (en) 2023-04-07

Family

ID=67487255

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910351555.3A Active CN110110299B (en) 2019-04-28 2019-04-28 Text conversion method, device and server

Country Status (1)

Country Link
CN (1) CN110110299B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112115063B (en) * 2020-09-29 2022-04-19 腾讯科技(深圳)有限公司 Software localization test method, device, terminal and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1763717A (en) * 2005-11-24 2006-04-26 北京中星微电子有限公司 System and method for calling host software functions by using script and its compiler
JP2010032289A (en) * 2008-07-28 2010-02-12 Sharp Corp Navigation device, navigation method, and navigation program
KR20100076767A (en) * 2008-12-26 2010-07-06 (주)이니셜커뮤니케이션즈 Apparatus and method for text and image contents transformation and advertisement insertion and computer readable medium storing program thereof
CN105808513A (en) * 2015-01-19 2016-07-27 富士通株式会社 Converting device and converting method
CN108304442A (en) * 2017-11-20 2018-07-20 腾讯科技(深圳)有限公司 A kind of text message processing method, device and storage medium

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6850930B2 (en) * 2001-03-13 2005-02-01 Honeywell International Inc. Method for transforming words to unique numerical representation
US20020156791A1 (en) * 2001-04-19 2002-10-24 Diaz Nesamoney Taxonomy of business metrics
CN1452063A (en) * 2002-04-18 2003-10-29 英业达股份有限公司 Method for transformation of character style of PhotoShop graphic letter
TW201203100A (en) * 2010-07-09 2012-01-16 Arphic Technology Co Ltd Method and network system for browsing web documents in different character set systems
CN106598937B (en) * 2015-10-16 2019-10-18 阿里巴巴集团控股有限公司 Language Identification, device and electronic equipment for text

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1763717A (en) * 2005-11-24 2006-04-26 北京中星微电子有限公司 System and method for calling host software functions by using script and its compiler
JP2010032289A (en) * 2008-07-28 2010-02-12 Sharp Corp Navigation device, navigation method, and navigation program
KR20100076767A (en) * 2008-12-26 2010-07-06 (주)이니셜커뮤니케이션즈 Apparatus and method for text and image contents transformation and advertisement insertion and computer readable medium storing program thereof
CN105808513A (en) * 2015-01-19 2016-07-27 富士通株式会社 Converting device and converting method
CN108304442A (en) * 2017-11-20 2018-07-20 腾讯科技(深圳)有限公司 A kind of text message processing method, device and storage medium

Also Published As

Publication number Publication date
CN110110299A (en) 2019-08-09

Similar Documents

Publication Publication Date Title
US8327328B2 (en) System and method for creating target byte code
US8850416B1 (en) System and method for creating target byte code
US8032860B2 (en) Methods for type-independent source code editing
US8707263B2 (en) Using a DSL for calling APIS to test software
WO2018082562A1 (en) Method and device for compiling page data and rendering page, and storage medium
US9965259B2 (en) System for translating diverse programming languages
US20080209395A1 (en) Automatic code replacement
US20040230890A1 (en) Information processing system, control method, control program, and recording medium
US10949175B2 (en) Method of carrying out modifications to a software application
CN111913741B (en) Object interception method, device, medium and electronic equipment
CN112379917A (en) Browser compatibility improving method, device, equipment and storage medium
WO2022146933A1 (en) Producing idiomatic software documentation for many programming languages from a common specification
CN113553035A (en) Design and construction method of universal front-end UI component library
EP1452962B1 (en) System and method for defining and using subclasses declaratively within markup
CN110110299B (en) Text conversion method, device and server
García-Pradales et al. An s (CASP) In-Browser Playground based on Ciao Prolog.
CN116243923A (en) Applet processing method and device and electronic equipment
CN115390846A (en) Compiling construction method and device, electronic equipment and storage medium
JP7391983B2 (en) Methods, decompiling devices, recompilation systems and computer program products for generating representations of program logic
CN113760360A (en) File generation method, device, equipment and storage medium
CN114489653A (en) Compiler-based data processing method, compiler-based data processing device and readable storage medium
CN112685049B (en) JAVA byte code compiling method
Schneider et al. Scripting: Higher-level programming for component-based systems
CN117149155A (en) Code verification method, device and equipment of service interface and storage medium
CN117170654A (en) Development method and device of graphical user interface application program and electronic equipment

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
GR01 Patent grant
GR01 Patent grant