Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
unlAnt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
UNL
unlAnt
Commits
ac19a74e
Commit
ac19a74e
authored
3 years ago
by
Aurélien Lamercerie
Browse files
Options
Downloads
Patches
Plain Diff
ORG and UNL parsing (Concrete syntax only)
parent
116f46a7
No related branches found
No related tags found
No related merge requests found
Changes
21
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
parse.py
+34
-2
34 additions, 2 deletions
parse.py
with
34 additions
and
2 deletions
parse.py
+
34
−
2
View file @
ac19a74e
...
...
@@ -85,11 +85,35 @@ def parse_document(input):
def
parse_org
(
input
):
pass
# -- Create python lexer and parser
create_lexer_parser_with_antlr
(
org_grammar
)
# -- Import Lexer/Parser (after creation by ANTLR4)
from
grammar.org.orgLexer
import
orgLexer
from
grammar.org.orgParser
import
orgParser
# -- Parse UNL part
parser
=
instantiate_lexer_parser
(
input
,
orgLexer
,
orgParser
)
print
(
"
--- Parse origin sentence
"
)
tree
=
parser
.
orgPart
()
print
(
"
----- resulting tree:
\n
"
+
tree
.
toStringTree
(
recog
=
parser
))
def
parse_unl
(
input
):
pass
# -- Create python lexer and parser
create_lexer_parser_with_antlr
(
unl_grammar
)
# -- Import Lexer/Parser (after creation by ANTLR4)
from
grammar.unl.unlLexer
import
unlLexer
from
grammar.unl.unlParser
import
unlParser
# -- Parse UNL part
parser
=
instantiate_lexer_parser
(
input
,
unlLexer
,
unlParser
)
print
(
"
--- Parse UNL representation
"
)
tree
=
parser
.
unlPart
()
print
(
"
----- resulting tree:
\n
"
+
tree
.
toStringTree
(
recog
=
parser
))
#==============================================================================
...
...
@@ -110,6 +134,14 @@ def main(argv):
print
(
"
----- org_part:
\n
"
+
org_part
)
print
(
"
----- unl_part:
\n
"
+
unl_part
)
# -- ORG Parsing (Sentence Original Part)
print
(
"
-- ORG Parsing (Origin Sentence)
"
)
parse_org
(
InputStream
(
org_part
))
# -- UNL Parsing (Sentence UNL Part)
print
(
"
-- UNL Parsing (UNL Representation)
"
)
parse_unl
(
InputStream
(
unl_part
))
if
__name__
==
'
__main__
'
:
main
(
sys
.
argv
)
This diff is collapsed.
Click to expand it.
Prev
1
2
Next
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment