Docsity

Shallow Natural Language Processing - Assignment 6 | LING 570, Assignments of Linguistics

Toggle sidebar
bg1
LING 570: Hw6
Due date: 3pm on Nov 7
Parts I-IV are the continuation of Hw5, and will use the same example files under dropbox/07-
08/570/hw5/examples/ as Hw5. Parts V and VI are a followup of Quiz #2 and do not require
programming.
Part I (20 points): Write a script, pp11.sh, that calculates the perplexity of a test data given an
LM built with GT smoothing.
•It is the same as ppl.sh in Part IV of Hw5 except that the probability here is calculated by
interpolating three models. That is, P(w3|w1, w2) = λ3Ptrigram (w3|w1, w2)+ λ2Pbigr am(w3|w2) +
λ1Punigram (w3)
•The format is: ppl1.sh lm file test data output file l1l2l3.
•The first three arguments have the same formats as the ones in Hw5, where lm file is created by
GT smoothing by Part II in Hw5.
•liis the value for λi. Note that the three lambdas should be nonnegative and add up to one. If
they don’t, your code will print out an error message and exit.
Part II (10 points): Write a script, build lm2.sh, that builds an LM using ngram counts.
•It is the same as build lm.sh in Hw5 except that no smoothing is done here; that is,
P(w3|w1, w2) = cnt(w1, w2, w3)
cnt(w1, w2)
Bigram and unigram models are calculated similarly.
•The format is: build lm2.sh ngram count file lm file
•ngram count file has the same format as in Hw5.
•lm file follows the ARPA format (not the modified ARPA format)
Part III (10 points): Write a script, ppl2.sh, that calculates the perplexity of a test data given an
LM built by build lm2.sh in Part II.
•The format is: ppl2.sh lm file test data output file l1l2l3.
•The arguments are the same as the ones for ppl1.sh except that the lm file for ppl2.sh follows
the ARPA format, and is created by build lm2.sh in Part II.
Part IV (30 points): Use hw5/examples/wsj sec0 19.word as training data, and calculate the per-
plexity of hw5/examples/wsj sec22.word.
1
pf2

Partial preview of the text

Download Shallow Natural Language Processing - Assignment 6 | LING 570 and more Assignments Linguistics in PDF only on Docsity!

LING 570: Hw

Due date: 3pm on Nov 7

Parts I-IV are the continuation of Hw5, and will use the same example files under dropbox/07- 08/570/hw5/examples/ as Hw5. Parts V and VI are a followup of Quiz #2 and do not require programming.

Part I (20 points): Write a script, pp11.sh, that calculates the perplexity of a test data given an LM built with GT smoothing.

  • It is the same as ppl.sh in Part IV of Hw5 except that the probability here is calculated by interpolating three models. That is, P (w 3 |w 1 , w 2 ) = λ 3 Ptrigram(w 3 |w 1 , w 2 )+λ 2 Pbigram(w 3 |w 2 )+ λ 1 Punigram(w 3 )
  • The format is: ppl1.sh lm file test data output file l 1 l 2 l 3.
  • The first three arguments have the same formats as the ones in Hw5, where lm file is created by GT smoothing by Part II in Hw5.
  • li is the value for λi. Note that the three lambdas should be nonnegative and add up to one. If they don’t, your code will print out an error message and exit.

Part II (10 points): Write a script, build lm2.sh, that builds an LM using ngram counts.

  • It is the same as build lm.sh in Hw5 except that no smoothing is done here; that is,

P (w 3 |w 1 , w 2 ) = cnt(w 1 , w 2 , w 3 ) cnt(w 1 , w 2 ) Bigram and unigram models are calculated similarly.

  • The format is: build lm2.sh ngram count file lm file
  • ngram count file has the same format as in Hw5.
  • lm file follows the ARPA format (not the modified ARPA format)

Part III (10 points): Write a script, ppl2.sh, that calculates the perplexity of a test data given an LM built by build lm2.sh in Part II.

  • The format is: ppl2.sh lm file test data output file l 1 l 2 l 3.
  • The arguments are the same as the ones for ppl1.sh except that the lm file for ppl2.sh follows the ARPA format, and is created by build lm2.sh in Part II.

Part IV (30 points): Use hw5/examples/wsj sec0 19.word as training data, and calculate the per- plexity of hw5/examples/wsj sec22.word.

Table 1: The perplexity of the test data with different λs and LMs λ 1 λ 2 λ 3 GT lm MLE lm 0.05 0.15 0. 0.1 0.1 0. 0.2 0.3 0. 0.2 0.5 0. 0.2 0.7 0. 0.2 0.8 0 1.0 0 0

(a) 15 points: Fill out Table 1, where each cell is the value of perplexity given the LM and λs. For the GT lm column, the lm is built by build lm.sh and the perplexity is calculated by ppl1.sh. For the MLE lm column, the lm is built by build lm2.sh and the perplexity is calculated by ppl2.sh. The perplexity should be between 100 and 2000. (b) 10 points: Try 10 more λ combinations, and show the results in a table like Table 1. Among the λ values you have tried so far, which yields the lowest perplexity for GT lm? Which yields the lowest perplexity for MLE lm? (c) 5 points: What can you conclude from these experiments?

Part V (20 points): Draw FSTs for the following regular relations.

(a) 5 points: R1 = {(a^2 n+1, bn) | n ≥ 0 }

⋃ {(an, b^2 n) | n ≥ 0 } (b) 5 points: R2 = {(a^2 n, (bcd)n) | n ≥ 0 } (c) 10 points: The FST will take a word x as the input, where a word is [a-z]+. If the word has at least seven characters and ends with -ing, the FST will output the word with -ing removed; otherwise, the FST will output the word unchanged. For instance, if the input is “walking”, the output will be “walk”. If the input is “fixing” or “walkings”, the output will be the same as the input. For the sake of simplicity, you can use the wildcard symbol *, which will match any input symbol. Note that the FST can be non-deterministic; that is, there could be multiple edges coming out of the same node with the same input symbols.

Part VI (10 points): Write a context-free grammar for the language {a+b^3 nc∗d^2 ne∗^ | n ≥ 0 }. Explain what each non-terminal symbol stands for. For instance, S 1 stands for the string c∗.

Submission: There are several ways to submit Part V:

  • Draw the FSTs on paper, and bring the paper to class on Nov 7.
  • Draw the FSTs on paper, scan it, and submit the image file by CollectIt.
  • Draw the FSTs with tools such as Word, Dia, gnuplot, and latex, and submit the electronic file by CollectIt. Choose whichever way is the most convenient to you. For the second and third options, call the file hw6 p5.*. For other parts of the assignment, submit the files by CollectIt.