I 256: Applied Natural Language Processing

Course Information

Assignment 1: Get really started with Python

Due September 8 at 12:3o pm (before class)


Create a file named with the following convention:

LastNameFirstName_assignment1.py

This is the main file where all your code will reside.
We will evaluate each question/sub-question as:
 

>>> python LastNameFirstName_assignment1.py question1

>>> python LastNameFirstName_assignment1.py question1.1
 

(For the few non programming questions, create a string with your answer and print it)

Add logic to your code based on the command line argument (process your command line argument string ) and output accordingly. The command line arguments in python are accessed through sys.argv list .  You can also use getopt module.
 
Make sure you  include a this header information in the beginning of your code
 

#! /usr/bin/env python  

#author: ‘Your name'
#email = ‘your email address'
#python_version = ‘python version you are using'
 

For any questions, please email gvaswani@ischool.berkeley.edu 

Email your assignment to gvaswani@ischool.berkeley.edu and barbara.rosario@intel.com

 

 

Assigment 1:

  1. Define the string silly = “newly formed bland ideas are unexpressible in an infuriating way” and create a new string where bland has been replaced with genial
  2. Write code to abbreviate text by removing all the vowels. Define sentence to hold any string you like (but formed of more than 3 words). Write a for loop to process the string sentence, one character at a time, to remove the vowels.
  3. Exercise 19 Chapter 1 NLTK book. Additional question: give some examples of why/when you would need to perform such operations.
  4. Exercise 24 Chapter 1
  5. Exercise 25 Chapter 1
  6. Exercise 26 Chapter 1
  7. Write code to find all the position in the text of a given word. Define a function indexes(word,text) that returns a list of all the word positions in the text.  Try calling that function  for whale in text1. Give some examples of why/when you would need to perform such operation.