CN116225450A - Text conversion method and apparatus, computing device and readable storage medium - Google Patents

Text conversion method and apparatus, computing device and readable storage medium Download PDF

Info

Publication number
CN116225450A
CN116225450A CN202310188890.2A CN202310188890A CN116225450A CN 116225450 A CN116225450 A CN 116225450A CN 202310188890 A CN202310188890 A CN 202310188890A CN 116225450 A CN116225450 A CN 116225450A
Authority
CN
China
Prior art keywords
data
annotation
class
text
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
CN202310188890.2A
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.)
Chezhi Interconnection Beijing Technology Co ltd
Original Assignee
Chezhi Interconnection Beijing Technology 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 Chezhi Interconnection Beijing Technology Co ltd filed Critical Chezhi Interconnection Beijing Technology Co ltd
Priority to CN202310188890.2A priority Critical patent/CN116225450A/en
Publication of CN116225450A publication Critical patent/CN116225450A/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/42Syntactic analysis
    • G06F8/427Parsing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/73Program documentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • G06F9/44526Plug-ins; Add-ons
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45575Starting, stopping, suspending or resuming virtual machine instances
    • 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

Abstract

The invention discloses a text conversion method, which is executed by a container framework application and comprises the following steps: reading the current class, and if the current class contains a field marked with a data conversion annotation, calling a section-oriented application to generate a proxy class of the current class; invoking concrete implementation logic of data conversion annotation by using proxy class for cut-plane application, the concrete implementation logic comprises: acquiring a specific value of a field marked with a data conversion annotation; obtaining code values of the data conversion notes, the code values corresponding to all possible values of the fields; searching data with all keys as possible values in a local or remote database according to the code values, and searching the data with the keys as specific values and texts in the data according to the specific values of the fields from all the data; a new field is added to the current class and the found text is assigned to the new field. According to the technical scheme of the invention, the data conversion logic is stripped from the service codes in the form of annotation, so that the service decoupling is realized.

Description

