Programming Assignment 1

Similar documents
Programming Standards: You must conform to good programming/documentation standards. Some specifics:

Assignment 1: PostgreSQL Buffer Manager

CMPSCI 187 / Spring 2015 Sorting Kata

CS2630: Computer Organization Project 2, part 1 Register file and ALU for MIPS processor Due July 25, 2017, 11:59pm

Assignment 3 ITCS-6010/8010: Cloud Computing for Data Analysis

CS155: Computer Security Spring Project #1

CS 344/444 Spring 2008 Project 2 A simple P2P file sharing system April 3, 2008 V0.2

CSCI544, Fall 2016: Assignment 1

CMPSCI 187 / Spring 2015 Postfix Expression Evaluator

EECE.2160: ECE Application Programming

CS ) PROGRAMMING ASSIGNMENT 11:00 PM 11:00 PM

Graduate-Credit Programming Project

CS160 - Assignment 2 Due: Friday Sept. 25, 6pm

Problem Set 1 Due: 11:59pm Wednesday, February 7

Please note that some of the resources used in this assignment require a Stanford Network Account and therefore may not be accessible.

CMPSCI 187 / Spring 2015 Implementing Sets Using Linked Lists

COMP90015: Distributed Systems Assignment 1 Multi-threaded Dictionary Server (15 marks)

HW 1: Shell. Contents CS 162. Due: September 18, Getting started 2. 2 Add support for cd and pwd 2. 3 Program execution 2. 4 Path resolution 3

Project #1 Computer Science 2334 Fall 2008

Due: 9 February 2017 at 1159pm (2359, Pacific Standard Time)

CS143 Handout 05 Summer 2011 June 22, 2011 Programming Project 1: Lexical Analysis

CS 470 Operating Systems Spring 2013 Shell Project

CSCI544, Fall 2016: Assignment 2

Programming Assignment I Due Thursday, October 7, 2010 at 11:59pm

Maps and Trees. CS310: Program 2. 1 Overview. 2 Requirements. Instructor Provided Files. Late Work: Up to 72 hours Penalty: 10% per 24

PROGRAMMING PROJECT ONE DEVELOPING A SHELL

Homework #1 From C to Binary

Shell Interface Assignment

The print queue was too long. The print queue is always too long shortly before assignments are due. Print your documentation

: the User (owner) for this file (your cruzid, when you do it) Position: directory flag. read Group.

Project 1 for CMPS 181: Implementing a Paged File Manager

Homework 1 Due Monday April 24, 2017, 11 PM

Ling 473 Project 4 Due 11:45pm on Thursday, August 31, 2017

Programming Assignment 5 (100 Points) START EARLY!

Assignment 6 Gale Shapley Python implementation Submit zip file to Canvas by 11:59 Saturday, September 23.

Machine Problem 1: A Simple Memory Allocator

CS3114 (Fall 2013) PROGRAMMING ASSIGNMENT #2 Due Tuesday, October 11:00 PM for 100 points Due Monday, October 11:00 PM for 10 point bonus

(Worth 50% of overall Project 1 grade)

Eclipse Environment Setup

Homework Assignment #3

CS 1110, LAB 3: STRINGS; TESTING

CS2630: Computer Organization Project 2, part 1 Register file and ALU for MIPS processor

Project #1 rev 2 Computer Science 2334 Fall 2013 This project is individual work. Each student must complete this assignment independently.

Shell Project Part 1 (140 points)

Homework #1 From C to Binary

Additional Guidelines and Suggestions for Project Milestone 1 CS161 Computer Security, Spring 2008

Lab 7 1 Due Thu., 6 Apr. 2017

ASSIGNMENT 5 Objects, Files, and More Garage Management

Project 1: Implementing a Shell

CSE 303 Lecture 2. Introduction to bash shell. read Linux Pocket Guide pp , 58-59, 60, 65-70, 71-72, 77-80

First, let's make sure we have all of the starter code downloaded. MAC (Go to the second part of the tutorial if you are using windows)

CS 261 Recitation 1 Compiling C on UNIX

Tips from the experts: How to waste a lot of time on this assignment

CS450 - Database Concepts Fall 2015

CSC116: Introduction to Computing - Java

CS159 - Assignment 2b

Assignment 1: Communicating with Programs

HOMEWORK 9. M. Neumann. Due: THU 8 NOV PM. Getting Started SUBMISSION INSTRUCTIONS

