Skip to main content
留学咨询

辅导案例-COMP3411-Assignment 3

By May 15, 2020No Comments

2020/5/7 Assignment 3 – Natural Language Processing (DRAFT !!!) | COMP3411 20T1 | WebCMS3 https://webcms3.cse.unsw.edu.au/COMP3411/20T1/resources/44713 1/9 Resources / Assignments (/COMP3411/20T1/resources/40712) / Assignment 3 – Natural Language Processing (DRAFT !!!) Assignment 3 – Natural Language Processing (DRAFT !!!) Assignment 3 – Natural Language Processing Due Monday 11 May 5pm This assignment requires extending a definite clause grammar to perform reference resolution. You can find the grammar for a subset of English here (http://cse.unsw.edu.au/~cs3411/20T1/prolog/ass3.pl.txt) . Download it as ass3.pl . You are required to write a Prolog predicate process(LogicalForm, Ref1, Ref2) , which you will find at the bottom of the file. DON’T PANIC!!! It’s a complicated program but most of the work has already been done for you. You run the program by calling the predicate run (Sentence, [RefList]) : run(S, Refs) :- sentence(X, S, []), !, writeln(X), process(X, [], Refs), listing(history/1). This takes an input sentence, S , and outputs, Refs , which is a list of the objects that each pronoun refers to. For example: ?- run([john,lost,his,wallet], Refs). event(lost,[actor(thing(john,[])),object(possessive(his,thing(wallet,[])))]) history(thing(john, [isa(person), gender(masculine), number(singular)])). history(thing(wallet, [isa(physical_object), gender(neutral), number(singular)])). history(event(lost, [actor(thing(john, [])), object(possessive(his, thing(wallet, [])))])). Refs = [john] This first line of the output is the parse of the sentence. You don’t have to do anything to get this. It’s already written for you, but you have to wrote the process predicate. This takes the logical form of the parsed sentence (i.e. event( lost, …)) and goes through the logical form, looking for pronouns and finding which previous phrases they refer to. Each time you encounter a noun phrase or a verb phrase, you should use assert to add a new entry to the history in Prolog’s database. Specification Make Submission Check Submission Collect Submission 2020/5/7 Assignment 3 – Natural Language Processing (DRAFT !!!) | COMP3411 20T1 | WebCMS3 https://webcms3.cse.unsw.edu.au/COMP3411/20T1/resources/44713 2/9 A history entry looks like history(H) , where H represents either an event for a verb phrase, or a thing for a noun phrase. The next three lines in the output are the history entries that the program should create as a result for processing the logical form in this example. The last line of the output is the list of resolved references. In this case, there’s only one: his resolves to John. Process takes three arguments. The first is the logical form, e.g. Your job is to write the process program. You can write as many additional predicates to help as you want, and you can even change the grammar, it you really want to dive into the code. You will have to work your way, recursively through the logical form and when you see a thing term or an event tern, assert a new history entry. When you see either a personal pronoun, or a possessive pronoun, you should use the history to find a suitable match. In the example above, the possessive pronoun, his , refers to something in the same sentence, i.e. john . You should also be able to resolve references across sentences: ?- run([he,looked,for,it], Refs). Refs =[john, wallet] This is why we use assert . It allows us to store the history so that can resolved references in subsequent sentences. If you want to reset the history, use the abolish built-in predicate: ?- abolish(history/1). This will clear the database of the history entries. You’ll need to use this when you are testing because assert because if you re-run the same code, you’ll end up with duplicates in the database. Resolving a Pronoun When you come across a pronoun, use the following strategy to find the object it is referring to: You’ll see in the code that all words have properties associated with them, e.g. number (singular, plural), gender (masculine, feminine, neutral), and a type (person, physical object, abstract object, place). You search the history for things that match the properties of the pronoun . Here is a hint for who to do that for a personal pronoun: personal(Pronoun, Props1), member(gender(Gender), Props1), member(number(Number), Props1), history(thing(Ref, Props2)), member(gender(Gender), Props2), member(number(Number), Props2). The first line of this code looks up the personal pronoun entry, e.g. the entry for she , is: ?- process(event(lost,[actor(thing(john,[])),object(possessive(his,thing(wallet,[])))]), [], Re Refs = [John] 2020/5/7 Assignment 3 – Natural Language Processing (DRAFT !!!) | COMP3411 20T1 | WebCMS3 https://webcms3.cse.unsw.edu.au/COMP3411/20T1/resources/44713 3/9 Resource created 13 days ago (Friday 24 April 2020, 03:23:07 AM), last modified 2 days ago (Monday 04 May 2020, 10:18:43 PM). personal(she, [number(singlar), gender(feminine)]). so a call: ?- personal(she, X). X = [number(singlar), gender(feminine)] returns the properties of the pronoun. Calling ?- member(gender(Gender), [number(singlar), gender(feminine)]). Gender = feminine returns the gender. The call history(thing(Ref, Props2)) will find an entry on the history list and the following calls to member , check if this history entry has the same number and gender. if they don’t match, Prolog will backtrack until it finds successful match, or else fail. This is the way you can search the history list. WARNING: This is not a perfect method for resolving references. In fact, there is no perfect method. All reference resolution methods involve heuristics that work a lot of the time, but can fail for some examples. For the purposes of this assignment, we will accept any code that makes reasonable matches. Submission You will submit using give, as usual. It has not been set up yet, but we will announce when give is open and the details. Please keep all your code in the one file, called ass3.pl. That is, only modify the file we’ve given you. Do not include your test examples. Comments   (/COMP3411/20T1/forums/search?forum_choice=resource/44713)  (/COMP3411/20T1/forums/resource/44713) Add a comment Luka Gamulin-Abedrop (/users/z5163726) about 9 hours ago (Wed May 06 2020 20:48:03 GMT+1000 (澳大利亚东部标准时间)) can we share tests? Reply Claude Sammut (/users/z8400090) about 6 hours ago (Wed May 06 2020 23:41:48 GMT+1000 (澳大利亚东部标准时间)) Do you mean you try another student’s tests and they try yours? Yes. No problem. Just don’t your share code!

admin

Author admin

More posts by admin