代写CSC 485H/2501H: Computational linguistics, Fall 2024 Assignment 3代做Java程序

CSC 485H/2501H: Computational linguistics, Fall 2024

Assignment 3

Overview: Symbolic Machine Translation

In this assignment, you will learn how to write phrase structure grammars for some different lin- guistic phenomena in two different languages: English and Chinese. You can use the two grammars to create an interlingual machine translation system by parsing in one, and generating in the other. Don’t panic if you don’t speak Chinese, and also don’t cheer up yet if you can speak the language — it won’t give you much of an advantage over other students. A facility with languages in general will help you, as will the ability to learn and understand the nuances between the grammars of two different languages. In particular, you will start by working on agreement. Then, you will need to analyse the quantifier scoping difference between the two languages.

TRALE Instructions    The instructions to setup and launch TRALE on teach.cs can be found in:

https://www.cs.toronto.edu/~niu/csc485/trale/setup/

1. Agreement: Determiners, Numbers and Classifiers [10 marks]

English expresses subject–verb agreement in person and number. English has two kinds of number: singular and plural. The subject of a clause must agree with its predicate: they should be both singular or both plural. However, the number of a direct object does not need to agree with anything.

(1)        A programmer annoys a dolphin.

(2)        Two programmers annoy a dolphin.

(3)      * Two programmers annoys two dolphins.

(4)      * A programmer annoy two dolphins.

Chinese, on the other hand, does not exhibit subject–verb agreement. As shown in the examples below, most nouns do not inflect at all for plurality. Chinese does, however, have a classifier (CL) part of speech that English does not. Semantically, classifiers are similar to English collective nouns (a bottle of water, a murder of crows), but English collective nouns are only used when describing collectives. With very few exceptions, classifiers are mandatory in complex Chinese noun phrases. Different CLs agree with different classes of nouns that are sorted by mostly semantic criteria. For example, 学生 (xuesheng)  student is a person and an occupation, so it should be classified by either 个 (ge) or 名 (ming) and cannot be classified by the animal CL 只 (zhi). However, the rules of determining a noun’s class constitute a formal system that must be followed irrespective of semantic similarity judgements. For example, while wolves and sheep are both animals and can both be classified by the animal CL 只 (zhi), 狼 (lang) wolf can take another classifier, 匹 (pi).

(5)        一    学生

yi   ge      xuesheng one ge-CL student

(6)        两     学生

liang ge      xuesheng two   ge-CL student

(7)        三     学生

san   ge      xuesheng three ge-CL student

(8)      * 三  学生

san   xuesheng three student

(9)      * 三  只   学生

san   zhi      xuesheng three zhi-CL student

(10)        一 只   羊

yi   zhi      yang  one zhi-CL sheep

(11)        两  只   羊

liang zhi      yang  two   zhi-CL sheep

(12)        三  只   羊

san   zhi      yang  three zhi-CL sheep

(13)      * 三  匹  羊

san   pi      yang  three pi-CL sheep

(14)      * 三  名     羊

san   ming      yang  three ming-CL sheep

You should be familiar by now with the terminology in the English grammar starter code for

this question. The Chinese grammar is fairly similar, but there is a new phrasal category called a classifier phrase (CLP), formed by a number and a classifier. The classifier phrase serves the same role as a determiner does in English.

The two grammars below don’t appropriately constrain the NPs generated. You need to design your own rules and features to properly enforce agreement.

English Grammar:

Chinese Grammar:

Rules:

Rules:

NP Det N

CLP Num CL

NP Num N

NP  CLP N

VP V NP

VP V NP

S NP VP

S NP VP

Lexicon:

Lexicon:

a:               Det

   yi one/a                   Num

one:           Num

   liang two                 Num

two:           Num

    san three                  Num

three:         Num

 

student:     N

学生  xuesheng student    N

students:    N

   lang wolf                 N

wolf:          N

   yang sheep              N

wolves:      N

 

sheep:        N

追逐  zhuizhu chase         V

sheep:        N

看见  kanjian see              V

see:            V

sees:          V

saw:           V

chase:        V

chases:      V

    ge                             CL

   ming                        CL

    zhi                           CL

    pi                             CL