Git. CSCI 5828: Foundations of Software Engineering Lecture 02a 08/27/2015

3 Threadsafe Bounded List Wrapper Library Monitor

1.204 Computer Algorithms in Systems Engineering Spring 2010 Problem Set 4: Satellite data sets Due: 12 noon, Monday, March 29, 2010

This is a combination of a programming assignment and ungraded exercises

Building a Search Engine: Part 2

Programming Assignment #4

Introduction to Linux Spring 2014, Section 02, Lecture 3 Jason Tang

Network Administration/System Administration (NTU CSIE, Spring 2018) Homework #1. Homework #1

Homework 1 CS161 Computer Security, Spring 2008 Assigned 2/4/08 Due 2/13/08

Instructions PLEASE READ (notice bold and underlined phrases)

CS52 - Assignment 8. Due Friday 4/15 at 5:00pm.

COMP Assignment 1

Lab Exercise #1 Project Compilation, Javadoc Generation, and Submission Computer Science 2334

UNIVERSITY OF NEBRASKA AT OMAHA Computer Science 4500/8506 Operating Systems Fall Programming Assignment 1 (updated 9/16/2017)

CIS 505: Software Systems

Shell Project, part 3 (with Buddy System Memory Manager) ( points)

Question 1: knn classification [100 points]

CSC116: Introduction to Computing - Java

Recitation # Embedded System Engineering Friday 16-Oct-2015

Data Structure and Algorithm Homework #3 Due: 2:20pm, Tuesday, April 9, 2013 TA === Homework submission instructions ===

Lab #2 Physics 91SI Spring 2013

Homework /681: Artificial Intelligence (Fall 2017) Out: October 18, 2017 Due: October 29, 2017 at 11:59PM

CS646 (Fall 2016) Homework 1

CS164: Programming Assignment 5 Decaf Semantic Analysis and Code Generation

Natural Language Processing - Project 2 CSE 398/ Prof. Sihong Xie Due Date: 11:59pm, Oct 12, 2017 (Phase I), 11:59pm, Oct 31, 2017 (Phase II)

COMPSCI 220 Programming Methodology Project Assignment 06: Expression Evaluator

CSC209. Software Tools and Systems Programming.

CS350 : Operating Systems. General Assignment Information

CSCI1410 Fall 2017 Assignment 3: Knowledge Representation and Reasoning

Essentials for Scientific Computing: Bash Shell Scripting Day 3

15-110: Principles of Computing, Spring 2018

be able to read, understand, and modify a program written by someone else utilize the Java Swing classes to implement a GUI

CSE Theory of Computing Fall 2017 Project 1-SAT Solving

Com S 227 Assignment Submission HOWTO

CSCI 2132 Software Development. Lecture 3: Unix Shells and Other Basic Concepts

Carnegie Mellon University Department of Computer Science /615 - Database Applications C. Faloutsos & A. Pavlo, Fall 2015

Tips from the experts: How to waste a lot of time on this assignment

Tips from the experts: How to waste a lot of time on this assignment

Introduction. Overview and Getting Started. CS 161 Computer Security Lab 1 Buffer Overflows v.01 Due Date: September 17, 2012 by 11:59pm

CSCI 161: Introduction to Programming I Lab 1b: Hello, World (Eclipse, Java)

MATLAB Demo. Preliminaries and Getting Started with Matlab

FILE SYSTEMS. CS124 Operating Systems Winter , Lecture 23

Transcription:

CS 276 / LING 286 Spring 2017 Programming Assignment 1 Due: Thursday, April 20, 2017 at 11:59pm Overview In this programming assignment, you will be applying knowledge that you have learned from lecture to build a simple indexing and retrieval system for a search engine. This assignment should be done in teams of two or individually. More specifically, it involves the following tasks: 1. Build an uncompressed index over a corpus of webpages from the stanford.edu domain, and implement retrieval for Boolean conjunctive queries. 2. Build a compressed index over the same corpus using variable length encoding and implement Boolean conjunctive queries. 3. Write up a report describing your program and answer a set of questions. 4. For extra credit, you are encouraged to implement other compression algorithms (e.g., gamma-encoding). You are required to submit your code on corn (which we will run with an auto-grader) and a write-up via Gradescope. See later sections for more details. Starter Code You will use Java for this programming assignment. Download the Java starter code from: http://web.stanford.edu/class/cs276/pa/pa1-skeleton.zip. You can use ant or Eclipse to build the code. For a quick introduction to Java, links to helpful tutorials, 1