Text conversion method and apparatus, computing device and readable storage medium
Technical Field
The present invention relates to the field of text conversion technology, and in particular, to a text conversion method and apparatus, a computing device, and a readable storage medium.
Background
In the development process of daily projects, information such as a data dictionary and enumeration is often used, and the data dictionary information and enumeration information are usually required to be converted into corresponding specific text information when displayed at the front end.
Data conversion is an operation often required in the development process, and it is common practice to write different conversion logic codes for different types of data and obtain data sources from different places. Data conversion is typically done by the server or front end. The server side typically needs to add a field to the returned entity object for such text conversion to store the corresponding text information. Manually writing data conversion logic codes by a developer, converting dictionary types, enumeration types or other types of data into corresponding text information and returning the text information to the front end for the front end to display or perform other processing. Different data conversion logic codes are written according to different data types, so that different versions of the data conversion logic codes can appear due to styles and levels of developers, and accordingly result inconsistency is caused, the logic code repeatability is high, and the maintenance cost is high.
If text conversion is performed by the front end, it is generally the case that: firstly, an array is created for storing the value and the corresponding text information, and the corresponding text information is acquired and displayed through the value. The front-end conversion has the disadvantage of higher maintenance cost, and the code needs to be modified if a new value exists, and the unification of the front-end data and the back-end data is not facilitated.
In the implementation process of the two schemes, a field needs to be manually added to the returned entity object for storing text information corresponding to the key, logic for manually implementing text conversion is also needed, the process is complex, and more workload is increased when the converted fields are more. If there are multiple entity objects that require the same type of text conversion, the process of manually adding fields, manually handling the conversion logic, also needs to be repeated. This is undoubtedly a repetitive effort, resulting in inefficiency.
In summary, the existing method has no unified data storage, unified data management and unified data conversion, is inconvenient for unified maintenance and unified management, needs repeated labor and has low working efficiency.
Disclosure of Invention
To this end, the present invention provides a text conversion method and apparatus, computing device and readable storage medium in an effort to solve or at least alleviate at least one of the problems presented above.
According to a first aspect of the present invention, there is provided a text conversion method performed by a container frame application, comprising: reading a current class, and if the current class contains a field marked with a data conversion annotation, calling a proxy class facing to a section application to generate the current class, wherein the data conversion annotation is packaged into a starter conforming to the specification of the container frame application and points to specific implementation logic, and the specific implementation logic is used for converting the field into a text; invoking concrete implementation logic of data conversion annotation by using proxy class for cut-plane application, the concrete implementation logic comprises: acquiring a specific value of a field marked with a data conversion annotation; obtaining code values of the data conversion notes, the code values corresponding to all possible values of the fields; searching data with all keys as possible values in a local or remote database according to the code values, and searching the data with the keys as specific values and texts in the data according to the specific values of the fields from all the data; a new field is added to the current class and the found text is assigned to the new field.
Optionally, the text conversion method of the present invention further includes: scanning an initialization annotation, wherein the initialization annotation is marked to a starting file of a container framework application, is packaged into the starter and points to specific implementation logic for executing initialization; the specific implementation logic for initializing comprises the following steps: initializing interface information of the remote acquired data, and executing one or more of the following initialization according to attribute contents of the initialization annotation: initializing locally stored interface information and initializing remotely stored interface information; loading the class marked with the data loading annotation and/or calling a remote interface marked with the data loading annotation, executing remote data calling, and storing the loaded data in a local or remote storage, so that corresponding text can be searched in the locally or remotely stored data according to the data conversion annotation, wherein the interface of the data loading annotation for marking the class or remotely acquiring the data points to specific implementation logic for executing the data loading and is packaged into the initiator.
Optionally, in the text conversion method of the present invention, the remote storage is a remote dictionary server.
Optionally, the text conversion method of the present invention further includes: the class to which the new field is added and assigned to the new field is output to the front end.
According to a second aspect of the present invention there is provided a text conversion device in a container frame application comprising: the agent class generating module reads the current class, if the current class contains a field marked with a data conversion annotation, invokes the section-oriented application to generate the agent class of the current class, wherein the data conversion annotation is packaged into a starter conforming to the specification of the container frame application and points to specific implementation logic, and the specific implementation logic is used for converting the field into a text; the data conversion module invokes specific implementation logic of the data conversion annotation by using the proxy class for the cut-plane application, wherein the specific implementation logic comprises: acquiring a specific value of a field marked with a data conversion annotation; obtaining code values of the data conversion notes, the code values corresponding to all possible values of the fields; searching data with all keys as possible values in a local or remote database according to the code values, and searching the data with the keys as specific values and texts in the data according to the specific values of the fields from all the data; a new field is added to the current class and the found text is assigned to the new field.
Optionally, the text conversion device of the present invention further includes: the initialization module is used for scanning initialization notes, the initialization notes are marked on a starting file of the container framework application, are packaged into the starter and point to specific implementation logic for executing initialization; the specific implementation logic for initializing comprises the following steps: initializing interface information of the remote acquired data, and executing one or more of the following initialization according to attribute contents of the initialization annotation: initializing locally stored interface information and initializing remotely stored interface information; loading the class marked with the data loading annotation and/or calling an interface marked with the data loading annotation for remotely acquiring data, executing remote data calling, converting the loaded data into a format, and storing the format in a local or remote storage, so that a corresponding text can be searched in the locally or remotely stored data according to the data conversion annotation, wherein the data loading annotation is used for marking the class or remotely acquiring the data, points to specific implementation logic for executing data loading, and is packaged into the initiator.
Optionally, in the text conversion device of the present invention, the remote storage is a remote dictionary server.
Optionally, the text conversion device of the present invention further includes: and the output module is used for outputting the class added with the new field and assigned to the new field to the front end.
According to a third aspect of the present invention there is provided a computing device comprising: at least one processor and a memory storing program instructions; the program instructions, when read and executed by the processor, cause the computing device to perform the text conversion method as described above.
According to a fourth aspect of the present invention, there is provided a readable storage medium storing program instructions that, when read and executed by a computing device, cause the computing device to perform a text conversion method as described above.
According to the technical scheme of the invention, the data conversion logic is subjected to high abstraction and high encapsulation in the form of annotation, so that the data conversion logic is stripped from service codes, and service decoupling is realized, so that a developer does not need to care about the realization of the conversion logic, and the development of the service can be focused.
Drawings
To the accomplishment of the foregoing and related ends, certain illustrative aspects are described herein in connection with the following description and the annexed drawings, which set forth the various ways in which the principles disclosed herein may be practiced, and all aspects and equivalents thereof are intended to fall within the scope of the claimed subject matter. The above, as well as additional objects, features, and advantages of the present disclosure will become more apparent from the following detailed description when read in conjunction with the accompanying drawings. Like reference numerals generally refer to like parts or elements throughout the present disclosure.
Fig. 1 shows a functional architecture diagram according to the technical solution of the invention;
FIG. 2 illustrates a specific initialization process and data loading process according to an embodiment of the present invention;
FIG. 3 illustrates a data conversion process according to an embodiment of the present invention;
fig. 4 illustrates a text conversion effect obtained by a text conversion method according to an embodiment of the present invention;
FIG. 5 shows a schematic flow chart of an example of a text conversion method according to an embodiment of the present invention;
fig. 6 shows a schematic block diagram of an example of a text conversion device according to an embodiment of the present invention;
FIG. 7 shows a schematic block diagram of a computing device according to an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
According to the technical scheme of the invention, a data text conversion mode based on statement is provided. The basic idea is that a developer can realize data conversion by adding an annotation on a field to be converted, so that specific conversion realization is not required to be provided. Therefore, the repeated data conversion implementation is not required to be written by a developer, various errors which occur according to different people are avoided, and the development efficiency is improved. Moreover, the mode of adding the notes realizes the unification of the data conversion logic, a developer does not need to care about how the conversion logic is realized, and the developer is prevented from realizing the same conversion logic under different service scenes, so that the working efficiency is improved.
According to the technical scheme of the invention, unified data management can be realized in an annotation mode, for example, data of types such as data dictionary, enumeration and the like can be automatically loaded and dynamically updated. In addition, data from different sources may be stored in a unified manner in one place (e.g., in a memory or dictionary server), and may be stored in the form of key-value pairs (key-value). The unified data storage is convenient for maintaining data, and the text conversion efficiency is improved.
In one implementation, the implementation of the data text conversion method (including the annotations for data conversion, the annotations for data management described above) may be packaged as an integrated splicer (SpringBoot-initiator) that complies with the container framework application (SpringBoot) development specification. Springboot is a brand new framework provided by Pivotal team, the design purpose of the Springboot is to simplify the initial construction and development process of new Spring application, and the Springboot-starter is an integrated connector and mainly completes two things, namely 1, introducing relevant jar packages required by modules and 2, automatically configuring the required attributes of the respective modules. The product of the technical scheme of the invention is finally a standard springboot-starter, and the springboot project can be used only by introducing starter dependence according to the technical scheme of the invention.
In conclusion, according to the technical scheme of the invention, declarative conversion, unified data storage, unified data management and unified data conversion are realized, and the portability and usability are high.
The functional design in the final packaged starter is described below. The functional modules in the initiator mainly include three notes: data conversion annotation, data loading annotation and initialization annotation. The data conversion annotation can be named as "@ TransText", and if a field marked with the annotation "@ TransText" is encountered, according to the technical scheme of the invention, data text conversion can be performed, and a new field is automatically added for storing the converted text information. The data load annotation may be named "@ TransStore" and marked onto the class or interface. After the application of the container framework is started, data is obtained from the local for the class (such as enumeration class) marked with the annotation @ TransStore ", the remote interface is called for the interface (such as remote interface) marked with the annotation @ TransStore", and the obtained data is stored in a local or remote memory, and the remote memory can be a dictionary server (redis) or the like. The conversion of the data format may also be performed prior to storage, converting e.g. the data dictionary, enumeration information and remote data into a corresponding format, e.g. into hashmap format for local storage and then storage, into a format required by the remote server for the remote server. The initialization annotation may be named "@ TransScanRegistrar", which is marked on the boot file of the springboot. And scanning the annotation of the starting file when the springboot is started, so as to realize configuration information initialization, component scanning and entity injection. Entity injection refers to bean injection, in which parsed component information is encapsulated as beans definition and registered in a spring container.
Fig. 1 shows a functional architecture diagram according to the technical solution of the present invention. As shown in fig. 1, after scanning the annotation "@ TransStore", the data is obtained locally or remotely, formatted, and saved in a local or remote server. When the field marked with the note @ TransText' is read, the previously acquired local or remote data is used for data text conversion, and the converted text is added to the new field.
A specific initialization process and data loading process are described below with reference to fig. 2. Firstly, starting a spring boot application, initializing data, refreshing/loading a context, creating a spring container, and configuring link variables, resources, constructors, listeners and the like to finish the initialization of the container. Then, the Springboot scans the components, scans to the @ TransScanRegistrar annotation, triggers the realization of the data conversion annotation @ TransText and the data loading annotation @ TransStore ". The operations implemented to scan the "@ TransScanRegistrar" annotation specifically include: 1. initializing interface information of remote acquired data (called remote interface information for short), and executing one or more of the following initialization according to attribute content of the initialization annotation: initializing interface information for realizing local storage and interface information for realizing remote storage (redis storage). The attribute content of the initialization annotation comprises the following information: whether the acquired data is stored locally, remotely, or both. If the attribute information is configured to be stored locally, the data is stored only in the local memory. If configured for remote storage, the data is stored only in the remote cache. If configured as "all," the data is stored in both local memory and remote cache. 2. Scanning the annotated class of the @ TransStore @, converting the annotated class into a unified data entity object, and storing the data in a local or Redis cache. 3. Scanning remote interface information marked by the annotation @ TransStore', performing remote call, acquiring remote data, and storing the data in a local or Redis cache. So far, the initialization of the component is completed, and the data loading is completed. The entity factory initialization, initialization entity, and completion entity shown in fig. 2 refer to the series of initialization and data loading processes described above, and then the completed entity is injected into the Spring container.
The implementation of the data conversion is described below with reference to fig. 3. First, a developer marks a field to be converted with a @ TransText' annotation, and a field is set in the annotation to place a parameter, which may be named a code parameter (code parameter) herein, and the parameter may have various forms, such as a table or an enumeration class. The one-to-one correspondence of values to text may be set in advance in the parameter by the developer. The value of the parameter corresponds to the data type of the data source: if the data is obtained from the memory, the code parameter value is the key (key) of the data in the hashmap file, and if the data is obtained from the Redis cache, the code parameter value is the key of the data in the Redis. The text is a specific text corresponding to the code parameter value. The correspondence of values to this text may be, for example: "1" corresponds to "male", "2" corresponds to "female", and "3" corresponds to "unknown". In the code parameter, all possible values of the field are contained. All possible values mean: for example, the field content is "integer sex", the current value is "1", however, it may also be "2", "3", depending on the type of the field content, then all possible values of the field are: 1. 2, 3.Springboot invokes a tangential-oriented application (Spring AOP) by which the CGLIB is used to dynamically proxy the target class (class to which the target field belongs), and if a field annotated with a "@ TransText" annotation is encountered, the AOP automatically generates a proxy (proxy class) for the class to which the field belongs. Spring AOP automatically invokes the concrete realization logic of data conversion through proxy class. The proxy class obtains some attribute values, such as code values or other values, in the annotation, and calls the concrete implementation logic of the data conversion corresponding to the annotation according to the values.
The Spring AOP is a method/function for realizing dynamic proxy in Spring application, CGLIB (Code Generation Library) is a strong, high-performance and high-quality Code generation class library, and Java classes can be expanded and Java interfaces can be realized in the running period.
The specific implementation logic of the data conversion comprises: 1. acquiring a specific value of a field marked with notes, such as '1'; the annotated code value (code value) is obtained and data for which all keys are possible values (data for which all keys are 1, 2, 3) is looked up from the local or redis cache based on the code value (e.g., all possible values 1, 2, 3 corresponding to the field). In local or redis caches, data is stored in key-value pairs, such as 1 (key) for male (value), 2 for female, and 3 for unknown. Then, from all the data, the data whose key is the specific value is found according to the specific value of the field (i.e. "1"), and the value in the data, i.e. the corresponding text (i.e. "male"), is found. 2. And adding a new field to the current class by using a CGLIB dynamic proxy mode, and assigning the text acquired in the last step to the new field. It should be understood that the "1" corresponds to "male", "2" corresponds to "female", and "3" corresponds to "unknown" are taken herein as examples, for convenience of description, and for other cases, there may be different values and correspondence.
Thus, the data conversion is completed, and the generated new object can be output to the front end.
The data text conversion effect is described below with reference to an example shown in fig. 4. In the conventional manner, the data conversion manner is shown in the upper part of fig. 4, and conversion logic needs to be manually added in the class, wherein "///" indicates that the value of the "SexText" field is set, and the value can be directly assigned or obtained through other methods. As shown in the middle of FIG. 4, the data conversion method according to the technical scheme of the present invention is to add notes to the field (integer six) to be converted, where "SexEnum" may be a table or enumeration class, in which the correspondence between the code parameter (code) value and the text is listed, and as mentioned above, the value may be 1, 2 or 3 in an illustrative example. The "//" indicates that the "SexText" field can be automatically generated by annotating, retrieving the corresponding text from memory or remote cache based on the value of "integer sex". The two modes realize the same effect by performing data conversion and feeding back to the front end, as shown in the lower part of fig. 4.
According to an embodiment of the present invention, there is provided a text conversion method performed by a container frame application (Springboot). Fig. 5 shows a schematic flow chart of an example of the method. As shown in fig. 5, the method includes: step 510, reading the current class, and if the current class contains a field marked with a data conversion annotation (@ TransText), calling a section-oriented application (Spring AOP) to generate a proxy class of the current class, wherein the data conversion annotation is packaged into a starter conforming to the specification of a container framework application (Spring boot), and points to specific implementation logic, and the specific implementation logic is used for converting the field into text; step 520, invoking concrete implementation logic of data conversion annotation (@ TransText) by using proxy class for tangential plane application (Spring AOP), the concrete implementation logic comprising: acquiring a specific value of a field marked with a data conversion annotation (@ TransText); obtaining code values of the data conversion notes, the code values corresponding to all possible values of the fields; searching data with all keys as possible values in a local or remote database according to the code values, and searching the data with the keys as specific values and texts in the data according to the specific values of the fields from all the data; a new field is added to the current class and the found text is assigned to the new field.
The method shown in fig. 5 may further comprise scanning an initialization annotation (@ TransScanRegistrar), which is annotated to the boot file of the container framework application (Springboot), also encapsulated in the initiator as described above. The annotation points to implementation-specific logic for performing the initialization, the implementation-specific logic for initializing comprising: initializing interface information of the remote acquired data, and executing one or more of the following initialization according to attribute contents of the initialization annotation: initializing locally stored interface information and initializing remotely stored interface information; loading the class marked with the data loading annotation and/or calling an interface marked with the data loading annotation for remotely acquiring data, executing remote data calling, converting the loaded data into a format, and storing the format in a local or remote storage, so that a corresponding text can be searched in the locally or remotely stored data according to the data conversion annotation, wherein the data loading annotation is used for marking the class or remotely acquiring the data, points to specific implementation logic for executing data loading, and is packaged into the initiator.
According to an embodiment of the present invention, there is provided a text conversion device located in a container frame application (Springboot). Fig. 6 shows a schematic block diagram of an example of the apparatus. As shown in fig. 6, the apparatus includes: the proxy class generating module 610 is configured to read a current class, and call a tangent plane application (Spring AOP) to generate a proxy class of the current class if the current class includes a field labeled with a data conversion annotation (@ TransText), where the data conversion annotation is encapsulated in a launcher conforming to a specification of a container framework application (Spring boot), and point to specific implementation logic, where the specific implementation logic is configured to convert the field into text; a data conversion module 620, configured to invoke concrete implementation logic of data conversion annotation (@ transform) by using proxy class through a tangent plane oriented application (Spring AOP), the concrete implementation logic comprising: acquiring a specific value of a field marked with a data conversion annotation (@ TransText); obtaining code values of the data conversion notes, the code values corresponding to all possible values of the fields; searching data with all keys as possible values in a local or remote database according to the code values, and searching the data with the keys as specific values and texts in the data according to the specific values of the fields from all the data; a new field is added to the current class and the found text is assigned to the new field.
The apparatus shown in fig. 6 may further comprise an initialization module for scanning an initialization annotation (@ TransScanRegistrar), which is annotated to a startup file of a container framework application (Springboot), also encapsulated in the initiator as described above. The annotation points to implementation-specific logic for performing the initialization, the implementation-specific logic for initializing comprising: initializing interface information of remote acquired data, and executing one or more of the following initialization according to attribute contents of the initialization annotation: initializing locally stored interface information and initializing remotely stored interface information; loading the class marked with the data loading annotation and/or calling an interface marked with the data loading annotation for remotely acquiring data, executing remote data calling, converting the loaded data into a format, and storing the format in a local or remote storage, so that a corresponding text can be searched in the locally or remotely stored data according to the data conversion annotation, wherein the data loading annotation is used for marking the class or remotely acquiring the data, points to specific implementation logic for executing data loading, and is packaged into the initiator.
In a non-detailed part of the text conversion device according to an embodiment of the invention, reference is also made to the above detailed description of the method embodiment.
According to the embodiment of the invention, a novel mode for converting data into text is provided. The data source may support enumeration types as well as remote interface acquisition. The developer can realize data text conversion by only adding notes on the field to be converted, and the scanned data conversion notes can be automatically converted and output text fields are generated. This declarative conversion approach has the following advantages over conventional conversion approaches: 1. the method is simple and easy to use, improves development efficiency, and avoids repeated development of the same logic because a developer does not need to pay attention to how data is stored or what is the converted logic. 2. The annotation is packaged as the starter, so that the waste of resources is avoided, other items can be conveniently introduced, and the situation that one part is written and used everywhere is realized. 3. Through unified data conversion logic encapsulation, unified data storage is convenient for unified management, and later version upgrading maintenance is facilitated.
The method of the present invention may be performed in a computing device. The computing device may be any device having storage and computing capabilities, and may be implemented, for example, as a server, a workstation, or the like, or may be implemented as a personal configured computer such as a desktop computer, a notebook computer, or may be implemented as a terminal device such as a mobile phone, a tablet computer, an intelligent wearable device, or an internet of things device, but is not limited thereto.
FIG. 7 shows a schematic diagram of a computing device 700 according to one embodiment of the invention. It should be noted that, the computing device 700 shown in fig. 7 is only an example, and in practice, the computing device used to implement the method of the present invention may be any type of device, and the hardware configuration of the computing device may be the same as the computing device shown in fig. 7 or may be different from the computing device shown in fig. 7. The hardware components of the computing device used in practice to implement the methods of the present invention may be added or subtracted from the hardware components of computing device 700 shown in fig. 7. The invention does not limit the specific hardware configuration of the computing device.
As shown in fig. 7, the computing device 700 may include: processor 710, memory 720, input/output interface 730, communication interface 740, and bus 750. Wherein processor 710, memory 720, input/output interface 730, and communication interface 740 implement a communication connection among each other within a computing device via bus 750.
The processor 710 may be implemented in a general-purpose CPU (Central Processing Unit ), microprocessor, application specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, etc. for executing relevant programs to implement the technical solutions provided in the embodiments of the present disclosure.
The Memory 720 may be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory ), static storage device, dynamic storage device, or the like. Memory 720 may store an operating system and other application programs, and when the technical solutions provided by the embodiments of the present specification are implemented in software or firmware, relevant program codes are stored in memory 720 and invoked for execution by processor 710.
The input/output interface 730 is used to connect with an input/output module to realize information input and output. The input/output modules may be configured as components in a computing device (not shown) or may be external to the computing device to provide corresponding functionality. Wherein the input devices may include a keyboard, mouse, touch screen, microphone, various types of sensors, etc., and the output devices may include a display, speaker, vibrator, indicator lights, etc.
The communication interface 740 is used to connect communication modules (not shown) to enable communication interactions of the present computing device with other devices. The communication module may implement communication through a wired manner (such as USB, network cable, etc.), or may implement communication through a wireless manner (such as mobile network, WIFI, bluetooth, etc.).
Bus 750 includes a path to transfer information between various components of the computing device (e.g., processor 710, memory 720, input/output interface 730, and communication interface 740).
It should be noted that although the above-described computing device only shows processor 710, memory 720, input/output interface 730, communication interface 740, and bus 750, in particular implementations, the computing device may include other components necessary to achieve proper operation. Moreover, those skilled in the art will appreciate that the computing devices described above may include only the components necessary to implement the embodiments of the present description, and not all of the components shown in the figures.
Embodiments of the present invention also provide a non-transitory readable storage medium storing instructions for causing the computing device to perform a method according to embodiments of the present invention. The readable media of the present embodiments, including both permanent and non-permanent, removable and non-removable media, may be any method or technology for information storage. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of readable storage media include, but are not limited to: phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage, and the like.
In the description provided herein, algorithms and displays are not inherently related to any particular computer, virtual system, or other apparatus. Various general-purpose systems may also be used with examples of the invention. The required structure for a construction of such a system is apparent from the description above. In addition, the present invention is not directed to any particular programming language. It should be appreciated that the teachings of the present invention as described herein may be implemented in a variety of programming languages and that the foregoing descriptions of specific languages are provided for disclosure of preferred embodiments of the present invention.
In the description provided herein, numerous specific details are set forth. However, it is understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the above description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be construed as reflecting the intention that: i.e., the claimed invention requires more features than are expressly recited in each claim. Those skilled in the art will appreciate that the modules or units or components of the devices in the examples disclosed herein may be arranged in a device as described in this embodiment, or alternatively may be located in one or more devices different from the devices in the examples. The modules in the foregoing examples may be combined into one module or may be further divided into a plurality of sub-modules.
Those skilled in the art will appreciate that the modules in the apparatus of the embodiments may be adaptively changed and disposed in one or more apparatuses different from the embodiments. The modules or units or components of the embodiments may be combined into one module or unit or component, and furthermore they may be divided into a plurality of sub-modules or sub-units or sub-components. Any combination may be employed to combine all features disclosed in this specification (including the accompanying claims, abstract and drawings), and all of the processes or units of any method or apparatus so disclosed, unless at least some of such features and/or processes or units are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings), may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments described herein include some features but not others included in other embodiments, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments. Furthermore, some of the embodiments are described herein as methods or combinations of method elements that may be implemented by a processor of a computer system or by other means of performing the functions. Thus, a processor with the necessary instructions for implementing the described method or method element forms a means for implementing the method or method element.
As used herein, unless otherwise specified the use of the ordinal terms "first," "second," "third," etc., to describe a general object merely denote different instances of like objects, and are not intended to imply that the objects so described must have a given order, either temporally, spatially, in ranking, or in any other manner.
While the invention has been described with respect to a limited number of embodiments, those skilled in the art, having benefit of the above description, will appreciate that other embodiments are contemplated within the scope of the invention as described herein. Furthermore, it should be noted that the language used in the specification has been principally selected for readability and instructional purposes, and may not have been selected to delineate or circumscribe the inventive subject matter.

