WO2021000512A1 - 自然语言转换成程序语言的方法、装置及计算机设备 - Google Patents

自然语言转换成程序语言的方法、装置及计算机设备 Download PDF

Info

Publication number
WO2021000512A1
WO2021000512A1 PCT/CN2019/122480 CN2019122480W WO2021000512A1 WO 2021000512 A1 WO2021000512 A1 WO 2021000512A1 CN 2019122480 W CN2019122480 W CN 2019122480W WO 2021000512 A1 WO2021000512 A1 WO 2021000512A1
Authority
WO
WIPO (PCT)
Prior art keywords
natural language
entity
template
entities
program
Prior art date
Application number
PCT/CN2019/122480
Other languages
English (en)
French (fr)
Inventor
刘利
Original Assignee
深圳壹账通智能科技有限公司
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 深圳壹账通智能科技有限公司 filed Critical 深圳壹账通智能科技有限公司
Publication of WO2021000512A1 publication Critical patent/WO2021000512A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • G06F16/334Query execution
    • G06F16/3347Query execution using vector based model
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/903Querying
    • G06F16/90335Query processing
    • G06F16/90344Query processing by using string matching techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/33Intelligent editors

Definitions

  • This application relates to the field of computers, in particular to methods, devices and computer equipment for converting natural language into programming language.
  • This application provides a method, device, and computer equipment for converting natural language into programming language, aiming to solve the technical problem that the corresponding programming content cannot be effectively searched and called through natural language sentences.
  • this application proposes a method for converting natural language into programming language, including:
  • All the entities are respectively filled into the slots to be filled in the program template to generate the program language corresponding to the natural language sentence.
  • this application also provides a device for converting natural language into programming language, including:
  • the distinguishing module is used to distinguish all entity types included in the natural language sentence, and extract all entities corresponding to the entity types;
  • the matching module is used to match natural language templates according to all the entity types
  • a conversion module for converting the natural language template into a program language template through a pre-trained neural network model, wherein the program language template carries a slot to be filled;
  • the filling module is used to fill all the entities corresponding to the slots to be filled in the program template to generate the program language corresponding to the natural language sentence.
  • the present application also provides a computer device, including a memory and a processor, the memory stores a computer program, and the processor implements the steps of the foregoing method when the computer program is executed.
  • the present application also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above method are implemented.
  • Fig. 1 is a schematic flow chart of a method for converting natural language into programming language according to an embodiment of the present application
  • Fig. 2 is a schematic structural diagram of an apparatus for converting natural language into programming language according to an embodiment of the present application
  • Fig. 3 is a schematic diagram of the internal structure of a computer device according to an embodiment of the present application.
  • the method for converting natural language into programming language includes:
  • S4 Transform the natural language template into a program language template through a pre-trained neural network model, where the program language template carries a slot to be filled.
  • the entity type in the natural language sentence is extracted, and the natural language template is generated according to the extracted entity type, and then the natural language template is input into the trained neural network, and the natural language template is calculated and iterated through fitting It is calculated and converted into a program template, and a slot to be filled is reserved in the filling program template through training design, which is used to fill the entities in the natural language sentence into the program template to form a program language corresponding to the natural language sentence.
  • the above entity type is the word type corresponding to the main word used to represent the natural language sentence, such as file name, path name, absolute path name, time, etc.
  • the above entity includes file name, path name, absolute path name, time, etc. The corresponding assignment.
  • the above process of extracting entity types is a process of identifying main words for semantic recognition, that is, the extracted words retain the original semantic expression of the original natural language sentence.
  • the natural language template is a sequence formed by the entity types corresponding to the main words respectively according to the sequence in the original natural language sentence. Then, by inputting the above sequence into the trained neural network, through the fitting and iterative calculation in encoding and decoding, the natural language template is gradually transformed into a sequence of program templates, and slots to be filled are reserved.
  • the natural language template is gradually transformed into a sequence of program templates, and slots to be filled are reserved.
  • step S5 of filling all the entities corresponding to the slots to be filled in the program template to generate the program language corresponding to the natural language sentence includes:
  • S51 Determine a first entity matching the first slot according to a preset matching calculation formula, where the first entity is included in all the entities, and the first slot is included in all the slots to be filled.
  • S53 Complete the filling of all the slots to be filled in the program template according to the filling process of the first slot, and generate the program language.
  • the entity and the slot are matched and matched, so that the entity is accurately filled in the slot, which solves the problem of aligning the correct input character string with the parameter value of the output command.
  • the preset matching calculation formula of this embodiment is completed by improving the k-nearest neighbor algorithm through the local matching function. Since the Euclidean distance in the existing k-nearest neighbor algorithm is not suitable for the matching of slots and entities in this application, There is no specific corresponding vector between the slot and the entity in the application.
  • the data pair composed of the closest entity and the slot is spliced into a long vector, and the similarity between the two long vectors is calculated to obtain the to-be-matched The match between the slot and the entity.
  • step S51 of determining the first entity matching the first slot according to the preset matching calculation formula includes:
  • S512 Determine the designated entity corresponding to the first slot when the matching score value is the largest.
  • the k-nearest neighbor algorithm is improved by the local matching function.
  • the principle of judging the similarity by calculating the probability of occurrence in the adjacent area is improved to be by selecting the distance to be matched entity and slot data pair
  • the latest entity and slot data pairs with matching data have been marked, and the matching scores of the two pairs of entity and slot data pairs are calculated to overcome the problem that the existing entities and slots cannot directly map the vector accurately, and through improved
  • the k-nearest neighbor algorithm reduces the amount of calculation and improves the matching accuracy of entities and slots.
  • the above-mentioned second entity e c and second slot s d correspond to a hidden layer variable h c , h d ⁇ in the Encoder model and the Decoder model, respectively, by concatenating the variables to form
  • the long vector (h c , h d ⁇ ) composes the reference entity and slot data pair, and identifies the matching state, the matching flag is 1, and the ratio matching flag is 0.
  • the first grooves respectively match all of the entities, entities and compositions comprising a plurality of data slots of a first slot
  • the same h i indicates the hidden layer are all entities in the variables in the model corresponding to the Encoder
  • the long vector (h i , h j ⁇ ) is formed by splicing, and the distance value is selected by filtering the entity and slot data pair of the first slot to be analyzed
  • the latest second entity and second slot that have been marked with matching status, and the matching score value of the second entity and second slot with the marked matching status is calculated. The larger the matching score, the greater the number of the first slot to be analyzed.
  • the entity and slot data pairs are more similar to the second entity and the second slot whose matching status has been marked. For example, if the second entity and the second slot that have been marked with a matching state are marked as matching, the entity and slot data pair of the first slot to be analyzed similar to it is also presumed to be a match, so that the entity and the slot are accurately corresponded.
  • the neural network model includes an encoding-decoding model
  • the step S4 of converting the natural language template into a program language template through a pre-trained neural network model includes:
  • S41 Input the natural language template into the hidden layer of the pre-trained decoding and coding model, and perform fitting to obtain a fitted natural language template and output it, wherein the hidden layer of the decoding and coding model includes a first specified number of morphologies , The first designated number is the same as the number of entity types included in the natural language template.
  • the hidden layer of the Encoder implements the dimensionality reduction and fitting of the natural language template, reduces the complexity in the processing process, and improves the correct recognition rate of the extracted features of the natural language template.
  • the Encoder includes 4 hidden layers corresponding to 7 fitting shapes H1 to H7, and the step size of each layer of LSTM is set to 20; on the MSCOCO data set, the hidden layer output is set to 1000, and on Flickr30K data On the set, the output of the hidden layer of LSTM is 512, and on Flickr8K, the output of the hidden layer is set to 256 to improve the dimensionality reduction effect.
  • the hidden layer of the Decoder in this embodiment receives the last hidden layer fitting form output by the Encoder as input, and after multiple iterations of input and output, a sorted list of the program language templates is obtained, and the waiting list is retained according to the preset mode. Fill the slot.
  • the hidden layer of the Encoder and the hidden layer of the Decoder are connected, and the best parameters are trained through the marked training samples, so that the program template output by the Encoder-Decoder model is infinitely close to the preset mode.
  • step S42 of inputting the fitted natural language template into the hidden layer of the pre-trained decoding model and converting it into a sorted list of the program language templates through iterative input calculation and outputting includes:
  • S421 Use the fitted natural language template as the first input data, input it into the first gradient layer of the hidden layer of the decoding model, determine and output the first entity type corresponding to the vector with the highest weight coefficient.
  • S422 Use the calculation data of the first entity type and the first gradient layer as second input data, and input it into the second gradient layer of the hidden layer of the decoding model, and determine the second entity corresponding to the vector with the second highest weight coefficient Type and output, where the first gradient layer and the second gradient layer are adjacently connected iterative layers in the hidden layer of the decoding model.
  • S423 According to the iterative process from the first input data to the second input data, sequentially iteratively input to the hidden layer of the decoding model until all the main words of the natural language sentence are determined, wherein each of the The main words are respectively determined according to the ranking of the respective weight coefficients, and the ranking of the program language templates is formed according to the ranking of the weight coefficients.
  • multiple interconnected gradient layers are used to perform iterative input and output, such as H1 ⁇ to H5 ⁇ , and the last hidden layer output by the Encoder is fitted to the shape, that is, the fitted natural language template is used as the first input data.
  • Input to H1 ⁇ of the hidden layer of Decoder output the first entity type Y1 ⁇ that is most important to the original semantics of natural language sentences, and then use Y1 ⁇ and the process data of calculating and extracting Y1 ⁇ as the input of H2 ⁇ at the same time.
  • the second entity type Y2 ⁇ which is the second most important in the original semantics of the language sentence, then uses Y2 ⁇ and the process data of calculating and extracting Y2 ⁇ as the input of H3 ⁇ at the same time, and iteratively performs calculation and extraction until the output includes all entities of the preset number A list of the program language templates of the type.
  • the list of the sequenced program language templates obtained is: Y1: find[path]-name[regex]-mtime[+Timespan]; Y2:find[path]-type f-name[regex]-mtime [+Timespan]; Y3:find[path]-type f-perm[permission]; Y4:find[path]-name[regex]-mtime[+Timespan]xargs ls; Y5:....
  • step S2 of distinguishing all entity types included in the natural language sentence and extracting entities corresponding to all the entity types respectively includes:
  • S21 Invoke a regular expression pre-configured according to the constituent elements of the program template, where the regular expression includes at least two types.
  • S22 Determine according to the first regular expression whether the natural language sentence contains a specified entity type adapted to the first regular expression, wherein the first regular expression is included in all the regular expressions in.
  • different entity types are identified by matching different regular expressions, and corresponding entities are extracted.
  • the method is simple, the amount of calculation is small, and the accuracy of identifying and extracting entities is high.
  • By sequentially inputting the natural language sentence into each regular expression it is judged whether the natural language sentence includes an entity type matching the current regular expression, and if it exists, the entity is extracted.
  • the arrangement of the multiple regular expressions in this embodiment can be arranged in descending order according to the important procedures of each entity type in advance, so that the recognized entity types are arranged in the order of importance.
  • the entity types include pattern entities and quantity entities
  • the step S3 of matching natural language templates according to all the entity types includes:
  • the entity types in this embodiment include multiple pattern entities and multiple quantity entities, for example, five pattern entities, including: "File: file name; Directory: directory name; Path: absolute path; Date/Time: date and time expression; Regex: other pattern arguments", and 3 quantitative entities, including "Number: number; Size: file size; Timespan: time duration” to fully cover all the main words of natural language sentences.
  • the natural language template is formed by determining the different entity types and the importance ranking of the natural language sentences corresponding to the different entity types. At the same time, the entities corresponding to the different entity types are determined and extracted as the assignment of the slot to be filled. For example, if the user enters "find all log files older than 15 days", the main words include “file name: log; Timespan: 15 days”, and the corresponding natural language template is: find all[file name]files older than[Timespan].
  • the apparatus for converting natural language into program language includes:
  • the obtaining module 1 is used to obtain natural language sentences input by the user.
  • the distinguishing module 2 is used to distinguish all entity types included in the natural language sentence, and extract all entities corresponding to the entity types.
  • the matching module 3 is used for matching natural language templates according to all the entity types.
  • the conversion module 4 is used to convert the natural language template into a program language template through a pre-trained neural network model, wherein the program language template carries a slot to be filled.
  • the filling module 5 is used to fill all the entities corresponding to the slots to be filled in the program template to generate the program language corresponding to the natural language sentence.
  • the entity type in the natural language sentence is extracted, and the natural language template is generated according to the extracted entity type, and then the natural language template is input into the trained neural network, and the natural language template is calculated and iterated through fitting It is calculated and converted into a program template, and a slot to be filled is reserved in the filling program template through training design, which is used to fill the entities in the natural language sentence into the program template to form a program language corresponding to the natural language sentence.
  • the above entity type is the word type corresponding to the main word used to represent the natural language sentence, such as file name, path name, absolute path name, time, etc.
  • the above entity includes file name, path name, absolute path name, time, etc. The corresponding assignment.
  • the above process of extracting entity types is a process of identifying main words for semantic recognition, that is, the extracted words retain the original semantic expression of the original natural language sentence.
  • the natural language template is a sequence formed by the entity types corresponding to the main words respectively according to the sequence in the original natural language sentence. Then, by inputting the above sequence into the trained neural network, through the fitting and iterative calculation in encoding and decoding, the natural language template is gradually transformed into a sequence of program templates, and slots to be filled are reserved.
  • the natural language template is gradually transformed into a sequence of program templates, and slots to be filled are reserved.
  • an embodiment of the present application also provides a computer device.
  • the computer device may be a server, and its internal structure may be as shown in FIG. 3.
  • the computer equipment includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the computer designed processor is used to provide calculation and control capabilities.
  • the memory of the computer device includes non-volatile and/or volatile storage media and internal memory.
  • the non-volatile and/or volatile storage medium stores an operating system, a computer program, and a database.
  • the memory provides an environment for the operation of the operating system and computer programs in the non-volatile and/or volatile storage medium.
  • the database of the computer equipment is used to store all the data required for the address matching process.
  • the network interface of the computer device is used to communicate with an external terminal through a network connection.
  • the computer program is executed by the processor to realize the method of converting natural language into programming language.
  • the above-mentioned processor executes the above-mentioned method of converting natural language into a programming language, including: obtaining a natural language sentence input by a user; distinguishing all entity types included in the natural language sentence, and extracting all entities corresponding to the entity types; All the entity types match a natural language template; the natural language template is converted into a program language template through a pre-trained neural network model, wherein the program language template carries a slot to be filled; and all the entities are respectively filled to The slot to be filled in the program template generates a program language corresponding to the natural language sentence.
  • the above-mentioned computer equipment extracts the entity type in the natural language sentence, and generates the natural language template according to the extracted entity type, and then inputs the natural language template into the trained neural network, and the natural language template is calculated by fitting and Iterative calculation is converted into a program template, and a slot to be filled is reserved in the filling program template through training design, which is used to fill the entities in the natural language sentence into the program template to form the program language corresponding to the natural language sentence.
  • the k-nearest neighbor algorithm is improved by the local matching function, which solves the problem that the Euclidean distance in the existing k-nearest neighbor algorithm is not suitable for the matching of slots and entities in this application.
  • the data pair of is spliced into a long vector, and the matching degree between the slot to be matched and the entity is obtained by calculating the similarity between the two long vectors.
  • the accurate alignment of the slot and the entity is realized, and the accurate correspondence from the natural language sentence to the programming language is improved.
  • the method is simple, the amount of calculation is small, and the accuracy of identifying and extracting entities is high.
  • the above-mentioned processor fills all the entities corresponding to the slots to be filled in the program template, and generates the program language corresponding to the natural language sentence, including: calculating according to preset matching The formula determines the first entity matching the first slot, where the first entity is included in all the entities, and the first slot is included in all the slots to be filled; if so, the first Physically filling the first slot; completing the filling of all the slots to be filled in the program template according to the filling process of the first slot to generate the program language.
  • the step of the processor determining the first entity matching the first slot according to the preset matching calculation formula includes: using the calculation formula Calculate the matching score values between all the entities and the first slot respectively, where h i represents the vector corresponding to all the entities, h j ⁇ represents the vector corresponding to the first slot, (e c , s d ) is the second entity and the second slot with the marked matching state, and h c represents all The vector corresponding to the second entity e c , h d ⁇ represents the vector corresponding to the second slot s d ; when it is determined that the matching score value is the largest, the designated entity corresponding to the first slot is determined; the designated entity Determined as the first entity.
  • the neural network model includes an encoding-decoding model
  • the step of converting the natural language template into a program language template by the processor through a pre-trained neural network model includes: inputting the natural language template In the hidden layer of the pre-trained decoding and coding model, fitting is performed to obtain the fitted natural language template and output, wherein the hidden layer of the decoding and coding model includes a first specified number of morphologies, and the first specified number is The number of entity types included in the natural language template is the same; the fitted natural language template is input into the hidden layer of the pre-trained decoding model, and it is converted into a sorted list of the program language templates through iterative input calculations and output , Wherein the program language template reserves the slot to be filled according to a preset format.
  • the above-mentioned processor inputs the fitted natural language template into the hidden layer of the pre-trained decoding model, and converts it into a sorted list of the program language templates through iterative input calculations and outputs the steps, including : Use the fitted natural language template as the first input data, input it into the first gradient layer of the hidden layer of the decoding model, determine and output the first entity type corresponding to the vector with the highest weight coefficient; and output the first entity
  • the type and the calculation data of the first gradient layer are used as the second input data, which is input to the second gradient layer of the hidden layer of the decoding model, and the second entity type corresponding to the vector with the second highest weight coefficient is determined and output.
  • a gradient layer and a second gradient layer are adjacently connected iterative layers in the hidden layer of the decoding model; according to the iterative process from the first input data to the second input data, iteratively input to the decoding
  • the hidden layer of the model until all the main words of the natural language sentence are determined, wherein each main word is determined according to the ranking of the respective weight coefficients, and the ranking of the program language templates is formed according to the ranking of the weight coefficients list of.
  • the above-mentioned processor distinguishes all entity types included in the natural language sentence, and extracts the entities corresponding to all the entity types, including: invoking the pre-configured according to the constituent elements of the program template Regular expressions, wherein the types of the regular expressions include at least two types; judging according to the first regular expression whether the natural language sentence contains a specified entity type adapted to the first regular expression, wherein, The first regular expression is included in all the regular expressions; if it is, the entity corresponding to the specified entity type is extracted through the first regular expression.
  • the entity types include pattern entities and quantity entities.
  • the step of matching natural language templates according to all the entity types includes: obtaining entities and entity quantities corresponding to the pattern entities, and The number of entities and the number of entities corresponding to the quantity type entities; according to the number of entities and the number of entities corresponding to the pattern type entities, and the number of entities and the number of entities corresponding to the quantity type entities, the corresponding pattern entities are arranged in a preset order The entities of and the entities corresponding to the quantitative entities form the natural language template.
  • FIG. 3 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied.
  • An embodiment of the present application also provides a computer-readable storage medium.
  • the computer-readable storage medium may be non-volatile or volatile.
  • a computer program is stored thereon.
  • the method for realizing the conversion of natural language into programming language includes: obtaining natural language sentences input by users; distinguishing all entity types included in the natural language sentences, and extracting entities corresponding to all the entity types; according to all the entities Type matching natural language template; convert the natural language template into a program language template through a pre-trained neural network model, wherein the program language template carries a slot to be filled; and fill all the entities into the program template correspondingly The slot to be filled in, generates the programming language corresponding to the natural language sentence.
  • the above-mentioned non-volatile and/or volatile computer-readable storage medium extracts the entity types in natural language sentences, generates natural language templates according to the extracted entity types, and then inputs the natural language templates into the trained In the neural network, the natural language template is converted into a program template through fitting calculation and iterative calculation, and a slot to be filled is reserved in the filling program template through training design, which is used to fill the entities in the natural language sentence into the program template In, the programming language corresponding to the natural language sentence is formed.
  • the k-nearest neighbor algorithm is improved by the local matching function, which solves the problem that the Euclidean distance in the existing k-nearest neighbor algorithm is not suitable for the matching of slots and entities in this application.
  • the data pair of is spliced into a long vector, and the matching degree between the slot to be matched and the entity is obtained by calculating the similarity between the two long vectors.
  • the accurate alignment of the slot and the entity is realized, and the accurate correspondence from the natural language sentence to the programming language is improved.
  • the method is simple, the amount of calculation is small, and the accuracy of identifying and extracting entities is high.
  • the above-mentioned processor fills all the entities corresponding to the slots to be filled in the program template, and generates the program language corresponding to the natural language sentence, including: calculating according to preset matching The formula determines the first entity matching the first slot, wherein the first entity is included in all the entities, and the first slot is included in all the slots to be filled; if so, the first entity is Physically filling the first slot; completing the filling of all the slots to be filled in the program template according to the filling process of the first slot to generate the program language.
  • the step of the processor determining the first entity matching the first slot according to the preset matching calculation formula includes: using the calculation formula Calculate the matching score values between all the entities and the first slot respectively, where h i represents the vector corresponding to all the entities, h j ⁇ represents the vector corresponding to the first slot, (e c , s d ) is the second entity and the second slot with the marked matching state, and h c represents all The vector corresponding to the second entity e c , h d ⁇ represents the vector corresponding to the second slot s d ; when it is determined that the matching score value is the largest, the designated entity corresponding to the first slot is determined; the designated entity Determined as the first entity.
  • the neural network model includes an encoding-decoding model
  • the step of converting the natural language template into a program language template by the processor through a pre-trained neural network model includes: inputting the natural language template In the hidden layer of the pre-trained decoding and coding model, fitting is performed to obtain the fitted natural language template and output, wherein the hidden layer of the decoding and coding model includes a first specified number of morphologies, and the first specified number is The number of entity types included in the natural language template is the same; the fitted natural language template is input into the hidden layer of the pre-trained decoding model, and it is converted into a sorted list of the program language templates through iterative input calculations and output , Wherein the program language template reserves the slot to be filled according to a preset format.
  • the above-mentioned processor inputs the fitted natural language template into the hidden layer of the pre-trained decoding model, and converts it into a sorted list of the program language templates through iterative input calculations and outputs the steps, including : Use the fitted natural language template as the first input data, input it into the first gradient layer of the hidden layer of the decoding model, determine and output the first entity type corresponding to the vector with the highest weight coefficient; and output the first entity
  • the type and the calculation data of the first gradient layer are used as the second input data, which is input to the second gradient layer of the hidden layer of the decoding model, and the second entity type corresponding to the vector with the second highest weight coefficient is determined and output.
  • a gradient layer and a second gradient layer are adjacently connected iterative layers in the hidden layer of the decoding model; according to the iterative process from the first input data to the second input data, iteratively input to the decoding
  • the hidden layer of the model until all the main words of the natural language sentence are determined, wherein each main word is determined according to the ranking of the respective weight coefficients, and the ranking of the program language templates is formed according to the ranking of the weight coefficients list of.
  • the above-mentioned processor distinguishes all entity types included in the natural language sentence, and extracts the entities corresponding to all the entity types, including: invoking the pre-configured according to the constituent elements of the program template Regular expressions, wherein the types of the regular expressions include at least two types; judging according to the first regular expression whether the natural language sentence contains a specified entity type adapted to the first regular expression, wherein, The first regular expression is included in all the regular expressions; if it is, the entity corresponding to the specified entity type is extracted through the first regular expression.
  • the entity types include pattern entities and quantity entities.
  • the step of matching natural language templates according to all the entity types includes: obtaining entities and entity quantities corresponding to the pattern entities, and The number of entities and the number of entities corresponding to the quantity type entities; according to the number of entities and the number of entities corresponding to the pattern type entities, and the number of entities and the number of entities corresponding to the quantity type entities, the corresponding pattern entities are arranged in a preset order The entities of and the entities corresponding to the quantitative entities form the natural language template.
  • Non-volatile memory may include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory.
  • Volatile memory may include random access memory (RAM) or external cache memory.
  • RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual-rate SDRAM (SSRSDRAM), enhanced SDRAM (ESDRAM), synchronous Link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Software Systems (AREA)
  • Machine Translation (AREA)
  • Stored Programmes (AREA)

