CONTROL 2 DAY 14 - 9/26/14 LING 3820 & 6820 Natural Language Processing Harry Howard Tulane University.

Slides:



Advertisements
Similar presentations
Strings and regular expressions Day 10 LING Computational Linguistics Harry Howard Tulane University.
Advertisements

TEXT STATISTICS 1 DAY /20/14 LING 3820 & 6820 Natural Language Processing Harry Howard Tulane University.
TEXT STATISTICS 7 DAY /05/14 LING 3820 & 6820 Natural Language Processing Harry Howard Tulane University.
Chapter 5 Decisions. Outline and Objectives Relational and Logical Operators If Blocks Select Case Blocks.
Introduction to Computers and Programming Lecture 7:
COMP 14 Introduction to Programming Miguel A. Otaduy May 18, 2004.
Primitive Types Java supports two kinds of types of values – objects, and – values of primitive data types variables store – either references to objects.
Identifiers and Assignment Statements. Data structures In any programming language you need to refer to data The simplest way is with the actual data.
UNICODE & CONTROL DAY /24/14 LING 3820 & 6820 Natural Language Processing Harry Howard Tulane University.
TEXT STATISTICS 5 DAY /29/14 LING 3820 & 6820 Natural Language Processing Harry Howard Tulane University.
NLTK & BASIC TEXT STATS DAY /08/14 LING 3820 & 6820 Natural Language Processing Harry Howard Tulane University.
COMPUTATION WITH STRINGS 4 DAY 5 - 9/05/14 LING 3820 & 6820 Natural Language Processing Harry Howard Tulane University.
ON-LINE DOCUMENTS 3 DAY /17/14 LING 3820 & 6820 Natural Language Processing Harry Howard Tulane University.
Chap 3 – PHP Quick Start COMP RL Professor Mattos.
UNICODE DAY /22/14 LING 3820 & 6820 Natural Language Processing Harry Howard Tulane University.
© 2006 Pearson Education 1 Obj: to use compound Boolean statements HW: p.184 True/False #1 – 6 (skip 3)  Do Now: 1.Test your “Charge Account Statement”
1 Data Comparisons and Switch Data Comparisons Switch Reading for this class: L&L 5.3,
Chapter 5 Decisions. Outline and Objectives Relational and Logical Operators If Blocks Select Case Blocks.
COMPUTATION WITH STRINGS 2 DAY 2 - 8/29/14 LING 3820 & 6820 Natural Language Processing Harry Howard Tulane University.
SCRIPTS & FUNCTIONS DAY /06/14 LING 3820 & 6820 Natural Language Processing Harry Howard Tulane University.
TWITTER DAY /07/14 LING 3820 & 6820 Natural Language Processing Harry Howard Tulane University.
TWITTER 2 DAY /10/14 LING 3820 & 6820 Natural Language Processing Harry Howard Tulane University.
WEB TEXT DAY /14/14 LING 3820 & 6820 Natural Language Processing Harry Howard Tulane University.
REGULAR EXPRESSIONS 3 DAY 8 - 9/12/14 LING 3820 & 6820 Natural Language Processing Harry Howard Tulane University.
REGULAR EXPRESSIONS 4 DAY 9 - 9/15/14 LING 3820 & 6820 Natural Language Processing Harry Howard Tulane University.
COMPUTATION WITH STRINGS 1 DAY 2 - 8/27/14 LING 3820 & 6820 Natural Language Processing Harry Howard Tulane University.
Semantics Day 38 LING Computational Linguistics Harry Howard Tulane University.
REGULAR EXPRESSIONS 2 DAY 7 - 9/10/14 LING 3820 & 6820 Natural Language Processing Harry Howard Tulane University.
NLTK & Python Day 6 LING Computational Linguistics Harry Howard Tulane University.
ICT Introduction to Programming Chapter 4 – Control Structures I.
Java Programming, Second Edition Chapter Two Using Data Within a Program.
CONDITIONALS. Boolean values Boolean value is either true or false It is name after the British mathemetician, George Boole who first formulated Boolean.
REGULAR EXPRESSIONS 1 DAY 6 - 9/08/14 LING 3820 & 6820 Natural Language Processing Harry Howard Tulane University.
TEXT STATISTICS 3 DAY /24/14 LING 3820 & 6820 Natural Language Processing Harry Howard Tulane University.
BOOLEAN OPERATIONS AND CONDITIONALS CHAPTER 20 1.
ON-LINE DOCUMENTS DAY /13/14 LING 3820 & 6820 Natural Language Processing Harry Howard Tulane University.
TWITTER 3 DAY /12/14 LING 3820 & 6820 Natural Language Processing Harry Howard Tulane University.
The If Statement There are no switch statements in Python. You need to use just if statements. There are no switch statements in Python. You need to use.
COMPUTATION WITH STRINGS 3 DAY 4 - 9/03/14 LING 3820 & 6820 Natural Language Processing Harry Howard Tulane University.
Primitive Data Types. int This is the type you are familiar with and have been using Stores an integer value (whole number) between -2,147,483,648 (-2.
Winter 2016CISC101 - Prof. McLeod1 CISC101 Reminders Quiz 3 next week. See next slide. Both versions of assignment 3 are posted. Due today.
CONTROL 3 DAY /29/14 LING 3820 & 6820 Natural Language Processing Harry Howard Tulane University.
PYTHON PROGRAMMING. WHAT IS PYTHON?  Python is a high-level language.  Interpreted  Object oriented (use of classes and objects)  Standard library.
 Type Called bool  Bool has only two possible values: True and False.
Topics introduced today (these topics would be covered in more detail in later classes) – Primitive Data types Variables Methods “for” loop “if-else” statement.
Lists 1 Day /17/14 LING 3820 & 6820 Natural Language Processing
CHAPTER 3 Logic.
Lists 2 Day /19/14 LING 3820 & 6820 Natural Language Processing
Computation with strings 2 Day 3 - 9/02/16
Flat text 2 Day 7 - 9/14/16 LING 3820 & 6820 Natural Language Processing Harry Howard Tulane University.
Computation with strings 3 Day 4 - 9/07/16
OPERATORS (2) CSC 111.
And now for something completely different . . .
Regular expressions 2 Day /23/16
LING 3820 & 6820 Natural Language Processing Harry Howard
control 4 Day /01/14 LING 3820 & 6820 Natural Language Processing
LING 3820 & 6820 Natural Language Processing Harry Howard
CISC101 Reminders Assn 3 due tomorrow, 7pm.
Control 3 Day /05/16 LING 3820 & 6820 Natural Language Processing
NLP 2 Day /07/16 LING 3820 & 6820 Natural Language Processing
Regular expressions 3 Day /26/16
Introduction to Syntax ANTH 3590/7590 Harry Howard Tulane University
CHAPTER 21 LOOPS 1.
Nate Brunelle Today: Conditional Decision Statements
Chapter 5 Decisions.
Computation with strings 4 Day 5 - 9/09/16
Chapter 2 Sets Active Learning Lecture Slides
Class code for pythonroom.com cchsp2cs
CHAPTER 3 Logic.
Control 1 Day /30/16 LING 3820 & 6820 Natural Language Processing
Presentation transcript:

CONTROL 2 DAY /26/14 LING 3820 & 6820 Natural Language Processing Harry Howard Tulane University

Course organization 26-Sept-2014NLP, Prof. Howard, Tulane University 2   The syllabus is under construction.   Chapter numbering  3.7. How to deal with non-English characters 3.7. How to deal with non-English characters  4.5. How to create a pattern with Unicode characters 4.5. How to create a pattern with Unicode characters  6. Control 6. Control

re.findall(pattern, source, re.UNICODE) ord() and unichar() Review of Unicode 26-Sept NLP, Prof. Howard, Tulane University

object in string or list object not in string or list Review of control 26-Sept NLP, Prof. Howard, Tulane University

Open Spyder 26-Sept NLP, Prof. Howard, Tulane University

6.1. How to check the truth of a statement 26-Sept NLP, Prof. Howard, Tulane University

How to check the properties of a string 1. >>> S = 'CoNfUsIoN' 2. >>> S.isalpha() 3. >>> S.isdigit() 4. >>> S.isalnum() 5. >>> S.isspace() 6. >>> S.islower() 7. >>> S.isupper() 8. >>> S.istitle() 9. >>> S.startswith('CoN') 10. >>> S.endswith('IoN') 26-Sept-2014NLP, Prof. Howard, Tulane University 7

How to compare magnitude with ==, !=,, >= 1. >>> dessert = 'watermelon' 2. >>> fruit = ['apple', 'cherry', 'mango', 'pear', 'watermelon'] 3. >>> len(dessert) == len(dessert) 4. >>> len(dessert) != len(fruit) 5. >>> len(fruit) < len(dessert) 6. >>> len(fruit) <= len(dessert) 7. >>> len(dessert) > len(fruit) 8. >>> len(dessert) >= len(fruit) 9. >>> len(fruit) < len(S) < len(dessert) == Sept-2014NLP, Prof. Howard, Tulane University 8

How to check identity and type with is and isinstance() 1. >>> dessert is dessert 2. >>> dessert is not fruit 3. >>> dessert is str 4. >>> isinstance(dessert, str) 5. >>> isinstance(fruit, list) 6. >>> isinstance(1, int) 7. >>> isinstance(1.0, float) 8. >>> isinstance(1, float) 9. >>> isinstance(dessert, list) 10. >>> not isinstance(dessert, list) 26-Sept-2014NLP, Prof. Howard, Tulane University 9

and, or 1. >>> S.isalpha() and S.startswith('CoN') 2. >>> not S.isdigit() and not S.startswith('oN') 3. >>> S.isalpha() or S.isdigit() 4. >>> S.isupper() or S.islower() 26-Sept-2014NLP, Prof. Howard, Tulane University 10

6.2. How to make action contingent on a condition with if 26-Sept NLP, Prof. Howard, Tulane University

if statements 1. >>> if 'N' in S: print 'yes' yes  'N' in S is the trigger or condition and print 'yes' is the action that are coordinated by if. 26-Sept-2014NLP, Prof. Howard, Tulane University 12

The condition must evaluate to true  The condition must evaluate to true, whether it is positive or negative; if the condition evaluates to false, the trigger fails and no action is taken. 1. >>> if 'n' in S: print 'yes' >>> 5. >>> if 'n' not in S: print 'no' no 9. >>> if 'N' not in S: print 'no' >>> 26-Sept-2014NLP, Prof. Howard, Tulane University 13

The general syntax for if is 1. >>> if True: do something Sept-2014NLP, Prof. Howard, Tulane University 14

More examples 1. >>> if S.isalpha(): print 'yes' yes 5. >>> if S.endswith('IoN'): print 'yes' yes 9. >>> if not S.endswith('CoN'): print 'yes' yes 26-Sept-2014NLP, Prof. Howard, Tulane University 15

More examples  >>> if re.search(r'N', S): ... print 'yes' ...  yes  >>> if re.search(r'IoN$', S): ... print 'yes' ...  yes  >>> if not re.search(r'CoN$', S): ... print 'yes' ...  yes  >>> if len('CoN') < len(S): ... print 'yes' ...  yes 26-Sept-2014NLP, Prof. Howard, Tulane University 16

More examples  >>> if isinstance(S, str): ... print 'yes' ...  yes  >>> if S.isalpha() or S.isdigit(): ... print 'yes' ...  yes 26-Sept-2014NLP, Prof. Howard, Tulane University 17

Note to self  This is 20m too short. 26-Sept-2014NLP, Prof. Howard, Tulane University 18

Q4 take home More on control Next time 26-Sept-2014NLP, Prof. Howard, Tulane University 19