CN110795697B - Method and device for acquiring logic expression, storage medium and electronic device - Google Patents

Method and device for acquiring logic expression, storage medium and electronic device Download PDF

Info

Publication number
CN110795697B
CN110795697B CN201911039398.9A CN201911039398A CN110795697B CN 110795697 B CN110795697 B CN 110795697B CN 201911039398 A CN201911039398 A CN 201911039398A CN 110795697 B CN110795697 B CN 110795697B
Authority
CN
China
Prior art keywords
target
logic
text
information
expression
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201911039398.9A
Other languages
Chinese (zh)
Other versions
CN110795697A (en
Inventor
袁灿
李倩兰
于政
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Mininglamp Software System Co ltd
Original Assignee
Beijing Mininglamp Software System 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 Mininglamp Software System Co ltd filed Critical Beijing Mininglamp Software System Co ltd
Priority to CN201911039398.9A priority Critical patent/CN110795697B/en
Publication of CN110795697A publication Critical patent/CN110795697A/en
Application granted granted Critical
Publication of CN110795697B publication Critical patent/CN110795697B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F17/00Digital computing or data processing equipment or methods, specially adapted for specific functions
    • G06F17/10Complex mathematical operations
    • G06F17/18Complex mathematical operations for evaluating statistical data, e.g. average values, frequency distributions, probability functions, regression analysis
    • 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/36Creation of semantic tools, e.g. ontology or thesauri
    • G06F16/367Ontology
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/08Insurance

Abstract

The invention provides a method and a device for acquiring a logic expression, a storage medium and an electronic device, wherein the method comprises the following steps: the method comprises the steps of obtaining a first text element belonging to a first element type from target text information of a logic expression to be obtained, constructing a logic expression architecture according to a target logic relationship indicated by the first text element, adding a second text element belonging to a second element type included in the target text information into the logic expression architecture to obtain the target logic expression, and adopting the scheme can achieve the technical effects of reducing maintenance cost of extracting the logic relation from the text and improving utilization efficiency of a user, thereby solving the problems of complex extraction of the logic relation from the text and high maintenance cost in a rule traversal matching mode in related technologies.

Description

Method and device for acquiring logic expression, storage medium and electronic device
Technical Field
The present invention relates to the field of computers, and in particular, to a method and an apparatus for acquiring a logic expression, a storage medium, and an electronic apparatus.
Background
In the process of knowledge graph construction, a large amount of text data is generally involved, and in the process of knowledge graph construction, especially in the process of domain knowledge graph application construction, the text data serving as a knowledge source generally contains a large amount of logic expression, for example, as is frequently encountered in the process of knowledge graph construction in the insurance industry, if "if the report time is in a waiting period, the payment is carried out according to 20% of the basic insurance amount of the contract" a plurality of logic judgment is involved. For the application of the knowledge graph, related business logic cannot be extracted, and the knowledge graph cannot be well played.
The logic expression in the business logic is extracted by a rule matching method, and the calculation logic is realized according to the logic expression. The scheme needs to maintain a larger rule base aiming at a service scene to ensure the guarantee of recall rate in the process of relation extraction, maintains a large number of rules and ensures that no conflict among the rules needs a large amount of work, and logic expression obtained through rule extraction has no standard form and unified specification, is difficult to use, and related logic needs to be developed in a targeted manner by application and use of service logic.
Aiming at the problems that the extraction of a logic relation from a text is complex and the maintenance cost is high by adopting a rule traversal matching mode in the related art, no effective solution exists at present.
Disclosure of Invention
The embodiment of the invention provides a method and a device for acquiring a logic expression, a storage medium and an electronic device, which at least solve the problems that the extraction of the logic expression from a text by adopting a rule traversal matching mode in the related technology is complex and the maintenance cost is high.
According to an embodiment of the present invention, there is provided a method for acquiring a logic expression, including: acquiring a first text element belonging to a first element type from target text information of a logic expression to be acquired, wherein the text element belonging to the first element type is used for indicating a logic relationship in the text information; constructing a logic expression architecture according to the target logic relationship indicated by the first text element; and adding a second text element belonging to a second element type included in the target text information into the logic expression architecture to obtain a target logic expression, wherein the text element belonging to the second element type comprises a main body with the logic relation in the text information.
Optionally, the obtaining the first text element belonging to the first element type from the target text information of the to-be-obtained logical expression includes at least one of the following: acquiring a computing element belonging to a computing type from the target text information of the logic expression to be acquired, wherein the first element type comprises the computing type, the first text element comprises the computing element, and the computing element is used for indicating computing logic in the target text information; and acquiring a condition element belonging to a condition type from the target text information of the logic expression to be acquired, wherein the first element type comprises the condition type, the first text element comprises the condition element, and the condition element is used for indicating judgment logic in the target text information.
Optionally, building a logical expression architecture according to the target logical relationship indicated by the first text element includes: mapping the computing element into a computing logic expression corresponding to the computing element when the first text element comprises the computing element; and constructing a judgment logic expression corresponding to the condition element under the condition that the first text element comprises the condition element.
Optionally, adding a second text element belonging to a second element type included in the target text information to the logic expression architecture, to obtain a target logic expression includes: constructing a dependency phrase structure tree corresponding to the target text information, wherein the dependency phrase structure tree is used for indicating the dependency relationship among text elements included in the target text information; obtaining a target dependency relationship between the first text element and the second text element from the dependency phrase structure tree; and adding the second text element into the logic expression architecture according to the target dependency relationship to obtain the target logic expression.
Optionally, after adding the second text element belonging to the second element type included in the target text information to the logic expression architecture to obtain a target logic expression, the method further includes: determining a target input variable and a target output variable corresponding to the target logic expression to obtain target logic information, wherein the target logic information is used for indicating the target logic expression, the target input variable and the target output variable which have a corresponding relation; numbering the target logic information to obtain a target number corresponding to the target logic information; storing the target number and the target logic information with the corresponding relation into a logic expression engine library, wherein the logic expression engine library is used for recording the label and the logic information with the corresponding relation, and the logic information is used for indicating the logic expression, the input variable and the output variable with the corresponding relation.
Optionally, after storing the target number and the target logic information having the correspondence relationship in a logic expression engine library, the method further includes: acquiring a call request of a logic relationship, wherein the call request carries the target number; acquiring the target logic information corresponding to the target number from the logic expression engine library; constructing a calculation script according to the target logic expression, the target input variable and the target output variable indicated by the target logic information; acquiring a first variable value of the target input variable; and acquiring a second variable value of the target output variable corresponding to the first variable value through the calculation script.
According to another embodiment of the present invention, there is provided an apparatus for acquiring a logic expression, including: the acquisition module is used for acquiring a first text element belonging to a first element type from target text information of a logic expression to be acquired, wherein the text element belonging to the first element type is used for indicating a logic relationship in the text information; the first construction module is used for constructing a logic expression architecture according to the target logic relationship indicated by the first text element; and the adding module is used for adding a second text element belonging to a second element type included in the target text information into the logic expression architecture to obtain a target logic expression, wherein the text element belonging to the second element type comprises a main body with the logic relation in the text information.
Optionally, the acquiring module includes:
a first obtaining unit, configured to obtain a computing element belonging to a computing type from the target text information of the logic expression to be obtained, where the first element type includes the computing type, the first text element includes the computing element, and the computing element is used to indicate computing logic in the target text information;
a second obtaining unit, configured to obtain a condition element belonging to a condition type from the target text information of the logic expression to be obtained, where the first element type includes the condition type, the first text element includes the condition element, and the condition element is used to indicate a judgment logic in the target text information.
Optionally, the first building module includes:
a mapping unit, configured to map the computing element to a computing logic expression corresponding to the computing element when the first text element includes the computing element; and a construction unit for constructing a judgment logic expression corresponding to the condition element when the first text element comprises the condition element.
Optionally, the adding module includes:
a first construction unit, configured to construct a dependency phrase structure tree corresponding to the target text information, where the dependency phrase structure tree is used to indicate a dependency relationship between text elements included in the target text information;
a third obtaining unit, configured to obtain a target dependency relationship between the first text element and the second text element from the dependency phrase structure tree;
and the adding unit is used for adding the second text element into the logic expression architecture according to the target dependency relationship to obtain the target logic expression.
Optionally, the apparatus further comprises:
the processing module is used for determining a target input variable and a target output variable corresponding to the target logic expression after adding a second text element belonging to a second element type and included in the target text information into the logic expression architecture to obtain the target logic expression, so as to obtain target logic information, wherein the target logic information is used for indicating the target logic expression, the target input variable and the target output variable which have a corresponding relation;
The numbering module is used for numbering the target logic information to obtain a target number corresponding to the target logic information;
the storage module is used for storing the target number and the target logic information with the corresponding relation into a logic expression engine library, wherein the logic expression engine library is used for recording the label and the logic information with the corresponding relation, and the logic information is used for indicating the logic expression, the input variable and the output variable with the corresponding relation.
Optionally, the apparatus further comprises:
the first acquisition module is used for acquiring a call request of a logic relationship after storing the target number and the target logic information with the corresponding relationship into a logic expression engine library, wherein the call request carries the target number;
the second acquisition module is used for acquiring the target logic information corresponding to the target number from the logic expression engine library;
the second construction module is used for constructing a calculation script according to the target logic expression, the target input variable and the target output variable indicated by the target logic information;
a third obtaining module, configured to obtain a first variable value of the target input variable;
And the fourth acquisition module is used for acquiring a second variable value of the target output variable corresponding to the first variable value through the calculation script.
Optionally, the apparatus further comprises:
a fifth obtaining module, configured to obtain one or more text information before obtaining a first text element belonging to a first element type from target text information of a logical expression to be obtained;
a sixth obtaining module, configured to obtain text information including text elements belonging to the first element type from the one or more text information;
and the determining module is used for determining the text information comprising the text elements belonging to the first element type as the target text information.
According to still another embodiment of the present invention, there is also provided a computer-readable storage medium including a stored program, wherein the program when run performs the above-described method of acquiring a logical expression.
According to yet another embodiment of the present invention, there is also provided an electronic device including a memory and a processor, characterized in that the memory stores a computer program, and the processor is configured to execute the method of acquiring the logical expression by the computer program.
According to the method and the device, the first text element belonging to the first element type is acquired from the target text information of the logic expression to be acquired, the logic expression architecture is constructed according to the target logic relation indicated by the first text element, and the second text element belonging to the second element type is added into the logic expression architecture to obtain the target logic expression.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiments of the invention and together with the description serve to explain the invention and do not constitute a limitation on the invention. In the drawings:
FIG. 1 is a schematic diagram of an application environment of a method for acquiring a logical expression according to an embodiment of the present invention;
FIG. 2 is a flow diagram of an alternative method of obtaining a logical expression according to an embodiment of the invention;
FIG. 3 is a schematic diagram of an alternative method of obtaining a logical expression according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of another alternative method of obtaining a logical expression according to an embodiment of the present invention;
fig. 5 is a schematic structural view of an alternative logic expression acquisition device according to an embodiment of the present invention.
Detailed Description
The invention will be described in detail hereinafter with reference to the drawings in conjunction with embodiments. It should be noted that, in the case of no conflict, the embodiments and features in the embodiments may be combined with each other.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present invention and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order.
In an alternative embodiment, the method embodiments provided herein may be performed in a mobile terminal, a computer terminal, or similar computing device. Taking a mobile terminal as an example, fig. 1 is a block diagram of a hardware structure of a mobile terminal according to an embodiment of the present invention, where, as shown in fig. 1, the mobile terminal 10 may include one or more (only one is shown in the figure) processors 102 (the processors 102 may include, but are not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 104 for storing data, and a transmission device 106 for communication functions. It will be appreciated by those of ordinary skill in the art that the configuration shown in fig. 1 is merely illustrative and is not intended to limit the configuration of the electronic device described above. For example, the mobile terminal 10 may also include more or fewer components than shown in FIG. 1 or have a different configuration than shown in FIG. 1.
The memory 104 may be used to store software programs and modules of application software, such as program instructions/modules corresponding to the carrier phase recovery method in the embodiment of the present invention, and the processor 102 executes the software programs and modules stored in the memory 104 to perform various functional applications and data processing, i.e., implement the above-mentioned method. Memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include memory located remotely from the processor 102, which may be connected to the mobile terminal 10 via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission means 106 is arranged to receive or transmit data via a network. The specific examples of networks described above may include wireless networks provided by the communication provider of the mobile terminal 10. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, NIC) that can connect to other network devices through a base station to communicate with the internet. In one example, the transmission device 106 may be a Radio Frequency (RF) module for communicating with the internet wirelessly.
In this embodiment, a method for obtaining a logic expression is provided, and fig. 2 is a flowchart of a method for obtaining a logic expression according to an embodiment of the present invention, as shown in fig. 2, where the flowchart includes the following steps:
step S202, acquiring a first text element belonging to a first element type from target text information of a logic expression to be acquired, wherein the text element belonging to the first element type is used for indicating a logic relation in the text information;
step S204, constructing a logic expression architecture according to the target logic relationship indicated by the first text element;
and S206, adding a second text element belonging to a second element type included in the target text information into the logic expression architecture to obtain a target logic expression, wherein the text element belonging to the second element type comprises a main body with the logic relation in the text information.
The steps may be performed by the terminal, or by another processing system capable of realizing the functions described above, but the present invention is not limited thereto.
Alternatively, in the present embodiment, the method for acquiring the above-described logic expression may be applied to, but not limited to, a knowledge graph application construction process.
For example: the embodiment described above is only an optional embodiment, and the specific application scenario is not limited in this embodiment.
Through the steps, the first text element belonging to the first element type is obtained from the target text information of the logic expression to be obtained, the logic expression architecture is constructed according to the target logic relation indicated by the first text element, and the second text element belonging to the second element type is added into the logic expression architecture to obtain the target logic expression.
In an alternative embodiment, the obtaining the first text element belonging to the first element type from the target text information of the logical expression to be obtained comprises at least one of: acquiring a computing element belonging to a computing type from the target text information of the logic expression to be acquired, wherein the first element type comprises the computing type, the first text element comprises the computing element, and the computing element is used for indicating computing logic in the target text information; and acquiring a condition element belonging to a condition type from the target text information of the logic expression to be acquired, wherein the first element type comprises the condition type, the first text element comprises the condition element, and the condition element is used for indicating judgment logic in the target text information.
Alternatively, in this embodiment, the first text element may include, but is not limited to, a calculation element that represents an operational relationship, where expressions such as "add", "and", "multiple", etc. relate to mathematical operations in the text expression. The above embodiment is merely an alternative implementation, and the specific types of computing elements may include one or more combinations of the foregoing, which are not limited in this embodiment.
Optionally, in this embodiment, the first text element may further include, but is not limited to, a condition element for representing a conditional operation, for example, "when x >5, then y=4" in the expression "when …, then" is a condition element. The above embodiment is merely an alternative implementation, and specific types of condition elements may include one or more combinations of the above, which are not limited in this embodiment.
Alternatively, in this embodiment, the first text element may be acquired by, but not limited to, using a named entity recognition method, where a named entity generally refers to an entity with a specific meaning or strong meaning in text information, and generally includes a name of a person, a place name, a organization name, a date and time, a proper noun, and the like.
In an alternative embodiment, constructing a logical expression architecture from the target logical relationship indicated by the first text element includes: mapping the computing element into a computing logic expression corresponding to the computing element when the first text element comprises the computing element; and constructing a judgment logic expression corresponding to the condition element under the condition that the first text element comprises the condition element.
Alternatively, in this embodiment, taking the computing element as an example, the first text element may be "20%", "add", "double", "half", and so on, and the constructed logic expression architecture may be "x=y×20%", "z=x+y", "x=2y", and "x=y/2", respectively. Wherein the X, Y, Z positions may be used to add a second text element.
Alternatively, in the present embodiment, referring to the design of the calculation element and the condition element in the computer language, a reserved word may be set for the calculation element and the condition element, and the logical expression is performed in cooperation with the numerical element and the variable element, and the constructed logical expression may be divided into a judgment sentence (equivalent to the above-described judgment logical expression) and a calculation sentence (equivalent to the above-described calculation logical expression) in terms of expression.
For example, "if the time to report is within the waiting period, we pay for 20% of the amount of the basic insurance of the contract" as follows:
IF [ report time < waiting period ] (payoff=20% of the basic insurance amount)
The "IF [ ] ()" is a judgment statement, "payoff amount=20% of the basic insurance amount" and "report time > waiting period" are calculation statements, wherein the calculation statement contains variable elements, calculation elements and numerical value elements, one calculation element can include but is not limited to elements with a plurality of variables or numerical values being linked, and the judgment statement links a plurality of calculation statements.
According to the embodiment, the expression of the calculation class is constructed by using the calculation elements, the expression of the judgment class is constructed by using the condition elements, and the text elements are constructed into different logic expressions according to different text elements, so that the reliable and convenient logic calculation expression can be provided for subsequent application, and further the logic expression engine library is constructed.
In an alternative embodiment, adding the second text element belonging to the second element type included in the target text information to the logic expression architecture, to obtain the target logic expression includes: constructing a dependency phrase structure tree corresponding to the target text information, wherein the dependency phrase structure tree is used for indicating the dependency relationship among text elements included in the target text information; obtaining a target dependency relationship between the first text element and the second text element from the dependency phrase structure tree; and adding the second text element into the logic expression architecture according to the target dependency relationship to obtain the target logic expression.
Optionally, in this embodiment, the second text element included in the target text information and belonging to the second element type includes, but is not limited to, a numeric element and a variable element. In the present embodiment, the numerical element is a numerical variable involved in the text information, for example, "2" in "35%" and "2-fold relationship"; the variable element is a variable of some text expressions related to the text expression, for example, the text "35% of premium" is a variable. The foregoing is merely an example, and the specific second text element belonging to the second element type may include one or more combinations of the foregoing, which is not limited in this embodiment.
Alternatively, in the present embodiment, the numerical elements and the variable elements are infinite elements, and specific numerical elements and variable elements are not limited in any way in the present embodiment.
In an optional embodiment, after adding the second text element belonging to the second element type included in the target text information to the logic expression architecture, obtaining a target logic expression, the method further includes: determining a target input variable and a target output variable corresponding to the target logic expression to obtain target logic information, wherein the target logic information is used for indicating the target logic expression, the target input variable and the target output variable which have a corresponding relation; numbering the target logic information to obtain a target number corresponding to the target logic information; storing the target number and the target logic information with the corresponding relation into a logic expression engine library, wherein the logic expression engine library is used for recording the label and the logic information with the corresponding relation, and the logic information is used for indicating the logic expression, the input variable and the output variable with the corresponding relation.
Alternatively, in the present embodiment, the logic information may be stored in the logic expression engine library by numbering in the form of character strings, and the type of the logic expression engine library may include, but is not limited to, a key-value database, and the like.
Alternatively, in the present embodiment, the storage of the logic information may be specifically performed by, but not limited to, the following manner:
the first step: determining a target input variable as the case reporting time, the waiting period and the basic insurance amount from a target logic expression IF [ case reporting time < waiting period ] (payoff amount=basic insurance amount ×20%), and a target output variable as the payoff amount;
and a second step of: numbering the target logic information to obtain a target number 43 corresponding to the target logic information;
and a third step of: target number 43 and its corresponding target logical expression: IF [ time to report < waiting period ] (payoff = 20% of the base insurance amount), target input variable: time to report, waiting period and basic insurance amount and target output variable: the payouts are stored in a logical expression engine library.
According to the embodiment, the logic expression engine library is used for storing the logic expression, so that the specification of the logic expression can be unified, and different logic expression standard forms can be stored according to different business logics, so that the logic expression system is convenient to use.
In an alternative embodiment, after storing the target number and the target logic information having the correspondence relationship in a logic expression engine library, the method further includes: acquiring a call request of a logic relationship, wherein the call request carries the target number; acquiring the target logic information corresponding to the target number from the logic expression engine library; constructing a calculation script according to the target logic expression, the target input variable and the target output variable indicated by the target logic information; acquiring a first variable value of the target input variable; and acquiring a second variable value of the target output variable corresponding to the first variable value through the calculation script.
Optionally, in this embodiment, the logic information may be called through a number, the logic expression character string in the logic information and the corresponding input/output variable are parsed to generate a calculation script constructed according to different service types, and then the target input variable corresponding to the calculation script is acquired to calculate the target output variable, so as to meet the calculation requirement of the service.
In an alternative embodiment, before acquiring the first text element belonging to the first element type from the target text information of the logical expression to be acquired, the method further includes: acquiring one or more text messages; obtaining text information comprising text elements belonging to the first element type from the one or more text information; and determining the text information comprising the text elements belonging to the first element type as the target text information.
Alternatively, in the present embodiment, one or more text information is first acquired, and target text information is determined based on the text element type from the acquired text information, where the one or more text information may include, but is not limited to, text files (e.g., courseware, ticket, newspaper, magazine, poster, paper, electronic document, contract, book), web pages, multimedia files, etc., and the text element of the first element type may include, but is not limited to, a calculation element, a condition element.
Optionally, in this embodiment, the calculation element and the condition element are both finite elements, that is, the calculation element and the condition element may be used to construct a trigger word of the logic expression, so as to determine whether the text information contains the logic expression.
According to the method and the device for obtaining the target text information, the target text information is obtained in different modes, rapid and accurate information obtaining can be achieved, text elements are obtained through a plurality of text information, the obtained text information is more comprehensive, and the utilization efficiency and the accuracy of the logic expression are improved.
The following is further described in connection with specific examples:
in an alternative embodiment, fig. 4 is a schematic diagram of a method for obtaining another alternative logic expression according to an embodiment of the present invention, as shown in fig. 4, taking "if the case report time is in the waiting period, we pay for the claim according to 20% of the basic insurance amount of the contract" as an example, the specific flow may include the following:
the first step: a logical expression engine design comprising logical expression elements and logical expression statement designs: the logical expression elements are constructed into four types of elements including calculation elements, condition elements, numerical elements and variable elements. The method comprises the steps of setting reserved words for computing elements and conditional elements according to designs of the computing elements and the conditional elements in a computer language, carrying out logic expression by matching the computing elements and the conditional elements, and judging sentences and computing sentences in expression forms. For example, "if the time to report is within the waiting period, we pay for 20% of the amount of the basic insurance of the contract" as follows:
IF [ report time < waiting period ] (payoff=20% of the basic insurance amount)
The time "IF [ ] ()" is a judgment statement, "payoff amount=20% of the basic insurance amount" and "report time > waiting period" are calculation statements, wherein the calculation statement contains variable elements, calculation elements and numerical value elements, one calculation element must be linked with two elements which are variables or numerical values, and the judgment statement is linked with a plurality of calculation statements.
And a second step of: constructing a logic expression trigger word library; preprocessing such as word segmentation and part-of-speech tagging is carried out, the word segmentation needs to add the trigger words related to the calculation elements and the condition elements into a trigger word library, the trigger words in example sentences are "within …", "if …", "20%" are the trigger words added into the trigger word library, and the construction process can be constructed in a named entity identification mode.
And a third step of: extracting the logic expression, namely extracting the logic expression by utilizing dependency syntactic analysis and rules: for sentences containing logic expressions, setting the sentences as sentences to be extracted for the existence of condition elements, and dividing the sentences to be extracted into two calculation sentences of which the case reporting time is in a waiting period and which pay for claims according to 20% of the basic insurance amount of the contract according to syntactic analysis; carrying out logic expression extraction on a statement to be extracted according to a syntax extraction rule constructed by constructing a dependency phrase structure tree and constructing a trigger word, taking a case report time in a waiting period as an example, wherein the dependency tree is shown in fig. 4, is mapped into an in or a < accordingto a calculation element in …, is judged to be <', and finds a subject case report time and a fixed language waiting period according to the dependency relationship in the dependency tree to construct a logic expression case report time < waiting period; and constructing logic information according to the calculation sentences generated by the phrases and the judgment sentences generated by the conditional elements in the sentences to obtain IF [ report time < waiting period ] (payoff amount=basic insurance amount: 20%) and target input variables are report time, waiting period and basic insurance amount, and target output variables are payoff amount.
Fourth step: logic expression store and call: and numbering the obtained logic information according to the character string form and storing the logic information into a logic expression engine library, wherein the logic expression engine library can be a key-value database. When the method is needed, the logic information is called through the number, the logic information character string and the input and output variables are analyzed to generate logic information which can be used for calculation after analysis, and the logic information comprises a logic calculation expression, a target input variable and a target output variable.
After receiving a call request for obtaining a logic relationship, the logic expression engine library invokes and analyzes target logic information corresponding to the target number to generate and obtain logic information constructed according to different service types, which specifically includes, but is not limited to, taking a pseudo code form as an example and can be expressed as:
input report time, waiting period, basic insurance amount
if report time < waiting period then
Payoff = base insurance amount 0.2
output payoff amount
The Input is a target Input variable, the output is a target output variable, the if report time < waiting period then, the payoff=the basic insurance amount is 0.2, and the logic expression is obtained.
The above-described embodiment is merely an example, and is not limited in any way in this embodiment. According to the embodiment, the extraction of the logic expression is performed by utilizing a method combining dependency syntactic analysis and rules, so that conflicts among the rules can be reduced, recall rate in the relation extraction process is ensured, and the problems of extracting and using the logic expression in text expression are effectively solved.
In an optional embodiment, a device for obtaining a logic expression is further provided in this embodiment, and this device is used to implement the foregoing embodiment and the preferred implementation, which are not described in detail. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. While the means described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware, is also possible and contemplated.
Fig. 5 is a block diagram of a logic expression acquisition apparatus according to an embodiment of the present invention, as shown in fig. 5, including:
an obtaining module 52, configured to obtain a first text element belonging to a first element type from target text information of a logical expression to be obtained, where the text element belonging to the first element type is used to indicate a logical relationship in the text information;
a first construction module 54, configured to construct a logical expression architecture according to the target logical relationship indicated by the first text element;
and an adding module 56, configured to add a second text element belonging to a second element type included in the target text information to the logic expression architecture, to obtain a target logic expression, where the text element belonging to the second element type includes a body having the logical relationship in the text information.
In an alternative embodiment, the acquisition module 52 includes:
a first obtaining unit, configured to obtain a computing element belonging to a computing type from the target text information of the logic expression to be obtained, where the first element type includes the computing type, the first text element includes the computing element, and the computing element is used to indicate computing logic in the target text information;
a second obtaining unit, configured to obtain a condition element belonging to a condition type from the target text information of the logic expression to be obtained, where the first element type includes the condition type, the first text element includes the condition element, and the condition element is used to indicate a judgment logic in the target text information.
In an alternative embodiment, the first building block 54 includes:
a mapping unit, configured to map the computing element to a computing logic expression corresponding to the computing element when the first text element includes the computing element; and a construction unit for constructing a judgment logic expression corresponding to the condition element when the first text element comprises the condition element.
In an alternative embodiment, the adding module 56 includes:
a first construction unit, configured to construct a dependency phrase structure tree corresponding to the target text information, where the dependency phrase structure tree is used to indicate a dependency relationship between text elements included in the target text information;
a third obtaining unit, configured to obtain a target dependency relationship between the first text element and the second text element from the dependency phrase structure tree;
and the adding unit is used for adding the second text element into the logic expression architecture according to the target dependency relationship to obtain the target logic expression.
In an alternative embodiment, the apparatus further comprises:
the processing module is used for determining a target input variable and a target output variable corresponding to the target logic expression after adding a second text element belonging to a second element type and included in the target text information into the logic expression architecture to obtain the target logic expression, so as to obtain target logic information, wherein the target logic information is used for indicating the target logic expression, the target input variable and the target output variable which have a corresponding relation;
The numbering module is used for numbering the target logic information to obtain a target number corresponding to the target logic information;
the storage module is used for storing the target number and the target logic information with the corresponding relation into a logic expression engine library, wherein the logic expression engine library is used for recording the label and the logic information with the corresponding relation, and the logic information is used for indicating the logic expression, the input variable and the output variable with the corresponding relation.
In an alternative embodiment, the apparatus further comprises:
the first acquisition module is used for acquiring a call request of a logic relationship after storing the target number and the target logic information with the corresponding relationship into a logic expression engine library, wherein the call request carries the target number;
the second acquisition module is used for acquiring the target logic information corresponding to the target number from the logic expression engine library;
the second construction module is used for constructing a calculation script according to the target logic expression, the target input variable and the target output variable indicated by the target logic information;
A third obtaining module, configured to obtain a first variable value of the target input variable;
and the fourth acquisition module is used for acquiring a second variable value of the target output variable corresponding to the first variable value through the calculation script.
In an alternative embodiment, the apparatus further comprises:
a fifth obtaining module, configured to obtain one or more text information before obtaining a first text element belonging to a first element type from target text information of a logical expression to be obtained;
a sixth obtaining module, configured to obtain text information including text elements belonging to the first element type from the one or more text information;
and the determining module is used for determining the text information comprising the text elements belonging to the first element type as the target text information.
It should be noted that each of the above modules may be implemented by software or hardware, and for the latter, it may be implemented by, but not limited to: the modules are all located in the same processor; alternatively, the modules are located in a plurality of processors, respectively.
The above embodiments are only for illustrating the technical solution of the present invention and not for limiting the same, and those skilled in the art may modify or substitute the technical solution of the present invention without departing from the spirit and scope of the present invention, and the protection scope of the present invention shall be subject to the claims.
According to a further aspect of embodiments of the present invention, there is also provided an electronic device for implementing the above-described method of obtaining a logical expression, the electronic device comprising a memory and a processor, the memory having stored therein a computer program, the processor being arranged to perform the steps of any of the method embodiments described above by the computer program.
Alternatively, in this embodiment, the electronic apparatus may be located in at least one network device of a plurality of network devices of the computer network.
Alternatively, in the present embodiment, the above-described processor may be configured to execute the following steps by a computer program:
s1, acquiring a first text element belonging to a first element type from target text information of a logic expression to be acquired, wherein the text element belonging to the first element type is used for indicating a logic relation in the text information.
S2, constructing a logic expression architecture according to the target logic relationship indicated by the first text element;
s3, adding a second text element belonging to a second element type in the target text information to the logic expression architecture to obtain a target logic expression, wherein the text element belonging to the second element type comprises a main body with the logic relation in the text information, and optionally, one of ordinary skill in the art can understand that the electronic device can also be a smart phone (such as an Android mobile phone, an iOS mobile phone, etc.), a tablet personal computer, a palm computer, mobile internet equipment (Mobile Internet Devices, MID), PAD, etc.
The memory may be used to store software programs and modules, such as program instructions/modules corresponding to the method and apparatus for obtaining a logic expression in the embodiment of the present invention, and the processor executes the software programs and modules stored in the memory, thereby executing various functional applications and data processing, that is, implementing the method for obtaining a logic expression described above. The memory may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory may further include memory remotely located with respect to the processor, the remote memory being connectable to the terminal through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof. The storage may be, but not limited to, a sample feature of the article and information such as a target virtual resource account number. As an example, the memory may include, but is not limited to, a first obtaining module 802, a display module 804, a second obtaining module 806, and a placement module 808 in the obtaining device including the above-mentioned logic expression, and may also include, but is not limited to, other module units in the obtaining device including the above-mentioned logic expression, which are not described in detail in this example.
Optionally, the above-mentioned transmission device is used for receiving or transmitting data via a network. Specific examples of the network described above may include wired networks and wireless networks. In one example, the transmission means comprises a network adapter (Network Interface Controller, NIC) which is connectable to other network devices via a network cable to a router for communication with the internet or a local area network. In one example, the transmission device is a Radio Frequency (RF) module, which is used to communicate with the internet wirelessly.
In addition, the electronic device further includes: the display is used for displaying the shooting game interface; and a connection bus for connecting the respective module components in the electronic device.
According to a further aspect of embodiments of the present invention, there is also provided a computer readable storage medium having a computer program stored therein, wherein the computer program is arranged to perform the steps of any of the method embodiments described above when run.
Alternatively, in the present embodiment, the above-described computer-readable storage medium may be configured to store a computer program for executing the steps of:
S1, acquiring a first text element belonging to a first element type from target text information of a logic expression to be acquired, wherein the text element belonging to the first element type is used for indicating a logic relationship in the text information;
s2, constructing a logic expression architecture according to the target logic relationship indicated by the first text element;
and S3, adding a second text element belonging to a second element type included in the target text information into the logic expression architecture to obtain a target logic expression, wherein the text element belonging to the second element type comprises a main body with the logic relation in the text information.
Alternatively, in this embodiment, it will be understood by those skilled in the art that all or part of the steps in the various methods of the above embodiments may be performed by a program for instructing a terminal device to execute the hardware related thereto, and the program may be stored in a computer readable storage medium, where the storage medium may include: flash disk, read-Only Memory (ROM), random-access Memory (Random Access Memory, RAM), magnetic or optical disk, and the like.
The foregoing embodiment numbers of the present invention are merely for the purpose of description, and do not represent the advantages or disadvantages of the embodiments.
The integrated units in the above embodiments may be stored in the above-described computer-readable storage medium if implemented in the form of software functional units and sold or used as separate products. Based on such understanding, the technical solution of the present invention may be embodied in essence or a part contributing to the prior art or all or part of the technical solution in the form of a software product stored in a storage medium, comprising several instructions for causing one or more computer devices (which may be personal computers, servers or network devices, etc.) to perform all or part of the steps of the method of the various embodiments of the present invention.
In the foregoing embodiments of the present invention, the descriptions of the embodiments are emphasized, and for a portion of this disclosure that is not described in detail in this embodiment, reference is made to the related descriptions of other embodiments.
In several embodiments provided in the present application, it should be understood that the disclosed client may be implemented in other manners. The above-described embodiments of the apparatus are merely exemplary, and are merely a logical functional division, and there may be other manners of dividing the apparatus in actual implementation, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some interfaces, units or modules, or may be in electrical or other forms.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The foregoing is merely a preferred embodiment of the present invention and it should be noted that modifications and adaptations to those skilled in the art may be made without departing from the principles of the present invention, which are intended to be comprehended within the scope of the present invention.

Claims (8)

1. A method for obtaining a logical expression, comprising:
acquiring a first text element belonging to a first element type from target text information of a logic expression to be acquired, wherein the text element belonging to the first element type is used for indicating a logic relationship in the text information;
Constructing a logic expression architecture according to the target logic relationship indicated by the first text element;
adding a second text element belonging to a second element type included in the target text information into the logic expression architecture to obtain a target logic expression, wherein the text element belonging to the second element type comprises a main body with the logic relation in the text information;
wherein adding a second text element belonging to a second element type included in the target text information to the logic expression architecture, to obtain a target logic expression includes:
constructing a dependency phrase structure tree corresponding to the target text information, wherein the dependency phrase structure tree is used for indicating the dependency relationship among text elements included in the target text information;
obtaining a target dependency relationship between the first text element and the second text element from the dependency phrase structure tree;
adding the second text element to the logic expression architecture according to the target dependency relationship to obtain the target logic expression;
wherein after adding a second text element belonging to a second element type included in the target text information to the logic expression architecture to obtain a target logic expression, the method further includes:
Determining a target input variable and a target output variable corresponding to the target logic expression to obtain target logic information, wherein the target logic information is used for indicating the target logic expression, the target input variable and the target output variable which have a corresponding relation;
numbering the target logic information to obtain a target number corresponding to the target logic information;
storing the target number and the target logic information with the corresponding relation into a logic expression engine library, wherein the logic expression engine library is used for recording the label and the logic information with the corresponding relation, and the logic information is used for indicating the logic expression, the input variable and the output variable with the corresponding relation.
2. The method of claim 1, wherein obtaining the first text element belonging to the first element type from the target text information of the logical expression to be obtained comprises at least one of:
acquiring a computing element belonging to a computing type from the target text information of the logic expression to be acquired, wherein the first element type comprises the computing type, the first text element comprises the computing element, and the computing element is used for indicating computing logic in the target text information;
And acquiring a condition element belonging to a condition type from the target text information of the logic expression to be acquired, wherein the first element type comprises the condition type, the first text element comprises the condition element, and the condition element is used for indicating judgment logic in the target text information.
3. The method of claim 2, wherein constructing a logical expression architecture from the target logical relationship indicated by the first text element comprises:
mapping the computing element into a computing logic expression corresponding to the computing element when the first text element comprises the computing element;
and constructing a judgment logic expression corresponding to the condition element under the condition that the first text element comprises the condition element.
4. The method of claim 1, wherein after storing the target number and the target logical information having a correspondence in a logical expression engine library, the method further comprises:
acquiring a call request of a logic relationship, wherein the call request carries the target number;
acquiring the target logic information corresponding to the target number from the logic expression engine library;
Constructing a calculation script according to the target logic expression, the target input variable and the target output variable indicated by the target logic information;
acquiring a first variable value of the target input variable;
and acquiring a second variable value of the target output variable corresponding to the first variable value through the calculation script.
5. An apparatus for obtaining a logical expression, comprising:
the acquisition module is used for acquiring a first text element belonging to a first element type from target text information of a logic expression to be acquired, wherein the text element belonging to the first element type is used for indicating a logic relationship in the text information;
the construction module is used for constructing a logic expression architecture according to the target logic relationship indicated by the first text element;
an adding module, configured to add a second text element belonging to a second element type included in the target text information to the logic expression architecture, to obtain a target logic expression, where the text element belonging to the second element type includes a main body having the logic relationship in the text information;
wherein, the adding module includes:
A first construction unit, configured to construct a dependency phrase structure tree corresponding to the target text information, where the dependency phrase structure tree is used to indicate a dependency relationship between text elements included in the target text information;
a third obtaining unit, configured to obtain a target dependency relationship between the first text element and the second text element from the dependency phrase structure tree;
an adding unit, configured to add the second text element to the logic expression architecture according to the target dependency relationship, to obtain the target logic expression;
wherein the apparatus further comprises:
the processing module is used for determining a target input variable and a target output variable corresponding to the target logic expression after adding a second text element belonging to a second element type and included in the target text information into the logic expression architecture to obtain the target logic expression, so as to obtain target logic information, wherein the target logic information is used for indicating the target logic expression, the target input variable and the target output variable which have a corresponding relation;
the numbering module is used for numbering the target logic information to obtain a target number corresponding to the target logic information;
The storage module is used for storing the target number and the target logic information with the corresponding relation into a logic expression engine library, wherein the logic expression engine library is used for recording the label and the logic information with the corresponding relation, and the logic information is used for indicating the logic expression, the input variable and the output variable with the corresponding relation.
6. The apparatus of claim 5, wherein the acquisition module comprises:
a first obtaining unit, configured to obtain a computing element belonging to a computing type from the target text information of the logic expression to be obtained, where the first element type includes the computing type, the first text element includes the computing element, and the computing element is used to indicate computing logic in the target text information;
a second obtaining unit, configured to obtain a condition element belonging to a condition type from the target text information of the logic expression to be obtained, where the first element type includes the condition type, the first text element includes the condition element, and the condition element is used to indicate a judgment logic in the target text information.
7. A computer readable storage medium comprising a stored program, wherein the program when run performs the method of any one of the preceding claims 1 to 4.
8. An electronic device comprising a memory and a processor, characterized in that the memory has stored therein a computer program, the processor being arranged to execute the method according to any of the claims 1-4 by means of the computer program.
CN201911039398.9A 2019-10-29 2019-10-29 Method and device for acquiring logic expression, storage medium and electronic device Active CN110795697B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911039398.9A CN110795697B (en) 2019-10-29 2019-10-29 Method and device for acquiring logic expression, storage medium and electronic device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911039398.9A CN110795697B (en) 2019-10-29 2019-10-29 Method and device for acquiring logic expression, storage medium and electronic device

Publications (2)

Publication Number Publication Date
CN110795697A CN110795697A (en) 2020-02-14
CN110795697B true CN110795697B (en) 2023-05-26

Family

ID=69442023

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911039398.9A Active CN110795697B (en) 2019-10-29 2019-10-29 Method and device for acquiring logic expression, storage medium and electronic device

Country Status (1)

Country Link
CN (1) CN110795697B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111462327B (en) * 2020-03-12 2022-12-13 成都飞机工业(集团)有限责任公司 Unstructured data analysis method for three-dimensional inspection model of three-dimensional modeling software
CN112541313B (en) * 2020-12-24 2022-03-11 山东高云半导体科技有限公司 Method and device for configuring trigger expression for logic analysis state
CN113421113A (en) * 2021-06-21 2021-09-21 上海微盟企业发展有限公司 Method and device for determining commodity participation coupon, electronic equipment and medium
CN114996452B (en) * 2022-06-02 2023-02-07 中国医学科学院医学信息研究所 Method, system and storage medium for generating medical insurance limited payment text logical expression
CN115345148B (en) * 2022-08-02 2023-07-21 北京新岳纵横科技有限公司 Formalized expression and analysis method for instantaneous state of power grid network

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109670024A (en) * 2018-12-17 2019-04-23 北京百度网讯科技有限公司 Logical expression determines method, apparatus, equipment and medium
CN110088754A (en) * 2016-10-26 2019-08-02 联邦科学和工业研究组织 It makes laws to the autocoder of logic

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9195853B2 (en) * 2012-01-15 2015-11-24 International Business Machines Corporation Automated document redaction

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110088754A (en) * 2016-10-26 2019-08-02 联邦科学和工业研究组织 It makes laws to the autocoder of logic
CN109670024A (en) * 2018-12-17 2019-04-23 北京百度网讯科技有限公司 Logical expression determines method, apparatus, equipment and medium

Also Published As

Publication number Publication date
CN110795697A (en) 2020-02-14

Similar Documents

Publication Publication Date Title
CN110795697B (en) Method and device for acquiring logic expression, storage medium and electronic device
CN112800095B (en) Data processing method, device, equipment and storage medium
CN110221968A (en) Method for testing software and Related product
CN111813963A (en) Knowledge graph construction method and device, electronic equipment and storage medium
US9754083B2 (en) Automatic creation of clinical study reports
CN109635094B (en) Method and device for generating answer
CN109669931A (en) Historical data exception analysis method, system, equipment and storage medium
CN111143505A (en) Document processing method, device, medium and electronic equipment
CN114201242B (en) Method, device, equipment and storage medium for processing data
CN113568626B (en) Dynamic packaging and application package opening method and device and electronic equipment
CN109284452A (en) The online methods of exhibiting of electronic protocol, device, electronic equipment, storage medium
CN108845864A (en) A kind of JVM rubbish recovering method and device based on spring frame
CN116450723A (en) Data extraction method, device, computer equipment and storage medium
CN111274813A (en) Language sequence marking method, device storage medium and computer equipment
CN115712422A (en) Form page generation method and device, computer equipment and storage medium
CN114201376A (en) Log analysis method and device based on artificial intelligence, terminal equipment and medium
CN114780688A (en) Text quality inspection method, device and equipment based on rule matching and storage medium
CN113220367A (en) Applet running method and device, electronic equipment and storage medium
CN111625749B (en) Method, device, equipment and medium for extracting website detail page information of participant company
CN111859985A (en) AI customer service model testing method, device, electronic equipment and storage medium
CN110457323A (en) The processing method and processing device of tables of data
CN115002011B (en) Flow bidirectional test method and device, electronic equipment and storage medium
CN109522211A (en) Interface parameters transmission method, device, electronic equipment and storage medium
CN113836314B (en) Knowledge graph construction method, device, equipment and storage medium
CN115242638B (en) Feasible touch screening method and device, electronic equipment and storage medium

Legal Events

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