chased:      V

 

Here is a list of all of the nouns in this question and their acceptable classifiers:

•  狼 lang wolf: 只 zhi; 匹 pi;

•  羊 yang sheep: 只 zhi

•  学生 xuesheng student: 个 ge, 名 ming.

(a)  (6 marks) Implement one grammar for each language pursuant to the specifications above. English: q1_en.pl and Chinese: q1_zh.pl.

Neither of your grammars need to handle embedded clauses, e.g., a student caught two wolves see a sheep. Similarly for Chinese, your grammar doesn’t need to parse sentences like example (15):

(15)    一 名  学生    看见  两  匹   追逐    

yi  ming xuesheng kanjian liang pi  lang zhuizhu yi  zhi yang A student saw two wolves chase a sheep.

For the Chinese grammar, code the lexical entries in pinyin (the Romanized transcriptions of the Chinese characters).

(b)  (4 marks) Use your grammars to parse and translate the following sentences. Save and submit all the translation results in the .grale format. The results of sentence (16) should be named q1b_en.grale and the results of sentence (17) should be named q1b_zh.grale.

(16)    Two wolves saw one sheep

(17)    两  个 学生    追逐    

liang ge xuesheng zhuizhu san zhi yang

Operational Instructions

•  Independently test your grammars in TRALE first, before trying to translate.

•  Use the function translate to generate a semantic representation of your source sen- tence. If your sentence can be parsed, the function translate should open another gralej interface with all of the translation results.

| ?- translate([two,wolves,catch,one,sheep]).

•  To save the translation results, on the top left of the Gralej window (the window with the INITIAL CATEGORY entry and all of the translated sentences listed),click File >> Save all >> TRALE format.

•  Don’t forget to close all of the windows or kill both of the Gralej processes after you finish. Each Gralej process will take up one port in the server, and no one can use the server if we run out of ports.


2. Quantifier Scope [30 marks]

For this assignment, we will consider two quantifiers: the universal quantifier (every, 每 mei) and the existential quantifier (a, 一 yi). In English, both quantifiers behave as singular determiners.

(18)        A professor stole every cookie.

(19)      * A professor stole every cookies.

(20)      * A professors stole every cookie.

In Chinese, both of these quantifiers behave more like numerical determiners. In addition, when a universal quantifier modifies an NP that occurs before the verb (such as with a universally quanti- fied subject), the preverbal operator  (dou) is required. When a universally quantified NP occurs after the verb, the dou-operator must not appear with it.

(21)        Every professor stole a cookie.

(22)        A professor stole every cookie.

(23)        每    教授     偷了 一 块    饼干

mei ge      jiaoshou  dou  tou-le yi  kuai      binggan ∀   ge-CL professor DOU stole   ∃  kuai-CL cookie

(24)      * 每    教授    偷了 一 块    饼干

mei ge      jiaoshou  tou-le yi  kuai      binggan ∀   ge-CL professor stole   ∃  kuai-CL cookie

(25)        一    教授    偷了  块    饼干

yi  ge      jiaoshou  tou-le mei kuai      binggan ∃  ge-CL professor stole   ∀   kuai-CL cookie

(26)      * 一    教授     偷了  块    饼干

yi  ge      jiaoshou  dou tou-le mei kuai      binggan ∃  ge-CL professor dou stole   ∀    kuai-CL cookie

Quantifier Scope Ambiguity    In lecture, we talked about different kinds of ambiguity. In many English sentences, no matter what the order of the quantifiers, there is a quantifier scope ambiguity. For example, the sentence every student takes a course has two readings:

•  (∃ > ∀) Every student takes a course. [The course is Math.]

•  (∀ >  ∃) Every student takes a course.  [Some students take Math and some students take History.]

The symbol (∃ > ∀) means the existential quantifier outscopes the universal quantifier in a logical form. representation of the sentence.

Figure 1: Beta Reduction. What should be the LF of S?


We can write the semantics of the two sentences in their logical forms (LF) to distinguish the two readings:

•  ∃y.(course(y) Λ ∀x.(student(x) ⇒ take(x, y)))

•  ∀x.(student(x) ⇒ ∃y.(course(y) Λ take(x, y)))

