LING 408/508: Computational Techniques for Linguists

Slides:



Advertisements
Similar presentations
Files Used to transfer data to and from disk. Opening an Output File Stream #include // File stream library. ofstream outfile;// Declare file stream variable.
Advertisements

Internship in DASAN networks C programing language Chapter 7 : Input and Output Present by Le Thi Hien 1/14.
Getting Data into Your Program
CompSci 101 Introduction to Computer Science February 3, 2015 Prof. Rodger Lecture given by Elizabeth Dowd.
Strings and regular expressions Day 10 LING Computational Linguistics Harry Howard Tulane University.
Case studies over structure types and strings
INTRODUCTION TO PYTHON PART 4 – TEXT AND FILE PROCESSING CSC482 Introduction to Text Analytics Thomas Tiahrt, MA, PhD.
CSE Lectures 22 – Huffman codes
LING 408/508: Programming for Linguists Lecture 19 November 4 th.
COMPUTER SCIENCE FEBRUARY 2011 Lists in Python. Introduction to Lists Lists (aka arrays): an ordered set of elements  A compound data type, like strings.
CS190/295 Programming in Python for Life Sciences: Lecture 3 Instructor: Xiaohui Xie University of California, Irvine.
OCR GCSE Computing © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 1: Introduction.
1 Introduction to Python LING 5200 Computational Corpus Linguistics Martha Palmer.
Files in Python Output techniques. Outputting to a file There are two ways to do this in Python – print (more familiar, more flexible) – write (more restrictive)
Python – May 12 Recap lab Chapter 2 –operators –Strings –Lists –Control structures.
LING 408/508: Programming for Linguists Lecture 20 November 16 th.
Midterm Exam Topics (Prof. Chang's section) CMSC 201.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Files in Python Opening and Closing. Big Picture To use a file in a programming language – You have to open the file – Then you process the data in the.
DAY 3. ADVANCED PYTHON PRACTICE SANGREA SHIM TAEYOUNG LEE.
Indentations makes the scope/block Function definition def print_message (): print “hello” Function usages print_message () hubo.move ()// hubo is a class.
DAY 2. GETTING FAMILIAR WITH NGS SANGREA SHIM. INDEX  Day 2  Get familiar with NGS  Understanding of NGS raw read file  Quality issue  Alignment/Mapping.
File Processing CMSC 120: Visualizing Information Lecture 4/15/08.
ENGINEERING 1D04 Tutorial 2. What we’re doing today More on Strings String input Strings as lists String indexing Slice Concatenation and Repetition len()
Topic: Binary Encoding – Part 1
CSc 120 Introduction to Computer Programing II Adapted from slides by
IGCSE 4 Cambridge Data types and arrays Computer Science Section 2
Main Points: - Working with strings. - Problem Solving.
Topic: Python’s building blocks -> Statements
Topic: Python’s building blocks -> Variables, Values, and Types
CSc 120 Introduction to Computer Programing II
Python’s input and output
CMPT 120 Topic: Python strings.
Lecture-5 Arrays.
Lesson 07: Strings Topic: Introduction to Programming, Zybook Ch 6, P4E Ch 6. Slides on website.
LING/C SC/PSYC 438/538 Lecture 4 Sandiway Fong.
Object-Orientated Programming
Computation with strings 1 Day 2 - 8/31/16
LING 388: Computers and Language
Class 9 Reading and writing to files chr, ord and Unicode
Topics Introduction to File Input and Output
Chapter 7 Files and Exceptions
Lists in Python.
CS190/295 Programming in Python for Life Sciences: Lecture 4
Python - Strings.
Lesson 09: Lists Topic: Introduction to Programming, Zybook Ch 8, P4E Ch 8. Slides on website.
LING 388: Computers and Language
Coding Concepts (Data- Types)
Lesson 09: Lists Class Chat: Attendance: Participation
Programming Training Main Points: - Working with strings.
CS190/295 Programming in Python for Life Sciences: Lecture 3
LING 408/508: Computational Techniques for Linguists
LING 388: Computers and Language
CS1110 Today: collections.
15-110: Principles of Computing
Nate Brunelle Today: Strings, Type Casting
15-110: Principles of Computing
Topics Introduction to File Input and Output
Introduction to Computer Science
CS2911 Week 2, Class 3 Today Return Lab 2 and Quiz 1
CS150 Introduction to Computer Science 1
Introduction to Computer Science
Data Types Every variable has a given data type. The most common data types are: String - Text made up of numbers, letters and characters. Integer - Whole.
Topics Introduction to File Input and Output
Nate Brunelle Today: Style, Collections
Nate Brunelle Today: Strings, Type Casting
More Basics of Python Common types of data we will work with
CMPT 120 Topic: Python strings.
Introduction to Computer Science
ME 123 Computer Applications I Lecture 5: Input and Output 3/17/03
Presentation transcript:

LING 408/508: Computational Techniques for Linguists Lecture 23

Today's Topic Hands-on Python Call for term project proposals Last Time: differences between Python 2.7 and Python 3 numbers built-in functions: type(), range(), input(), eval(), coercion: list(), int(), float() formatted output

String slicing String is like an array of characters (strings): str[i] index i (from 0 to len(str)-1) str[-i] index i from the end (1 = last) str[i:j] slice from index i until index j-1 str[:j] slice from index 0 until index j-1 str[i:] slice from index i until end of the string

List vs. Strings Although Strings are like Lists, Lists are mutable, Strings are not.

Strings and Unicode ASCII ⇔ string: Python 3

Strings and Unicode Example: u (unicode) prefix (for Python 2.7)

Python: Files Like all other programming languages, uses a file handle, called file variable: open() infile = open("file.txt","r") outfile = open("results.txt,"w") f = open(fname) f = open(fname, encoding="utf-8") f = open(fname, encoding="latin-1") f = open(fname, encoding="ascii") Removing the newline: .strip() .rstrip() .lstrip() Python 2.7