

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


LING 570: Hw Due date: 3pm on Oct 31 All the examples are under ~/dropbox/07-08/570/hw5/examples/. Part I (20 points) : write a script, ngram_count.sh , that collects ngram counts (n=1,2,3). o The format is: ngram_count.sh training_data ngram_count_file The format of the training data: w1 w2 … w_n; that is, one sentence per line. See training_data_ex as an example. The format of ngram_count_file is: key count o key and count are separated by a tab (i.e., \t) o The words in a key are separated by a space (i.e., \s) o See ngram_count_ex as an example You need to add BOS and EOS to the input sentence yourself. The BOS string is “” and the EOS string is “”. For instance, if the input sentence is John call Mary After adding the markup, the sentence will become John call Mary Part II (40 points): write a script, build_lm.sh, that builds an LM using ngram counts: o The format is: build_lm.sh ngram_count_file lm_file o ngram_count_file is the file produced by Part I. o lm_file follows the modified ARPA format, as discussed in class. See lm_ex as an example. o Use Good-Turing for smoothing. o gt_min values are 1, 1, 2 for unigram, bigram, and trigram, respectively. o gt_max values are 1, 7, 7 for unigram, bigram, and trigram, respectively. Part III (15 points): run Part I and II with wsj_sec0_19.word as the training data and fill out the following tables. N is the number of ngram tokens in the training data. N_i is the number of ngram types that occur i times in the training data. N N_0 N_1 N_2 N_3 N_4 N_5 N_6 N_7 N_ unigram bigram trigram
c_i* is the adjusted count for a ngram if the ngram occurs i times in the training data. c_0* c_1* c_2* c_3* c_4* c_5* c_6* c_7* c_8* unigram bigram trigram Part IV (25 points): Write a script, ppl.sh , that calculates the perplexity of a test data given an LM. o The format is: ppl.sh lm_file test_data output_file o lm_file is created in Part II. o test_data has the same format as the training data. See test_data_ex as an example. o output_file’s format has been discussed in class. An example file, ppl_ex, will be created under the examples/ directory soon.