English sentences (27, 28) are scopally ambiguous no matter what the linear order of the quan- tifiers is. But in Chinese, a sentence is scopally ambiguous only when the universally quantified NP precedes the existential NP: (29) is ambiguous, but (30) is unambiguous.

(27)    Every student takes a course Ambiguous: ∃ > ∀, ∀ > ∃

(28)    A student takes every course Ambiguous: ∃ > ∀, ∀ > ∃

(29)    每    学生      会上           课程

mei ge      xuesheng dou  huishangyi  zhong      kecheng ∀   ge-CL student     DOU take          ∃  zhong-CL course    Ambiguous: ∃ > ∀, ∀ > ∃

(30)    一    学生    会上   每 种      课程

yi  ge      xuesheng huishang mei zhong      kecheng ∃  ge-CL student     take         ∀   zhong-CL course    Unambiguous: ∃ > ∀

How can we derive the LF of the two readings? We use a process called beta reduction. Recall the lambda-calculus notation: λx.x2  denotes a function that takes a variable x, and returns the square of its value (x2 ). After substituting the value for the bound variable x, we can reduce the function application in the body of the lambda term to a new expression. For example, applying 2 to λx.xwill get us:

λx.x2 (2) = 22


Figure 2: Beta reduction analysis of the sentence every student takes a course.



This process is also known as beta reduction (denoted as β ). Note that beta reduction itself does not tell us that this equals 4. That is obtained by a subsequent process of arithmetic evaluation. But we can use beta reduction even if we don’t evaluate.

We can also perform beta reduction on variables for functions. For example, applying in λF.F (2) to λx.x2  will yield:

λF.F (2) (λx.x2 ) = (λx.x2 )(2) = 22

Now, let’s look at an example that uses beta reduction to compute the LF of a sentence. For ex- ample, as shown in figure 1, we know that the LF of the NP every student is λP.丫x.(student(x) 今 P (x)) and the LF of the VP takes a course is λz.彐y.(course(y) Λ take(z, y)). What is the LF of every student takes a course?

λP.丫x.(student(x)  P (x))(λz.彐y.(course(y) Λ take(z, y))) 今β  丫x.(student(x)  λz.彐y.(course(y) Λ take(z, y))(x))

β  丫x.(student(x)  彐y.(course(y) Λ take(x, y)))

Each step of repeatedly applying beta reduction to every subterm until we reach an irreducible statement is called beta normalisation.

Figure 2 shows the complete analysis of the sentence every student takes a course. Familiarize yourself with every part of the analysis. But this only generates one of the two readings – the surface reading (丫 > 彐). We will use a technique called quantifier storage to capture the scopal ambiguity and make both readings available.

Quantifier Storage    If quantifier scoping is a semantic effect, how do we represent it in syntax? When there is no ambiguity, keeping track of the quantifier scope is pretty straightforward. To keep track of and resolve scope ambiguities, we will use a list called a quantifier store. The idea behind QSTORE is that, instead of consuming all of the LF components right away, we can choose to keep them in QSTORE and apply them later.

Figure 3: Quantifier Storage. Storing the quantifier at (1), and retrieve it later at (2).


Let’s go back to the example, every student takes a course (figure 3). We first store the LF of the NP a course at (1) and replace the LF of the NP with a placeholder λF.F (z). The variable z in this expression is a free occurrence, and it is the same variable as the z in the store and in the LF of the sentence (the free occurrences of z are highlighted in red). We retrieve the logical form from the store at (2). The retrieval process consists of three steps:

1.  First, we construct a function λz.LS , where LS is the current LF, and z is the variable paired in the QSTORE entry. In our particular case, this will yield λz. (丫x, student(x)  take(x, z)).

2.  Then, we apply this function to the LF from the QSTORE entry.

3.  Finally, we beta normalise. Using beta normalisation, we obtain the second reading of the sentence.

λG.彐y.(course(y) Λ G(y))(λz. (丫x, student(x)  take(x, z))) 今β  彐y.(course(y) Λ (λz. (丫x.student(x)  take(x, z))(y))

β  彐y.(course(y) Λ (丫x.student(x)  take(x, y))


热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图