and instructions to build the code, check out this document (link). To import the skeleton code into Eclipse, you could do File New Project Java Project from Existing Ant Buildfile, and then select build.xml in your skeleton code folder. If you decide to develop code locally, please remember to test your code on corn. You can find some sample skeleton code under the pa1-skeleton directory inside the assignment package. Two main file entries for this assignment are: Index.java (for indexing) and Query.java (for boolean conjunctive retrieval). For task1, task2 and extra credit, you are required to implement the BaseIndex interface. Task1 requires you to fill in the two functions in BasicIndex.java, and task2 requires you to fill in the two functions in VBIndex.java. If you choose to do gamma-encoding for extra credit, you should fill in the two functions in GammaIndex.java. (Or alternatively you can implement your own encoding algorithm.) We have also provided some scripts to help you with your development. You can find examples of how to run the provided scripts in the Running the Provided Scripts section near the end of this spec. Note: There is one known Mac issue that you may encounter: memusg is designed to be run on Linux, and while developing locally on macos, it could output abnormally large memory peak/samples. Running code on corn would fix the problem. Corpus The corpus you will be working with for this assignment contains webpages from the stanford.edu domain. The data for this assignment is available as a.zip file at: http://web.stanford.edu/class/cs276/pa/pa1-data.zip. You should put the data folder under the pa1-skeleton directory. The total size of the corpus is about 170MB. There are 10 sub-directories (named 0-9) under the data directory. Each file under the subdirectory is the content of an individual webpage. You should assume that the individual file names are unique within each sub-directory, but not necessarily the case across subdirectories (i.e., the full path of the files are unique). All the HTML info has been stripped off from those webpages, so they only contain space-delimited words. You should not re-tokenize the words. Each consecutive span of non-space characters consists of a word token in the corpus. Task 1: Building an uncompressed index and retrieval (45%) The first part of this assignment is to build an inverted index of this corpus, and implement Boolean conjunctive queries. In particular, you need to implement the blocked sort-based indexing (BSBI) algorithm described in Section 4.2 of the textbook 1. You should treat each sub-directory as a block, and only load one block in memory at a time when you build your index (note: you will be penalized if you construct the index by loading blocks of larger than one directory in memory at once). Note that we are 1 http://nlp.stanford.edu/ir-book/pdf/04const.pdf 2

abstracting away from the operating systems meaning of blocks. You can assume that each block is small enough to be stored in memory. All of your submitted code for this PA should reside in a directory pa1-skeleton. Under the pa1-skeleton/task1 directory, you must supply two shell scripts, named index.sh and query.sh. Each script should invoke the necessary Java program to perform the indexing and retrieval tasks. The index.sh and query.sh scripts that invoke the cs276.assignments.index and cs276.assignments.query Java programs can be found under pa1-skeleton/task1. Prior to running the scripts, be sure to compile using ant or Eclipse. If you change the scripts, make sure that they can be invoked from the parent directory (however, you may not change the input arguments for the sake of our auto-grader). For example, ant sh task1/index.sh [input arguments - see below] sh task1/query.sh [input arguments - see below] For convenience, we have marked where to add your code with TODO: Your code here comments in the Java files. Please feel free to add any helper methods you find helpful. Indexing The index.sh script should take two command-line arguments: input data dir: a string-valued argument. This describes the directory location of the input corpus data. output index dir: a string-valued argument. This is the location of the output directory containing the generated index. You should assume the output directory does not exist yet. In addition, the index.sh script should only print the total number of files in the corpus to stdout. At grading time, we will be invoking the index.sh script as follows. sh task1/index.sh input_data_dir output_data_dir We will then collect timing statistics on how long the indexing takes, the size of your generated index, and the amount of memory used when building the index. We will also verify that the total number of documents you output matches the expected count. Boolean conjunctive retrieval The script query.sh will take one command-line argument, which is the directory location of the index you built. Your retrieval program should read from stdin a sequence of word tokens separated by space, which forms the Boolean conjunctive query. There could be any non-zero number of query terms. Your program should print to stdout the list of documents containing the query terms, one document file name on each line, 3

