Question
---------------------------------------------------------------------------- Updated Grammar Rules and the Translation Results ----------------------------------------------------------------------------- Your program will be producing internal representations of sentences. The Internal Rep (IR) and updated grammar
----------------------------------------------------------------------------
Updated Grammar Rules and the Translation Results
-----------------------------------------------------------------------------
Your program will be producing internal representations of sentences.
The Internal Rep (IR) and updated grammar rules that include calls to semantic routines for the 5 cases of are as follows.
Please note that #s are used to indicate names of semantic routines.
e.g.
In a, call b, call the semantic routine xyz, and then call c.
In the following IRs, italics is used for description of actual values while
Upper Case letters are used for scanner token types of some reserved words.
For Case 1:
::= [CONNECTOR #getEword# #gen#]
PERIOD
IR to be produced is:
CONNECTOR: english-word
ACTOR: word or english-word
ACTION: word
TENSE: VERB or VERBNEG or VERBPAST or VERBPASTNEG
e.g. for "rika wa naki masen" (there is no connector)
ACTOR: rika
ACTION: naki
TENSE: VERBNEG
For Case2:
::= [CONNECTOR #getEword# #gen#]
PERIOD
IR to be produced is:
CONNECTOR: english-word
ACTOR: word or english-word
DESCRIPTION: word or english-word
TENSE: IS or WAS
e.g. for "rika wa shiawase desu" (there is no connector)
ACTOR: rika
DESCRIPTION: shiawase
TENSE: IS
e.g. for "dakara watashi wa kanashii deshita" (there is a connector)
CONNECTOR: Therefore
ACTOR: I/me
DESCRIPTION: kanashii
TENSE: WAS
For Case 3:
::= [CONNECTOR #getEword# #gen#]
IR to be produced is:
CONNECTOR: english-word
ACTOR: word or english-word
TO: word or english-word
ACTION: word
TENSE: VERB or VERBNEG or VERBPAST or VERBPASTNEG
e.g. for "rika wa kurasu ni iki masu"
ACTOR: rika
TO: kurasu
ACTION: Iki
TENSE: VERB
For Case 4:
::= [CONNECTOR #getEword# #gen#]
PERIOD
IR to be produced is:
CONNECTOR: english-word
ACTOR: word or english-word
OBJECT: word or english-word
ACTION: word
TENSE: VERB or VERBNEG or VERBPAST or VERBPASTNEG
e.g. for "rika wa ringo o tabe mashita"
ACTOR: rika
OBJECT: ringo
ACTION: tabe
TENSE: VERBPAST
For Case 5:
::= [CONNECTOR #getEword# #gen#]
PERIOD
IR to be produced is:
CONNECTOR: english-word
ACTOR: word or english-word
OBJECT: word or english-word
TO: word or english-word
ACTION: word
TENSE: VERB or VERBNEG or VERBPAST or VERBPASTNEG
e.g. for "shikashi watashi wa okane o kare ni
age masendeshita"
CONNECTOR: However
ACTOR: I/me
OBJECT: okane
TO: he/him
ACTION: age
TENSE: VERBPASTNEG
NOTE:
1) Notice that some parts of the Internal Representations are still in
Japanese. This is because your dictionary is incomplete. Thats fine.
2) We are NOT writing the generator which transforms the above Internal
Representations into actual English sentences.
That would be a separate program.
----------------------------------------------------------------
How to get English Words from the Lexicon/Dictionary:
Tasks for semantic function #getEword#
-----------------------------------------------------------------
For each entry in the Internal Representation of a sentence,
either a Japanese word or its English equivalent must be displayed.
To do this we will use #getEword#.
Whatever #getEword# retrieves will be saved and then be later used by #gen#
As soon as each CONNECTOR,
(before we lose the current lexeme), call #getEword#.
Hint: current lexeme saved in saved_lexeme.
#getEword# looks up the Lexicon/Dictionary and saves the English word in saved_E_word..
But if the word is not in the Lexicon/Dictionary, just save the Japanese word saved_E_word.
The exact places in your code where you call #getEword# depend on
how you re-wrote the grammar rules. But it has to be right after
CONNECTOR was matched,
-------------------------------------------------
How to produce IR with #gen#
-------------------------------------------------
In the grammar rules above,
#gen# marks the places in where
generation of a line of the Internal Representation has to occur.
e.g. ACTOR: rika
The output from #gen# should go to the file translated.txt.
Make sure this file is new each time you use the parser.
In , right after CONNECTOR is seen,
#gen# generates the CONNECTOR: line with #getEword# result of CONNECTOR
In , right after SUBJECT is seen,
#gen# generates the ACTOR: line with #getEword# result of
In , right after
#gen# generates the DESCRIPTION: line with #getEword# result of
#gen# generates the TENSE: line with scanner token type of the tense.
Hint: current token_type is found in saved_token.
In , right after OBJECT is seen,
#gen# generates the OBJECT: line with #getEword# result of
In , right after DESTINATION is seen,
#gen# generates the TO: line with #getEword# result of
In , right after
#gen# generates the ACTION: line with #getEword# result of
In , right after
#gen# generates the TENSE: line with scanner token type of the tense.
Hint: current token_type is found in saved_token.
The exact places in your code where you call #gen# depend
on how you re-wrote the grammar rules.
Note that #gen# has to be passed what kind of line it is to generate
e.g. gen(description of line).
Given the kind of line and the saved_E_word or saved_token a line can be generated.
How do we write the grammar rule for it??
There has to be 8 cases.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started