CN113778387A - Method and apparatus for generating code - Google Patents

Method and apparatus for generating code Download PDF

Info

Publication number
CN113778387A
CN113778387A CN202010518023.7A CN202010518023A CN113778387A CN 113778387 A CN113778387 A CN 113778387A CN 202010518023 A CN202010518023 A CN 202010518023A CN 113778387 A CN113778387 A CN 113778387A
Authority
CN
China
Prior art keywords
sample
event
target
event name
variable element
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
CN202010518023.7A
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.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network 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 Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN202010518023.7A priority Critical patent/CN113778387A/en
Publication of CN113778387A publication Critical patent/CN113778387A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

Embodiments of the present disclosure disclose methods and apparatus for generating code. One embodiment of the method comprises: in response to receiving a target event name input by a user, acquiring a pre-generated association information set, wherein the association information comprises an associated sample event name and a sample variable element; determining a sample event name matched with the target event name from the sample event names included in the associated information set as a matched event name; determining a sample variable element associated with the matching event name in the association information set as a target variable element associated with a target event name; and adding the target variable element into a preset initial code to obtain a result code, wherein the initial code is a code which is preset for the target event indicated by the target event name and does not comprise the variable element. The implementation mode can save human resources and improve the efficiency and diversity of code generation.

Description

Method and apparatus for generating code
Technical Field
Embodiments of the present disclosure relate to the field of computer technologies, and in particular, to a method and an apparatus for generating a code.
Background
Currently, event codes for implementing events (e.g., a buried point event, a network request event) require manual writing by a technician.
In the process of implementing the present application, the inventors found that: for two events of the same type that include different variable elements, the technician needs to write the event code separately.
For example, for two buried point events a, b, where buried point event a includes a variable element "click times"; the buried point event b includes a variable element "response time after click", and even if both the buried point event a and the buried point event b are buried point type events, since the buried point event a and the buried point event b are not the same event and include different variable elements, in practice, technicians need to write event codes for the buried point event a and the buried point event b, respectively.
Disclosure of Invention
The embodiment of the disclosure provides a method and a device for generating codes.
In a first aspect, an embodiment of the present disclosure provides a method for generating a code, the method including: in response to receiving a target event name input by a user, acquiring a pre-generated association information set, wherein the association information comprises an associated sample event name and a sample variable element; determining a sample event name matched with the target event name from the sample event names included in the associated information set as a matched event name; determining a sample variable element associated with the matching event name in the association information set as a target variable element associated with a target event name; and adding the target variable element into a preset initial code to obtain a result code, wherein the initial code is a code which is preset for the target event indicated by the target event name and does not comprise the variable element.
In some embodiments, the set of association information is obtained by: acquiring a predetermined sample data set for describing a sample event, wherein the sample data comprises a sample event name and a sample variable element of the described sample event; for sample data in the sample data set, performing the following steps: extracting a sample event name and a sample variable element from the sample data; composing associated information using the extracted sample event name and the sample variable element; and generating a related information set by using the formed related information.
In some embodiments, adding the target variable element to a preset initial code, and obtaining the result code includes: and in response to determining at least two groups of target variable elements associated with the target event name, adding the determined at least two groups of target variable elements to a preset initial code respectively to obtain at least two groups of result codes.
In some embodiments, adding the target variable element to a preset initial code, and obtaining the result code includes: and adding the target variable element into preset initial code by using a pre-installed script to obtain result code, wherein the script comprises the initial code.
In some embodiments, the target event to which the target event name corresponds is one of: a buried point event, a network request event and an information reminding event.
In some embodiments, the method further comprises: and outputting the obtained result code to the user.
In a second aspect, an embodiment of the present disclosure provides an apparatus for generating a code, the apparatus including: the device comprises an acquisition unit, a processing unit and a display unit, wherein the acquisition unit is used for responding to a target event name input by a user and acquiring a pre-generated association information set, and the association information comprises an associated sample event name and a sample variable element; a first determination unit configured to determine, as a matching event name, a sample event name that matches a target event name from among sample event names included in the associated information set; a second determining unit, configured to determine a sample variable element associated with the matching event name in the association information set as a target variable element associated with the target event name; and an adding unit, configured to add the target variable element to a preset initial code, and obtain a result code, where the initial code is a code that is preset for the target event indicated by the target event name and does not include the variable element.
In some embodiments, the set of association information is obtained by: acquiring a predetermined sample data set for describing a sample event, wherein the sample data comprises a sample event name and a sample variable element of the described sample event; for sample data in the sample data set, performing the following steps: extracting a sample event name and a sample variable element from the sample data; composing associated information using the extracted sample event name and the sample variable element; and generating a related information set by using the formed related information.
In some embodiments, the adding unit is further configured to include: and in response to determining at least two groups of target variable elements associated with the target event name, adding the determined at least two groups of target variable elements to a preset initial code respectively to obtain at least two groups of result codes.
In some embodiments, the adding unit is further configured to: and adding the target variable element into preset initial code by using a pre-installed script to obtain result code, wherein the script comprises the initial code.
In some embodiments, the target event to which the target event name corresponds is one of: a buried point event, a network request event and an information reminding event.
In some embodiments, the apparatus further comprises: and the output unit is used for outputting the obtained result code to the user.
In a third aspect, an embodiment of the present disclosure provides an electronic device, including: one or more processors; a storage device having one or more programs stored thereon, which when executed by one or more processors, cause the one or more processors to implement the methods of any of the embodiments of the method for generating code described above.
In a fourth aspect, embodiments of the present disclosure provide a computer-readable medium on which a computer program is stored, which when executed by a processor, implements the method of any of the above-described methods for generating code.
The method and apparatus for generating a code provided by the embodiments of the present disclosure obtain a pre-generated association information set by obtaining a pre-generated association information set in response to receiving a target event name input by a user, wherein the association information includes an associated sample event name and a sample variable element, then determine a sample event name matching the target event name from the sample event names included in the association information set as a matching event name, then determine the sample variable element associated with the matching event name in the association information set as a target variable element associated with the target event name, and finally add the target variable element to a pre-set initial code to obtain a result code, wherein the initial code is a code that is pre-set for the target event indicated by the target event name and does not include a variable element, thereby automatically generating an event code of an event requested by the user based on the event name input by the user, the code generation mode is enriched, and the diversity of code generation is improved; moreover, for two events with different variable elements but the same type, a technician only needs to determine an initial code for the two events, and then can generate event codes of the two events through the scheme recorded in the embodiment of the disclosure without writing the event codes for the two events respectively.
Drawings
Other features, objects and advantages of the disclosure will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
FIG. 1 is an exemplary system architecture diagram in which one embodiment of the present disclosure may be applied;
FIG. 2 is a flow diagram for one embodiment of a method for generating code, according to the present disclosure;
FIG. 3 is a schematic diagram of one application scenario of a method for generating code in accordance with an embodiment of the present disclosure;
FIG. 4 is a flow diagram of yet another embodiment of a method for generating code according to the present disclosure;
FIG. 5 is a schematic block diagram of one embodiment of an apparatus for generating code according to the present disclosure;
FIG. 6 is a schematic block diagram of a computer system suitable for use with an electronic device implementing embodiments of the present disclosure.
Detailed Description
The present disclosure is described in further detail below with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that, in the present disclosure, the embodiments and features of the embodiments may be combined with each other without conflict. The present disclosure will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
Fig. 1 illustrates an exemplary system architecture 100 to which embodiments of the disclosed method for generating code or apparatus for generating code may be applied.
As shown in fig. 1, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal devices 101, 102, 103 to interact with the server 105 via the network 104 to receive or send messages or the like. Various client applications, such as code development tools, web browser-like applications, search-like applications, instant messaging tools, mailbox clients, social platform software, etc., may be installed on the terminal devices 101, 102, 103.
The terminal apparatuses 101, 102, and 103 may be hardware or software. When the terminal devices 101, 102, 103 are hardware, they may be various electronic devices, including but not limited to smart phones, tablet computers, electronic book readers, MP3 players (Moving Picture Experts Group Audio Layer III, mpeg Audio Layer 3), MP4 players (Moving Picture Experts Group Audio Layer IV, mpeg Audio Layer 4), laptop portable computers, desktop computers, and the like. When the terminal apparatuses 101, 102, 103 are software, they can be installed in the electronic apparatuses listed above. It may be implemented as multiple pieces of software or software modules (e.g., multiple pieces of software or software modules to provide distributed services) or as a single piece of software or software module. And is not particularly limited herein.
The server 105 may be a server providing various services, such as a backend server providing support for code development tools installed on the terminal devices 101, 102, 103. The background server may analyze and perform other processing on the received data such as the target event name, and feed back a processing result (e.g., a result code) to the terminal device.
It should be noted that the method for generating the code provided by the embodiment of the present disclosure may be executed by the terminal devices 101, 102, and 103, or may be executed by the server 105, and accordingly, the apparatus for generating the code may be disposed in the terminal devices 101, 102, and 103, or may be disposed in the server 105.
The server may be hardware or software. When the server is hardware, it may be implemented as a distributed server cluster formed by multiple servers, or may be implemented as a single server. When the server is software, it may be implemented as multiple pieces of software or software modules (e.g., multiple pieces of software or software modules used to provide distributed services), or as a single piece of software or software module. And is not particularly limited herein.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
With continued reference to FIG. 2, a flow 200 of one embodiment of a method for generating code in accordance with the present disclosure is shown. The method for generating codes comprises the following steps:
step 201, in response to receiving a target event name input by a user, acquiring a pre-generated association information set.
In this embodiment, an execution subject (e.g., a terminal device shown in fig. 1) of the method for generating a code may acquire a pre-generated association information set in response to receiving a target event name input by a user through a wired connection manner or a wireless connection manner. The target event name may be an event name of an event requested by the user. Specifically, when a user requests to acquire an event code of an event, the user may input an event name of the event, and the execution subject may use the event requested by the user as a target event and use the event name input by the user as a target event name.
Here, the target event requested by the user may be an event in which there are a limited number of variable elements. Variable elements refer to factors that can vary in an event. For example, for a certain buried point type event, the event records the response time of the click. However, in general, the buried point event may also record the number of clicks, that is, the "response time" in the event may be changed into the "number", which is a variable element of the event.
In some optional implementations of this embodiment, the target event corresponding to the target event name may be, but is not limited to, one of the following: a buried point event, a network request event and an information reminding event.
In practice, the trigger of the event may be used as the event name of the event, for example, for a buried point event, if the trigger is a Click action, the word "Click" corresponding to the Click action may be used as the event name of the event. In addition, other elements that can represent the main content of the event in the event may be used as the event name of the event. As an example, the result of the event may also be taken as the event name of the event. For example, for an event of the information reminding type, if the trigger factor is that the environment meets the preset condition and the result is that the user is reminded, the word "Warn" corresponding to the reminding action may be used as the event name of the event.
It should be noted that the target event name input by the user may be an event name selected from a plurality of predetermined event names; or the event name of the event requested by the user, which the user has entered based on personal experience.
In this embodiment, the associated information in the associated information set may include an associated sample event name and a sample variable element. The sample event name may be a predetermined event name used to generate the set of associated information. The sample variable element may be a predetermined variable element used to generate the association information set. The associated sample event name and sample variable element correspond to the same sample event.
In practice, the set of association information may be stored in various forms, such as in the form of a table, in the form of key-value pairs, and so on.
In this embodiment, the execution subject may acquire the associated information set in various manners, for example, the execution subject may acquire the associated information set pre-stored locally; alternatively, the execution subject may obtain the association information set sent by other electronic devices in communication connection.
In some optional implementations of this embodiment, the association information set may be obtained by the execution subject or other electronic device through the following steps:
first, a predetermined set of sample data describing sample events is obtained.
Each sample data in the sample data set may correspond to a sample event. The sample data may include a sample event name and a sample variable element for the described sample event. Specifically, the sample data may be data input by a technician for generating the related information set, or may be description data corresponding to a generated sample event.
In practice, when writing an event code of an event, a technician generally writes description data of the event (e.g., { name: "Click", keys [ { name: "Time" } ]), and then, in order to generate a correlation information set, the execution subject may select an event that has already been generated as a sample event and use the description data corresponding to the sample event as sample data.
It is to be understood that, after the sample event name and the sample variable element of the sample event are determined, the content of the sample event may be determined, so that the sample event name and the sample variable element may be used to describe the content of the sample event, and further, the sample data used to describe the sample event may include the sample event name and the sample variable element of the sample event.
Then, for the sample data in the sample data set, the following steps are executed: extracting a sample event name and a sample variable element from the sample data; and composing the association information by using the extracted sample event name and the sample variable element.
Here, the execution agent may extract the sample event name and the sample variable element from the sample data by using various methods.
Specifically, as an example, the sample data may include an event name identifier indicating a sample event name and an element identifier indicating a sample variable element, and the execution subject may extract the sample event name and the sample variable element based on the event name identifier and the element identifier. For example, for sample data { name: "Click", keys: [ name: "Time" ] }), name: "can be used as an event name identifier of a sample event name, and key: [ name:" is used as an element identifier of a sample variable element, and then the execution subject can use the word "Click" after the event name identifier "name:" as a sample event name and the word "Time" after the element identifier "key: [ name:" as a sample variable element.
As another example, the sample data may be input to a annotating person, the annotating person annotates the sample event name and the sample variable element in the sample data, and the executing subject may extract the sample event name and the sample variable element from the sample data according to the annotation result of the annotating person.
And finally, generating a correlation information set by using the formed correlation information.
Specifically, for each sample data in the sample data set, the execution principal or other electronic device may compose one piece of associated information, and further, the execution principal or other electronic device may combine the composed pieces of associated information into an associated information set.
In step 202, a sample event name matching the target event name is determined as a matching event name from the sample event names included in the association information set.
In the present embodiment, based on the associated information set obtained in step 201, the execution subject may determine a sample event name matching the target event name as a matching event name from the sample event names included in the associated information set.
Specifically, the execution subject may match the sample event name and the target event name in the association information set to obtain a matching event name. Here, the execution subject may perform matching between the sample event name and the target event name in various manners, for example, the execution subject may perform similarity calculation between the sample event name and the target event name, and further may use the sample event name with the highest similarity to the target event name as the matching event name; or, when the target event name is different from the language corresponding to the sample event name, the execution subject may first translate the target event name according to the language of the sample event name, then perform similarity calculation on the translated target event name and the sample event name, and further use the sample event name with the highest similarity to the translated target event name as the matching event name.
And step 203, determining the sample variable element associated with the matching event name in the association information set as a target variable element associated with the target event name.
In the present embodiment, based on the matching event name obtained in step 202, the execution principal may determine a sample variable element associated with the matching event name from the association information set, and determine the determined sample variable element as a target variable element associated with the target event name.
As an example, the target event name is "click". The matching event name "Click" with the target event name "Click" is determined based on step 202. The associated information set comprises associated information "Click-Time". Furthermore, in this step, the execution subject may first determine that the sample variable element corresponding to "Click" is "Time" from the association information set, and then determine that the determined sample variable element is "Time" as the target variable element associated with the target event name "Click".
And step 204, adding the target variable element into a preset initial code to obtain a result code.
In this embodiment, based on the target variable element obtained in step 203, the execution subject may add the target variable element to an initial code set in advance, and obtain a result code. Wherein the initial code is a code which is preset for the target event indicated by the target event name and does not include a variable element. The result code is an event code of the target event requested by the user.
In practice, the initial code may include a location identifier for indicating a location of the variable element in the initial code, and the execution subject may add the target variable element to the initial code based on the location identifier. For example, the position of the initial code where the variable element needs to be added may be identified by a space, and the execution body may add the target variable element to the space position in the initial code.
In some optional implementations of this embodiment, in response to determining at least two sets of target variable elements associated with the target event name through step 203, the executing body may further add the determined at least two sets of target variable elements to a preset initial code, respectively, to obtain at least two sets of result codes.
As an example, the target event name is "click". The matching event name "Click" with the target event name "Click" is determined based on step 202. The associated information set comprises associated information 'Click-Time' and associated information 'Click-Count'. Further, in step 203, the executing agent may determine two sets of target variable elements "Time" and "Count" corresponding to "Click" from the association information set. Further, the executing entity may add two sets of target variable elements "Time" and "Count" to the initial code, respectively, in response to determining two sets of target variable elements associated with the target event name, to obtain two sets of result codes.
In the implementation mode, the user only needs to input the event name of the target event, and the execution main body can automatically generate a plurality of event codes which correspond to the target event and have different variable elements, so that the code generation efficiency is improved.
In some optional implementation manners of this embodiment, after obtaining the result code, the execution main body may further output the obtained result code to the user.
In particular, the execution subject may present the result code to the user so that the user may process the result code (e.g., add the result code to the written code, run the result code, etc.).
With continued reference to fig. 3, fig. 3 is a schematic diagram of an application scenario of the method for generating a code according to the present embodiment. In the application scenario of fig. 3, the terminal device 301 may first obtain a pre-generated association information set 304 in response to receiving a target event name 303 (e.g., "Click") input by the user 302, where the association information in the association information set 304 includes associated sample event names and sample variable elements. Then, the terminal device 301 can determine a sample event name matching the target event name 303 as a matching event name 305 (e.g., "Click") from the sample event names included in the association information set 304. Next, the terminal device 301 may determine the sample variable element associated with the matching event name 305 in the association information set 304 as the target variable element 306 (e.g., "Time") associated with the target event name 303. Finally, the terminal device 301 may add the target variable element 306 to a preset initial code 307, and obtain a result code 308, where the initial code 307 is a code that is preset for a target event (e.g., a buried point event) indicated by the target event name 303 and does not include a variable element.
The method provided by the embodiment of the disclosure can automatically generate the event code of the event requested by the user based on the event name input by the user, enriches the code generation mode, and improves the diversity of code generation; moreover, for two events with different variable elements but the same type, a technician only needs to determine an initial code for the two events, and then can generate event codes of the two events through the scheme recorded by the disclosure without writing the event codes for the two events respectively, so that the scheme recorded by the disclosure can save human resources and improve the code generation efficiency.
With further reference to FIG. 4, a flow 400 of yet another embodiment of a method for generating code is shown. The flow 400 of the method for generating code includes the steps of:
step 401, in response to receiving a target event name input by a user, acquiring a pre-generated association information set.
In this embodiment, an execution subject (e.g., a terminal device shown in fig. 1) of the method for generating a code may acquire a pre-generated association information set in response to receiving a target event name input by a user through a wired connection manner or a wireless connection manner. The target event name may be an event name of an event requested by the user. Specifically, when a user requests to acquire an event code of an event, the user may input an event name of the event, and the execution subject may use the event requested by the user as a target event and use the event name input by the user as a target event name.
Here, the target event requested by the user may be an event in which there are a limited number of variable elements. Variable elements refer to factors that can vary in an event.
In this embodiment, the associated information in the associated information set may include an associated sample event name and a sample variable element. The sample event name may be a predetermined event name used to generate the set of associated information. The sample variable element may be a predetermined variable element used to generate the association information set. The associated sample event name and sample variable element correspond to the same sample event.
Step 402, determining a sample event name matched with the target event name from the sample event names included in the association information set as a matched event name.
In this embodiment, based on the associated information set obtained in step 401, the execution subject may determine a sample event name matching the target event name as a matching event name from the sample event names included in the associated information set.
In step 403, the sample variable element associated with the matching event name in the association information set is determined as the target variable element associated with the target event name.
In the present embodiment, based on the matching event name obtained in step 402, the execution subject may determine a sample variable element associated with the matching event name from the association information set, and determine the determined sample variable element as a target variable element associated with the target event name.
Step 401, step 402, and step 403 may be performed in a manner similar to that of step 201, step 202, and step 203 in the foregoing embodiment, respectively, and the above description for step 201, step 202, and step 203 also applies to step 401, step 402, and step 403, and is not described herein again.
And step 404, adding the target variable element into the preset initial code by using the pre-installed script to obtain a result code.
In this embodiment, based on the target variable element obtained in step 203, the execution subject may add the target variable element to the preset initial code by using a script installed in advance, and obtain a result code. Wherein the initial code may be a code which is preset for the target event indicated by the target event name and does not include a variable element. The result code is an event code of the target event requested by the user.
In this embodiment, the script may be a script that is installed in advance on the execution body and is used to generate the event code. The script may record an initial code corresponding to a target event requested by a user. Furthermore, after the execution subject acquires the target variable element, the execution subject may add the target variable element to the initial code corresponding to the target event by running the script, and obtain a result code corresponding to the target event.
It should be noted that the script may be used to add the target variable element to the initial code corresponding to the target event, and may also be used to perform other steps described in the present disclosure, for example, to perform step 402.
In particular, the script described above may be used to perform all steps recited in this disclosure except "target event name in response to receiving user input" in step 401. Furthermore, the execution main body can automatically generate the event code of the target event corresponding to the target event name only by running the script in response to receiving the target event name input by the user.
As can be seen from fig. 4, compared with the embodiment corresponding to fig. 2, the flow 400 of the method for generating code in the present embodiment highlights the step of adding the target variable element to the preset initial code by using the pre-installed script, and obtaining the result code. Therefore, the scheme described in this embodiment can package the method for obtaining the result code into a script, and further realize the generation of the result code by running the script. Here, since the script can be installed and maintained independently, the solution described in this embodiment can simplify the propagation path of the result code generation method by using the script, further expand the use range of the code generation method, and reduce the maintenance difficulty of the result code generation method.
With further reference to fig. 5, as an implementation of the method shown in the above figures, the present disclosure provides an embodiment of an apparatus for generating a code, which corresponds to the method embodiment shown in fig. 2, and which is particularly applicable to various electronic devices.
As shown in fig. 5, the apparatus 500 for generating a code of the present embodiment includes: an acquisition unit 501, a first determination unit 502, a second determination unit 503, and an addition unit 504. The obtaining unit 501 is configured to obtain a pre-generated association information set in response to receiving a target event name input by a user, where the association information includes an associated sample event name and a sample variable element; the first determining unit 502 is configured to determine, as a matching event name, a sample event name that matches the target event name from the sample event names included in the associated information set; the second determining unit 503 is configured to determine a sample variable element associated with the matching event name in the association information set as a target variable element associated with the target event name; the adding unit 504 is configured to add the target variable element to a preset initial code, and obtain a result code, where the initial code is a code that is preset for the target event indicated by the target event name and does not include the variable element.
In this embodiment, the obtaining unit 501 of the apparatus 500 for generating a code may obtain a pre-generated association information set in response to receiving a target event name input by a user through a wired connection manner or a wireless connection manner. The target event name may be an event name of an event requested by the user. Specifically, when a user requests to acquire an event code of an event, the user may input an event name of the event, and the acquiring unit 501 may use the event requested by the user as a target event and use the event name input by the user as a target event name.
Here, the target event requested by the user may be an event in which there are a limited number of variable elements. Variable elements refer to factors that can vary in an event.
In this embodiment, the associated information in the associated information set may include an associated sample event name and a sample variable element. The sample event name may be a predetermined event name used to generate the set of associated information. The sample variable element may be a predetermined variable element used to generate the association information set. The associated sample event name and sample variable element correspond to the same sample event.
In this embodiment, based on the association information set obtained by the obtaining unit 501, the upper first determining unit 502 may determine, as a matching event name, a sample event name that matches the target event name from among sample event names included in the association information set.
In the present embodiment, based on the matching event name obtained by the first determining unit 502, the second determining unit 503 may determine a sample variable element associated with the matching event name from the association information set, and determine the determined sample variable element as a target variable element associated with the target event name.
In the present embodiment, based on the target variable element obtained by the second determining unit 503, the adding unit 504 may add the target variable element to an initial code set in advance, and obtain a result code. Wherein the initial code is a code which is preset for the target event indicated by the target event name and does not include a variable element. The result code is an event code of the target event requested by the user.
In some optional implementations of this embodiment, the association information set is obtained by: acquiring a predetermined sample data set for describing a sample event, wherein the sample data comprises a sample event name and a sample variable element of the described sample event; for sample data in the sample data set, performing the following steps: extracting a sample event name and a sample variable element from the sample data; composing associated information using the extracted sample event name and the sample variable element; and generating a related information set by using the formed related information.
In some optional implementations of this embodiment, the adding unit 504 may be further configured to include: and in response to determining at least two groups of target variable elements associated with the target event name, adding the determined at least two groups of target variable elements to a preset initial code respectively to obtain at least two groups of result codes.
In some optional implementations of this embodiment, the adding unit 504 may be further configured to: and adding the target variable element into preset initial code by using a pre-installed script to obtain result code, wherein the script comprises the initial code.
In some optional implementations of this embodiment, the target event corresponding to the target event name is one of the following: a buried point event, a network request event and an information reminding event.
In some optional implementations of this embodiment, the apparatus 500 may further include: an output unit (not shown in the figure) for outputting the obtained result code to the user.
It will be understood that the elements described in the apparatus 500 correspond to various steps in the method described with reference to fig. 2. Thus, the operations, features and resulting advantages described above with respect to the method are also applicable to the apparatus 500 and the units included therein, and are not described herein again.
The device 500 provided by the above embodiment of the present disclosure can automatically generate an event code of an event requested by a user based on an event name input by the user, enrich the code generation manner, and improve the diversity of code generation; moreover, for two events with different variable elements but the same type, a technician only needs to determine an initial code for the two events, and then can generate event codes of the two events through the scheme recorded by the disclosure without writing the event codes for the two events respectively, so that the scheme recorded by the disclosure can save human resources and improve the code generation efficiency.
Referring now to fig. 6, a schematic diagram of an electronic device (e.g., the terminal device of fig. 1) 600 suitable for implementing embodiments of the present disclosure is shown. The terminal device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a stationary terminal such as a digital TV, a desktop computer, and the like. The electronic device shown in fig. 6 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 6, electronic device 600 may include a processing means (e.g., central processing unit, graphics processor, etc.) 601 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)602 or a program loaded from a storage means 608 into a Random Access Memory (RAM) 603. In the RAM603, various programs and data necessary for the operation of the electronic apparatus 600 are also stored. The processing device 601, the ROM 602, and the RAM603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
Generally, the following devices may be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 607 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 608 including, for example, tape, hard disk, etc.; and a communication device 609. The communication means 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. While fig. 6 illustrates an electronic device 600 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication means 609, or may be installed from the storage means 608, or may be installed from the ROM 602. The computer program, when executed by the processing device 601, performs the above-described functions defined in the methods of the embodiments of the present disclosure.
It should be noted that the computer readable medium in the present disclosure may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled into the electronic device. The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: in response to receiving a target event name input by a user, acquiring a pre-generated association information set, wherein the association information comprises an associated sample event name and a sample variable element; determining a sample event name matched with the target event name from the sample event names included in the associated information set as a matched event name; determining a sample variable element associated with the matching event name in the association information set as a target variable element associated with a target event name; and adding the target variable element into a preset initial code to obtain a result code, wherein the initial code is a code which is preset for the target event indicated by the target event name and does not comprise the variable element.
Computer program code for carrying out operations for aspects of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. Where the name of a unit does not in some cases constitute a limitation on the unit itself, for example, the obtaining unit may also be described as a "unit that obtains a set of associated information".
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other embodiments in which any combination of the features described above or their equivalents does not depart from the spirit of the disclosure. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.