sorted in lexicographical order. The document file name should only include the subdirectory name and the file name. For example, 0/crypto.stanford.edu_ 0/crypto.stanford.edu_DRM2002_ 1/crypto.stanford.edu_cs142_ 1/crypto.stanford.edu_cs155_hw_and_proj_ If the conjunctive query has no results (could also be caused by any of the terms in the query is not being found in the corpus), your program should output no results found to stdout. Note: You MUST print precisely the string no results found if there are no results, otherwise our autograder will consider it wrong. It is important to make sure that you are not loading the whole index into memory at any time for both index construction and querying. The whole point of indexing is that you can seek to the corresponding index position of a query term on the disk, and just read into memory the posting list of that term, without having to load the full index. When you merge postings lists, you should merge them step by step. In other words, for the Merge blocks step in the main function of Index.java, you want to get postings lists for both blocks separately before trying to merge them. The getchannel method of the RandomAccessFile class and the readposting method you implemented should be helpful. You are also required to implement efficient intersection and merging of postings lists. You will be penalized for using Java Set and Set Union methods for doing intersection and merging operations. For example, you are NOT allowed to use retainall to do the intersection. You are required to order the terms by postings list length to optimize query performance. You will be penalized if you do not implement this optimization. We will be invoking your script with the following command. sh task1/query.sh index < query.txt where index is the directory where your index resides and query.txt contains a list of query terms, all in one line. Toy dataset It is usually a good idea to verify your programs output on a small toy dataset first during development. We have provided you with a small toy dataset and a set of sample queries and outputs, under the toy example directory. There is a script called grader.sh under the same toy example directory. It is similar to the auto-grader script we use for final evaluation. You should be able to run it to verify your program meets our input/output requirements. Also, a set of development queries and their outputs are given at the dev queries and dev output directories. The script run dev.sh is provided to help you run these development queries. 4

Grading To ensure your index is built correctly, you will be tested on 20 Boolean conjunctive queries of one or multiple terms. For those queries, you will get 1.5% of the final grade for each query you answer correctly, for a total of 30% of your grade. You will earn another 20% if none of the following penalties apply to your program. You will be penalized by 1. 5% if you do not order the query terms by postings list length in retrieval. 2. 4% if your retrieval program loads the whole index into memory rather than simply loading the postings lists of just the query terms. 3. 3% if the total number of files your indexer outputs does not match the correct count. 4. 3% if the timing statistics of your retrieval algorithm are way out of the norm. The maximum combined grades for this task is 45%. Task 2: Building a compressed index and retrieval (30%) In the second task, you should build a compressed index using gap encoding with variable byte encoding for each gap. The input/output format and code structure is the same as Task 1, but you should provide scripts under directory pa1-skeleton/task2. We will also use an auto-grader to build a compressed index with your program, and run a set of queries. Similar to Task 1, we will be invoking your scripts in a similar fashion: ant sh task2/index.sh [input arguments - discussed above] sh task2/query.sh [input arguments - discussed above] Grading Similar to Task 1, you will be tested on 20 conjunctive queries (1% for each query you answer correctly, for a total of 20%). And you will earn another 10% if none of the following penalties apply: 1. 5% if your compression algorithm does not achieve a reduction in index size. 2. 5% if your query response time with the compressed index is way out of norm. The combined total grade of this task is 30%. Note that if your program does not implement the variable length encoding compression algorithm, you will receive no credit for this task. 5

Task 3: Report (25%) Please write up a 1-2 page report and submit it alongside with your code. It should contain the following sections: 1. A brief description of how your program is structured and the key steps in your indexing and retrieval algorithms. Make sure you report statistics on the size of the index (compressed and uncompressed), statistics of retrieval time for the development queries. We provide helper scripts which output relevant timing and memory statistics. (7%) 2. Answers to each of the following questions: (6% each) a) In this PA we asked you to use each sub-directory as a block and build index for one block at a time. Can you discuss the trade-off of different sizes of blocks? Is there a general strategy when we are working with limited memory but want to minimize indexing time? b) Is there a part of your indexing program that limits its scalability to larger datasets? Describe all the other parts of the indexing process that you can optimize for indexing time/scalability and retrieval time. c) Any more ideas of how to improve indexing or retrieval performance? Please note if you go drastically beyond the 2-page limit, we may penalize you for an overly long report. Grading Your write-up will contribute to 25% of your final grade. Extra credit: experiment with additional compression methods (15%) Implement one more index compression method (e.g., gamma-encoding), and supply your code in the same structure as Task 1 and 2 under directory extra credit. Section 5.4 in the textbook points to a few techniques and related publications. You can also look into Delta Encoding, a compression technique very similar to Gamma Encoding, which can achieve an even better compression rate. Also, ALGORITHM SIMPLE-9 (link) is an interesting encoding technique that you could also consider implementing. Similar to Tasks 1 and 2, we will be invoking your scripts with ant sh extra_credit/index.sh [input arguments - discussed above] sh extra_credit/query.sh [input arguments - discussed above] 6