Abstract

一种自然语言转换成程序语言的方法、装置及计算机设备,其中,自然语言转换成程序语言的方法,包括:获取用户输入的自然语言语句(S1);区分所述自然语言语句中包括的所有实体类型,并提取所有所述实体类型分别对应的实体(S2);根据所有所述实体类型匹配自然语言模板(S3);将所述自然语言模板通过预训练的神经网络模型转换成程序语言模板,其中所述程序语言模板携带待填充槽(S4);将所有所述实体分别对应填充至所述程序模板中的所述待填充槽,生成所述自然语言语句对应的程序语言(S5)。通过训练设计使填充程序模板中预留了待填充槽,用于将自然语言语句中的实体填充至程序模板中,形成自然语言语句对应的程序语言。

Description

自然语言转换成程序语言的方法、装置及计算机设备
本申请要求于2019年7月4日提交中国专利局、申请号为201910600648.5、发明名称为“自然语言转换成程序语言的方法、装置及计算机设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及到计算机领域,特别是涉及到自然语言转换成程序语言的方法、装置及计算机设备。
背景技术
现有技术中,没有程序语言和自然语言语句的对译工具,通常情况下程序员在编程过程中可能会遇到可以用自然语言描述他构想好的实现方案,但是却在将其翻译成代码过程中遇到技术困难;而且现有的互联网资源,比如问答类型的网站,将程序员提交的编程问题制成程序表格,当设计新任务或复合任务,需要结合历史的编程内容时,无法通过自然语言语句实现对相应编程内容的有效的查找和调用。
发明内容
本申请提供了一种自然语言转换成程序语言的方法、装置及计算机设备,旨在解决无法通过自然语言语句实现对相应编程内容的有效的查找和调用的技术问题。
第一方面,本申请提出一种自然语言转换成程序语言的方法,包括:
获取用户输入的自然语言语句;
区分所述自然语言语句中包括的所有实体类型,并提取所有所述实体类型分别对应的实体;
根据所有所述实体类型匹配自然语言模板;
将所述自然语言模板通过预训练的神经网络模型转换成程序语言模板,其中所述程序语言模板携带待填充槽;
将所有所述实体分别对应填充至所述程序模板中的所述待填充槽,生成所述自然语言语句对应的程序语言。
第二方面,本申请还提供了一种自然语言转换成程序语言的装置,包括:
获取模块,用于获取用户输入的自然语言语句;
区分模块,用于区分所述自然语言语句中包括的所有实体类型,并提取所有所述实体类型分别对应的实体;
匹配模块,用于根据所有所述实体类型匹配自然语言模板;
转换模块,用于将所述自然语言模板通过预训练的神经网络模型转换成程序语言模板,其中,所述程序语言模板携带待填充槽;
填充模块,用于将所有所述实体分别对应填充至所述程序模板中的所述待填充槽,生成所述自然语言语句对应的程序语言。
第三方面,本申请还提供了一种计算机设备,包括存储器和处理器,所述存储器存储有计算机程序,所述处理器执行所述计算机程序时实现上述方法的步骤。
第四方面,本申请还提供了一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现上述的方法的步骤。
附图说明
图1本申请一实施例的自然语言转换成程序语言的方法流程示意图;
图2本申请一实施例的自然语言转换成程序语言的装置结构示意图;
图3本申请一实施例的计算机设备内部结构示意图。
具体实施方式
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。
参照图1,本申请一实施例的自然语言转换成程序语言的方法,包括:
S1:获取用户输入的自然语言语句。
S2:区分所述自然语言语句中包括的所有实体类型,并提取所有所述实体类型分别对应的实体。
S3:根据所有所述实体类型匹配自然语言模板。
S4:将所述自然语言模板通过预训练的神经网络模型转换成程序语言模板,其中,所述程序语言模板携带待填充槽。
S5:将所有所述实体分别对应填充至所述程序模板中的所述待填充槽,生成所述自然语言语句对应的程序语言。
本实施例通过将自然语言语句中的实体类型提取出来,并根据提取的实体类型生成自然语言模板,然后将自然语言模板输入到训练好的神经网络中,将自然语言模板通过拟合计算以及迭代计算,转换成程序模板,并通过训练设计使填充程序模板中预留了待填充槽,用于将自然语言语句中的实体填充至程序模板中,形成自然语言语句对应的程序语言。上述实体类型为用于表示自然语言语句的主干词语对应的词语类型,比如包括文件名,路径名,绝对路径名、时间等,上述的实体包括文件名,路径名,绝对路径名、时间等分别对应的赋值。上述提取实体类型的过程,为识别语义确定主干词语的过程,即提取出的词保留了原自然语言语句的原始语义表达。上述自然语言模板为上述主干词语分别对应的实体类型,按照在原自然语言语句中的排列次序而形成的序列。然后通过将上述序列输入到训练好的神经网络中,通过编码和解码中的拟合和迭代计算,使自然语言模板逐渐转变为程序模板的序列,并预留了待填充槽。本实施例通过将自然语言语句直接转换为程序语言,实现能够让编程人员使用自然语言来表达预期的操作,方便程序员审查和使用。
进一步地,所述将所有所述实体分别对应填充至所述程序模板中的所述待填充槽,生成所述自然语言语句对应的程序语言的步骤S5,包括:
S51:根据预设匹配计算公式确定与第一槽匹配的第一实体,其中,所述第一实体包含于所有所述实体中,所述第一槽包含于所有所述待填充的槽。
S52:若是,则将所述第一实体填充至所述第一槽中。
S53:按照所述第一槽的填充过程完成所述程序模板中的所有所述待填充槽的填充,生成所述程序语言。
本实施例通过将实体和槽进行匹配配对,实现将实体准确填充于槽,解决了将将正确的输入字符串与输出命令的参数值对齐。本实施例的预设匹配计算公式为通过局部匹配函数改进了k-近邻算法来完成的,由于现有k-近邻算法中的欧式距离等不适用于本申请中的槽和实体的匹配,本申请中的槽和实体无具体对应的向量,本实施例通过将距离最近的实体和槽组成的数据对,拼接为一个长向量,通过计算两个长向量之间的相似度,进而得到待匹配的槽和实体之间的匹配度。通过上述方式实现槽与实体的准确对齐,提高从自然语言语句到程序语言的准确对应性。
进一步地,所述根据预设匹配计算公式确定与第一槽匹配的第一实体的 步骤S51,包括:
S511:通过计算公式
Figure PCTCN2019122480-appb-000001
分别计算所有所述实体与所述第一槽之间的匹配分数值,其中
Figure PCTCN2019122480-appb-000002
Figure PCTCN2019122480-appb-000003
h i表示所有所述实体分别对应的向量,h j`表示所述第一槽对应的向量,(e c,s d)为已标注匹配状态的第二实体和第二槽,h c表示所述第二实体e c对应的向量,h d`表示所述第二槽s d对应的向量。
S512:确定所述匹配分数值最大时,与所述第一槽对应的指定实体。
S513:将所述指定实体确定为所述第一实体。
本实施例中,通过局部匹配函数改进了k-近邻算法,根据k-近邻算法通过计算在相邻区域内出现概率,来判断相似性的原理,改进成通过选择距离待匹配实体和槽数据对最近的已标记匹配数据的实体和槽数据对,并计算上述两对实体和槽数据对的匹配分数值,来克服现有实体和槽之间无法直接实现准确映射向量的问题,且通过改进的k-近邻算法,减少了计算量且提高了实体和槽的匹配准确度。举例地,上述第二实体e c和第二槽s d,分别在编码模型(Encoder model)和解码模型(Decoder model)里对应一个隐藏层变量h c,h d`,通过将变量拼接,形成长向量(h c,h d`),组成了参照实体和槽数据对,且标识了匹配状态,匹配标识为1,比匹配标识为0。通过已确定的待填充槽,即第一槽,分别匹配所有的实体,组成多个包括第一槽的实体和槽数据对,同样h i表示所有实体分别在Encoder模型里对应的隐藏层变量,h j`表示所述第一槽Decoder模型里对应的隐藏层变量,通过拼接形成长向量(h i,h j`),通过筛选距离待分析的第一槽的实体和槽数据对,距离值最近的已标注匹配状态的第二实体和第二槽,并计算与已标注匹配状态的第二实体和第二槽的匹配分数值,匹配分数值越大,则表明待分析的第一槽的实体和槽数据对,与已标注匹配状态的第二实体和第二槽越相似。比如已标注匹配状态的第二实体和第二槽标注为匹配,则跟它相似的待分析的第一槽的实体和槽数据对也推定为匹配,实现实体和槽的准确对应。
进一步地,所述神经网络模型包括编码-解码模型,所述将所述自然语言模板通过预训练的神经网络模型转换成程序语言模板的步骤S4,包括:
S41:将所述自然语言模板输入预训练的解码编码模型的隐藏层中,进行拟合得到拟合态自然语言模板并输出,其中,所述解码编码模型的隐藏层包含第一指定数量的形态,所述第一指定数量与所述自然语言模板中包含的实体类型的数量相同。
S42:将所述拟合态自然语言模板输入预训练的解码模型的隐藏层,通过迭代输入计算转换为已排序的所述程序语言模板的列表并输出,其中所述程序语言模板按照预设格式保留所述待填充槽。
本实施例通过Encoder的隐藏层实现对自然语言模板的降维拟合,降低处理过程中的复杂度,且提高了对自然语言模板的提取特征的正确识别率。本实施例中Encoder包括4层隐藏层对应7个拟合形态依次为H1至H7,将每层LSTM的步长设置为20;在MSCOCO数据集上,其隐层输出设置为1000,在Flickr30K数据集上,LSTM隐层输出为512,在Flickr8K上,隐层输出设置为256,以提高降维效果。本实施例的Decoder的隐藏层通过接收Encoder输出的最后一个隐藏层拟合形态作为输入,经过多次迭代输入输出,得到已排序的所述程序语言模板的列表,并按照预设模式保留了待填充槽。上述的Encoder的隐藏层和Decoder的隐藏层相连,且均通过已标记的训练样本训练出最佳参量,使Encoder-Decoder模型输出的程序模板无限接近预设模式。
进一步地,所述将所述拟合态自然语言模板输入预训练的解码模型的隐藏层,通过迭代输入计算转换为已排序的所述程序语言模板的列表并输出的步骤S42,包括:
S421:将所述拟合态自然语言模板作为第一输入数据,输入到解码模型的隐藏层的第一梯度层,确定权重系数最高的向量对应的第一实体类型并输出。
S422:将所述第一实体类型与所述第一梯度层的计算数据作为第二输入数据,输入到解码模型的隐藏层的第二梯度层,确定权重系数次高的向量对应的第二实体类型并输出,其中所述第一梯度层和第二梯度层为所述解码模型的隐藏层中相邻连接的迭代层。
S423:按照由所述第一输入数据到所述第二输入数据的迭代过程,依次迭代输入至所述解码模型的隐藏层,至确定出所述自然语言语句的所有主干词语,其中各所述主干词语分别根据各自对应的权重系数的排序确定,并根 据权重系数的排序,形成排序的所述程序语言模板的列表。
本实施例通过多个相互连接的梯度层,进行迭代输入输出,比如包括H1`至H5`,将Encoder输出的最后一个隐藏层拟合形态,即拟合态自然语言模板作为第一输入数据,输入到Decoder的隐藏层的H1`,输出对自然语言语句的原语义最重要的第一实体类型Y1`,然后将Y1`以及计算提取Y1`的过程数据同时作为H2`的输入,输出对自然语言语句的原语义次重要的第二实体类型Y2`,然后将将Y2`以及计算提取Y2`的过程数据同时作为H3`的输入,依次迭代进行计算提取,直至输出包括预设数量的所有实体类型的所述程序语言模板的列表。举例地,用户输入“查找15天前的日志文件”,对应的自然语言模板为:find all[file name]files older than[Timespan],经过Encoder拟合输出后,经过Decoder的隐藏层的迭代输入输出计算,得到的排序的所述程序语言模板的列表为:Y1:find[path]-name[regex]-mtime[+Timespan];Y2:find[path]-type f-name[regex]-mtime[+Timespan];Y3:find[path]-type f-perm[permission];Y4:find[path]-name[regex]-mtime[+Timespan]xargs ls;Y5:...。
进一步地,所述区分所述自然语言语句中包括的所有实体类型,并提取所有所述实体类型分别对应的实体的步骤S2,包括:
S21:调用根据所述程序模板的构成要素预配置的正则表达式,其中所述正则表达式的类型至少包括两种。
S22:根据第一正则表达式判断所述自然语言语句中,是否包含与所述第一正则表达式适配的指定实体类型,其中,所述第一正则表达式包含于所有所述正则表达式中。
S23:若是,则通过所述第一正则表达式提取所述指定实体类型对应的实体。
本实施例通过匹配不同的正则表达式来识别不同的实体类型,并提取相应的实体,方法简便,计算量小且识别提取实体的准确度高。通过将自然语言语句依次输入到各正则表达式中,以判断自然语言语句中是否包括与当前正则表达式匹配的实体类型,若存在,则提取出该实体。本实施例的多个正则表达式的排布可预先根据各实体类型的重要程序,依次降序排布,以便识别的实体类型按照重要次序形成排列。
进一步地,所述实体类型包括模式类实体和数量类实体,所述根据所有所述实体类型匹配自然语言模板的步骤S3,包括:
S31:分别获取所述模式类实体对应的实体和实体数量,以及所述数量类实体对应的实体和实体数量。
S32:根据所述所述模式类实体对应的实体和实体数量,以及所述数量类实体对应的实体和实体数量,按照预设次序排列所述模式类实体对应的实体和以及所述数量类实体对应的实体,形成所述自然语言模板。
本实施例的实体类型包括多个模式类实体和多个数量类实体,比如包括5个模式类实体,包括:“File:file name;Directory:directory name;Path:absolute path;Date/Time:date and time expression;Regex:other pattern arguments”,以及3个数量类实体,包括“Number:number;Size:file size;Timespan:time duration”,以尽量全面覆盖自然语言语句的所有主干词语。通过确定不同实体类型,以及各不同实体类型对应自然语言语句的重要性排序,形成自然语言模板,同时确定并提取各不同实体类型分别对应的实体,作为待填充槽的赋值。比如,用户输入“查找15天前的日志文件,即find all log files older than 15 days”,主干词语包括“file name:log;Timespan:15 days”,对应的自然语言模板为:find all[file name]files older than[Timespan]。
参照图2,本申请一实施例的自然语言转换成程序语言的装置,包括:
获取模块1,用于获取用户输入的自然语言语句。
区分模块2,用于区分所述自然语言语句中包括的所有实体类型,并提取所有所述实体类型分别对应的实体。
匹配模块3,用于根据所有所述实体类型匹配自然语言模板。
转换模块4,用于将所述自然语言模板通过预训练的神经网络模型转换成程序语言模板,其中,所述程序语言模板携带待填充槽。
填充模块5,用于将所有所述实体分别对应填充至所述程序模板中的所述待填充槽,生成所述自然语言语句对应的程序语言。
本实施例通过将自然语言语句中的实体类型提取出来,并根据提取的实体类型生成自然语言模板,然后将自然语言模板输入到训练好的神经网络中,将自然语言模板通过拟合计算以及迭代计算,转换成程序模板,并通过训练 设计使填充程序模板中预留了待填充槽,用于将自然语言语句中的实体填充至程序模板中,形成自然语言语句对应的程序语言。上述实体类型为用于表示自然语言语句的主干词语对应的词语类型,比如包括文件名,路径名,绝对路径名、时间等,上述的实体包括文件名,路径名,绝对路径名、时间等分别对应的赋值。上述提取实体类型的过程,为识别语义确定主干词语的过程,即提取出的词保留了原自然语言语句的原始语义表达。上述自然语言模板为上述主干词语分别对应的实体类型,按照在原自然语言语句中的排列次序而形成的序列。然后通过将上述序列输入到训练好的神经网络中,通过编码和解码中的拟合和迭代计算,使自然语言模板逐渐转变为程序模板的序列,并预留了待填充槽。本实施例通过将自然语言语句直接转换为程序语言,实现能够让编程人员使用自然语言来表达预期的操作,方便程序员审查和使用。
参照图3,本申请实施例中还提供一种计算机设备,该计算机设备可以是服务器,其内部结构可以如图3所示。该计算机设备包括通过系统总线连接的处理器、存储器、网络接口和数据库。其中,该计算机设计的处理器用于提供计算和控制能力。该计算机设备的存储器包括非易失性和/或易失性存储介质、内存储器。该非易失性和/或易失性存储介质存储有操作系统、计算机程序和数据库。该内存器为非易失性和/或易失性存储介质中的操作系统和计算机程序的运行提供环境。该计算机设备的数据库用于存储地址匹配的过程需要的所有数据。该计算机设备的网络接口用于与外部的端通过网络连接通信。该计算机程序被处理器执行时以实现自然语言转换成程序语言的方法。
上述处理器执行上述自然语言转换成程序语言的方法,包括:获取用户输入的自然语言语句;区分所述自然语言语句中包括的所有实体类型,并提取所有所述实体类型分别对应的实体;根据所有所述实体类型匹配自然语言模板;将所述自然语言模板通过预训练的神经网络模型转换成程序语言模板,其中,所述程序语言模板携带待填充槽;将所有所述实体分别对应填充至所述程序模板中的所述待填充槽,生成所述自然语言语句对应的程序语言。
上述计算机设备,通过将自然语言语句中的实体类型提取出来,并根据提取的实体类型生成自然语言模板,然后将自然语言模板输入到训练好的神经网络中,将自然语言模板通过拟合计算以及迭代计算,转换成程序模板,并通过训练设计使填充程序模板中预留了待填充槽,用于将自然语言语句中 的实体填充至程序模板中,形成自然语言语句对应的程序语言。通过将自然语言语句直接转换为程序语言,实现能够让编程人员使用自然语言来表达预期的操作,方便程序员审查和使用。通过局部匹配函数改进了k-近邻算法来完成,解决了现有k-近邻算法中的欧式距离等不适用于本申请中的槽和实体的匹配的问题,通过将距离最近的实体和槽组成的数据对,拼接为一个长向量,通过计算两个长向量之间的相似度,进而得到待匹配的槽和实体之间的匹配度。通过上述方式实现槽与实体的准确对齐,提高从自然语言语句到程序语言的准确对应性。通过匹配不同的正则表达式来识别不同的实体类型,并提取相应的实体,方法简便,计算量小且识别提取实体的准确度高。通过将自然语言语句依次输入到各正则表达式中,以判断自然语言语句中是否包括与当前正则表达式匹配的实体类型,若存在,则提取出该实体。
在一个实施例中,上述处理器将所有所述实体分别对应填充至所述程序模板中的所述待填充槽,生成所述自然语言语句对应的程序语言的步骤,包括:根据预设匹配计算公式确定与第一槽匹配的第一实体,其中,所述第一实体包含于所有所述实体中,所述第一槽包含于所有所述待填充的槽;若是,则将所述第一实体填充至所述第一槽中;按照所述第一槽的填充过程完成所述程序模板中的所有所述待填充槽的填充,生成所述程序语言。
在一个实施例中,上述处理器根据预设匹配计算公式确定与第一槽匹配的第一实体的步骤,包括:通过计算公式
Figure PCTCN2019122480-appb-000004
分别计算所有所述实体与所述第一槽之间的匹配分数值,其中
Figure PCTCN2019122480-appb-000005
Figure PCTCN2019122480-appb-000006
h i表示所有所述实体分别对应的向量,h j`表示所述第一槽对应的向量,(e c,s d)为已标注匹配状态的第二实体和第二槽,h c表示所述第二实体e c对应的向量,h d`表示所述第二槽s d对应的向量;确定所述匹配分数值最大时,与所述第一槽对应的指定实体;将所述指定实体确定为所述第一实体。
在一个实施例中,所述神经网络模型包括编码-解码模型,上述处理器将所述自然语言模板通过预训练的神经网络模型转换成程序语言模板的步骤,包括:将所述自然语言模板输入预训练的解码编码模型的隐藏层中,进行拟合得到拟合态自然语言模板并输出,其中,所述解码编码模型的隐藏层包含 第一指定数量的形态,所述第一指定数量与所述自然语言模板中包含的实体类型的数量相同;将所述拟合态自然语言模板输入预训练的解码模型的隐藏层,通过迭代输入计算转换为已排序的所述程序语言模板的列表并输出,其中所述程序语言模板按照预设格式保留所述待填充槽。
在一个实施例中,上述处理器将所述拟合态自然语言模板输入预训练的解码模型的隐藏层,通过迭代输入计算转换为已排序的所述程序语言模板的列表并输出的步骤,包括:将所述拟合态自然语言模板作为第一输入数据,输入到解码模型的隐藏层的第一梯度层,确定权重系数最高的向量对应的第一实体类型并输出;将所述第一实体类型与所述第一梯度层的计算数据作为第二输入数据,输入到解码模型的隐藏层的第二梯度层,确定权重系数次高的向量对应的第二实体类型并输出,其中所述第一梯度层和第二梯度层为所述解码模型的隐藏层中相邻连接的迭代层;按照由所述第一输入数据到所述第二输入数据的迭代过程,依次迭代输入至所述解码模型的隐藏层,至确定出所述自然语言语句的所有主干词语,其中各所述主干词语分别根据各自对应的权重系数的排序确定,并根据权重系数的排序,形成排序的所述程序语言模板的列表。
在一个实施例中,上述处理器区分所述自然语言语句中包括的所有实体类型,并提取所有所述实体类型分别对应的实体的步骤,包括:调用根据所述程序模板的构成要素预配置的正则表达式,其中所述正则表达式的类型至少包括两种;根据第一正则表达式判断所述自然语言语句中,是否包含与所述第一正则表达式适配的指定实体类型,其中,所述第一正则表达式包含于所有所述正则表达式中;若是,则通过所述第一正则表达式提取所述指定实体类型对应的实体。
在一个实施例中,所述实体类型包括模式类实体和数量类实体,根据所有所述实体类型匹配自然语言模板的步骤,包括:分别获取所述模式类实体对应的实体和实体数量,以及所述数量类实体对应的实体和实体数量;根据所述所述模式类实体对应的实体和实体数量,以及所述数量类实体对应的实体和实体数量,按照预设次序排列所述模式类实体对应的实体和以及所述数量类实体对应的实体,形成所述自然语言模板。
本领域技术人员可以理解,图3中示出的结构,仅仅是与本申请方案相 关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定。
本申请一实施例还提供一种计算机可读存储介质,该计算机可读存储介质可以是非易失性的,也可以是易失性的,其上存储有计算机程序,计算机程序被处理器执行时实现自然语言转换成程序语言的方法,包括:获取用户输入的自然语言语句;区分所述自然语言语句中包括的所有实体类型,并提取所有所述实体类型分别对应的实体;根据所有所述实体类型匹配自然语言模板;将所述自然语言模板通过预训练的神经网络模型转换成程序语言模板,其中,所述程序语言模板携带待填充槽;将所有所述实体分别对应填充至所述程序模板中的所述待填充槽,生成所述自然语言语句对应的程序语言。
上述非易失性和/或易失性计算机可读存储介质,通过将自然语言语句中的实体类型提取出来,并根据提取的实体类型生成自然语言模板,然后将自然语言模板输入到训练好的神经网络中,将自然语言模板通过拟合计算以及迭代计算,转换成程序模板,并通过训练设计使填充程序模板中预留了待填充槽,用于将自然语言语句中的实体填充至程序模板中,形成自然语言语句对应的程序语言。通过将自然语言语句直接转换为程序语言,实现能够让编程人员使用自然语言来表达预期的操作,方便程序员审查和使用。通过局部匹配函数改进了k-近邻算法来完成,解决了现有k-近邻算法中的欧式距离等不适用于本申请中的槽和实体的匹配的问题,通过将距离最近的实体和槽组成的数据对,拼接为一个长向量,通过计算两个长向量之间的相似度,进而得到待匹配的槽和实体之间的匹配度。通过上述方式实现槽与实体的准确对齐,提高从自然语言语句到程序语言的准确对应性。通过匹配不同的正则表达式来识别不同的实体类型,并提取相应的实体,方法简便,计算量小且识别提取实体的准确度高。通过将自然语言语句依次输入到各正则表达式中,以判断自然语言语句中是否包括与当前正则表达式匹配的实体类型,若存在,则提取出该实体。
在一个实施例中,上述处理器将所有所述实体分别对应填充至所述程序模板中的所述待填充槽,生成所述自然语言语句对应的程序语言的步骤,包括:根据预设匹配计算公式确定与第一槽匹配的第一实体,其中,所述第一实体包含于所有所述实体中,所述第一槽包含于所有所述待填充的槽;若是, 则将所述第一实体填充至所述第一槽中;按照所述第一槽的填充过程完成所述程序模板中的所有所述待填充槽的填充,生成所述程序语言。
在一个实施例中,上述处理器根据预设匹配计算公式确定与第一槽匹配的第一实体的步骤,包括:通过计算公式
Figure PCTCN2019122480-appb-000007
分别计算所有所述实体与所述第一槽之间的匹配分数值,其中
Figure PCTCN2019122480-appb-000008
Figure PCTCN2019122480-appb-000009
h i表示所有所述实体分别对应的向量,h j`表示所述第一槽对应的向量,(e c,s d)为已标注匹配状态的第二实体和第二槽,h c表示所述第二实体e c对应的向量,h d`表示所述第二槽s d对应的向量;确定所述匹配分数值最大时,与所述第一槽对应的指定实体;将所述指定实体确定为所述第一实体。
在一个实施例中,所述神经网络模型包括编码-解码模型,上述处理器将所述自然语言模板通过预训练的神经网络模型转换成程序语言模板的步骤,包括:将所述自然语言模板输入预训练的解码编码模型的隐藏层中,进行拟合得到拟合态自然语言模板并输出,其中,所述解码编码模型的隐藏层包含第一指定数量的形态,所述第一指定数量与所述自然语言模板中包含的实体类型的数量相同;将所述拟合态自然语言模板输入预训练的解码模型的隐藏层,通过迭代输入计算转换为已排序的所述程序语言模板的列表并输出,其中所述程序语言模板按照预设格式保留所述待填充槽。
在一个实施例中,上述处理器将所述拟合态自然语言模板输入预训练的解码模型的隐藏层,通过迭代输入计算转换为已排序的所述程序语言模板的列表并输出的步骤,包括:将所述拟合态自然语言模板作为第一输入数据,输入到解码模型的隐藏层的第一梯度层,确定权重系数最高的向量对应的第一实体类型并输出;将所述第一实体类型与所述第一梯度层的计算数据作为第二输入数据,输入到解码模型的隐藏层的第二梯度层,确定权重系数次高的向量对应的第二实体类型并输出,其中所述第一梯度层和第二梯度层为所述解码模型的隐藏层中相邻连接的迭代层;按照由所述第一输入数据到所述第二输入数据的迭代过程,依次迭代输入至所述解码模型的隐藏层,至确定出所述自然语言语句的所有主干词语,其中各所述主干词语分别根据各自对应的权重系数的排序确定,并根据权重系数的排序,形成排序的所述程序语 言模板的列表。
在一个实施例中,上述处理器区分所述自然语言语句中包括的所有实体类型,并提取所有所述实体类型分别对应的实体的步骤,包括:调用根据所述程序模板的构成要素预配置的正则表达式,其中所述正则表达式的类型至少包括两种;根据第一正则表达式判断所述自然语言语句中,是否包含与所述第一正则表达式适配的指定实体类型,其中,所述第一正则表达式包含于所有所述正则表达式中;若是,则通过所述第一正则表达式提取所述指定实体类型对应的实体。
在一个实施例中,所述实体类型包括模式类实体和数量类实体,根据所有所述实体类型匹配自然语言模板的步骤,包括:分别获取所述模式类实体对应的实体和实体数量,以及所述数量类实体对应的实体和实体数量;根据所述所述模式类实体对应的实体和实体数量,以及所述数量类实体对应的实体和实体数量,按照预设次序排列所述模式类实体对应的实体和以及所述数量类实体对应的实体,形成所述自然语言模板。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,上述的计算机程序可存储于一非易失性和/或易失性计算机可读取存储介质中,该计算机程序在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的和实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和/或易失性存储器。非易失性存储器可以包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM)或者外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双速据率SDRAM(SSRSDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)等。
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、装置、物品或者方法不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括 为这种过程、装置、物品或者方法所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、装置、物品或者方法中还存在另外的相同要素。
以上所述仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。

Claims (20)

  1. 一种自然语言转换成程序语言的方法,包括:
    获取用户输入的自然语言语句;
    区分所述自然语言语句中包括的所有实体类型,并提取所有所述实体类型分别对应的实体;
    根据所有所述实体类型匹配自然语言模板;
    将所述自然语言模板通过预训练的神经网络模型转换成程序语言模板,其中,所述程序语言模板携带待填充槽;
    将所有所述实体分别对应填充至所述程序模板中的所述待填充槽,生成所述自然语言语句对应的程序语言。
  2. 根据权利要求1所述的自然语言转换成程序语言的方法,其中,所述将所有所述实体分别对应填充至所述程序模板中的所述待填充槽,生成所述自然语言语句对应的程序语言,包括:
    根据预设匹配计算公式确定与第一槽匹配的第一实体,其中,所述第一实体包含于所有所述实体中,所述第一槽包含于所有所述待填充的槽;
    若是,则将所述第一实体填充至所述第一槽中;
    按照所述第一槽的填充过程完成所述程序模板中的所有所述待填充槽的填充,生成所述程序语言。
  3. 根据权利要求2所述的自然语言转换成程序语言的方法,其中,所述根据预设匹配计算公式确定与第一槽匹配的第一实体,包括:
    通过计算公式
    Figure PCTCN2019122480-appb-100001
    分别计算所有所述实体与所述第一槽之间的匹配分数值,其中
    Figure PCTCN2019122480-appb-100002
    Figure PCTCN2019122480-appb-100003
    h i表示所有所述实体分别对应的向量,h j`表示所述第一槽对应的向量,(e c,s d)为已标注匹配状态的第二实体和第二槽,h c表示所述第二实体e c对应的向量,h d`表示所述第二槽s d对应的向量;
    确定所述匹配分数值最大时,与所述第一槽对应的指定实体;
    将所述指定实体确定为所述第一实体。
  4. 根据权利要求1所述的自然语言转换成程序语言的方法,其中,所述 神经网络模型包括编码-解码模型,所述将所述自然语言模板通过预训练的神经网络模型转换成程序语言模板,包括:
    将所述自然语言模板输入预训练的解码编码模型的隐藏层中,进行拟合得到拟合态自然语言模板并输出,其中,所述解码编码模型的隐藏层包含第一指定数量的形态,所述第一指定数量与所述自然语言模板中包含的实体类型的数量相同;
    将所述拟合态自然语言模板输入预训练的解码模型的隐藏层,通过迭代输入计算转换为已排序的所述程序语言模板的列表并输出,其中所述程序语言模板按照预设格式保留所述待填充槽。
  5. 根据权利要求4所述的自然语言转换成程序语言的方法,其中,所述将所述拟合态自然语言模板输入预训练的解码模型的隐藏层,通过迭代输入计算转换为已排序的所述程序语言模板的列表并输出,包括:
    将所述拟合态自然语言模板作为第一输入数据,输入到解码模型的隐藏层的第一梯度层,确定权重系数最高的向量对应的第一实体类型并输出;
    将所述第一实体类型与所述第一梯度层的计算数据作为第二输入数据,输入到解码模型的隐藏层的第二梯度层,确定权重系数次高的向量对应的第二实体类型并输出,其中所述第一梯度层和第二梯度层为所述解码模型的隐藏层中相邻连接的迭代层;
    按照由所述第一输入数据到所述第二输入数据的迭代过程,依次迭代输入至所述解码模型的隐藏层,至确定出所述自然语言语句的所有主干词语,其中各所述主干词语分别根据各自对应的权重系数的排序确定,并根据权重系数的排序,形成排序的所述程序语言模板的列表。
  6. 根据权利要求1所述的自然语言转换成程序语言的方法,其中,所述区分所述自然语言语句中包括的所有实体类型,并提取所有所述实体类型分别对应的实体,包括:
    调用根据所述程序模板的构成要素预配置的正则表达式,其中所述正则表达式的类型至少包括两种;
    根据第一正则表达式判断所述自然语言语句中,是否包含与所述第一正则表达式适配的指定实体类型,其中,所述第一正则表达式包含于所有所述正则表达式中;
    若是,则通过所述第一正则表达式提取所述指定实体类型对应的实体。
  7. 根据权利要求1所述的自然语言转换成程序语言的方法,其中,所述实体类型包括模式类实体和数量类实体,所述根据所有所述实体类型匹配自然语言模板,包括:
    分别获取所述模式类实体对应的实体和实体数量,以及所述数量类实体对应的实体和实体数量;
    根据所述所述模式类实体对应的实体和实体数量,以及所述数量类实体对应的实体和实体数量,按照预设次序排列所述模式类实体对应的实体和以及所述数量类实体对应的实体,形成所述自然语言模板。
  8. 一种自然语言转换成程序语言的装置,其中,包括:
    获取模块,用于获取用户输入的自然语言语句;
    区分模块,用于区分所述自然语言语句中包括的所有实体类型,并提取所有所述实体类型分别对应的实体;
    匹配模块,用于根据所有所述实体类型匹配自然语言模板;
    转换模块,用于将所述自然语言模板通过预训练的神经网络模型转换成程序语言模板,其中,所述程序语言模板携带待填充槽;
    填充模块,用于将所有所述实体分别对应填充至所述程序模板中的所述待填充槽,生成所述自然语言语句对应的程序语言。
  9. 一种计算机设备,包括存储器和处理器,所述存储器存储有计算机程序,其中,所述处理器执行所述计算机程序时实现如下步骤:
    获取用户输入的自然语言语句;
    区分所述自然语言语句中包括的所有实体类型,并提取所有所述实体类型分别对应的实体;
    根据所有所述实体类型匹配自然语言模板;
    将所述自然语言模板通过预训练的神经网络模型转换成程序语言模板,其中,所述程序语言模板携带待填充槽;
    将所有所述实体分别对应填充至所述程序模板中的所述待填充槽,生成所述自然语言语句对应的程序语言。
  10. 根据权利要求9所述的计算机设备,其中,所述处理器在实现所述将所有所述实体分别对应填充至所述程序模板中的所述待填充槽,生成所述 自然语言语句对应的程序语言时,用于实现:
    根据预设匹配计算公式确定与第一槽匹配的第一实体,其中,所述第一实体包含于所有所述实体中,所述第一槽包含于所有所述待填充的槽;
    若是,则将所述第一实体填充至所述第一槽中;
    按照所述第一槽的填充过程完成所述程序模板中的所有所述待填充槽的填充,生成所述程序语言。
  11. 根据权利要求10所述的计算机设备,其中,所述处理器在实现所述根据预设匹配计算公式确定与第一槽匹配的第一实体时,用于实现:
    通过计算公式
    Figure PCTCN2019122480-appb-100004
    分别计算所有所述实体与所述第一槽之间的匹配分数值,其中
    Figure PCTCN2019122480-appb-100005
    Figure PCTCN2019122480-appb-100006
    h i表示所有所述实体分别对应的向量,h j`表示所述第一槽对应的向量,(e c,s d)为已标注匹配状态的第二实体和第二槽,h c表示所述第二实体e c对应的向量,h d`表示所述第二槽s d对应的向量;
    确定所述匹配分数值最大时,与所述第一槽对应的指定实体;
    将所述指定实体确定为所述第一实体。
  12. 根据权利要求9所述的计算机设备,其中,所述处理器在实现所述神经网络模型包括编码-解码模型,所述将所述自然语言模板通过预训练的神经网络模型转换成程序语言模板时,用于实现:
    将所述自然语言模板输入预训练的解码编码模型的隐藏层中,进行拟合得到拟合态自然语言模板并输出,其中,所述解码编码模型的隐藏层包含第一指定数量的形态,所述第一指定数量与所述自然语言模板中包含的实体类型的数量相同;
    将所述拟合态自然语言模板输入预训练的解码模型的隐藏层,通过迭代输入计算转换为已排序的所述程序语言模板的列表并输出,其中所述程序语言模板按照预设格式保留所述待填充槽。
  13. 根据权利要求12所述的计算机设备,其中,所述处理器在实现所述将所述拟合态自然语言模板输入预训练的解码模型的隐藏层,通过迭代输入计算转换为已排序的所述程序语言模板的列表并输出时,用于实现:
    将所述拟合态自然语言模板作为第一输入数据,输入到解码模型的隐藏 层的第一梯度层,确定权重系数最高的向量对应的第一实体类型并输出;
    将所述第一实体类型与所述第一梯度层的计算数据作为第二输入数据,输入到解码模型的隐藏层的第二梯度层,确定权重系数次高的向量对应的第二实体类型并输出,其中所述第一梯度层和第二梯度层为所述解码模型的隐藏层中相邻连接的迭代层;
    按照由所述第一输入数据到所述第二输入数据的迭代过程,依次迭代输入至所述解码模型的隐藏层,至确定出所述自然语言语句的所有主干词语,其中各所述主干词语分别根据各自对应的权重系数的排序确定,并根据权重系数的排序,形成排序的所述程序语言模板的列表。
  14. 根据权利要求9所述的计算机设备,其中,所述处理器在实现所述区分所述自然语言语句中包括的所有实体类型,并提取所有所述实体类型分别对应的实体时,用于实现:
    调用根据所述程序模板的构成要素预配置的正则表达式,其中所述正则表达式的类型至少包括两种;
    根据第一正则表达式判断所述自然语言语句中,是否包含与所述第一正则表达式适配的指定实体类型,其中,所述第一正则表达式包含于所有所述正则表达式中;
    若是,则通过所述第一正则表达式提取所述指定实体类型对应的实体。
  15. 一种计算机可读存储介质,其上存储有计算机程序,其中,所述计算机程序被处理器执行时使所述处理器实现如下步骤:
    获取用户输入的自然语言语句;
    区分所述自然语言语句中包括的所有实体类型,并提取所有所述实体类型分别对应的实体;
    根据所有所述实体类型匹配自然语言模板;
    将所述自然语言模板通过预训练的神经网络模型转换成程序语言模板,其中,所述程序语言模板携带待填充槽;
    将所有所述实体分别对应填充至所述程序模板中的所述待填充槽,生成所述自然语言语句对应的程序语言。
  16. 根据权利要求15所述的计算机可读存储介质,其中,所述处理器在实现所述将所有所述实体分别对应填充至所述程序模板中的所述待填充槽, 生成所述自然语言语句对应的程序语言时,用于实现:
    根据预设匹配计算公式确定与第一槽匹配的第一实体,其中,所述第一实体包含于所有所述实体中,所述第一槽包含于所有所述待填充的槽;
    若是,则将所述第一实体填充至所述第一槽中;
    按照所述第一槽的填充过程完成所述程序模板中的所有所述待填充槽的填充,生成所述程序语言。
  17. 根据权利要求16所述的计算机可读存储介质,其中,所述处理器在实现所述根据预设匹配计算公式确定与第一槽匹配的第一实体时,用于实现:
    通过计算公式
    Figure PCTCN2019122480-appb-100007
    分别计算所有所述实体与所述第一槽之间的匹配分数值,其中
    Figure PCTCN2019122480-appb-100008
    Figure PCTCN2019122480-appb-100009
    h i表示所有所述实体分别对应的向量,h j`表示所述第一槽对应的向量,(e c,s d)为已标注匹配状态的第二实体和第二槽,h c表示所述第二实体e c对应的向量,h d`表示所述第二槽s d对应的向量;
    确定所述匹配分数值最大时,与所述第一槽对应的指定实体;
    将所述指定实体确定为所述第一实体。
  18. 根据权利要求15所述的计算机可读存储介质,其中,所述处理器在实现所述神经网络模型包括编码-解码模型,所述将所述自然语言模板通过预训练的神经网络模型转换成程序语言模板时,用于实现:
    将所述自然语言模板输入预训练的解码编码模型的隐藏层中,进行拟合得到拟合态自然语言模板并输出,其中,所述解码编码模型的隐藏层包含第一指定数量的形态,所述第一指定数量与所述自然语言模板中包含的实体类型的数量相同;
    将所述拟合态自然语言模板输入预训练的解码模型的隐藏层,通过迭代输入计算转换为已排序的所述程序语言模板的列表并输出,其中所述程序语言模板按照预设格式保留所述待填充槽。
  19. 根据权利要求18所述的计算机可读存储介质,其中,所述处理器在实现所述将所述拟合态自然语言模板输入预训练的解码模型的隐藏层,通过迭代输入计算转换为已排序的所述程序语言模板的列表并输出时,用于实现:
    将所述拟合态自然语言模板作为第一输入数据,输入到解码模型的隐藏 层的第一梯度层,确定权重系数最高的向量对应的第一实体类型并输出;
    将所述第一实体类型与所述第一梯度层的计算数据作为第二输入数据,输入到解码模型的隐藏层的第二梯度层,确定权重系数次高的向量对应的第二实体类型并输出,其中所述第一梯度层和第二梯度层为所述解码模型的隐藏层中相邻连接的迭代层;
    按照由所述第一输入数据到所述第二输入数据的迭代过程,依次迭代输入至所述解码模型的隐藏层,至确定出所述自然语言语句的所有主干词语,其中各所述主干词语分别根据各自对应的权重系数的排序确定,并根据权重系数的排序,形成排序的所述程序语言模板的列表。
  20. 根据权利要求15所述的计算机可读存储介质,其中,所述处理器在实现所述区分所述自然语言语句中包括的所有实体类型,并提取所有所述实体类型分别对应的实体时,用于实现:
    调用根据所述程序模板的构成要素预配置的正则表达式,其中所述正则表达式的类型至少包括两种;
    根据第一正则表达式判断所述自然语言语句中,是否包含与所述第一正则表达式适配的指定实体类型,其中,所述第一正则表达式包含于所有所述正则表达式中;
    若是,则通过所述第一正则表达式提取所述指定实体类型对应的实体。
PCT/CN2019/122480 2019-07-04 2019-12-02 自然语言转换成程序语言的方法、装置及计算机设备 WO2021000512A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910600648.5A CN110442332A (zh) 2019-07-04 2019-07-04 自然语言转换成程序语言的方法、装置及计算机设备
CN201910600648.5 2019-07-04

Publications (1)

Publication Number Publication Date
WO2021000512A1 true WO2021000512A1 (zh) 2021-01-07

Family

ID=68428517

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/122480 WO2021000512A1 (zh) 2019-07-04 2019-12-02 自然语言转换成程序语言的方法、装置及计算机设备

Country Status (2)

Country Link
CN (1) CN110442332A (zh)
WO (1) WO2021000512A1 (zh)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110442332A (zh) * 2019-07-04 2019-11-12 深圳壹账通智能科技有限公司 自然语言转换成程序语言的方法、装置及计算机设备
CN111191439A (zh) * 2019-12-16 2020-05-22 浙江大搜车软件技术有限公司 自然语句生成的方法、装置、计算机设备和存储介质
CN111008213B (zh) * 2019-12-23 2023-05-26 百度在线网络技术(北京)有限公司 用于生成语言转换模型的方法和装置
CN112306497B (zh) * 2020-11-03 2024-04-26 高炼 一种将自然语言转化为程序代码的方法及系统
CN113934684B (zh) * 2021-12-16 2022-04-29 四川省交通勘察设计研究院有限公司 一种数据格式自动转换方法、装置、电子设备及存储介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120101803A1 (en) * 2007-11-14 2012-04-26 Ivaylo Popov Formalization of a natural language
CN103617159A (zh) * 2012-12-07 2014-03-05 万继华 将自然语言翻译成计算机语言的方法、语义分析器及人机对话系统
CN107291701A (zh) * 2016-04-01 2017-10-24 阿里巴巴集团控股有限公司 一种机器语言生成方法及装置
CN109918680A (zh) * 2019-03-28 2019-06-21 腾讯科技(上海)有限公司 实体识别方法、装置及计算机设备
CN110442332A (zh) * 2019-07-04 2019-11-12 深圳壹账通智能科技有限公司 自然语言转换成程序语言的方法、装置及计算机设备

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101930428A (zh) * 2009-06-18 2010-12-29 万继华 计算机理解自然语言的系统及方法
CN109144493A (zh) * 2018-07-18 2019-01-04 平安科技(深圳)有限公司 业务规则的生成方法、电子装置及可读存储介质
CN109739483B (zh) * 2018-12-28 2022-02-01 北京百度网讯科技有限公司 用于生成语句的方法和装置

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120101803A1 (en) * 2007-11-14 2012-04-26 Ivaylo Popov Formalization of a natural language
CN103617159A (zh) * 2012-12-07 2014-03-05 万继华 将自然语言翻译成计算机语言的方法、语义分析器及人机对话系统
CN107291701A (zh) * 2016-04-01 2017-10-24 阿里巴巴集团控股有限公司 一种机器语言生成方法及装置
CN109918680A (zh) * 2019-03-28 2019-06-21 腾讯科技(上海)有限公司 实体识别方法、装置及计算机设备
CN110442332A (zh) * 2019-07-04 2019-11-12 深圳壹账通智能科技有限公司 自然语言转换成程序语言的方法、装置及计算机设备

Also Published As

Publication number Publication date
CN110442332A (zh) 2019-11-12

Similar Documents

Publication Publication Date Title
WO2021000512A1 (zh) 自然语言转换成程序语言的方法、装置及计算机设备
WO2021042503A1 (zh) 信息分类抽取方法、装置、计算机设备和存储介质
CN108416058B (zh) 一种基于Bi-LSTM输入信息增强的关系抽取方法
CN110704588A (zh) 基于长短期记忆网络的多轮对话语义分析方法和系统
Liu et al. Structural embedding of syntactic trees for machine comprehension
CN112052324A (zh) 智能问答的方法、装置和计算机设备
CN111680494A (zh) 相似文本的生成方法及装置
CN113536795B (zh) 实体关系抽取的方法、系统、电子装置和存储介质
JP2021033995A (ja) テキスト処理装置、方法、デバイス及びコンピューター読み取り可能な記憶媒体
CN109408628B (zh) 一种解析句子语义结构的方法及相关设备
CN112766319A (zh) 对话意图识别模型训练方法、装置、计算机设备及介质
CN114489669A (zh) 一种基于图学习的Python语言代码片段生成方法
WO2023226292A1 (zh) 从文本中进行关系抽取的方法、关系抽取模型及介质
CN114237621A (zh) 一种基于细粒度共注意机制的语义代码搜索方法
US11983506B2 (en) Hybrid translation system using a general-purpose neural network machine translator
CN111831624A (zh) 数据表创建方法、装置、计算机设备及存储介质
CN113343692B (zh) 搜索意图的识别方法、模型训练方法、装置、介质及设备
CN113408307B (zh) 一种基于翻译模板的神经机器翻译方法
CN114239555A (zh) 一种关键词提取模型的训练方法及相关装置
CN114328924A (zh) 一种基于预训练模型结合句法子树的关系分类方法
CN114756679A (zh) 基于交谈注意力机制的中文医学文本实体关系联合抽取方法
CN116881471B (zh) 一种基于知识图谱的大语言模型微调方法及装置
CN112836514B (zh) 嵌套实体识别方法、装置、电子设备和存储介质
CN113723058B (zh) 文本摘要与关键词抽取方法、装置、设备及介质
JP2002014990A (ja) 質問応答システム,質問応答処理方法,変形規則自動獲得処理方法およびそれらのプログラム記録媒体

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19935954

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205 DATED 16/05/2022)

122 Ep: pct application non-entry in european phase

Ref document number: 19935954

Country of ref document: EP

Kind code of ref document: A1