Claims (14)

1. A method for generating code, comprising:
in response to receiving a target event name input by a user, acquiring a pre-generated association information set, wherein the association information comprises an associated sample event name and a sample variable element;
determining a sample event name matched with the target event name from the sample event names included in the associated information set as a matched event name;
determining a sample variable element in the association information set associated with the matching event name as a target variable element associated with the target event name;
and adding the target variable element into a preset initial code to obtain a result code, wherein the initial code is a code which is preset for the target event indicated by the target event name and does not comprise the variable element.
2. The method of claim 1, wherein the set of association information is obtained by:
acquiring a predetermined sample data set for describing a sample event, wherein the sample data comprises a sample event name and a sample variable element of the described sample event;
for sample data in the sample data set, performing the following steps: extracting a sample event name and a sample variable element from the sample data; composing associated information using the extracted sample event name and the sample variable element;
and generating a related information set by using the formed related information.
3. The method of claim 1, wherein the adding the target variable element to a preset initial code, obtaining a result code comprises:
and in response to determining at least two groups of target variable elements associated with the target event name, adding the determined at least two groups of target variable elements to a preset initial code respectively to obtain at least two groups of result codes.
4. The method of claim 1, wherein the adding the target variable element to a preset initial code, obtaining a result code comprises:
and adding the target variable element into preset initial code by using a pre-installed script to obtain a result code, wherein the script comprises the initial code.
5. The method of claim 1, wherein the target event to which the target event name corresponds is one of:
a buried point event, a network request event and an information reminding event.
6. The method according to one of claims 1-5, wherein the method further comprises:
and outputting the obtained result code to the user.
7. An apparatus for generating code, comprising:
the device comprises an acquisition unit, a processing unit and a display unit, wherein the acquisition unit is used for responding to a target event name input by a user and acquiring a pre-generated association information set, and the association information comprises an associated sample event name and a sample variable element;
a first determining unit configured to determine, as a matching event name, a sample event name that matches the target event name from among sample event names included in the associated information set;
a second determining unit, configured to determine a sample variable element associated with the matching event name in the association information set as a target variable element associated with the target event name;
and the adding unit is used for adding the target variable element into a preset initial code to obtain a result code, wherein the initial code is a code which is preset for the target event indicated by the target event name and does not comprise the variable element.
8. The apparatus of claim 7, wherein the set of association information is obtained by:
acquiring a predetermined sample data set for describing a sample event, wherein the sample data comprises a sample event name and a sample variable element of the described sample event;
for sample data in the sample data set, performing the following steps: extracting a sample event name and a sample variable element from the sample data; composing associated information using the extracted sample event name and the sample variable element;
and generating a related information set by using the formed related information.
9. The apparatus of claim 7, wherein the adding unit is further configured to include:
and in response to determining at least two groups of target variable elements associated with the target event name, adding the determined at least two groups of target variable elements to a preset initial code respectively to obtain at least two groups of result codes.
10. The apparatus of claim 7, wherein the adding unit is further configured to:
and adding the target variable element into preset initial code by using a pre-installed script to obtain a result code, wherein the script comprises the initial code.
11. The apparatus of claim 7, wherein the target event corresponding to the target event name is one of:
a buried point event, a network request event and an information reminding event.
12. The apparatus according to one of claims 7-11, wherein the apparatus further comprises:
an output unit for outputting the obtained result code to the user.
13. An electronic device, comprising:
one or more processors;
a storage device having one or more programs stored thereon,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-6.
14. A computer-readable medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-6.
CN202010518023.7A 2020-06-09 2020-06-09 Method and apparatus for generating code Pending CN113778387A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010518023.7A CN113778387A (en) 2020-06-09 2020-06-09 Method and apparatus for generating code

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010518023.7A CN113778387A (en) 2020-06-09 2020-06-09 Method and apparatus for generating code