Also include in the report a description of your index compression method as well as a discussion of the space/speed trade-off of this additional compression method, in comparison to Task 2 and Task 1. Grading You will be awarded 10% for answering 20 queries correctly (0.5% each). Note that since the objective of this task is to achieve better compression rate, you ll receive 0% out of 10% if the size of your compressed index is larger than those of Tasks 1 and 2. 2% will be given for the space/speed discussion in your report. An extra 3% will be given to the top 10 teams who answer all 20 queries correctly and achieve the best compression rates. You will be penalized if the retrieval times are abnormally long. We will inspect your code for implementation correctness if necessary. Running the Provided Scripts This sections shows how to run the provided scripts: index.sh, query.sh, grader.sh, run dev.sh and formatverification.py. ant clean ant Assuming the generated index will be stored in pa1-skeleton/index Here is how you would execute index.sh for task1 sh task1/index.sh pa1-data index After the execution, your index folder should contains 4 things. corpus.index doc.dict posting.dict term.dict To execute query.sh for task1 on toy_example/queries/query.5: sh task1/query.sh index < toy_example/queries/query.5 You will also want to test your implementation on the dev set. Here is how you should run run_dev.sh for task1. You could invoke 7

run_dev.sh for task2 in a similar fashion. The script will output the number of different lines with respect to the correct solution. A correct implementation should output 8 lines of 0 s. sh run_dev.sh task1 To play with the grader.sh script in toy_example, you need to make sure you have the correct index type in index.sh and query.sh. For example, to invoke grader.sh with Basic index (similarly for VB and Gamma), you should have cs276.assignments.index Basic $1 $2 in index.sh and cs276.assignments.query Basic $1 in query.sh Then you can execute grader.sh like: cd toy_example sh grader.sh formatverification.py takes no arguments. It verifies that you are printing output correctly to stdout based off of the toy_example. It does NOT verify that you are printing the correct output, only the correct output format. You could invoke the script with: python formatverification.py Submission We will use corn and Gradescope for grading and collecting the assignment. Make sure that all.sh scripts are executable. There are two steps for submission: 1. Submitting your code on corn using our submit script 2. Uploading your report as a pdf file to Gradescope Submitting Code Before, submitting please make sure that your code follows the following directory structure to ensure auto-grading goes smoothly. pa1-skeleton build.xml src <any source files of your program> task1 8

index.sh query.sh <any additional files your program needs> task2 index.sh query.sh <any additional files your program needs> extra credit (optional) index.sh query.sh <any additional files your program needs> In addition, it will be a good idea to run the grader.sh script on the toy data set, and the run dev.sh script on the development queries prior to submission. Note that the indexes for Task 1, Task 2, and Extra Credit have to be constructed from scratch (that is, they are not built upon indexes from other tasks). Also, remember that indexes in Task 2 and Extra Credit will need to be stored in binary format. Note that we will compile and run your program on Farmshare using ant and our standard build.xml. If you did not complete the assignment on Farmshare, please verify your code compiles and runs on it before submission. You will submit your program code using a Unix script that we ve prepared. To submit your program, first put your files in a directory on Farmshare (e.g. corn.stanford.edu). Then, from your parent directory (this would be pa1-skeleton in the above directory structure), submit, i.e.: /afs/ir/class/cs276/bin/submit If you are working in a team, only one team member needs to submit, but remember to indicate your partner s SUNetID when prompted by the submit script. As a summary, here is a check list. Make sure your program has correct output format. Make sure there are no extraneous print statements. Make sure your program compiles with ant, and can be run on Farmshare. Follow the directory structure, remove the data folder and submit. Uploading Report to Gradescope Please upload your report to Gradescope under the Assignments section. Again, if you are working in a team, only one team member needs to submit, but remember to add your partner as a team member for the assignment on Gradescope. 9