Claims (10)

1. A text conversion method performed by a container framework application, comprising:
reading a current class, and if the current class contains a field marked with a data conversion annotation, calling a proxy class facing to a section application to generate the current class, wherein the data conversion annotation is packaged into a starter conforming to the specification of the container frame application and points to specific implementation logic, and the specific implementation logic is used for converting the field into a text;
invoking concrete implementation logic of data conversion annotation by using proxy class for cut-plane application, the concrete implementation logic comprises: acquiring a specific value of a field marked with a data conversion annotation; obtaining code values of the data conversion notes, the code values corresponding to all possible values of the fields; searching data with all keys as possible values in a local or remote database according to the code values, and searching the data with the keys as specific values and texts in the data according to the specific values of the fields from all the data; a new field is added to the current class and the found text is assigned to the new field.
2. The text conversion method of claim 1, further comprising: scanning an initialization annotation, wherein the initialization annotation is marked to a starting file of a container framework application, is packaged into the starter and points to specific implementation logic for executing initialization; the specific implementation logic for initializing comprises the following steps:
initializing interface information of the remote acquired data, and executing one or more of the following initialization according to attribute contents of the initialization annotation: initializing locally stored interface information and initializing remotely stored interface information;
loading the class marked with the data loading annotation and/or calling the remote interface marked with the data loading annotation, executing remote data calling,
the loaded data is stored locally or remotely, so that corresponding text can be looked up in the locally or remotely stored data according to the data conversion annotation,
wherein the data loading annotation is used to annotate a class or to remotely retrieve data, and points to implementation-specific logic for performing the data loading, encapsulated into the initiator.
3. The text conversion method of claim 2, wherein the remote storage is a remote dictionary server.
4. A text conversion method as claimed in any one of claims 1 to 3, further comprising: the class to which the new field is added and assigned to the new field is output to the front end.
5. A text conversion device in a container frame application, comprising:
the agent class generating module reads the current class, if the current class contains a field marked with a data conversion annotation, invokes the section-oriented application to generate the agent class of the current class, wherein the data conversion annotation is packaged into a starter conforming to the specification of the container frame application and points to specific implementation logic, and the specific implementation logic is used for converting the field into a text;
the data conversion module invokes specific implementation logic of the data conversion annotation by using the proxy class for the cut-plane application, wherein the specific implementation logic comprises: acquiring a specific value of a field marked with a data conversion annotation; obtaining code values of the data conversion notes, the code values corresponding to all possible values of the fields; searching data with all keys as possible values in a local or remote database according to the code values, and searching the data with the keys as specific values and texts in the data according to the specific values of the fields from all the data; a new field is added to the current class and the found text is assigned to the new field.
6. The text conversion device of claim 5, further comprising: the initialization module is used for scanning initialization notes, the initialization notes are marked on a starting file of the container framework application, are packaged into the starter and point to specific implementation logic for executing initialization; the specific implementation logic for initializing comprises the following steps:
initializing interface information of the remote acquired data, and executing one or more of the following initialization according to attribute contents of the initialization annotation: initializing locally stored interface information and initializing remotely stored interface information;
loading the class marked with the data loading annotation and/or calling the interface marked with the data loading annotation for remotely acquiring the data, executing remote data calling,
the loaded data is converted into a format and stored in a local or remote storage, so that corresponding text can be searched in the locally or remotely stored data according to the data conversion annotation,
wherein the data loading annotation is used to annotate a class or to remotely retrieve data, and points to implementation-specific logic for performing the data loading, encapsulated into the initiator.
7. The text conversion device of claim 6, wherein the remote storage is a remote dictionary server.
8. The text conversion device of any of claims 5-7, further comprising an output module for outputting a class to which the new field is added and assigned to the new field to the front end.
9. A computing device, comprising:
at least one processor and a memory storing program instructions;
the program instructions, when read and executed by the processor, cause the computing device to perform the text conversion method of any of claims 1-4.
10. A readable storage medium storing program instructions which, when read and executed by a computing device, cause the computing device to perform the text conversion method of any of claims 1-4.
CN202310188890.2A 2023-02-22 2023-02-22 Text conversion method and apparatus, computing device and readable storage medium Pending CN116225450A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310188890.2A CN116225450A (en) 2023-02-22 2023-02-22 Text conversion method and apparatus, computing device and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310188890.2A CN116225450A (en) 2023-02-22 2023-02-22 Text conversion method and apparatus, computing device and readable storage medium