Publications (1)

Publication Number Publication Date
CN113778387A true CN113778387A (en) 2021-12-10

Family

ID=78834336

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010518023.7A Pending CN113778387A (en) 2020-06-09 2020-06-09 Method and apparatus for generating code

Country Status (1)

Country Link
CN (1) CN113778387A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140074762A1 (en) * 2011-09-12 2014-03-13 Stanley Victor CAMPBELL Systems and methods for monitoring and analyzing transactions
CN107077391A (en) * 2014-10-03 2017-08-18 益焦.com有限公司 System and method for classifying and analyzing run time events
CN110647438A (en) * 2019-08-13 2020-01-03 平安科技(深圳)有限公司 Event monitoring method and device, computer equipment and storage medium
CN111241444A (en) * 2020-01-09 2020-06-05 深圳壹账通智能科技有限公司 Webpage embedded point code adding method and device, computer equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140074762A1 (en) * 2011-09-12 2014-03-13 Stanley Victor CAMPBELL Systems and methods for monitoring and analyzing transactions
CN107077391A (en) * 2014-10-03 2017-08-18 益焦.com有限公司 System and method for classifying and analyzing run time events
CN110647438A (en) * 2019-08-13 2020-01-03 平安科技(深圳)有限公司 Event monitoring method and device, computer equipment and storage medium
CN111241444A (en) * 2020-01-09 2020-06-05 深圳壹账通智能科技有限公司 Webpage embedded point code adding method and device, computer equipment and storage medium

