CN116048526B - Method, device and storage medium for processing route availability document - Google Patents

Method, device and storage medium for processing route availability document Download PDF

Info

Publication number
CN116048526B
CN116048526B CN202310114970.3A CN202310114970A CN116048526B CN 116048526 B CN116048526 B CN 116048526B CN 202310114970 A CN202310114970 A CN 202310114970A CN 116048526 B CN116048526 B CN 116048526B
Authority
CN
China
Prior art keywords
document
rule
route availability
mark
availability
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
CN202310114970.3A
Other languages
Chinese (zh)
Other versions
CN116048526A (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.)
China Southern Airlines Co Ltd
Original Assignee
China Southern Airlines 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 China Southern Airlines Co Ltd filed Critical China Southern Airlines Co Ltd
Priority to CN202310114970.3A priority Critical patent/CN116048526B/en
Publication of CN116048526A publication Critical patent/CN116048526A/en
Application granted granted Critical
Publication of CN116048526B publication Critical patent/CN116048526B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/447Target code generation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/205Parsing
    • G06F40/211Syntactic parsing, e.g. based on context-free grammar [CFG] or unification grammars

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • Software Systems (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Machine Translation (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

The invention discloses a method, a device and a storage medium for processing a course availability document, which comprise the following steps: preprocessing the route availability document to be processed to obtain a preprocessed route availability document; performing lexical analysis on the preprocessed route availability document to obtain a mark stream; adopting a recursion descent method, and carrying out grammar analysis on the mark stream according to a preset grammar rule to generate an abstract grammar tree; and analyzing the abstract syntax tree to obtain the target code of the route availability document to be processed. By adopting the embodiment of the invention, the encoding of the route availability document can be realized, so that the route availability document can be directly processed for a machine.

Description

Method, device and storage medium for processing route availability document
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method, an apparatus, and a storage medium for processing a route availability document.
Background
In order to uniformly manage airspace, more reasonably utilize airspace resources, reduce flow control and improve flight normality, the European Union proposes an ONESKY concept, and a route availability document (Route Availability Document, RAD) is generated by European air navigation safety organization (EUROCONTROL, abbreviated as European control) based on the ONESKY concept, describing rules and constraints which must be followed in order to realize legal route selection. However, while RAD custom defines rule grammars to describe business rules, it is still a human-oriented language that does not form strict structured grammar rules, resulting in a failure to process directly for the machine.
Disclosure of Invention
The invention provides a method, a device and a storage medium for processing a channel availability document, which are used for solving the problem that the channel availability document cannot be directly processed by a machine in the prior art.
In order to achieve the above object, an embodiment of the present invention provides a method for processing a route availability document, including:
preprocessing the route availability document to be processed to obtain a preprocessed route availability document;
performing lexical analysis on the preprocessed route availability document to obtain a mark stream;
adopting a recursion descent method, and carrying out grammar analysis on the mark stream according to a preset grammar rule to generate an abstract grammar tree;
and analyzing the abstract syntax tree to obtain the target code of the route availability document to be processed.
As an improvement of the above solution, the route availability document processing method further includes:
and executing the semantic action corresponding to the target code through a stack virtual machine based on a preset semantic action table so as to restore the business logic of the route availability document to be processed.
As an improvement of the scheme, the preprocessing of the route availability document to be processed to obtain the preprocessed route availability document comprises the following steps:
and according to a preset restoration rule, restoring the logic operators hidden in the route availability document to be processed to obtain the preprocessed route availability document.
As an improvement of the above-described scheme, the restoration rule includes:
when judging that the first sub-rule templates in the route availability document to be processed are directly connected, restoring the hidden logic operators and between the first sub-rule templates;
when the fact that the second sub-rule templates in the route availability document to be processed are segmented by taking the number sequence number as the prefix is judged, restoring the hidden logic operators or between the second sub-rule templates;
and when judging that the sub-rule template allowable-via exists in the route availability document to be processed, taking the non operation for all sub-rule template results after the sub-rule template allowable-via.
As an improvement of the above scheme, the performing lexical analysis on the preprocessed route availability document to obtain a symbol stream includes:
dividing the preprocessed route availability document by taking a logic operator, a left bracket and a right bracket as dividing points to obtain a plurality of marks;
marking the label of each mark according to a preset lexical rule to obtain a mark stream.
As an improvement of the above solution, the preset lexical rule includes:
when judging that the first sign is a logical operator AND, the label of the first sign is AND;
when the second mark is judged to be a logic operator OR, the label of the second mark is OR;
when the third mark is judged to be a logic operator NOT, the label of the third mark is NOT;
when judging that the fourth sign is a logic operator seq, the label of the fourth sign is SEP;
when judging that the fifth mark is left brackets, the label of the fifth mark is LP;
when judging that the sixth mark is a right bracket, the label of the sixth mark is RP;
when judging that the seventh symbol does not belong to any logic operator, a left bracket or a right bracket, the label of the seventh symbol is RULE OBJ.
As an improvement of the above solution, the performing, by using a recursive descent method, a syntax analysis on the symbol stream according to a preset syntax rule, to generate an abstract syntax tree, includes:
converting a preset grammar rule to eliminate left recursion;
and adopting a recursion descent method, and carrying out grammar analysis on the mark stream according to the converted grammar rule to generate an abstract grammar tree.
As an improvement of the above solution, the preset grammar rule includes:
S := S OP T | T (1)
OP := and | or | seq (2)
T := not T | (S) | rule (3)
wherein the derivation formula (1) represents that the non-terminal symbol S derives S OP T or T;
the derivation formula (2) indicates that the non-terminal OP derives a terminal and, or seq;
the derivation formula (3) indicates that the non-terminal T derives a non-T, bracketed expression (S) or rule entity rule.
As an improvement of the above solution, the route availability document processing method further includes:
and executing the semantic action corresponding to the target code through a stack virtual machine based on a preset semantic action table so as to restore the business logic of the route availability document to be processed.
In order to achieve the above object, the embodiment of the present invention further provides a route availability document processing device, including:
the preprocessing module is used for preprocessing the route availability document to be processed to obtain a preprocessed route availability document;
the lexical analysis module is used for performing lexical analysis on the preprocessed route availability document to obtain a mark stream;
the grammar analysis module is used for carrying out grammar analysis on the mark stream according to a preset grammar rule by adopting a recursion descent method to generate an abstract grammar tree;
and the object code generating module is used for analyzing the abstract syntax tree to obtain the object code of the route availability document to be processed.
To achieve the above object, embodiments of the present invention also provide a computer-readable storage medium including a stored computer program; wherein the computer program, when run, controls the device in which the computer readable storage medium resides to perform the route availability document processing method as described above.
Compared with the prior art, the method, the device and the storage medium for processing the route availability document provided by the embodiment of the invention have the advantages that the route availability document to be processed is preprocessed, and the preprocessed route availability document is obtained; performing lexical analysis on the preprocessed route availability document to obtain a mark stream; adopting a recursion descent method, and carrying out grammar analysis on the mark stream according to a preset grammar rule to generate an abstract grammar tree; and analyzing the abstract syntax tree to obtain the target code of the route availability document to be processed, realizing the encoding of the route availability document, directly using the obtained target code by a machine, greatly reducing the code quantity and maintenance work and saving the manpower.
Drawings
FIG. 1 is a flow chart of a way availability document processing method provided by an embodiment of the present invention;
FIG. 2 is a schematic diagram of a lexical rule provided by an embodiment of the present invention;
FIG. 3 is a schematic diagram of an abstract syntax tree provided by an embodiment of the present invention;
FIG. 4 is a schematic diagram of a first execution action of a stacked virtual machine according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of a second execution action of a stacked virtual machine according to an embodiment of the present invention;
FIG. 6 is a schematic diagram of a third execution action of a stacked virtual machine according to an embodiment of the present invention;
FIG. 7 is a schematic diagram of a fourth execution action of a stacked virtual machine according to an embodiment of the present invention;
FIG. 8 is a schematic diagram of a fifth execution of a stacked virtual machine according to an embodiment of the present invention;
FIG. 9 is a schematic diagram of a sixth execution action of a stacked virtual machine according to an embodiment of the present invention;
FIG. 10 is a schematic diagram of a seventh execution action of a stacked virtual machine according to an embodiment of the present invention;
FIG. 11 is a schematic diagram of an eighth execution action of a stacked virtual machine according to an embodiment of the present invention;
FIG. 12 is a schematic diagram of a ninth execution action of a stacked virtual machine according to an embodiment of the present invention;
FIG. 13 is a schematic diagram of a tenth execution of a stacked virtual machine according to an embodiment of the present invention;
FIG. 14 is a block diagram of a route availability document processing device according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Referring to fig. 1, fig. 1 is a flowchart of a route availability document processing method provided by an embodiment of the present invention, where the route availability document processing method includes:
s1, preprocessing a route availability document to be processed to obtain a preprocessed route availability document;
s2, performing lexical analysis on the preprocessed route availability document to obtain a mark stream;
s3, performing syntax analysis on the mark stream according to a preset syntax rule by adopting a recursion descent method to generate an abstract syntax tree;
s4, analyzing the abstract syntax tree to obtain the target code of the route availability document to be processed.
In an alternative embodiment, the preprocessing the route availability document to be processed to obtain a preprocessed route availability document includes:
and according to a preset restoration rule, restoring the logic operators hidden in the route availability document to be processed to obtain the preprocessed route availability document.
Further, the restoration rule includes:
when judging that the first sub-rule templates in the route availability document to be processed are directly connected, restoring the hidden logic operators and between the first sub-rule templates;
when the fact that the second sub-rule templates in the route availability document to be processed are segmented by taking the number sequence number as the prefix is judged, restoring the hidden logic operators or between the second sub-rule templates;
and when judging that the sub-rule template allowable-via exists in the route availability document to be processed, taking the non operation for all sub-rule template results after the sub-rule template allowable-via.
In an alternative embodiment, the performing lexical analysis on the preprocessed route availability document to obtain a token stream includes:
dividing the preprocessed route availability document by taking a logic operator, a left bracket and a right bracket as dividing points to obtain a plurality of marks;
marking the label of each mark according to a preset lexical rule to obtain a mark stream.
In an alternative embodiment, the preset lexical rule includes:
when judging that the first sign is a logical operator AND, the label of the first sign is AND;
when the second mark is judged to be a logic operator OR, the label of the second mark is OR;
when the third mark is judged to be a logic operator NOT, the label of the third mark is NOT;
when judging that the fourth sign is a logic operator seq, the label of the fourth sign is SEP;
when judging that the fifth mark is left brackets, the label of the fifth mark is LP;
when judging that the sixth mark is a right bracket, the label of the sixth mark is RP;
when judging that the seventh symbol does not belong to any logic operator, a left bracket or a right bracket, the label of the seventh symbol is RULE OBJ.
In an alternative embodiment, the parsing the token stream according to a preset syntax rule by using a recursive descent method to generate an abstract syntax tree includes:
converting a preset grammar rule to eliminate left recursion;
and adopting a recursion descent method, and carrying out grammar analysis on the mark stream according to the converted grammar rule to generate an abstract grammar tree.
In an alternative embodiment, the preset grammar rule includes:
S := T { OP T} (1)
OP := and | or | seq (2)
T := not T | (S) | rule (3)
wherein the derivation formula (1) represents that the non-terminal symbol S derives S OP T or T;
the derivation formula (2) indicates that the non-terminal OP derives a terminal and, or seq;
the derivation formula (3) indicates that the non-terminal T derives a non-T, bracketed expression (S) or rule entity rule.
In an alternative embodiment, the route availability document processing method further includes:
and executing the semantic action corresponding to the target code through a stack virtual machine based on a preset semantic action table so as to restore the business logic of the route availability document to be processed.
It will be appreciated that the number of rules for RAD is extremely large, and in order to make it easier to interpret, the rule system has defined basic grammar rules, specifically comprising 3 parts, sub-rule templates, logical operators, special symbols (left brackets, right brackets), where logical operators and special symbols are hidden meanings and are not directly described in the grammar. Each rule is composed of a plurality of sub-rule templates, logical operators and brackets, and a plurality of simple sub-rules are combined through the logical operators and the brackets to construct a specific required business rule.
In order to better understand the embodiment of the present invention, take the following European RAD rule as an example, compile and parse:
ARR FRANKFURT_YZ_GROUP With-RFL-above FL245 in EDVVUIR
except-via
1.LIPMI T911 COL
2.PESOV T180 NIVNU
pretreatment: if the sub-rule templates are directly connected, the templates are in an and relationship; if the rule templates are divided by taking the number sequence number as the prefix, the templates are in an or relationship; if the rule is an accept-via, it means that the result of the rule below it is not.
The result of restoring the example European RAD rule hiding logic operator is as follows:
ARR FRANKFURT_YZ_GROUP
and
With-RFL-above FL245
and
in EDVVUIR
and
not
(LIPMI T911 COL
or
PESOV T180 NIVNU
)
this example means: the arrival airport is a GROUP of frankfurt_yz_group airports, flights having a height greater than FL245 when passing through EDVVUIR information, and except for flights passing through the route lipi waypoint to the route leg of COL waypoint of the T911 route or the route leg of PESOV waypoint to the NIVNU waypoint of the T180 route. The rule contains 5 sub-rules, AND or NOT 3 logical operators, and implies brackets.
Lexical analysis: a typical lexical analyzer breaks down an original text into individual words and tags each word, which are known as tokens. The lexical analysis performed by the embodiment of the invention takes the pretreated course availability document as initial input, and the pretreated course availability document is divided into a sub-rule by traversing the pretreated course availability document and taking a logic operator and brackets (left brackets and right brackets) as dividing points, wherein the sub-rule is similar to the word mark. The lexical rule is shown in FIG. 2 and includes 4 reserved words of logical operations, 2 special symbols of left bracket and right bracket, and other sub-rule entities.
According to lexical rules, the example European RAD rules are segmented and labeled as shown in Table 1:
table 1 symbol and corresponding tag table
Marking device Label (Label)
ARR FRANKFURT_YZ_GROUP RULE OBJ
and AND
With-RFL-above FL245 RULE OBJ
and AND
in EDVVUIR RULE OBJ
and AND
not NOT
( LP
LIPMI T911COL RULE OBJ
or OR
PESOV T180NIVNU RULE OBJ
) RP
Syntax analysis: the module responsible for the parsing is called a parser, which takes the token stream as input, combines the grammar rules, and finally generates an abstract syntax tree. In the lexical analysis stage, the source code is segmented into labeled tokens, and in the grammar analysis stage, the relation between the tokens is defined by grammar rules. For a given token stream and grammar rule, logical relationships between sub-rule entities in the source code can be determined. The grammar rules related to the embodiment of the invention are as follows:
S := S OP T | T (1)
OP := and | or | seq (2)
T := not T | (S) | rule (3)
the above is a derivation of the grammar rules, =can be understood as "derivation", all left symbols (S, OP, T) are non-terminators, meaning that new symbols can be derived from left symbols; a terminator is an abstract symbol that is ultimately derived as a concrete terminator. Except for non-terminal symbols, the remaining symbols are sign correlations from lexical analysis, called terminal symbols.
After the source code is subjected to lexical analysis, if the source code can be deduced from the deduction formula, the source code is indicated to accord with the grammar rule, and a corresponding abstract grammar tree can be generated; the abstract syntax tree stores all information of source codes by using structured data, and is the basis for generating codes subsequently.
Derivation formula (1): s can deduce S OP T or T;
derivation formula (2): the OP may derive and, or, seq three terminators;
derivation formula (3): t may derive a non-T, bracketed expression (S) or a rule entity rule;
for example, for S: =siopt, replacing S to the right with siopt, then converts to:
s: = S OP T OP T OP T OP t..op T, after a certain derivation, the right side S is replaced with T, the final derivation is S: = T OP T OP T OP T OP t..op T, where OP can be replaced with one of 3 terminators according to derivation (2), i.e. the derivation can derive an expression of arbitrary length containing OP operators. For derivation (3), it is described that an expression of one priority over OP, such as T, may derive (S), whereas from the above it is known that S may derive an expression of arbitrary length containing OP operators, i.e. T may be a bracketed priority expression, and that the derivation is recursively nested. Specifically, for each T in the above example, one of 3 expressions, such as T and T not T or (S) and T, may be replaced, and the S derivative returns to the derivative (1), so that the recursive derivative may finally express any length and any nested expression satisfying the above syntax. The result of the grammar and the European RAD rule are matched, so that the grammar rule has the capability of describing the structure of the European RAD rule.
For derivative (2), seq is a unique logic that indicates that the aircraft is passing in sequence, and may not be directly connected.
For the implementation method of the grammar analyzer, the embodiment of the invention is implemented by adopting a recursive descent method. The recursive descent method is to write a subroutine for each non-terminal symbol of the grammar based on the structure of each candidate of the corresponding derivation, for identifying the grammar category represented by the non-terminal symbol. The recursive descent method adopts a recursive realization idea as the name implies, but the grammar is currently a left recursive grammar, and coding according to the grammar can cause infinite recursion, so the grammar needs to be converted to eliminate the left recursion, and the grammar rules after conversion are as follows:
S:=T{OP T} (1')
OP := and | or | seq (2)
T := not T | (S) | rule (3)
wherein { OP T } in the derivative (1') represents that the expression in parentheses is repeated 0 times or more.
In combination with the above derivation, for each non-terminal symbol, a sub-program is written for each non-terminal symbol by a recursive descent method according to the structure of each candidate of the corresponding derivation, so as to identify the grammar category represented by the non-terminal symbol. The abstract syntax tree is a structured description of regular source code, containing all the information expressed by the source code. An example of the abstract syntax tree that the European RAD rules ultimately generate is shown in FIG. 3:
ARR FRANKFURT_YZ_GROUP With-RFL-above FL245 in EDVVUIR and not(LIPMI T911 COL or PESOV T180 NIVNU)
generating an object code: the abstract syntax tree is taken as input, and the target language is generated by analyzing the abstract syntax tree. Each leaf node on the abstract syntax tree represents a sub-rule entity rule; each non-leaf node represents a logical relationship; one for each node. The final target code is a simple instruction composed of some similar assembly languages, and the instruction is simple enough to be analyzed and processed by a stack virtual machine which is created later to restore the business meaning to be expressed by the source code. The semantic action table according to the embodiment of the invention is shown in table 2:
TABLE 2 semantic action table
The semantic actions of table 2 represent the command sequences that the virtual machine actually needs to execute when it parses the instruction. The code generation is carried out by carrying out subsequent traversal on the abstract syntax tree, and each traversed node is generated with a corresponding instruction, so that an instruction sequence (target code) corresponding to the rule can be finally obtained.
The example European RAD rules ultimately generate the object code as follows:
push ARR FRANKFURT_YZ_GROUP;
push With-RFL-above FL245;
and;
push in EDVVUIR;
and;
push LIPMI T911 COL;
push PESOV T180 NIVNU;
or;
not;
and;
target code execution:
the European rule combines a plurality of simple sub-rules through logical operators to form a complex rule, and the complex structure is decomposed into simple instructions, and for rule instructions in the instructions, the rule instructions actually consist of a sub-rule template and specific parameters. The sub-rule templates are simple, and can be processed by a mode matching method; the parsing of rule templates is relatively simple and is not discussed herein.
The object code is similar to assembly language, each command is very simple, and by creating a stack virtual machine to interpret and execute the instructions, the equivalent business effect of source language, such as java's virtual machine JVM, is realized, and is also a stack virtual machine.
The stack virtual machine performs operations such as stacking and popping the generated instruction sequence by establishing a stack, and gradually completes execution of the rule. The actions performed on each instruction stack virtual machine may refer to the semantic actions of table 2. Referring to fig. 4-13, the specific implementation steps of this example are as follows:
instruction 1: push ARR FRANKFURT _YZ_GROUP;
semantic action is: the rule ARR f lankfurt_yz_group is stacked.
Instruction 2: push With-RFL-above FL245;
semantic action is: the rule With-RFL-above FL245 is pushed onto the stack.
Instruction 3: and;
the semantic actions are as follows:
a=check(pop());
the sub-rule With-RFL-above FL245 is popped off, rule checking is carried out, and the obtained result is stored in a;
b=check(pop());
the sub-rule ARR FRANKFURT_YZ_GROUP is popped off, rule checking is carried out, and the obtained result is stored in b;
c=a&&b;
performing AND operation on the two results a and b to obtain a new result and storing the new result into c;
push c;
the new result c is pushed onto the stack.
Instruction 4: push in EDVVUIR;
semantic action is: the rule in EDVVUIR is pushed onto the stack.
Instruction 5: and;
the semantic actions are as follows:
a=check(pop());
the sub-rule in EDVVUIR is popped off the stack, rule checking is carried out, and the obtained result is stored in a;
b=check(pop());
c (previous rule calculation result, bool type) is popped off the stack, rule checking is carried out (checking is not needed here), and the obtained result is saved to b;
c=a&&b;
performing AND operation on the two results a and b to obtain a new result and storing the new result into c;
push c;
the new result c is pushed onto the stack.
Instruction 6: push LIPMI T911 COL;
semantic action is: the rule LIPMI T911 COL is pushed onto the stack.
Instruction 7: push RESOV T180 NIVNU;
semantic action is: the rule RESOV T180 NIVNU is stacked.
Instruction 8: or;
the semantic actions are as follows:
a=check(pop());
the sub-rule PESOV T180 NIVNU is popped out of the stack, and regular check is carried out, so that a result is obtained and stored in a;
b=check(pop());
the sub-rule LIPMI T911 COL is popped off the stack, and regular check is carried out, so that a result is obtained and is stored in b;
c2=a||b;
performing OR operation on the results of the two sub-rules, and storing the results to c2;
push c2;
the new result c2 is pushed.
Instruction 9: non;
the semantic actions are as follows:
a=check(pop());
c2 The (previous rule calculation result, bool type) is popped up, rule check is carried out (check is not needed here), and the obtained result is saved to a;
b=-a;
inverting the new result a and storing the new result a to b;
push b;
the new result b is pushed onto the stack.
Instruction 10: and;
the corresponding semantic actions are as follows:
a=check(pop());
b (previous rule calculation result, bool type) popping, performing rule check (no check is needed here), and saving the obtained result to a;
b=check(pop());
c (previous rule calculation result, bool type) is popped off the stack, rule checking is carried out (checking is not needed here), and the obtained result is saved to b;
c=a&&b;
performing AND operation on the two results a and b to obtain a new result and storing the new result into c;
push c;
the new result c is pushed onto the stack. At this time, all rules are executed and completed, and the obtained c is the final result of the rules.
Through the steps, the source code can be converted into a simple instruction sequence, and the stack virtual machine analyzes the instruction sequence one by one to restore service logic, so that automatic loading and execution of all rules are realized. Therefore, the embodiment of the invention is based on the European control RAD rule grammar, combines with the computer compiling theory, designs a set of rule grammar facing to the computer, and forms a unified rule data model by analyzing the set of rule scripts, thereby finally realizing unified coding and analysis of all European control RAD rules and greatly reducing code quantity and maintenance work.
Referring to fig. 14, fig. 14 is a block diagram showing a path availability document processing apparatus 10 according to an embodiment of the present invention, the path availability document processing apparatus 10 including:
the preprocessing module 11 is used for preprocessing the route availability document to be processed to obtain a preprocessed route availability document;
the lexical analysis module 12 is used for performing lexical analysis on the preprocessed route availability document to obtain a mark stream;
a syntax analysis module 13, configured to perform syntax analysis on the symbol stream according to a preset syntax rule by using a recursive descent method, so as to generate an abstract syntax tree;
and the target code generating module 14 is used for analyzing the abstract syntax tree to obtain the target code of the route availability document to be processed.
Preferably, the route availability document processing device further includes:
and the execution module is used for executing the semantic action corresponding to the target code through the stack virtual machine based on a preset semantic action table so as to restore the business logic of the route availability document to be processed.
Preferably, the preprocessing the path availability document to be processed to obtain a preprocessed path availability document includes:
and according to a preset restoration rule, restoring the logic operators hidden in the route availability document to be processed to obtain the preprocessed route availability document.
Preferably, the restoration rule includes:
when judging that the first sub-rule templates in the route availability document to be processed are directly connected, restoring the hidden logic operators and between the first sub-rule templates;
when the fact that the second sub-rule templates in the route availability document to be processed are segmented by taking the number sequence number as the prefix is judged, restoring the hidden logic operators or between the second sub-rule templates;
and when judging that the sub-rule template allowable-via exists in the route availability document to be processed, taking the non operation for all sub-rule template results after the sub-rule template allowable-via.
Preferably, the lexical analysis is performed on the preprocessed route availability document to obtain a mark stream, which comprises the following steps:
dividing the preprocessed route availability document by taking a logic operator, a left bracket and a right bracket as dividing points to obtain a plurality of marks;
marking the label of each mark according to a preset lexical rule to obtain a mark stream.
Preferably, the preset lexical rule includes:
when judging that the first sign is a logical operator AND, the label of the first sign is AND;
when the second mark is judged to be a logic operator OR, the label of the second mark is OR;
when the third mark is judged to be a logic operator NOT, the label of the third mark is NOT;
when judging that the fourth sign is a logic operator seq, the label of the fourth sign is SEP;
when judging that the fifth mark is left brackets, the label of the fifth mark is LP;
when judging that the sixth mark is a right bracket, the label of the sixth mark is RP;
when judging that the seventh symbol does not belong to any logic operator, a left bracket or a right bracket, the label of the seventh symbol is RULE OBJ.
Preferably, the applying a recursive descent method to parse the token stream according to a preset syntax rule to generate an abstract syntax tree includes:
converting a preset grammar rule to eliminate left recursion;
and adopting a recursion descent method, and carrying out grammar analysis on the mark stream according to the converted grammar rule to generate an abstract grammar tree.
Preferably, the preset grammar rule includes:
S := S OP T | T (1)
OP := and | or | seq (2)
T := not T | (S) | rule (3)
wherein the derivation formula (1) represents that the non-terminal symbol S derives S OP T or T;
the derivation formula (2) represents the non-terminal OP derivation and, or seq;
the derivation formula (3) indicates that the non-terminal T derives a non-T, bracketed expression (S) or rule entity rule.
It should be noted that, the working process of each module in the route availability document processing device 10 according to the embodiment of the present invention may refer to the working process of the route availability document processing method according to the above embodiment, which is not described herein.
To achieve the above object, embodiments of the present invention also provide a computer-readable storage medium including a stored computer program; wherein the computer program, when run, controls a device in which the computer readable storage medium resides to perform the route availability document processing method of the above-described embodiment.
While the foregoing is directed to the preferred embodiments of the present invention, it will be appreciated by those skilled in the art that changes and modifications may be made without departing from the principles of the invention, such changes and modifications are also intended to be within the scope of the invention.

Claims (8)

1. A method of processing a route availability document, comprising:
preprocessing the route availability document to be processed to obtain a preprocessed route availability document;
performing lexical analysis on the preprocessed route availability document to obtain a mark stream;
adopting a recursion descent method, and carrying out grammar analysis on the mark stream according to a preset grammar rule to generate an abstract grammar tree;
and analyzing the abstract syntax tree to obtain the target code of the route availability document to be processed.
The method for preprocessing the route availability document to be processed to obtain the preprocessed route availability document comprises the following steps:
restoring the logic operators hidden in the route availability document to be processed according to a preset restoring rule to obtain a preprocessed route availability document;
performing lexical analysis on the preprocessed route availability document to obtain a mark stream, wherein the method comprises the following steps:
dividing the preprocessed route availability document by taking a logic operator, a left bracket and a right bracket as dividing points to obtain a plurality of marks;
marking the label of each mark according to a preset lexical rule to obtain a mark stream.
2. The route availability document processing method of claim 1, further comprising:
and executing the semantic action corresponding to the target code through a stack virtual machine based on a preset semantic action table so as to restore the business logic of the route availability document to be processed.
3. The route availability document processing method of claim 1, wherein the restoration rule comprises:
when judging that the first sub-rule templates in the route availability document to be processed are directly connected, restoring the hidden logic operators and between the first sub-rule templates;
when the fact that the second sub-rule templates in the route availability document to be processed are segmented by taking the number sequence number as the prefix is judged, restoring the hidden logic operators or between the second sub-rule templates;
and when judging that the sub-rule template allowable-via exists in the route availability document to be processed, taking the non operation for all sub-rule template results after the sub-rule template allowable-via.
4. The route availability document processing method of claim 1, wherein the preset lexical rule comprises:
when judging that the first sign is a logical operator AND, the label of the first sign is AND;
when the second mark is judged to be a logic operator OR, the label of the second mark is OR;
when the third mark is judged to be a logic operator NOT, the label of the third mark is NOT;
when judging that the fourth sign is a logic operator seq, the label of the fourth sign is SEP;
when judging that the fifth mark is left brackets, the label of the fifth mark is LP;
when judging that the sixth mark is a right bracket, the label of the sixth mark is RP;
when judging that the seventh symbol does not belong to any logic operator, a left bracket or a right bracket, the label of the seventh symbol is RULE OBJ.
5. The route availability document processing method of claim 1, wherein the parsing the stream of tokens according to a preset syntax rule using a recursive descent method to generate an abstract syntax tree comprises:
converting a preset grammar rule to eliminate left recursion;
and adopting a recursion descent method, and carrying out grammar analysis on the mark stream according to the converted grammar rule to generate an abstract grammar tree.
6. The route availability document processing method of claim 5, wherein the preset grammar rules comprise:
S := S OP T | T (1)
OP := and | or | seq (2)
T := not T | (S) | rule (3)
wherein the derivation formula (1) represents that the non-terminal symbol S derives S OP T or T;
the derivation formula (2) indicates that the non-terminal OP derives a terminal and, or seq;
the derivation formula (3) indicates that the non-terminal T derives a non-T, bracketed expression (S) or rule entity rule.
7. A route availability document processing device, comprising:
the preprocessing module is used for preprocessing the route availability document to be processed to obtain a preprocessed route availability document;
the lexical analysis module is used for performing lexical analysis on the preprocessed route availability document to obtain a mark stream;
the grammar analysis module is used for carrying out grammar analysis on the mark stream according to a preset grammar rule by adopting a recursion descent method to generate an abstract grammar tree;
the object code generating module is used for analyzing the abstract syntax tree to obtain an object code of the route availability document to be processed;
the method for preprocessing the route availability document to be processed to obtain the preprocessed route availability document comprises the following steps:
restoring the logic operators hidden in the route availability document to be processed according to a preset restoring rule to obtain a preprocessed route availability document;
performing lexical analysis on the preprocessed route availability document to obtain a mark stream, wherein the method comprises the following steps:
dividing the preprocessed route availability document by taking a logic operator, a left bracket and a right bracket as dividing points to obtain a plurality of marks;
marking the label of each mark according to a preset lexical rule to obtain a mark stream.
8. A computer readable storage medium, wherein the computer readable storage medium comprises a stored computer program; wherein the computer program, when run, controls a device in which the computer readable storage medium is located to perform the route availability document processing method according to any one of claims 1 to 6.
CN202310114970.3A 2023-02-13 2023-02-13 Method, device and storage medium for processing route availability document Active CN116048526B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310114970.3A CN116048526B (en) 2023-02-13 2023-02-13 Method, device and storage medium for processing route availability document

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310114970.3A CN116048526B (en) 2023-02-13 2023-02-13 Method, device and storage medium for processing route availability document

Publications (2)

Publication Number Publication Date
CN116048526A CN116048526A (en) 2023-05-02
CN116048526B true CN116048526B (en) 2023-11-10

Family

ID=86131380

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310114970.3A Active CN116048526B (en) 2023-02-13 2023-02-13 Method, device and storage medium for processing route availability document

Country Status (1)

Country Link
CN (1) CN116048526B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020013694A1 (en) * 2000-07-26 2002-01-31 Toshiki Murata Apparatus and method for natural language processing
CN101621480A (en) * 2008-06-30 2010-01-06 国际商业机器公司 Presence server and XSL file processing method used in the same
CN110826314A (en) * 2019-11-07 2020-02-21 中金智汇科技有限责任公司 Rule analysis method and device, electronic equipment and storage medium
CN113971044A (en) * 2021-10-29 2022-01-25 平安科技(深圳)有限公司 Component document generation method, device, equipment and readable storage medium
CN115145584A (en) * 2022-07-15 2022-10-04 杭州博盾习言科技有限公司 Parser generation method, data processing method, medium, and device

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020013694A1 (en) * 2000-07-26 2002-01-31 Toshiki Murata Apparatus and method for natural language processing
CN101621480A (en) * 2008-06-30 2010-01-06 国际商业机器公司 Presence server and XSL file processing method used in the same
CN110826314A (en) * 2019-11-07 2020-02-21 中金智汇科技有限责任公司 Rule analysis method and device, electronic equipment and storage medium
CN113971044A (en) * 2021-10-29 2022-01-25 平安科技(深圳)有限公司 Component document generation method, device, equipment and readable storage medium
CN115145584A (en) * 2022-07-15 2022-10-04 杭州博盾习言科技有限公司 Parser generation method, data processing method, medium, and device

Also Published As

Publication number Publication date
CN116048526A (en) 2023-05-02

Similar Documents

Publication Publication Date Title
CN110196719B (en) Business rule generation method and system based on natural language processing
US9710243B2 (en) Parser that uses a reflection technique to build a program semantic tree
US20070136698A1 (en) Method, system and apparatus for a parser for use in the processing of structured documents
CN106843849B (en) Automatic synthesis method of code model based on library function of document
US9122540B2 (en) Transformation of computer programs and eliminating errors
Cheatham Jr The introduction of definitional facilities into higher level programming languages
US20020143823A1 (en) Conversion system for translating structured documents into multiple target formats
CN113741869B (en) High-performance variable grammar programming language construction method
EP4195092B1 (en) Text processing method and apparatus, system, device, and storage medium
CN110347416B (en) Script updating method and device
Drewes et al. Extending predictive shift-reduce parsing to contextual hyperedge replacement grammars
KR102546424B1 (en) Machine learning data generating apparatus, apparatus and method for analyzing errors in source code
US20080141230A1 (en) Scope-Constrained Specification Of Features In A Programming Language
CN116048526B (en) Method, device and storage medium for processing route availability document
CN112114817A (en) COBOL language-based data dictionary field information acquisition method and device
CN116257245A (en) Multi-output compiling method and system based on flex and bison grammar analysis
CN116483314A (en) Automatic intelligent activity diagram generation method
JPH11249903A (en) Abstract syntax tree processing method, computer readable storage medium recording abstract syntax tree processing program, computer readable storage medium recording abstract syntax tree data, and abstract syntax tree processing
CN114757181A (en) Method and device for training and extracting event of end-to-end event extraction model based on prior knowledge
CN112507083A (en) Anti-error rule base construction method based on scheduling anti-error field language
CN112905232A (en) Program code parallel corpus mining method and system based on syntax analysis tree
Plátek et al. On pumping RP-automata controlled by complete LRG (¢, $)-grammars
Nilsson et al. Parsing formal languages using natural language parsing techniques
CN115130434A (en) Paragraph text information processing method and system
van Staden et al. Parsing Semi-structured Languages: A Crochet Pattern to Diagram Translation

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