


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!



CSE 231 Summer 2009
This assignment is worth 80 points (8% of the course grade) and must be completed and turned in before midnight on Tuesday, June 23 rd . This assignment is an exercise in the use of dictionaries and functions. Background In this project, we will do some more work on text processing. You will explore the n-gram concept in Natural Language Processing. N-grams are sequential patterns of n-words that appear in a document. To simplify the project, we are just considering unigrams and bigrams. Unigrams are the unique words that appear in a text whereas bigrams (bi-grams) are patterns of two-word sequences that appear together in a document. Essentially, unigrams are word counts, the number of times a word occurred in documents in the data set being examined. Bigrams are the number of times a two-word sequence has occurred in documents of our data set. Consider the following short document: This is a test This is only a test A test should not cause concern Is this test difficult? First, we note that case does not matter. Thus “Test” and “test” are equivalent for our purposes. For unigrams (word counts), we have the following: “test”:4, “this”:3, “is”:3, “a”:3, “only”:1, “should”:1, “not”:1, “cause”:1, “concern”:1, “difficult”: For bigrams, we look for two word sequences in either order. That is, the two words “operating systems” or “systems operating” should count as the same bigram. With that in mind, we get the following bigrams from our text: “this is”:3, “is a”:1, “a test”:3, “is only”:1, “test should”:1, “should not”:1, “not cause”:1, “cause concern”:1, “this test”:1, “test difficult”: Note the count of the bigram “this is” is 3, since “This is” occurred on lines 1 and 2 and “Is this” occurred on line 4. Also, note that we typically process documents to remove common words such as “a”, “an”, “or”, “and”, “but”, or “the” as they contribute little to the uniqueness of a document. In the end, we can use the statistics of bigram occurrence vs. unigram occurrence to tell something about the uniqueness of a document.
Assignment Overview You will are given a dataset called “web.txt” which is a collection of web pages that were extracted from the webkb publically available dataset (http://www.cs.cmu.edu/~WebKB/). The goal of webkb is to provide a common set of documents to test the ability of search engines. We did some preprocessing on this dataset and selected a subset of webkb for this project. You are required to find all the unigrams and the bigrams in the data set and display the contingency table (described below) for a selected number of bigrams which are given in “bigram.txt”; a file that we provided for you. Task There are three main components of this project. Each component is to be written as a separate function (that means three functions, at a minimum).
systems ~systems programming 6 364 ~programming 121 88306
home ~home frontpage 1 0 ~frontpage 302 88494
science ~science fall 8 133 ~fall 142 88514