Similar Documents

Publication Publication Date Title
CN110213614B (en) Method and device for extracting key frame from video file
CN112040330B (en) Video file processing method and device, electronic equipment and computer storage medium
WO2020143555A1 (en) Method and device used for displaying information
CN111857858A (en) Method and apparatus for processing information
CN111596991A (en) Interactive operation execution method and device and electronic equipment
CN110704833A (en) Data permission configuration method, device, electronic device and storage medium
CN112737927A (en) Information display method and device and electronic equipment
CN110619100A (en) Method and apparatus for acquiring data
CN111881216A (en) Data acquisition method and device based on shared template
CN111694629A (en) Information display method and device and electronic equipment
CN114116247A (en) Redis-based message processing method, device, system, server and medium
CN110708238B (en) Method and apparatus for processing information
WO2020233171A1 (en) Song list switching method, apparatus and system, terminal, and storage medium
CN110619101B (en) Method and apparatus for processing information
CN110442416B (en) Method, electronic device and computer-readable medium for presenting information
CN112148744A (en) Page display method and device, electronic equipment and computer readable medium
CN111756953A (en) Video processing method, device, equipment and computer readable medium
CN111813685A (en) Automatic testing method and device
CN113628097A (en) Image special effect configuration method, image recognition method, image special effect configuration device and electronic equipment
CN112307393A (en) Information issuing method and device and electronic equipment
CN111385599B (en) Video processing method and device
CN111460211A (en) Audio information playing method and device and electronic equipment
CN113360704A (en) Voice playing method and device and electronic equipment
CN109889737B (en) Method and apparatus for generating video
CN113778387A (en) Method and apparatus for generating code

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