Publications (1)

Publication Number Publication Date
CN116225450A true CN116225450A (en) 2023-06-06

Family

ID=86578298

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310188890.2A Pending CN116225450A (en) 2023-02-22 2023-02-22 Text conversion method and apparatus, computing device and readable storage medium

Country Status (1)

Country Link
CN (1) CN116225450A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117422071A (en) * 2023-12-19 2024-01-19 中南大学 Text term multiple segmentation annotation conversion method and device

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117422071A (en) * 2023-12-19 2024-01-19 中南大学 Text term multiple segmentation annotation conversion method and device
CN117422071B (en) * 2023-12-19 2024-03-15 中南大学 Text term multiple segmentation annotation conversion method and device

Similar Documents

Publication Publication Date Title
US7761586B2 (en) Accessing and manipulating data in a data flow graph
EP2827244A1 (en) Extension mechanism for scripting language compiler
US8924944B2 (en) Implementation of distributed methods that support generic functions
CN110007920B (en) Method and device for acquiring code dependency relationship and electronic equipment
US20090037459A1 (en) Annotation data handlers for data stream processing
US9043757B2 (en) Identifying differences between source codes of different versions of a software when each source code is organized using incorporated files
WO2017219526A1 (en) Method for using graphic file format and storage device
CN106648569B (en) Target serialization realization method and device
CN106850650B (en) Method for accessing data by game client and client game system
CN110609687A (en) Compiling method, device, electronic equipment and storage medium
US20230214231A1 (en) Driver Configuration Management Method and Apparatus, Medium, Device, and System
CN110109983B (en) Method and device for operating Redis database
CN116225450A (en) Text conversion method and apparatus, computing device and readable storage medium
US10620916B2 (en) Read-only communication operator
CN110888794A (en) Interface test method and device
CN110457013B (en) Program component configuration device and method
CN111488144A (en) Data processing method and equipment
CN113094086B (en) Component integration method, device, computer readable storage medium and electronic equipment
CN111796865B (en) Byte code file modification method, device, terminal equipment and medium
CN111459584B (en) Page rendering method and device and electronic equipment
US9720660B2 (en) Binary interface instrumentation
CN113296975A (en) Service calling method and device
CN110837896B (en) Storage and calling method and device of machine learning model
CN115658276B (en) Service development method, device, electronic equipment and readable storage medium
CN116610324A (en) Method and system for optimizing ebpf program CO-RE

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