LING 408/508: Computational Techniques for Linguists

Slides:



Advertisements
Similar presentations
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 219 Bell Hall 1.
Advertisements

©2004 Brooks/Cole Chapter 2 Variables, Values and Operations.
More on Numerical Computation CS-2301 B-term More on Numerical Computation CS-2301, System Programming for Non-majors (Slides include materials from.
Lecture 2: Topics Bits and Bytes Primitive Types Casting Strings Boolean expressions.
LING 408/508: Programming for Linguists Lecture 16 October 16 th.
Printing. printf: formatted printing So far we have just been copying stuff from standard-in, files, pipes, etc to the screen or another file. Say I have.
The printf Method The printf method is another way to format output. It is based on the printf function of the C language. System.out.printf(,,,..., );
LING 408/508: Programming for Linguists Lecture 19 November 4 th.
LING 408/508: Programming for Linguists Lecture 17 October 21 st.
Introduction to Python
Scientific Notation. What is scientific notation? Scientific notation is a way of expressing really big numbers or really small numbers. It is most often.
Computer Science 111 Fundamentals of Programming I Number Systems.
LING 408/508: Programming for Linguists Lecture 3 August 31 st.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
CS190/295 Programming in Python for Life Sciences: Lecture 3 Instructor: Xiaohui Xie University of California, Irvine.
Input, Output, and Processing
Computer Science 101 Introduction to Programming.
Sept 18, 2007Sprenkle - CS111 Lab 0 Feedback Great! Great! Details got some of you Details got some of you  Print out copy  Copy directory to turnin.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Introducing Python CS 4320, SPRING Lexical Structure Two aspects of Python syntax may be challenging to Java programmers Indenting ◦Indenting is.
LING 408/508: Programming for Linguists Lecture 8 September 23 rd.
LING 408/508: Programming for Linguists Lecture 18 November 2 nd.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
CS1Q Computer Systems Lecture 2 Simon Gay. Lecture 2CS1Q Computer Systems - Simon Gay2 Binary Numbers We’ll look at some details of the representation.
Data Types and Conversions, Input from the Keyboard CS303E: Elements of Computers and Programming.
LING 408/508: Programming for Linguists Lecture 20 November 16 th.
LING 408/508: Programming for Linguists Lecture 19 November 9 th.
A data type in a programming language is a set of data with values having predefined characteristics.data The language usually specifies:  the range.
CSCI 125 & 161 / ENGR 144 Lecture 6 Martin van Bommel.
Topic: Binary Encoding – Part 2
Creating Database Objects
Topic: Binary Encoding – Part 1
Topics Designing a Program Input, Processing, and Output
Topics Introduction Hardware and Software How Computers Store Data
Introduction To Computer Science
Scientific Notation.
Formatting Output.
Programming Fundamentals
CSC 131: Introduction to Computer Science
Variables, Expressions, and IO
LING 388: Computers and Language
LING 408/508: Computational Techniques for Linguists
Representing Data How does a computer represent data?
Scientific Notation.
Scientific Notation.
Fundamentals of Programming I Number Systems
Arithmetic Logical Unit
Scientific Notation.
First Python Program Professor Hugh C. Lauer CS-1004 — Introduction to Programming for Non-Majors (Slides include materials from Python Programming: An.
Topics Introduction Hardware and Software How Computers Store Data
LING 408/508: Computational Techniques for Linguists
Plan Attendance Files Posted on Campus Cruiser Homework Reminder
How Computers Store Data
CS190/295 Programming in Python for Life Sciences: Lecture 3
LING 408/508: Computational Techniques for Linguists
LING 388: Computers and Language
LING 408/508: Computational Techniques for Linguists
LING 388: Computers and Language
LING 408/508: Computational Techniques for Linguists
Topics Designing a Program Input, Processing, and Output
Summary of what we learned yesterday
Topics Designing a Program Input, Processing, and Output
Scientific Notation.
Scientific Notation.
Lab 1: Getting Started.
Creating Database Objects
LING/C SC 581: Advanced Computational Linguistics
Lecture 36 – Unit 6 – Under the Hood Binary Encoding – Part 2
Lecture 37 – Practice Exercises 9
Lecture 37 – Practice Exercises 9
Presentation transcript:

LING 408/508: Computational Techniques for Linguists Lecture 22

Administrivia Homework 9 graded Python: cgi-bin: bash scripting requires attention to detail (unfortunately finicky) that shell script "glue" could access any programming language, e.g. Python Python: from a command line calculator to the Natural Language Toolkit (nltk)

Homework 9 Example Use the cgi-bin methods to implement a BMI bash shell script on the webserver.

Homework 9 Example

Homework 9 Example

Next Programming Language So far, in this course you've been exposed to: Binary language of the CPU: encoding of numbers and characters (unicode) Linux (Ubuntu under VirtualBox) command line: bash shell bash shell scripting: #!/bin/bash awk and regular expressions (regex) html/css Javascript + DOM Web client/server model Now we switch for the rest of the semester to a regular programming course: Python

Term Programming Project It's time to think about the end of the semester … Propose a programming project half of your grade Send your proposal to me If I give up the go-ahead, you can start working on it …

Why Python? Installed by default on OSX but you should install and use python3

www.python.org

Python on Ubuntu sudo apt install python3-pip

Python on Ubuntu

Python resources Many (free) online resources Through UA: 1.5hrs (18 Lessons) QuickStart! - Python https://www.vtc.com/products/Q uickStart!-Python-Tutorials.htm 8hrs (64 Lessons) Practical Python for Beginners Course https://www.vtc.com/products/py thon.htm Pythonbook (based on Python 2.7): On course website: pythonbook.pdf

Python resources python.org

Python At the interpreter:

Python: Numbers pythonbook page 53 pythonbook page 54

Python: Numbers Python: Javascript: Number data types: int, float Matters for things like division: / Javascript: everything is a floating point number

Python: Numbers import math math.pi complex numbers: import cmath

Python range(): produces a list (sequence) range(n) [0,1,..,n-1] range(start,n) [start,start+1,..,n-1] range(start,n,step) [start,start+step,…,last] last=start+k*step < n range(n,stop,-step) counts down (pythonbook page 40)

Python How about to 2 decimal places? use raw_input() instead of input() for strings eval(raw_input()))is equivalent to input()

Formatted Output Lots of ways: (Old way) Notation comes originally from C : sprintf function http://www.tutorialspoint.com/c_standard_library/c_function_sprintf.htm

Formatted Output %<width>.<precision><type> <type> = d, f, s <width> = minimum number of characters; right-justified by default, -width => left-justified 0 = as wide as needed <precision> = number of places after decimal point e.g. 02d two digits wide, pad with 0 if needed

Formatted Output Newer way: https://docs.python.org/2/tutorial/inputoutput.html#fancier-output- formatting Use {} for each argument (can be numbered, e.g. {0}, {1},… or referenced by keyword {x}) {:width}

Python pythonbook page 60: see factorial.py Python automatically converts to type long int from int (32 bit 2's complement), (page 64–65, section 3.5) explicit type coercion: float() int() long() complex(r,i) complex numbers complex(string)